From 5afa79a11a4578a77dd1efbb2ef1579a26432bbe Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Sun, 8 Sep 2013 17:17:35 -0400 Subject: [PATCH] AC-351 latest SCM changes. Added 'Authentication Required' checkbox. Enabled SCM password prompting on job submission. --- awx/ui/static/js/controllers/Credentials.js | 2 +- awx/ui/static/js/controllers/Jobs.js | 12 +++++---- awx/ui/static/js/controllers/Projects.js | 30 ++++++++++++++++++++- awx/ui/static/js/forms/Projects.js | 24 +++++++++++------ awx/ui/static/js/helpers/JobSubmission.js | 13 ++++----- 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/awx/ui/static/js/controllers/Credentials.js b/awx/ui/static/js/controllers/Credentials.js index 91740aff4c..51e4779327 100644 --- a/awx/ui/static/js/controllers/Credentials.js +++ b/awx/ui/static/js/controllers/Credentials.js @@ -202,7 +202,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP scope[fld + '_ask'] = false; $("#" + fld + "-clear-btn").removeAttr("disabled"); } - + master[fld + '_ask'] = scope[fld + '_ask']; } } diff --git a/awx/ui/static/js/controllers/Jobs.js b/awx/ui/static/js/controllers/Jobs.js index fb09b5f8d7..588811221c 100644 --- a/awx/ui/static/js/controllers/Jobs.js +++ b/awx/ui/static/js/controllers/Jobs.js @@ -33,11 +33,13 @@ function JobsListCtrl ($scope, $rootScope, $location, $log, $routeParams, Rest, scope[ngc] = ""; }); - // Convert created date to local time zone - var cDate; - for (var i=0; i < scope[list.name].length; i++) { - cDate = new Date(scope[list.name][i].created); - scope[list.name][i].created = FormatDate(cDate); + if (scope[list.name]) { + // Convert created date to local time zone + var cDate; + for (var i=0; i < scope[list.name].length; i++) { + cDate = new Date(scope[list.name][i].created); + scope[list.name][i].created = FormatDate(cDate); + } } }); diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index 564554e824..29cbf46279 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -39,7 +39,8 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, // will contain status of last update, which is not what we want. scope.projects[i].last_update_failed = false; } - scope.projects[i].last_updated = FormatDate(new Date(scope.projects[i].last_updated)); + scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ? + FormatDate(new Date(scope.projects[i].last_updated)) : null; } }); @@ -233,6 +234,18 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch'; } + scope.authChange = function() { + if (!scope.auth_required) { + scope.scm_username = null; + scope.scm_password = null; + scope.scm_password_confirm = null; + scope.scm_key_data = null; + scope.scm_key_unlock = null; + scope.scm_key_unlock_confirm = null; + scope.scm_password_ask = false; + } + } + // Cancel scope.formReset = function() { $rootScope.flashMessage = null; @@ -288,6 +301,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara scope[fld + '_ask'] = false; $("#" + fld + "-clear-btn").removeAttr("disabled"); } + master[fld + '_ask'] = scope[fld + '_ask']; } } @@ -308,6 +322,8 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara scope.project_local_paths = opts; scope.base_dir = 'You do not have access to view this property'; } + scope.auth_required = (scope.scm_type && (scope.scm_username || scope.scm_key_unlock)) ? true : false; + master.auth_required = scope.auth_required; }); // Retrieve detail record and prepopulate the form @@ -403,6 +419,18 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara } }; + scope.authChange = function() { + if (!scope.auth_required) { + scope.scm_username = null; + scope.scm_password = null; + scope.scm_password_confirm = null; + scope.scm_key_data = null; + scope.scm_key_unlock = null; + scope.scm_key_unlock_confirm = null; + scope.scm_password_ask = false; + } + } + // Related set: Add button scope.add = function(set) { $rootScope.flashMessage = null; diff --git a/awx/ui/static/js/forms/Projects.js b/awx/ui/static/js/forms/Projects.js index 6534cb0f0e..0073d36766 100644 --- a/awx/ui/static/js/forms/Projects.js +++ b/awx/ui/static/js/forms/Projects.js @@ -109,17 +109,25 @@ angular.module('ProjectFormDefinition', []) addRequired: false, editRequired: false }, + auth_required: { + label: 'Authorization required?', + type: 'checkbox', + ngShow: "scm_type !== '' && scm_type !== null", + addRequired: false, + editRequired: false, + ngChange: 'authChange()' + }, scm_username: { label: 'SCM Username', type: 'text', - ngShow: "scm_type !== '' && scm_type !== null", + ngShow: "scm_type !== '' && scm_type !== null && auth_required", addRequired: false, editRequired: false }, "scm_password": { label: 'SCM Password', type: 'password', - ngShow: "scm_type !== '' && scm_type !== null", + ngShow: "scm_type !== '' && scm_type !== null && auth_required", addRequired: false, editRequired: false, ngChange: "clearPWConfirm('scm_password_confirm')", @@ -129,9 +137,9 @@ angular.module('ProjectFormDefinition', []) autocomplete: false }, "scm_password_confirm": { - label: 'Confirm Password', + label: 'Confirm SCM Password', type: 'password', - ngShow: "scm_type !== '' && scm_type !== null", + ngShow: "scm_type !== '' && scm_type !== null && auth_required", addRequired: false, editRequired: false, awPassMatch: true, @@ -141,7 +149,7 @@ angular.module('ProjectFormDefinition', []) "scm_key_data": { label: 'SCM Private Key', type: 'textarea', - ngShow: "scm_type !== '' && scm_type !== null", + ngShow: "scm_type !== '' && scm_type !== null && auth_required", xtraWide: true, addRequired: false, editRequired: false, @@ -151,7 +159,7 @@ angular.module('ProjectFormDefinition', []) "scm_key_unlock": { label: 'SCM Key Password', type: 'password', - ngShow: "scm_type !== '' && scm_type !== null && scm_key_data", + ngShow: "scm_type !== '' && scm_type !== null && scm_key_data && auth_required", addRequired: false, editRequired: false, ngChange: "clearPWConfirm('scm_key_unlock_confirm')", @@ -160,9 +168,9 @@ angular.module('ProjectFormDefinition', []) clear: true }, "scm_key_unlock_confirm": { - label: 'Confirm Key Password', + label: 'Confirm SCM Key Password', type: 'password', - ngShow: "scm_type !== '' && scm_type !== null && scm_key_data", + ngShow: "scm_type !== '' && scm_type !== null && scm_key_data && auth_required", addRequired: false, editRequired: false, awPassMatch: true, diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index a8022cc593..c6d7f2fb2d 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -5,16 +5,17 @@ * */ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition', - 'LookUpHelper', 'JobTemplateFormDefinition', 'ProjectFormDefinition' ]) + 'LookUpHelper', 'ProjectFormDefinition' ]) - .factory('PromptPasswords',['CredentialForm', '$compile', 'Rest', '$location', 'ProcessErrors', 'GetBasePath', 'Alert', - function(JobTemplateForm, $compile, Rest, $location, ProcessErrors, GetBasePath, Alert) { + .factory('PromptPasswords', ['CredentialForm', 'JobTemplateForm', 'ProjectsForm', '$compile', 'Rest', '$location', 'ProcessErrors', 'GetBasePath', + 'Alert', + function(CredentialForm, JobTemplateForm, ProjectsForm, $compile, Rest, $location, ProcessErrors, GetBasePath, Alert) { return function(params) { var scope = params.scope; var passwords = params.passwords; var start_url = params.start_url; - var form = params.form; + var form = CredentialForm; var html = ''; var field, element, dialogScope, fld; var base = $location.path().replace(/^\//,'').split('/')[0]; @@ -97,7 +98,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential html += html += "
\n"; for (var i=0; i < passwords.length; i++) { // Add the password field - field = form.fields[passwords[i]]; + field = (form.fields[passwords[i]]) ? form.fields[passwords[i]] : ProjectsForm.fields[passwords[i]]; fld = passwords[i]; scope[fld] = ''; html += "
\n"; @@ -119,7 +120,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential // Add the related confirm field fld = field.associated; - field = form.fields[field.associated]; + field = (form.fields[field.associated]) ? form.fields[field.associated] : ProjectsForm.fields[field.associated]; scope[fld] = ''; html += "
\n"; html += "' + "\n";