mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
AC-435 enable/disable/require User fields based on LDAP settings.
This commit is contained in:
@@ -33,6 +33,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
scope.projectsPostRefresh();
|
||||
}
|
||||
scope.projectsPostRefresh = scope.$on('PostRefresh', function() {
|
||||
if (scope.projects) {
|
||||
for (var i=0; i < scope.projects.length; i++) {
|
||||
switch(scope.projects[i].status) {
|
||||
case 'updating':
|
||||
@@ -49,6 +50,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
||||
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
|
||||
FormatDate(new Date(scope.projects[i].last_updated)) : null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'projects', list: list, url: defaultUrl });
|
||||
|
||||
@@ -32,9 +32,11 @@ function TeamsList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale
|
||||
}
|
||||
scope.PostRefershRemove = scope.$on('PostRefresh', function() {
|
||||
// After a refresh, populate the organization name on each row
|
||||
if (scope.teams) {
|
||||
for ( var i=0; i < scope.teams.length; i++) {
|
||||
scope.teams[i].organization_name = scope.teams[i].summary_fields.organization.name;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
||||
|
||||
@@ -83,8 +83,22 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
// Inject dynamic view
|
||||
var defaultUrl = GetBasePath('organizations');
|
||||
var form = UserForm;
|
||||
|
||||
// Restore form to default condition. It may have been modified during edit of an LDAP user
|
||||
form.fields['first_name'].readonly = false;
|
||||
form.fields['first_name'].editRequired = true;
|
||||
form.fields['last_name'].readonly = false;
|
||||
form.fields['last_name'].editRequired = true;
|
||||
form.fields['email'].readonly = false;
|
||||
form.fields['email'].editRequired = true;
|
||||
form.fields['organization'].awRequiredWhen = { variable: "orgrequired", init: true};
|
||||
|
||||
var generator = GenerateForm;
|
||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
||||
|
||||
scope.not_ldap_user = true;
|
||||
scope.ldap_dn = null;
|
||||
|
||||
generator.reset();
|
||||
|
||||
LoadBreadCrumbs();
|
||||
@@ -176,6 +190,8 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
var generator = GenerateForm;
|
||||
var form = UserForm;
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
|
||||
$scope.$on('formReady', function() {
|
||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
||||
generator.reset();
|
||||
var master = {};
|
||||
@@ -215,6 +231,8 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
}
|
||||
}
|
||||
|
||||
scope.not_ldap_user = (scope.ldap_dn) ? false : true;
|
||||
|
||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||
@@ -341,6 +359,36 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
||||
});
|
||||
}
|
||||
|
||||
}); // $scope.$on
|
||||
|
||||
// Restore form to default condition
|
||||
form.fields['first_name'].readonly = false;
|
||||
form.fields['first_name'].editRequired = true;
|
||||
form.fields['last_name'].readonly = false;
|
||||
form.fields['last_name'].editRequired = true;
|
||||
form.fields['email'].readonly = false;
|
||||
form.fields['email'].editRequired = true;
|
||||
form.fields['organization'].awRequiredWhen = { variable: "orgrequired", init: true};
|
||||
|
||||
// Modify form based on LDAP settings
|
||||
Rest.setUrl(GetBasePath('config'));
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
if (data['user_ldap_fields']) {
|
||||
for (var fld in data['user_ldap_fields']) {
|
||||
form.fields[fld]['readonly'] = true;
|
||||
form.fields[fld]['editRequired'] = false;
|
||||
if (form.fields[fld].awRequiredWhen) {
|
||||
delete form.fields[fld].awRequiredWhen;
|
||||
}
|
||||
}
|
||||
}
|
||||
$scope.$emit('formReady');
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to retrieve application config. GET status: ' + status });
|
||||
});
|
||||
}
|
||||
|
||||
UsersEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm',
|
||||
|
||||
@@ -46,24 +46,26 @@ angular.module('UserFormDefinition', [])
|
||||
type: 'lookup',
|
||||
sourceModel: 'organization',
|
||||
sourceField: 'name',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
ngClick: 'lookUpOrganization()',
|
||||
excludeMode: 'edit',
|
||||
awRequiredWhen: {variable: "orgrequired", init: "true" }
|
||||
awRequiredWhen: { variable: "orgrequired", init: true}
|
||||
},
|
||||
username: {
|
||||
label: 'Username',
|
||||
type: 'text',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
awRequiredWhen: { variable: "not_ldap_user", init: true },
|
||||
autocomplete: false
|
||||
},
|
||||
ldap_dn: {
|
||||
label: 'Created by LDAP?',
|
||||
type: 'checkbox',
|
||||
readonly: true
|
||||
},
|
||||
password: {
|
||||
label: 'Password',
|
||||
type: 'password',
|
||||
addRequired: true,
|
||||
editRequired: false,
|
||||
ngShow: 'not_ldap_user == true',
|
||||
awRequiredWhen: { variable: "not_ldap_user", init: true},
|
||||
ngChange: "clearPWConfirm('password_confirm')",
|
||||
autocomplete: false,
|
||||
chkPass: true
|
||||
@@ -71,6 +73,7 @@ angular.module('UserFormDefinition', [])
|
||||
password_confirm: {
|
||||
label: 'Confirm Password',
|
||||
type: 'password',
|
||||
ngShow: 'not_ldap_user == true',
|
||||
addRequired: false,
|
||||
editRequired: false,
|
||||
awPassMatch: true,
|
||||
|
||||
@@ -131,8 +131,10 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
|
||||
ctrl.$setValidity('required', validity);
|
||||
}
|
||||
|
||||
if (attrs.awrequiredInit !== undefined && attrs.awrequiredInit !== null) {
|
||||
scope[attrs.awRequiredWhen] = attrs.awrequiredInit;
|
||||
checkIt();
|
||||
}
|
||||
|
||||
scope.$watch(attrs.awRequiredWhen, function() {
|
||||
// watch for the aw-required-when expression to change value
|
||||
|
||||
1
awx/ui/static/lib/jquery/jquery-1.10.2.min.map
Normal file
1
awx/ui/static/lib/jquery/jquery-1.10.2.min.map
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user