mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
update configure tower in tower test ui for log aggregator form
This commit is contained in:
committed by
Christian Adams
parent
c0af3c537b
commit
88ca4b63e6
@@ -92,6 +92,7 @@ export default [
|
|||||||
var populateFromApi = function() {
|
var populateFromApi = function() {
|
||||||
SettingsService.getCurrentValues()
|
SettingsService.getCurrentValues()
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
|
$scope.logAggregatorEnabled = data.LOG_AGGREGATOR_ENABLED;
|
||||||
// these two values need to be unnested from the
|
// these two values need to be unnested from the
|
||||||
// OAUTH2_PROVIDER key
|
// OAUTH2_PROVIDER key
|
||||||
data.ACCESS_TOKEN_EXPIRE_SECONDS = data
|
data.ACCESS_TOKEN_EXPIRE_SECONDS = data
|
||||||
@@ -538,8 +539,11 @@ export default [
|
|||||||
var payload = {};
|
var payload = {};
|
||||||
payload[key] = $scope[key];
|
payload[key] = $scope[key];
|
||||||
SettingsService.patchConfiguration(payload)
|
SettingsService.patchConfiguration(payload)
|
||||||
.then(function() {
|
.then(function(data) {
|
||||||
//TODO consider updating form values with returned data here
|
//TODO consider updating form values with returned data here
|
||||||
|
if (key === 'LOG_AGGREGATOR_ENABLED') {
|
||||||
|
$scope.logAggregatorEnabled = data.LOG_AGGREGATOR_ENABLED;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function(data) {
|
.catch(function(data) {
|
||||||
//Change back on unsuccessful update
|
//Change back on unsuccessful update
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default [
|
|||||||
'ProcessErrors',
|
'ProcessErrors',
|
||||||
'ngToast',
|
'ngToast',
|
||||||
'$filter',
|
'$filter',
|
||||||
function(
|
function (
|
||||||
$rootScope, $scope, $stateParams,
|
$rootScope, $scope, $stateParams,
|
||||||
systemActivityStreamForm,
|
systemActivityStreamForm,
|
||||||
systemLoggingForm,
|
systemLoggingForm,
|
||||||
@@ -41,8 +41,8 @@ export default [
|
|||||||
formTracker.setCurrentSystem(activeSystemForm);
|
formTracker.setCurrentSystem(activeSystemForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeForm = function(tab) {
|
var activeForm = function (tab) {
|
||||||
if(!_.get($scope.$parent, [formTracker.currentFormName(), '$dirty'])) {
|
if (!_.get($scope.$parent, [formTracker.currentFormName(), '$dirty'])) {
|
||||||
systemVm.activeSystemForm = tab;
|
systemVm.activeSystemForm = tab;
|
||||||
formTracker.setCurrentSystem(systemVm.activeSystemForm);
|
formTracker.setCurrentSystem(systemVm.activeSystemForm);
|
||||||
} else {
|
} else {
|
||||||
@@ -52,7 +52,7 @@ export default [
|
|||||||
label: i18n._('Discard changes'),
|
label: i18n._('Discard changes'),
|
||||||
"class": "btn Form-cancelButton",
|
"class": "btn Form-cancelButton",
|
||||||
"id": "formmodal-cancel-button",
|
"id": "formmodal-cancel-button",
|
||||||
onClick: function() {
|
onClick: function () {
|
||||||
$scope.$parent.vm.populateFromApi();
|
$scope.$parent.vm.populateFromApi();
|
||||||
$scope.$parent[formTracker.currentFormName()].$setPristine();
|
$scope.$parent[formTracker.currentFormName()].$setPristine();
|
||||||
systemVm.activeSystemForm = tab;
|
systemVm.activeSystemForm = tab;
|
||||||
@@ -61,15 +61,15 @@ export default [
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: i18n._('Save changes'),
|
label: i18n._('Save changes'),
|
||||||
onClick: function() {
|
onClick: function () {
|
||||||
$scope.$parent.vm.formSave()
|
$scope.$parent.vm.formSave()
|
||||||
.then(function() {
|
.then(function () {
|
||||||
$scope.$parent[formTracker.currentFormName()].$setPristine();
|
$scope.$parent[formTracker.currentFormName()].$setPristine();
|
||||||
$scope.$parent.vm.populateFromApi();
|
$scope.$parent.vm.populateFromApi();
|
||||||
systemVm.activeSystemForm = tab;
|
systemVm.activeSystemForm = tab;
|
||||||
formTracker.setCurrentSystem(systemVm.activeSystemForm);
|
formTracker.setCurrentSystem(systemVm.activeSystemForm);
|
||||||
$('#FormModal-dialog').dialog('close');
|
$('#FormModal-dialog').dialog('close');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
"class": "btn btn-primary",
|
"class": "btn btn-primary",
|
||||||
"id": "formmodal-save-button"
|
"id": "formmodal-save-button"
|
||||||
@@ -80,9 +80,9 @@ export default [
|
|||||||
};
|
};
|
||||||
|
|
||||||
var dropdownOptions = [
|
var dropdownOptions = [
|
||||||
{label: i18n._('Misc. System'), value: 'misc'},
|
{ label: i18n._('Misc. System'), value: 'misc' },
|
||||||
{label: i18n._('Activity Stream'), value: 'activity_stream'},
|
{ label: i18n._('Activity Stream'), value: 'activity_stream' },
|
||||||
{label: i18n._('Logging'), value: 'logging'},
|
{ label: i18n._('Logging'), value: 'logging' },
|
||||||
];
|
];
|
||||||
|
|
||||||
var systemForms = [{
|
var systemForms = [{
|
||||||
@@ -97,14 +97,14 @@ export default [
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
var forms = _.map(systemForms, 'formDef');
|
var forms = _.map(systemForms, 'formDef');
|
||||||
_.each(forms, function(form) {
|
_.each(forms, function (form) {
|
||||||
var keys = _.keys(form.fields);
|
var keys = _.keys(form.fields);
|
||||||
_.each(keys, function(key) {
|
_.each(keys, function (key) {
|
||||||
if($scope.configDataResolve[key].type === 'choice') {
|
if ($scope.configDataResolve[key].type === 'choice') {
|
||||||
// Create options for dropdowns
|
// Create options for dropdowns
|
||||||
var optionsGroup = key + '_options';
|
var optionsGroup = key + '_options';
|
||||||
$scope.$parent.$parent[optionsGroup] = [];
|
$scope.$parent.$parent[optionsGroup] = [];
|
||||||
_.each($scope.configDataResolve[key].choices, function(choice){
|
_.each($scope.configDataResolve[key].choices, function (choice) {
|
||||||
$scope.$parent.$parent[optionsGroup].push({
|
$scope.$parent.$parent[optionsGroup].push({
|
||||||
name: choice[0],
|
name: choice[0],
|
||||||
label: choice[1],
|
label: choice[1],
|
||||||
@@ -121,7 +121,7 @@ export default [
|
|||||||
function addFieldInfo(form, key) {
|
function addFieldInfo(form, key) {
|
||||||
_.extend(form.fields[key], {
|
_.extend(form.fields[key], {
|
||||||
awPopOver: ($scope.configDataResolve[key].defined_in_file) ?
|
awPopOver: ($scope.configDataResolve[key].defined_in_file) ?
|
||||||
null: $scope.configDataResolve[key].help_text,
|
null : $scope.configDataResolve[key].help_text,
|
||||||
label: $scope.configDataResolve[key].label,
|
label: $scope.configDataResolve[key].label,
|
||||||
name: key,
|
name: key,
|
||||||
toggleSource: key,
|
toggleSource: key,
|
||||||
@@ -138,7 +138,7 @@ export default [
|
|||||||
|
|
||||||
$scope.$parent.$parent.parseType = 'json';
|
$scope.$parent.$parent.parseType = 'json';
|
||||||
|
|
||||||
_.each(systemForms, function(form) {
|
_.each(systemForms, function (form) {
|
||||||
generator.inject(form.formDef, {
|
generator.inject(form.formDef, {
|
||||||
id: form.id,
|
id: form.id,
|
||||||
mode: 'edit',
|
mode: 'edit',
|
||||||
@@ -150,37 +150,37 @@ export default [
|
|||||||
|
|
||||||
var dropdownRendered = false;
|
var dropdownRendered = false;
|
||||||
|
|
||||||
$scope.$on('populated', function() {
|
$scope.$on('populated', function () {
|
||||||
populateLogAggregator(false);
|
populateLogAggregator(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('LOG_AGGREGATOR_TYPE_populated', function(e, data, flag) {
|
$scope.$on('LOG_AGGREGATOR_TYPE_populated', function (e, data, flag) {
|
||||||
populateLogAggregator(flag);
|
populateLogAggregator(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('LOG_AGGREGATOR_PROTOCOL_populated', function(e, data, flag) {
|
$scope.$on('LOG_AGGREGATOR_PROTOCOL_populated', function (e, data, flag) {
|
||||||
populateLogAggregator(flag);
|
populateLogAggregator(flag);
|
||||||
});
|
});
|
||||||
|
|
||||||
function populateLogAggregator(flag){
|
function populateLogAggregator(flag) {
|
||||||
|
|
||||||
if($scope.$parent.$parent.LOG_AGGREGATOR_TYPE !== null) {
|
if ($scope.$parent.$parent.LOG_AGGREGATOR_TYPE !== null) {
|
||||||
$scope.$parent.$parent.LOG_AGGREGATOR_TYPE = _.find($scope.$parent.$parent.LOG_AGGREGATOR_TYPE_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_TYPE });
|
$scope.$parent.$parent.LOG_AGGREGATOR_TYPE = _.find($scope.$parent.$parent.LOG_AGGREGATOR_TYPE_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_TYPE });
|
||||||
}
|
}
|
||||||
|
|
||||||
if($scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL !== null) {
|
if ($scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL !== null) {
|
||||||
$scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL = _.find($scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL });
|
$scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL = _.find($scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_PROTOCOL });
|
||||||
}
|
}
|
||||||
|
|
||||||
if($scope.$parent.$parent.LOG_AGGREGATOR_LEVEL !== null) {
|
if ($scope.$parent.$parent.LOG_AGGREGATOR_LEVEL !== null) {
|
||||||
$scope.$parent.$parent.LOG_AGGREGATOR_LEVEL = _.find($scope.$parent.$parent.LOG_AGGREGATOR_LEVEL_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_LEVEL });
|
$scope.$parent.$parent.LOG_AGGREGATOR_LEVEL = _.find($scope.$parent.$parent.LOG_AGGREGATOR_LEVEL_options, { value: $scope.$parent.$parent.LOG_AGGREGATOR_LEVEL });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag !== undefined){
|
if (flag !== undefined) {
|
||||||
dropdownRendered = flag;
|
dropdownRendered = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dropdownRendered) {
|
if (!dropdownRendered) {
|
||||||
dropdownRendered = true;
|
dropdownRendered = true;
|
||||||
CreateSelect2({
|
CreateSelect2({
|
||||||
element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE',
|
element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE',
|
||||||
@@ -193,33 +193,45 @@ export default [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$parent.vm.testLogging = function() {
|
$scope.$watchGroup(['configuration_logging_template_form.$pending', 'configuration_logging_template_form.$dirty', '!logAggregatorEnabled'], (vals) => {
|
||||||
Rest.setUrl("/api/v2/settings/logging/test/");
|
if (vals.some(val => val === true)) {
|
||||||
Rest.post($scope.$parent.vm.getFormPayload())
|
$scope.$parent.vm.disableTestButton = true;
|
||||||
.then(() => {
|
$scope.$parent.vm.testTooltip = i18n._('Save and enable log aggregation before testing the log aggregator.');
|
||||||
ngToast.success({
|
} else {
|
||||||
content: `<i class="fa fa-check-circle
|
$scope.$parent.vm.disableTestButton = false;
|
||||||
Toast-successIcon"></i>` +
|
$scope.$parent.vm.testTooltip = i18n._('Send a test response to the configured log aggregator.');
|
||||||
i18n._('Log aggregator test successful.')
|
}
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.catch(({data, status}) => {
|
$scope.$parent.vm.testLogging = function () {
|
||||||
if (status === 500) {
|
if (!$scope.$parent.vm.disableTestButton) {
|
||||||
ngToast.danger({
|
Rest.setUrl("/api/v2/settings/logging/test/");
|
||||||
content: '<i class="fa fa-exclamation-triangle Toast-successIcon"></i>' +
|
Rest.post({})
|
||||||
i18n._('Log aggregator test failed. <br> Detail: ') + $filter('sanitize')(data.error),
|
.then(() => {
|
||||||
additionalClasses: "LogAggregator-failedNotification"
|
ngToast.success({
|
||||||
|
content: `<i class="fa fa-check-circle
|
||||||
|
Toast-successIcon"></i>` +
|
||||||
|
i18n._('Log aggregator test sent successfully.')
|
||||||
});
|
});
|
||||||
} else {
|
})
|
||||||
ProcessErrors($scope, data, status, null,
|
.catch(({ data, status }) => {
|
||||||
{
|
if (status === 500) {
|
||||||
hdr: i18n._('Error!'),
|
ngToast.danger({
|
||||||
msg: i18n._('There was an error testing the ' +
|
content: '<i class="fa fa-exclamation-triangle Toast-successIcon"></i>' +
|
||||||
'log aggregator. Returned status: ') +
|
i18n._('Log aggregator test failed. <br> Detail: ') + $filter('sanitize')(data.error),
|
||||||
status
|
additionalClasses: "LogAggregator-failedNotification"
|
||||||
});
|
});
|
||||||
}
|
} 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, {
|
angular.extend(systemVm, {
|
||||||
|
|||||||
@@ -75,10 +75,13 @@
|
|||||||
class: 'Form-resetAll'
|
class: 'Form-resetAll'
|
||||||
},
|
},
|
||||||
testLogging: {
|
testLogging: {
|
||||||
|
ngClass: "{'Form-button--disabled': vm.disableTestButton}",
|
||||||
ngClick: 'vm.testLogging()',
|
ngClick: 'vm.testLogging()',
|
||||||
label: i18n._('Test'),
|
label: i18n._('Test'),
|
||||||
class: 'btn-primary',
|
class: 'Form-primaryButton',
|
||||||
ngDisabled: 'configuration_logging_template_form.$pending'
|
awToolTip: '{{vm.testTooltip}}',
|
||||||
|
dataTipWatch: 'vm.testTooltip',
|
||||||
|
dataPlacement: 'top',
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
ngClick: 'vm.formCancel()',
|
ngClick: 'vm.formCancel()',
|
||||||
|
|||||||
@@ -1690,6 +1690,9 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
if (button.ngClick) {
|
if (button.ngClick) {
|
||||||
html += this.attr(button, 'ngClick');
|
html += this.attr(button, 'ngClick');
|
||||||
}
|
}
|
||||||
|
if (button.ngClass) {
|
||||||
|
html += this.attr(button, 'ngClass');
|
||||||
|
}
|
||||||
if (button.ngDisabled) {
|
if (button.ngDisabled) {
|
||||||
ngDisabled = (button.ngDisabled===true) ? `${this.form.name}_form.$invalid || ${this.form.name}_form.$pending`: button.ngDisabled;
|
ngDisabled = (button.ngDisabled===true) ? `${this.form.name}_form.$invalid || ${this.form.name}_form.$pending`: button.ngDisabled;
|
||||||
if (btn !== 'reset') {
|
if (btn !== 'reset') {
|
||||||
|
|||||||
Reference in New Issue
Block a user