mirror of
https://github.com/ansible/awx.git
synced 2026-07-09 15:28:05 -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.projectsPostRefresh = scope.$on('PostRefresh', function() {
|
scope.projectsPostRefresh = scope.$on('PostRefresh', function() {
|
||||||
|
if (scope.projects) {
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
for (var i=0; i < scope.projects.length; i++) {
|
||||||
switch(scope.projects[i].status) {
|
switch(scope.projects[i].status) {
|
||||||
case 'updating':
|
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) ?
|
scope.projects[i].last_updated = (scope.projects[i].last_updated !== null) ?
|
||||||
FormatDate(new Date(scope.projects[i].last_updated)) : null;
|
FormatDate(new Date(scope.projects[i].last_updated)) : null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'projects', list: list, url: defaultUrl });
|
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() {
|
scope.PostRefershRemove = scope.$on('PostRefresh', function() {
|
||||||
// After a refresh, populate the organization name on each row
|
// After a refresh, populate the organization name on each row
|
||||||
|
if (scope.teams) {
|
||||||
for ( var i=0; i < scope.teams.length; i++) {
|
for ( var i=0; i < scope.teams.length; i++) {
|
||||||
scope.teams[i].organization_name = scope.teams[i].summary_fields.organization.name;
|
scope.teams[i].organization_name = scope.teams[i].summary_fields.organization.name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: 'teams', list: list, url: defaultUrl });
|
||||||
|
|||||||
@@ -83,8 +83,22 @@ function UsersAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
// Inject dynamic view
|
// Inject dynamic view
|
||||||
var defaultUrl = GetBasePath('organizations');
|
var defaultUrl = GetBasePath('organizations');
|
||||||
var form = UserForm;
|
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 generator = GenerateForm;
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
var scope = generator.inject(form, {mode: 'add', related: false});
|
||||||
|
|
||||||
|
scope.not_ldap_user = true;
|
||||||
|
scope.ldap_dn = null;
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
@@ -176,6 +190,8 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
|
|||||||
var generator = GenerateForm;
|
var generator = GenerateForm;
|
||||||
var form = UserForm;
|
var form = UserForm;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
|
|
||||||
|
$scope.$on('formReady', function() {
|
||||||
var scope = generator.inject(form, {mode: 'edit', related: true});
|
var scope = generator.inject(form, {mode: 'edit', related: true});
|
||||||
generator.reset();
|
generator.reset();
|
||||||
var master = {};
|
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.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, 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',
|
UsersEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'UserForm',
|
||||||
|
|||||||
@@ -46,24 +46,26 @@ angular.module('UserFormDefinition', [])
|
|||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
sourceModel: 'organization',
|
sourceModel: 'organization',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
addRequired: true,
|
|
||||||
editRequired: true,
|
|
||||||
ngClick: 'lookUpOrganization()',
|
ngClick: 'lookUpOrganization()',
|
||||||
excludeMode: 'edit',
|
excludeMode: 'edit',
|
||||||
awRequiredWhen: {variable: "orgrequired", init: "true" }
|
awRequiredWhen: { variable: "orgrequired", init: true}
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
label: 'Username',
|
label: 'Username',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
addRequired: true,
|
awRequiredWhen: { variable: "not_ldap_user", init: true },
|
||||||
editRequired: true,
|
|
||||||
autocomplete: false
|
autocomplete: false
|
||||||
},
|
},
|
||||||
|
ldap_dn: {
|
||||||
|
label: 'Created by LDAP?',
|
||||||
|
type: 'checkbox',
|
||||||
|
readonly: true
|
||||||
|
},
|
||||||
password: {
|
password: {
|
||||||
label: 'Password',
|
label: 'Password',
|
||||||
type: 'password',
|
type: 'password',
|
||||||
addRequired: true,
|
ngShow: 'not_ldap_user == true',
|
||||||
editRequired: false,
|
awRequiredWhen: { variable: "not_ldap_user", init: true},
|
||||||
ngChange: "clearPWConfirm('password_confirm')",
|
ngChange: "clearPWConfirm('password_confirm')",
|
||||||
autocomplete: false,
|
autocomplete: false,
|
||||||
chkPass: true
|
chkPass: true
|
||||||
@@ -71,6 +73,7 @@ angular.module('UserFormDefinition', [])
|
|||||||
password_confirm: {
|
password_confirm: {
|
||||||
label: 'Confirm Password',
|
label: 'Confirm Password',
|
||||||
type: 'password',
|
type: 'password',
|
||||||
|
ngShow: 'not_ldap_user == true',
|
||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false,
|
editRequired: false,
|
||||||
awPassMatch: true,
|
awPassMatch: true,
|
||||||
|
|||||||
@@ -131,8 +131,10 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
|
|||||||
ctrl.$setValidity('required', validity);
|
ctrl.$setValidity('required', validity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attrs.awrequiredInit !== undefined && attrs.awrequiredInit !== null) {
|
||||||
scope[attrs.awRequiredWhen] = attrs.awrequiredInit;
|
scope[attrs.awRequiredWhen] = attrs.awrequiredInit;
|
||||||
checkIt();
|
checkIt();
|
||||||
|
}
|
||||||
|
|
||||||
scope.$watch(attrs.awRequiredWhen, function() {
|
scope.$watch(attrs.awRequiredWhen, function() {
|
||||||
// watch for the aw-required-when expression to change value
|
// 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