1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #6783 from jlmitch5/testLogAggregator

add test log aggregator button to ui
This commit is contained in:
jlmitch5 2017-06-29 14:56:41 -04:00 committed by GitHub
commit 59775c52c9
3 changed files with 54 additions and 5 deletions

View File

@ -352,11 +352,11 @@ export default [
// Some dropdowns are listed as "list" type in the API even though they're a dropdown:
var multiselectDropdowns = ['AD_HOC_COMMANDS'];
var formSave = function() {
var saveDeferred = $q.defer();
var getFormPayload = function() {
var keys = _.keys(formDefs[formTracker.getCurrent()].fields);
var payload = {};
clearApiErrors();
_.each(keys, function(key) {
if($scope.configDataResolve[key].type === 'choice' || multiselectDropdowns.indexOf(key) !== -1) {
//Parse dropdowns and dropdowns labeled as lists
@ -396,8 +396,14 @@ export default [
}
});
return payload;
};
var formSave = function() {
var saveDeferred = $q.defer();
clearApiErrors();
Wait('start');
ConfigurationService.patchConfiguration(payload)
ConfigurationService.patchConfiguration(getFormPayload())
.then(function(data) {
loginUpdate();
saveDeferred.resolve(data);
@ -560,6 +566,7 @@ export default [
formCancel: formCancel,
formTracker: formTracker,
formSave: formSave,
getFormPayload: getFormPayload,
populateFromApi: populateFromApi,
resetAllConfirm: resetAllConfirm,
show_auditor_bar: show_auditor_bar,

View File

@ -15,6 +15,9 @@ export default [
'CreateSelect2',
'GenerateForm',
'i18n',
'Rest',
'ProcessErrors',
'ngToast',
function(
$rootScope, $scope, $state, $stateParams, $timeout,
AngularCodeMirror,
@ -25,7 +28,10 @@ export default [
ConfigurationUtils,
CreateSelect2,
GenerateForm,
i18n
i18n,
Rest,
ProcessErrors,
ngToast
) {
var systemVm = this;
@ -186,6 +192,36 @@ export default [
$scope.$parent.configuration_logging_template_form.$setPristine();
}, 1000);
$scope.$parent.vm.testLogging = function() {
Rest.setUrl("/api/v2/settings/logging/test/");
Rest.post($scope.$parent.vm.getFormPayload())
.then(() => {
ngToast.success({
content: `<i class="fa fa-check-circle
Toast-successIcon"></i>` +
i18n._('Log aggregator test successful.')
});
})
.catch(({data, status}) => {
if (status === 500) {
ngToast.danger({
content: `<i class="fa fa-exclamation-triangle
Toast-successIcon"></i>` +
i18n._('Log aggregator test failed.<br />Detail: ') +
data.error
});
} else {
ProcessErrors($scope, data, status, null,
{
hdr: i18n._('Error!'),
msg: i18n._('There was an error testing the ' +
'log aggregator. Returned status: ') +
status
});
}
});
};
angular.extend(systemVm, {
activeForm: activeForm,
activeSystemForm: activeSystemForm,

View File

@ -51,6 +51,12 @@
label: i18n._('Revert all to default'),
class: 'Form-resetAll'
},
testLogging: {
ngClick: 'vm.testLogging()',
label: i18n._('Test'),
class: 'btn-primary',
ngDisabled: 'configuration_logging_template_form.$invalid'
},
cancel: {
ngClick: 'vm.formCancel()',
},