1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 18:21:12 +03:00

Latest AC-351 changes. Halfway through AC-282. On users page the complexity progress bar is rendering correctly according to password strength.

This commit is contained in:
chouseknecht 2013-09-04 18:16:25 -04:00
parent 54972c6038
commit 7bd3177e0c
7 changed files with 88 additions and 45 deletions

View File

@ -64,7 +64,13 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
} }
} }
if (project.scm_type !== null) { 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 { else {
Alert('Missing SCM Configuration', 'The selected project is not configured for SCM. You must first edit the project, provide SCM settings, ' + 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() { scope.scmChange = function() {
// When an scm_type is set, path is not required // When an scm_type is set, path is not required
scope.pathRequired = (scope.scm_type) ? false : true; scope.pathRequired = (scope.scm_type) ? false : true;
scope.scmBranchLabel = (scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
} }
} }

View File

@ -157,6 +157,10 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
// If password value changes, make sure password_confirm must be re-entered // If password value changes, make sure password_confirm must be re-entered
scope[fld] = ''; scope[fld] = '';
scope[form.name + '_form'][fld].$setValidity('awpassmatch', false); 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?
//}
} }
} }

View File

@ -65,7 +65,8 @@ angular.module('UserFormDefinition', [])
addRequired: true, addRequired: true,
editRequired: false, editRequired: false,
ngChange: "clearPWConfirm('password_confirm')", ngChange: "clearPWConfirm('password_confirm')",
autocomplete: false autocomplete: false,
pwMeter: true
}, },
password_confirm: { password_confirm: {
label: 'Confirm Password', label: 'Confirm Password',
@ -74,8 +75,7 @@ angular.module('UserFormDefinition', [])
editRequired: false, editRequired: false,
awPassMatch: true, awPassMatch: true,
associated: 'password', associated: 'password',
autocomplete: false, autocomplete: false
pwMeter: true
}, },
is_superuser: { is_superuser: {
label: 'Superuser?', label: 'Superuser?',

View File

@ -17,51 +17,45 @@ angular.module('ProjectsHelper', ['RestServices', 'Utilities', 'ProjectStatusDef
return function(params) { return function(params) {
var project_id = params.project_id; var project_id = params.project_id;
var last_update = params.last_update;
var generator = GenerateForm; var generator = GenerateForm;
var form = ProjectStatusForm; var form = ProjectStatusForm;
var scope; var scope;
var defaultUrl = GetBasePath('projects') + project_id + '/project_updates/';
// Retrieve detail record and prepopulate the form // Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl); Rest.setUrl(last_update);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
// load up the form // load up the form
if (data.results.length > 0) { scope = generator.inject(form, { mode: 'edit', modal: true, related: false});
scope = generator.inject(form, { mode: 'edit', modal: true, related: false}); generator.reset();
generator.reset(); var results = data;
var results = data.results[data.results.length - 1]; //get the latest for (var fld in form.fields) {
for (var fld in form.fields) { if (results[fld]) {
if (results[fld]) { if (fld == 'created') {
if (fld == 'created') { scope[fld] = FormatDate(new Date(results[fld]));
scope[fld] = FormatDate(new Date(results[fld])); }
} else {
else { scope[fld] = results[fld];
scope[fld] = results[fld]; }
}
}
else {
if (results.summary_fields.project[fld]) {
scope[fld] = results.summary_fields.project[fld]
}
}
} }
scope.formModalAction = function() { else {
$('#form-modal').modal("hide"); if (results.summary_fields.project[fld]) {
} scope[fld] = results.summary_fields.project[fld]
scope.formModalActionLabel = 'OK'; }
scope.formModalCancelShow = false;
scope.formModalInfo = false;
scope.formModalHeader = results.summary_fields.project.name + '<span class="subtitle"> - SCM Status</span>';
$('#form-modal .btn-success').removeClass('btn-success').addClass('btn-none');
$('#form-modal').addClass('skinny-modal');
if (!scope.$$phase) {
scope.$digest();
} }
} }
else { scope.formModalAction = function() {
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' + $('#form-modal').modal("hide");
' completed. If you have not already done so, start an update for this project.', 'alert-info'); }
scope.formModalActionLabel = 'OK';
scope.formModalCancelShow = false;
scope.formModalInfo = false;
scope.formModalHeader = results.summary_fields.project.name + '<span class="subtitle"> - SCM Status</span>';
$('#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) { .error( function(data, status, headers, config) {

View File

@ -878,6 +878,21 @@ tr td button i {
height: 40px; 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 */ /* Large desktop */
@media (min-width: 1200px) { @media (min-width: 1200px) {

View File

@ -382,6 +382,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += "ng-model=\"" + fld + '" '; html += "ng-model=\"" + fld + '" ';
html += 'name="' + fld + '" '; html += 'name="' + fld + '" ';
html += (field.ngChange) ? this.attr(field,'ngChange') : ""; html += (field.ngChange) ? this.attr(field,'ngChange') : "";
//html += (field.pwMeter) ? "ng-change=\"chkPass()\" " : "";
html += (field.id) ? this.attr(field,'id') : ""; html += (field.id) ? this.attr(field,'id') : "";
html += "class=\"form-control"; html += "class=\"form-control";
html += (field['class']) ? " " + this.attr(field, 'class') : ""; html += (field['class']) ? " " + this.attr(field, 'class') : "";
@ -430,6 +431,26 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld + html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
".$error.awpassmatch\">Must match Password value</div>\n"; ".$error.awpassmatch\">Must match Password value</div>\n";
} }
if (field.pwMeter) {
html += "<div class=\"pw-progress\">\n";
html += "<div class=\"progress progress-striped\">\n";
html += "<div id=\"progbar\" class=\"progress-bar\" role=\"progress\"></div>\n";
html += "</div>\n";
html += "<p>Password strength requirements:</p>";
html += "<ul class=\"pwddetails\">\n";
html += "<li>Minimum 8 characters in length</li>\n";
html += "<li>Contains 3/4 of the following items:\n";
html += "<ul>\n";
html += "<li>UPPERCASE letters</li>\n";
html += "<li>lowercase letters</li>\n";
html += "<li>Numbers</li>\n";
html += "<li>Symbols !@#$%^&*()</li>\n";
html += "</ul>\n";
html += "</li>\n";
html += "</ul>\n";
html += "</div>\n";
}
html += "<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>\n"; html += "<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>\n";
html += "</div>\n"; html += "</div>\n";

View File

@ -65,6 +65,7 @@ var nScore = 0;
function chkPass(pwd) { function chkPass(pwd) {
// Simultaneous variable declaration and value assignment aren't supported in IE apparently // 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* // 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, 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, 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, nConsecNumber=0, nConsecSymbol=0, nConsecCharType=0, nSeqAlpha=0, nSeqNumber=0, nSeqSymbol=0,
@ -229,22 +230,23 @@ function chkPass(pwd) {
if (nScore >= 0 && nScore <= 33) { if (nScore >= 0 && nScore <= 33) {
sComplexity = 'Weak'; sComplexity = 'Weak';
progbar.addClass('bar-danger') progbar.addClass('progress-bar-danger')
progbar.removeClass('bar-success bar-warning') progbar.removeClass('progress-bar-success progress-bar-warning')
} else if (nScore > 33 && nScore <= 67) { } else if (nScore > 33 && nScore <= 67) {
sComplexity = 'Good'; sComplexity = 'Good';
progbar.addClass('bar-warning') progbar.addClass('progress-bar-warning')
progbar.removeClass('bar-success bar-danger') progbar.removeClass('progress-bar-success progress-bar-danger')
} else if (nScore > 67) { } else if (nScore > 67) {
sComplexity = "Strong"; sComplexity = "Strong";
progbar.addClass('bar-success') progbar.addClass('progress-bar-success')
progbar.removeClass('bar-warning bar-danger') progbar.removeClass('progress-bar-warning progress-bar-danger')
} }
} }
else { else {
/* no password, so reset the displays */ /* no password, so reset the displays */
var progbar = $("#progbar"); var progbar = $("#progbar");
progbar.css("width", '0%'); 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;
} }