From 7bd3177e0ca94d2d30a3e7895f1f32568c515062 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Wed, 4 Sep 2013 18:16:25 -0400 Subject: [PATCH] Latest AC-351 changes. Halfway through AC-282. On users page the complexity progress bar is rendering correctly according to password strength. --- awx/ui/static/js/controllers/Projects.js | 9 ++- awx/ui/static/js/controllers/Users.js | 4 ++ awx/ui/static/js/forms/Users.js | 6 +- awx/ui/static/js/helpers/Projects.js | 62 ++++++++++----------- awx/ui/static/less/ansible-ui.less | 15 +++++ awx/ui/static/lib/ansible/form-generator.js | 21 +++++++ awx/ui/static/lib/ansible/pwdmeter.js | 16 +++--- 7 files changed, 88 insertions(+), 45 deletions(-) diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index 7b484b60a0..de0b282e55 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -64,7 +64,13 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } } if (project.scm_type !== null) { - ProjectStatus({ project_id: id }); + if (project.related.last_update !== undefined) { + ProjectStatus({ project_id: id, last_update: project.related.last_update }); + } + else { + Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' + + ' completed. If you have not already done so, start an update for this project.', 'alert-info'); + } } else { Alert('Missing SCM Configuration', 'The selected project is not configured for SCM. You must first edit the project, provide SCM settings, ' + @@ -438,6 +444,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara scope.scmChange = function() { // When an scm_type is set, path is not required scope.pathRequired = (scope.scm_type) ? false : true; + scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch'; } } diff --git a/awx/ui/static/js/controllers/Users.js b/awx/ui/static/js/controllers/Users.js index 9c29967f78..59300db90d 100644 --- a/awx/ui/static/js/controllers/Users.js +++ b/awx/ui/static/js/controllers/Users.js @@ -157,6 +157,10 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, // If password value changes, make sure password_confirm must be re-entered scope[fld] = ''; scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); + var score = chkPass(scope.password); + //if (score < 67) { + // good stuff happens... maybe this could be handled by a directive? + //} } } diff --git a/awx/ui/static/js/forms/Users.js b/awx/ui/static/js/forms/Users.js index 3c6fb7b556..1a777e23c7 100644 --- a/awx/ui/static/js/forms/Users.js +++ b/awx/ui/static/js/forms/Users.js @@ -65,7 +65,8 @@ angular.module('UserFormDefinition', []) addRequired: true, editRequired: false, ngChange: "clearPWConfirm('password_confirm')", - autocomplete: false + autocomplete: false, + pwMeter: true }, password_confirm: { label: 'Confirm Password', @@ -74,8 +75,7 @@ angular.module('UserFormDefinition', []) editRequired: false, awPassMatch: true, associated: 'password', - autocomplete: false, - pwMeter: true + autocomplete: false }, is_superuser: { label: 'Superuser?', diff --git a/awx/ui/static/js/helpers/Projects.js b/awx/ui/static/js/helpers/Projects.js index 2ebcddbe3e..5369929e9b 100644 --- a/awx/ui/static/js/helpers/Projects.js +++ b/awx/ui/static/js/helpers/Projects.js @@ -17,51 +17,45 @@ angular.module('ProjectsHelper', ['RestServices', 'Utilities', 'ProjectStatusDef return function(params) { var project_id = params.project_id; + var last_update = params.last_update; var generator = GenerateForm; var form = ProjectStatusForm; var scope; - var defaultUrl = GetBasePath('projects') + project_id + '/project_updates/'; // Retrieve detail record and prepopulate the form - Rest.setUrl(defaultUrl); + Rest.setUrl(last_update); Rest.get() .success( function(data, status, headers, config) { // load up the form - if (data.results.length > 0) { - scope = generator.inject(form, { mode: 'edit', modal: true, related: false}); - generator.reset(); - var results = data.results[data.results.length - 1]; //get the latest - for (var fld in form.fields) { - if (results[fld]) { - if (fld == 'created') { - scope[fld] = FormatDate(new Date(results[fld])); - } - else { - scope[fld] = results[fld]; - } - } - else { - if (results.summary_fields.project[fld]) { - scope[fld] = results.summary_fields.project[fld] - } - } + scope = generator.inject(form, { mode: 'edit', modal: true, related: false}); + generator.reset(); + var results = data; + for (var fld in form.fields) { + if (results[fld]) { + if (fld == 'created') { + scope[fld] = FormatDate(new Date(results[fld])); + } + else { + scope[fld] = results[fld]; + } } - scope.formModalAction = function() { - $('#form-modal').modal("hide"); - } - scope.formModalActionLabel = 'OK'; - scope.formModalCancelShow = false; - scope.formModalInfo = false; - scope.formModalHeader = results.summary_fields.project.name + ' - SCM Status'; - $('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none'); - $('#form-modal').addClass('skinny-modal'); - if (!scope.$$phase) { - scope.$digest(); + else { + if (results.summary_fields.project[fld]) { + scope[fld] = results.summary_fields.project[fld] + } } } - else { - Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' + - ' completed. If you have not already done so, start an update for this project.', 'alert-info'); + scope.formModalAction = function() { + $('#form-modal').modal("hide"); + } + scope.formModalActionLabel = 'OK'; + scope.formModalCancelShow = false; + scope.formModalInfo = false; + scope.formModalHeader = results.summary_fields.project.name + ' - SCM Status'; + $('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none'); + $('#form-modal').addClass('skinny-modal'); + if (!scope.$$phase) { + scope.$digest(); } }) .error( function(data, status, headers, config) { diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index ae5fe80fac..8afc2f7f8b 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -878,6 +878,21 @@ tr td button i { height: 40px; } + +/* PW progress bar */ +.pw-progress { + margin-top: 10px; + + li { + line-height: normal; + margin-bottom: 10px; + } + ul:last-child { + margin-top: 10px; + } + +} + /* Large desktop */ @media (min-width: 1200px) { diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index d87c2300cd..c3b76cd7cc 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -382,6 +382,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) html += "ng-model=\"" + fld + '" '; html += 'name="' + fld + '" '; html += (field.ngChange) ? this.attr(field,'ngChange') : ""; + //html += (field.pwMeter) ? "ng-change=\"chkPass()\" " : ""; html += (field.id) ? this.attr(field,'id') : ""; html += "class=\"form-control"; html += (field['class']) ? " " + this.attr(field, 'class') : ""; @@ -430,6 +431,26 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) html += "
Must match Password value
\n"; } + + if (field.pwMeter) { + html += "
\n"; + html += "
\n"; + html += "
\n"; + html += "
\n"; + html += "

Password strength requirements:

"; + html += "\n"; + html += "
\n"; + } html += "
\n"; html += "\n"; diff --git a/awx/ui/static/lib/ansible/pwdmeter.js b/awx/ui/static/lib/ansible/pwdmeter.js index c05f463393..2af8a38c9d 100644 --- a/awx/ui/static/lib/ansible/pwdmeter.js +++ b/awx/ui/static/lib/ansible/pwdmeter.js @@ -65,6 +65,7 @@ var nScore = 0; function chkPass(pwd) { // Simultaneous variable declaration and value assignment aren't supported in IE apparently // so I'm forced to assign the same value individually per var to support a crappy browser *sigh* + console.log('here!'); var nLength=0, nAlphaUC=0, nAlphaLC=0, nNumber=0, nSymbol=0, nMidChar=0, nRequirements=0, nAlphasOnly=0, nNumbersOnly=0, nUnqChar=0, nRepChar=0, nRepInc=0, nConsecAlphaUC=0, nConsecAlphaLC=0, nConsecNumber=0, nConsecSymbol=0, nConsecCharType=0, nSeqAlpha=0, nSeqNumber=0, nSeqSymbol=0, @@ -229,22 +230,23 @@ function chkPass(pwd) { if (nScore >= 0 && nScore <= 33) { sComplexity = 'Weak'; - progbar.addClass('bar-danger') - progbar.removeClass('bar-success bar-warning') + progbar.addClass('progress-bar-danger') + progbar.removeClass('progress-bar-success progress-bar-warning') } else if (nScore > 33 && nScore <= 67) { sComplexity = 'Good'; - progbar.addClass('bar-warning') - progbar.removeClass('bar-success bar-danger') + progbar.addClass('progress-bar-warning') + progbar.removeClass('progress-bar-success progress-bar-danger') } else if (nScore > 67) { sComplexity = "Strong"; - progbar.addClass('bar-success') - progbar.removeClass('bar-warning bar-danger') + progbar.addClass('progress-bar-success') + progbar.removeClass('progress-bar-warning progress-bar-danger') } } else { /* no password, so reset the displays */ var progbar = $("#progbar"); progbar.css("width", '0%'); - progbar.removeClass('bar-success bar-warning bar-danger') + progbar.removeClass('progress-bar-success progress-bar-warning progress-bar-danger') } + return nScore; } \ No newline at end of file