Merge pull request #4431 from kensible/4315-logging-settings

[Configure TinT] Added logging, timeouts, various updates
This commit is contained in:
kensible 2016-12-14 14:37:26 -05:00 committed by GitHub
commit 4b87e0a80d
11 changed files with 396 additions and 38 deletions

View File

@ -99,9 +99,9 @@ export default [
var dropdownOptions = [
{label: i18n._('Azure AD'), value: 'azure'},
{label: i18n._('Github'), value: 'github'},
{label: i18n._('Github Org'), value: 'github_org'},
{label: i18n._('Github Team'), value: 'github_team'},
{label: i18n._('GitHub'), value: 'github'},
{label: i18n._('GitHub Org'), value: 'github_org'},
{label: i18n._('GithHub Team'), value: 'github_team'},
{label: i18n._('Google OAuth2'), value: 'google_oauth'},
{label: i18n._('LDAP'), value: 'ldap'},
{label: i18n._('RADIUS'), value: 'radius'},

View File

@ -1,7 +1,7 @@
<div class="tab-pane Configuration-container" id="configuration_edit">
<!-- <div ui-view="form"></div>
<div ng-cloak id="htmlTemplate"> -->
<div class="Form-nav--dropdown">
<div class="Form-nav--dropdownContainer">
<div class="Form-nav--dropdownLabel">Sub Category</div>
<div class="Form-nav--dropdown">
<select
id="configure-dropdown-nav"
class="form-control"
@ -9,6 +9,7 @@
ng-options="opt.value as opt.label for opt in authVm.dropdownOptions"
ng-change="authVm.activeForm()">
</select>
</div>
</div>
<div class="row">
<div class="col-lg-12">

View File

@ -21,11 +21,26 @@
margin-left: 0;
}
.Form-nav--dropdown {
width: 175px;
.Form-nav--dropdownContainer {
width: 285px;
margin-top: -52px;
margin-bottom: 22px;
margin-left: auto;
display: flex;
justify-content: space-between;
}
.Form-nav--dropdown {
width: 60%;
}
.Form-nav--dropdownLabel {
text-transform: uppercase;
color: @default-interface-txt;
font-size: 14px;
font-weight: bold;
padding-right: 5px;
padding-top: 5px;
}
.Form-tabRow {

View File

@ -17,8 +17,10 @@ export default [
'configurationLdapForm',
'configurationRadiusForm',
'configurationSamlForm',
'systemActivityStreamForm',
'systemLoggingForm',
'systemMiscForm',
'ConfigurationJobsForm',
'ConfigurationSystemForm',
'ConfigurationUiForm',
function(
$scope, $rootScope, $state, $stateParams, $timeout, $q, Alert, ClearScope,
@ -33,8 +35,10 @@ export default [
configurationLdapForm,
configurationRadiusForm,
configurationSamlForm,
systemActivityStreamForm,
systemLoggingForm,
systemMiscForm,
ConfigurationJobsForm,
ConfigurationSystemForm,
ConfigurationUiForm
) {
var vm = this;
@ -48,8 +52,10 @@ export default [
'ldap': configurationLdapForm,
'radius': configurationRadiusForm,
'saml': configurationSamlForm,
'activity_stream': systemActivityStreamForm,
'logging': systemLoggingForm,
'misc': systemMiscForm,
'jobs': ConfigurationJobsForm,
'system': ConfigurationSystemForm,
'ui': ConfigurationUiForm
};
@ -84,19 +90,24 @@ export default [
lastForm: '',
currentForm: '',
currentAuth: '',
currentSystem: '',
setCurrent: function(form) {
this.lastForm = this.currentForm;
this.currentForm = form;
},
setCurrentAuth: function(form) {
this.currentAuth = form;
this.setCurrent(this.currentAuth);
},
getCurrent: function() {
return this.currentForm;
},
currentFormName: function() {
return 'configuration_' + this.currentForm + '_template_form';
},
setCurrentAuth: function(form) {
this.currentAuth = form;
this.setCurrent(this.currentAuth);
},
setCurrentSystem: function(form) {
this.currentSystem = form;
this.setCurrent(this.currentSystem);
}
};
@ -182,6 +193,7 @@ export default [
}
function active(setForm) {
// Authentication and System's sub-module dropdowns handled first:
if (setForm === 'auth') {
// Default to 'azure' on first load
if (formTracker.currentAuth === '') {
@ -190,7 +202,15 @@ export default [
// If returning to auth tab reset current form to previously viewed
formTracker.setCurrentAuth(formTracker.currentAuth);
}
} else {
} else if (setForm === 'system') {
if (formTracker.currentSystem === '') {
formTracker.setCurrentSystem('misc');
} else {
// If returning to system tab reset current form to previously viewed
formTracker.setCurrentSystem(formTracker.currentSystem);
}
}
else {
formTracker.setCurrent(setForm);
}
vm.activeTab = setForm;

View File

@ -46,7 +46,19 @@
},
AWX_PROOT_ENABLED: {
type: 'toggleSwitch',
}
},
DEFAULT_JOB_TIMEOUT: {
type: 'text',
reset: 'DEFAULT_JOB_TIMEOUT',
},
DEFAULT_INVENTORY_UPDATE_TIMEOUT: {
type: 'text',
reset: 'DEFAULT_INVENTORY_UPDATE_TIMEOUT',
},
DEFAULT_PROJECT_UPDATE_TIMEOUT: {
type: 'text',
reset: 'DEFAULT_PROJECT_UPDATE_TIMEOUT',
},
},
buttons: {

View File

@ -20,8 +20,12 @@ import configurationLdapForm from './auth-form/sub-forms/auth-ldap.form.js';
import configurationRadiusForm from './auth-form/sub-forms/auth-radius.form.js';
import configurationSamlForm from './auth-form/sub-forms/auth-saml.form';
//system sub-forms
import systemActivityStreamForm from './system-form/sub-forms/system-activity-stream.form.js';
import systemLoggingForm from './system-form/sub-forms/system-logging.form.js';
import systemMiscForm from './system-form/sub-forms/system-misc.form.js';
import configurationJobsForm from './jobs-form/configuration-jobs.form';
import configurationSystemForm from './system-form/configuration-system.form';
import configurationUiForm from './ui-form/configuration-ui.form';
export default
@ -36,10 +40,15 @@ angular.module('configuration', [])
.factory('configurationLdapForm', configurationLdapForm)
.factory('configurationRadiusForm', configurationRadiusForm)
.factory('configurationSamlForm', configurationSamlForm)
//system forms
.factory('systemActivityStreamForm', systemActivityStreamForm)
.factory('systemLoggingForm', systemLoggingForm)
.factory('systemMiscForm', systemMiscForm)
//other forms
.factory('ConfigurationJobsForm', configurationJobsForm)
.factory('ConfigurationSystemForm', configurationSystemForm)
.factory('ConfigurationUiForm', configurationUiForm)
//helpers and services
.factory('ConfigurationUtils', ConfigurationUtils)
.service('ConfigurationService', configurationService)

View File

@ -5,22 +5,120 @@
*************************************************/
export default [
'$rootScope', '$scope', '$state', 'AngularCodeMirror', 'Authorization', 'ConfigurationSystemForm', 'ConfigurationService',
'ConfigurationUtils', 'GenerateForm',
'$rootScope', '$scope', '$state', '$stateParams',
'AngularCodeMirror',
'systemActivityStreamForm',
'systemLoggingForm',
'systemMiscForm',
'ConfigurationService',
'ConfigurationUtils',
'CreateSelect2',
'GenerateForm',
'i18n',
function(
$rootScope, $scope, $state, AngularCodeMirror, Authorization, ConfigurationSystemForm, ConfigurationService, ConfigurationUtils, GenerateForm
$rootScope, $scope, $state, $stateParams,
AngularCodeMirror,
systemActivityStreamForm,
systemLoggingForm,
systemMiscForm,
ConfigurationService,
ConfigurationUtils,
CreateSelect2,
GenerateForm,
i18n
) {
var systemVm = this;
var generator = GenerateForm;
var form = ConfigurationSystemForm;
var keys = _.keys(form.fields);
_.each(keys, function(key) {
addFieldInfo(form, key);
var generator = GenerateForm;
var formTracker = $scope.$parent.vm.formTracker;
var dropdownValue = 'misc';
var activeSystemForm = 'misc';
if ($stateParams.currentTab === 'system') {
formTracker.setCurrentSystem(activeSystemForm);
}
var activeForm = function() {
if(!$scope.$parent[formTracker.currentFormName()].$dirty) {
systemVm.activeSystemForm = systemVm.dropdownValue;
formTracker.setCurrentSystem(systemVm.activeSystemForm);
} else {
var msg = i18n._('You have unsaved changes. Would you like to proceed <strong>without</strong> saving?');
var title = i18n._('Warning: Unsaved Changes');
var buttons = [{
label: i18n._('Discard changes'),
"class": "btn Form-cancelButton",
"id": "formmodal-cancel-button",
onClick: function() {
$scope.$parent.vm.populateFromApi();
$scope.$parent[formTracker.currentFormName()].$setPristine();
systemVm.activeSystemForm = systemVm.dropdownValue;
formTracker.setCurrentSystem(systemVm.activeSystemForm);
$('#FormModal-dialog').dialog('close');
}
}, {
label: i18n._('Save changes'),
onClick: function() {
$scope.$parent.vm.formSave()
.then(function() {
$scope.$parent[formTracker.currentFormName()].$setPristine();
$scope.$parent.vm.populateFromApi();
systemVm.activeSystemForm = systemVm.dropdownValue;
formTracker.setCurrentSystem(systemVm.activeSystemForm);
$('#FormModal-dialog').dialog('close');
});
},
"class": "btn btn-primary",
"id": "formmodal-save-button"
}];
$scope.$parent.vm.triggerModal(msg, title, buttons);
}
formTracker.setCurrentSystem(systemVm.activeSystemForm);
};
var dropdownOptions = [
{label: i18n._('Misc. System'), value: 'misc'},
{label: i18n._('Activity Stream'), value: 'activity_stream'},
{label: i18n._('Logging'), value: 'logging'},
];
CreateSelect2({
element: '#system-configure-dropdown-nav',
multiple: false,
});
// Disable the save button for system auditors
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
var systemForms = [{
formDef: systemLoggingForm,
id: 'system-logging-form'
}, {
formDef: systemActivityStreamForm,
id: 'system-activity-stream-form'
}, {
formDef: systemMiscForm,
id: 'system-misc-form'
}];
var forms = _.pluck(systemForms, 'formDef');
_.each(forms, function(form) {
var keys = _.keys(form.fields);
_.each(keys, function(key) {
if($scope.$parent.configDataResolve[key].type === 'choice') {
// Create options for dropdowns
var optionsGroup = key + '_options';
$scope.$parent[optionsGroup] = [];
_.each($scope.$parent.configDataResolve[key].choices, function(choice){
$scope.$parent[optionsGroup].push({
name: choice[0],
label: choice[1],
value: choice[0]
});
});
}
addFieldInfo(form, key);
});
// Disable the save button for system auditors
form.buttons.save.disabled = $rootScope.user_is_system_auditor;
});
function addFieldInfo(form, key) {
_.extend(form.fields[key], {
@ -29,21 +127,56 @@ export default [
name: key,
toggleSource: key,
dataPlacement: 'top',
placeholder: ConfigurationUtils.formatPlaceholder($scope.$parent.configDataResolve[key].placeholder, key) || null,
dataTitle: $scope.$parent.configDataResolve[key].label,
required: $scope.$parent.configDataResolve[key].required,
ngDisabled: $rootScope.user_is_system_auditor
});
}
generator.inject(form, {
id: 'configure-system-form',
mode: 'edit',
scope: $scope.$parent,
related: true
$scope.$parent.parseType = 'json';
_.each(systemForms, function(form) {
generator.inject(form.formDef, {
id: form.id,
mode: 'edit',
scope: $scope.$parent,
related: true
});
});
var dropdownRendered = false;
$scope.$on('populated', function() {
var opts = [];
if($scope.$parent.LOG_AGGREGATOR_TYPE !== null) {
_.each(ConfigurationUtils.listToArray($scope.$parent.LOG_AGGREGATOR_TYPE), function(type) {
opts.push({
id: type,
text: type
});
});
}
if(!dropdownRendered) {
dropdownRendered = true;
CreateSelect2({
element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE',
multiple: true,
placeholder: i18n._('Select types'),
opts: opts
});
}
});
angular.extend(systemVm, {
activeForm: activeForm,
activeSystemForm: activeSystemForm,
dropdownOptions: dropdownOptions,
dropdownValue: dropdownValue,
systemForms: systemForms
});
}
];

View File

@ -1,9 +1,34 @@
<div class="tab-pane Configuration-container">
<!-- <div ui-view="form"></div>
<div ng-cloak id="htmlTemplate"> -->
<div class="Form-nav--dropdownContainer">
<div class="Form-nav--dropdownLabel">Sub Category</div>
<div class="Form-nav--dropdown">
<select
id="system-configure-dropdown-nav"
class="form-control"
ng-model="systemVm.dropdownValue"
ng-options="opt.value as opt.label for opt in systemVm.dropdownOptions"
ng-change="systemVm.activeForm()">
</select>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div id="configure-system-form"></div>
<!-- <div id="configure-system-form"></div> -->
<div ng-show="systemVm.activeSystemForm === 'misc'">
<div id="system-misc-form">
</div>
</div>
<div ng-show="systemVm.activeSystemForm === 'activity_stream'">
<div id="system-activity-stream-form">
</div>
</div>
<div ng-show="systemVm.activeSystemForm === 'logging'">
<div id="system-logging-form">
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,38 @@
/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['i18n', function(i18n) {
return {
name: 'configuration_activity_stream_template',
showActions: true,
showHeader: false,
fields: {
ACTIVITY_STREAM_ENABLED: {
type: 'toggleSwitch',
},
ACTIVITY_STREAM_ENABLED_FOR_INVENTORY_SYNC: {
type: 'toggleSwitch'
}
},
buttons: {
reset: {
ngClick: 'vm.resetAllConfirm()',
label: i18n._('Reset All'),
class: 'Form-button--left Form-cancelButton'
},
cancel: {
ngClick: 'vm.formCancel()',
},
save: {
ngClick: 'vm.formSave()',
ngDisabled: true
}
}
};
}
];

View File

@ -0,0 +1,63 @@
/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['i18n', function(i18n) {
return {
name: 'configuration_logging_template',
showActions: true,
showHeader: false,
fields: {
LOG_AGGREGATOR_HOST: {
type: 'text',
reset: 'LOG_AGGREGATOR_HOST'
},
LOG_AGGREGATOR_PORT: {
type: 'text',
reset: 'LOG_AGGREGATOR_PORT'
},
LOG_AGGREGATOR_TYPE: {
type: 'select',
reset: 'LOG_AGGREGATOR_TYPE',
ngOptions: 'type.label for type in LOG_AGGREGATOR_TYPE_options track by type.value',
},
LOG_AGGREGATOR_USERNAME: {
type: 'text',
reset: 'LOG_AGGREGATOR_USERNAME'
},
LOG_AGGREGATOR_PASSWORD: {
type: 'text',
reset: 'LOG_AGGREGATOR_PASSWORD'
},
LOG_AGGREGATOR_LOGGERS: {
type: 'textarea',
reset: 'LOG_AGGREGATOR_PASSWORD'
},
LOG_AGGREGATOR_INDIVIDUAL_FACTS: {
type: 'toggleSwitch',
},
LOG_AGGREGATOR_ENABLED: {
type: 'toggleSwitch',
}
},
buttons: {
reset: {
ngClick: 'vm.resetAllConfirm()',
label: i18n._('Reset All'),
class: 'Form-button--left Form-cancelButton'
},
cancel: {
ngClick: 'vm.formCancel()',
},
save: {
ngClick: 'vm.formSave()',
ngDisabled: true
}
}
};
}
];

View File

@ -0,0 +1,42 @@
/*************************************************
* Copyright (c) 2016 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['i18n', function(i18n) {
return {
showHeader: false,
name: 'configuration_misc_template',
showActions: true,
fields: {
TOWER_URL_BASE: {
type: 'text',
reset: 'TOWER_URL_BASE',
},
TOWER_ADMIN_ALERTS: {
type: 'toggleSwitch',
},
ORG_ADMINS_CAN_SEE_ALL_USERS: {
type: 'toggleSwitch',
}
},
buttons: {
reset: {
ngClick: 'vm.resetAllConfirm()',
label: i18n._('Reset All'),
class: 'Form-button--left Form-cancelButton'
},
cancel: {
ngClick: 'vm.formCancel()',
},
save: {
ngClick: 'vm.formSave()',
ngDisabled: true
}
}
};
}
];