diff --git a/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js b/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js index 33d1a53c37..5c3d31a0bc 100644 --- a/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js +++ b/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js @@ -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'}, diff --git a/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html b/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html index 5efeeed532..71192e17c6 100644 --- a/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html +++ b/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html @@ -1,7 +1,7 @@
- -
+
+
Sub Category
+
+
diff --git a/awx/ui/client/src/configuration/configuration.block.less b/awx/ui/client/src/configuration/configuration.block.less index de4dae2e2c..0b2a1ea0ee 100644 --- a/awx/ui/client/src/configuration/configuration.block.less +++ b/awx/ui/client/src/configuration/configuration.block.less @@ -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 { diff --git a/awx/ui/client/src/configuration/configuration.controller.js b/awx/ui/client/src/configuration/configuration.controller.js index e5d3d6049d..153434ef84 100644 --- a/awx/ui/client/src/configuration/configuration.controller.js +++ b/awx/ui/client/src/configuration/configuration.controller.js @@ -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; diff --git a/awx/ui/client/src/configuration/jobs-form/configuration-jobs.form.js b/awx/ui/client/src/configuration/jobs-form/configuration-jobs.form.js index 05b9d664a7..caf0392c24 100644 --- a/awx/ui/client/src/configuration/jobs-form/configuration-jobs.form.js +++ b/awx/ui/client/src/configuration/jobs-form/configuration-jobs.form.js @@ -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: { diff --git a/awx/ui/client/src/configuration/main.js b/awx/ui/client/src/configuration/main.js index 74dce80c8f..f37bab3d84 100644 --- a/awx/ui/client/src/configuration/main.js +++ b/awx/ui/client/src/configuration/main.js @@ -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) 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 c22131c2bc..2774c8ade5 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 @@ -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 without 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 }); } ]; diff --git a/awx/ui/client/src/configuration/system-form/configuration-system.partial.html b/awx/ui/client/src/configuration/system-form/configuration-system.partial.html index 7ff91b4441..0b039e761b 100644 --- a/awx/ui/client/src/configuration/system-form/configuration-system.partial.html +++ b/awx/ui/client/src/configuration/system-form/configuration-system.partial.html @@ -1,9 +1,34 @@
- +
+
Sub Category
+
+ +
+
-
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
diff --git a/awx/ui/client/src/configuration/system-form/sub-forms/system-activity-stream.form.js b/awx/ui/client/src/configuration/system-form/sub-forms/system-activity-stream.form.js new file mode 100644 index 0000000000..09cf80eccd --- /dev/null +++ b/awx/ui/client/src/configuration/system-form/sub-forms/system-activity-stream.form.js @@ -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 + } + } + }; + } +]; 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 new file mode 100644 index 0000000000..2329fde488 --- /dev/null +++ b/awx/ui/client/src/configuration/system-form/sub-forms/system-logging.form.js @@ -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 + } + } + }; + } +]; diff --git a/awx/ui/client/src/configuration/system-form/sub-forms/system-misc.form.js b/awx/ui/client/src/configuration/system-form/sub-forms/system-misc.form.js new file mode 100644 index 0000000000..690418f323 --- /dev/null +++ b/awx/ui/client/src/configuration/system-form/sub-forms/system-misc.form.js @@ -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 + } + } + }; +} +];