diff options
author | John Mitchell <jlmitch5@ncsu.edu> | 2017-06-28 22:25:51 +0200 |
---|---|---|
committer | John Mitchell <jlmitch5@ncsu.edu> | 2017-06-28 22:25:51 +0200 |
commit | 0731b658c807ac69de24669804aaca2b48b20ffe (patch) | |
tree | 4d08d5e4705c5879ac070f296a7cb37aca361328 | |
parent | Merge pull request #6775 from AlanCoding/testing_fix (diff) | |
download | awx-0731b658c807ac69de24669804aaca2b48b20ffe.tar.xz awx-0731b658c807ac69de24669804aaca2b48b20ffe.zip |
add test log aggregator button to ui
3 files changed, 54 insertions, 5 deletions
diff --git a/awx/ui/client/src/configuration/configuration.controller.js b/awx/ui/client/src/configuration/configuration.controller.js index b1529a9ac3..d68c22e9b4 100644 --- a/awx/ui/client/src/configuration/configuration.controller.js +++ b/awx/ui/client/src/configuration/configuration.controller.js @@ -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, diff --git a/awx/ui/client/src/configuration/system-form/configuration-system.controller.js b/awx/ui/client/src/configuration/system-form/configuration-system.controller.js index 17b1f8edfb..bf31b99881 100644 --- a/awx/ui/client/src/configuration/system-form/configuration-system.controller.js +++ b/awx/ui/client/src/configuration/system-form/configuration-system.controller.js @@ -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, diff --git a/awx/ui/client/src/configuration/system-form/sub-forms/system-logging.form.js b/awx/ui/client/src/configuration/system-form/sub-forms/system-logging.form.js index 9669d8074a..5763e450b5 100644 --- a/awx/ui/client/src/configuration/system-form/sub-forms/system-logging.form.js +++ b/awx/ui/client/src/configuration/system-form/sub-forms/system-logging.form.js @@ -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()', }, |