diff --git a/lib/ui/static/css/ansible-ui.css b/lib/ui/static/css/ansible-ui.css index f13456035d..fc157fdc99 100644 --- a/lib/ui/static/css/ansible-ui.css +++ b/lib/ui/static/css/ansible-ui.css @@ -218,3 +218,7 @@ height: 22px; font-size: 10.5px; } + + .ask-checkbox { + margin-left: 10px; + } diff --git a/lib/ui/static/js/controllers/Credentials.js b/lib/ui/static/js/controllers/Credentials.js index e7d71b3472..b662481d3e 100644 --- a/lib/ui/static/js/controllers/Credentials.js +++ b/lib/ui/static/js/controllers/Credentials.js @@ -190,12 +190,26 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa generator.reset(); }; - // Password change + // Password change scope.clearPWConfirm = function(fld) { // If password value changes, make sure password_confirm must be re-entered scope[fld] = ''; scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); } + + // Respond to 'Ask at runtime?' checkbox + scope.ask = function(fld, associated) { + if (scope[fld + '_ask']) { + scope[fld] = 'ASK'; + scope[associated] = ''; + scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); + } + else { + scope[fld] = ''; + scope[associated] = ''; + scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); + } + } } CredentialsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'CredentialForm', 'GenerateForm', @@ -236,6 +250,21 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP list: TeamList, field: 'team' }); + + function setAskCheckboxes() { + for (var fld in form.fields) { + if (form.fields[fld].type == 'password' && form.fields[fld].ask && scope[fld] == 'ASK') { + // turn on 'ask' checkbox for password fields with value of 'ASK' + $("#" + fld + "-clear-btn").attr("disabled","disabled"); + scope[fld + '_ask'] = true; + } + else { + scope[fld + '_ask'] = false; + $("#" + fld + "-clear-btn").removeAttr("disabled"); + } + + } + } // After Credential is loaded, retrieve each related set and any lookups scope.$on('credentialLoaded', function() { @@ -260,6 +289,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] = scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField]; } + setAskCheckboxes(); } var related = data.related; for (var set in form.related) { @@ -288,7 +318,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP Rest.put(data) .success( function(data, status, headers, config) { var base = $location.path().replace(/^\//,'').split('/')[0]; - (base == 'Credentials') ? ReturnToCaller() : ReturnToCaller(1); + (base == 'credentials') ? ReturnToCaller() : ReturnToCaller(1); }) .error( function(data, status, headers, config) { ProcessErrors(scope, data, status, form, @@ -302,6 +332,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP for (var fld in master) { scope[fld] = master[fld]; } + setAskCheckboxes(); }; // Related set: Add button @@ -348,6 +379,28 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP scope[fld] = ''; scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); } + + // Respond to 'Ask at runtime?' checkbox + scope.ask = function(fld, associated) { + if (scope[fld + '_ask']) { + $("#" + fld + "-clear-btn").attr("disabled","disabled"); + scope[fld] = 'ASK'; + scope[associated] = ''; + scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); + } + else { + $("#" + fld + "-clear-btn").removeAttr("disabled"); + scope[fld] = ''; + scope[associated] = ''; + scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); + } + } + + scope.clear = function(fld, associated) { + scope[fld] = ''; + scope[associated] = ''; + scope[form.name + '_form'][associated].$setValidity('awpassmatch', true); + } } diff --git a/lib/ui/static/js/forms/Credentials.js b/lib/ui/static/js/forms/Credentials.js index 6adc05473b..e0bd2f3a7d 100644 --- a/lib/ui/static/js/forms/Credentials.js +++ b/lib/ui/static/js/forms/Credentials.js @@ -39,7 +39,10 @@ angular.module('CredentialFormDefinition', []) type: 'password', addRequired: false, editRequired: false, - ngChange: "clearPWConfirm('ssh_password_confirm')" + ngChange: "clearPWConfirm('ssh_password_confirm')", + ask: true, + clear: true, + associated: 'ssh_password_confirm' }, "ssh_password_confirm": { label: 'Confirm SSH Password', @@ -61,7 +64,10 @@ angular.module('CredentialFormDefinition', []) type: 'password', addRequired: false, editRequired: false, - ngChange: "clearPWConfirm('ssh_key_unlock_confirm')" + ngChange: "clearPWConfirm('ssh_key_unlock_confirm')", + associated: 'ssh_key_unlock_confirm', + ask: true, + clear: true }, "ssh_key_unlock_confirm": { label: 'Confirm Key Password', @@ -79,10 +85,13 @@ angular.module('CredentialFormDefinition', []) }, "sudo_password": { label: 'Sudo Password', - type: 'text', + type: 'password', addRequired: false, editRequired: false, - ngChange: "clearPWConfirm('sudo_password_confirm')" + ngChange: "clearPWConfirm('sudo_password_confirm')", + ask: true, + clear: true, + associated: 'sudo_password_confirm' }, "sudo_password_confirm": { label: 'Confirm Sudo Password', diff --git a/lib/ui/static/js/lists/Credentials.js b/lib/ui/static/js/lists/Credentials.js index aad83429da..703556fb46 100644 --- a/lib/ui/static/js/lists/Credentials.js +++ b/lib/ui/static/js/lists/Credentials.js @@ -41,9 +41,9 @@ angular.module('CredentialListDefinition', []) actions: { add: { icon: 'icon-plus', - mode: 'select', // One of: edit, select, all + mode: 'all', // One of: edit, select, all ngClick: 'addCredential()', - basePaths: ['credentials'], // base path must be in list, or action not available + basePaths: ['credentials'], // base path must be in list, or action not available class: 'btn btn-mini btn-success', awToolTip: 'Create a new credential' } diff --git a/lib/ui/static/lib/ansible/form-generator.js b/lib/ui/static/lib/ansible/form-generator.js index f831057009..c55572c055 100644 --- a/lib/ui/static/lib/ansible/form-generator.js +++ b/lib/ui/static/lib/ansible/form-generator.js @@ -99,6 +99,9 @@ angular.module('FormGenerator', ['GeneratorHelpers']) if (this.form.fields[fld].awPassMatch) { this.scope[this.form.name + '_form'][fld].$setValidity('awpassmatch', true); } + if (this.form.fields[fld].ask) { + this.scope[fld + '_ask'] = false; + } } if (this.mode == 'add') { this.applyDefaults(); @@ -164,6 +167,7 @@ angular.module('FormGenerator', ['GeneratorHelpers']) html += ">\n"; html += "' + "\n"; html += "
\n"; + html += (field.clear) ? "
\n" : ""; html += "\n"; + html += "
\n"; + } + if (field.ask) { + html += " \n"; + } + html += "
\n"; // Add error messages if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) { html += "\n"; for (action in list.actions) { if (list.actions[action].mode == 'all' || list.actions[action].mode == options.mode) { - if (list.basePaths && list.basePaths.indexOf(base) > -1) { + if ( (list.basePaths == undefined) || (list.basePaths && list.basePaths.indexOf(base) > -1) ) { html += "