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:
parent
54972c6038
commit
7bd3177e0c
@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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?
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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?',
|
||||
|
@ -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 + '<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 {
|
||||
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 + '<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) {
|
||||
|
@ -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) {
|
||||
|
@ -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 += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||
".$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>\n";
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user