mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Update user add/edit UI to support System Auditor setting
Also moved the LDAP indicator to be inline with the mockups (bubble next to the uesrname in the upper left) #1937 #1888
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
min-height: 40px;
|
min-height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.Form-title--is_superuser{
|
.Form-title--is_superuser, .Form-title--is_system_auditor, .Form-title--is_ldap_user{
|
||||||
height:15px;
|
height:15px;
|
||||||
color: @default-interface-txt;
|
color: @default-interface-txt;
|
||||||
background-color: @default-list-header-bg;
|
background-color: @default-list-header-bg;
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
position: absolute;
|
//position: absolute;
|
||||||
margin-top: 2.25px;
|
margin-top: 2.25px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,26 @@
|
|||||||
* @description This controller's the Users page
|
* @description This controller's the Users page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const user_type_options = [
|
||||||
|
{type: 'normal' , label: 'Normal User' },
|
||||||
|
{type: 'system_auditor' , label: 'System Auditor' },
|
||||||
|
{type: 'system_administrator', label: 'System Administrator' },
|
||||||
|
];
|
||||||
|
|
||||||
|
function user_type_sync($scope) {
|
||||||
|
return (type_option) => {
|
||||||
|
$scope.is_superuser = false;
|
||||||
|
$scope.is_system_auditor = false;
|
||||||
|
switch (type_option.type) {
|
||||||
|
case 'system_administrator':
|
||||||
|
$scope.is_superuser = true;
|
||||||
|
break;
|
||||||
|
case 'system_auditor':
|
||||||
|
$scope.is_system_auditor = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function UsersList($scope, $rootScope, $location, $log, $stateParams,
|
export function UsersList($scope, $rootScope, $location, $log, $stateParams,
|
||||||
Rest, Alert, UserList, GenerateList, Prompt, SearchInit, PaginateInit,
|
Rest, Alert, UserList, GenerateList, Prompt, SearchInit, PaginateInit,
|
||||||
@@ -116,10 +136,13 @@ UsersList.$inject = ['$scope', '$rootScope', '$location', '$log',
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function UsersAdd($scope, $rootScope, $compile, $location, $log,
|
export function UsersAdd($scope, $rootScope, $compile, $location, $log,
|
||||||
$stateParams, UserForm, GenerateForm, Rest, Alert, ProcessErrors,
|
$stateParams, UserForm, GenerateForm, Rest, Alert, ProcessErrors,
|
||||||
ReturnToCaller, ClearScope, GetBasePath, LookUpInit, OrganizationList,
|
ReturnToCaller, ClearScope, GetBasePath, LookUpInit, OrganizationList,
|
||||||
ResetForm, Wait, $state) {
|
ResetForm, Wait, CreateSelect2, $state) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -138,6 +161,15 @@ export function UsersAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
|
$scope.user_type_options = user_type_options;
|
||||||
|
$scope.user_type = user_type_options[0]
|
||||||
|
$scope.$watch('user_type', user_type_sync($scope));
|
||||||
|
|
||||||
|
CreateSelect2({
|
||||||
|
element: '#user_user_type',
|
||||||
|
multiple: false
|
||||||
|
});
|
||||||
|
|
||||||
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
|
// Configure the lookup dialog. If we're adding a user through the Organizations tab,
|
||||||
// default the Organization value.
|
// default the Organization value.
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
@@ -177,7 +209,8 @@ export function UsersAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
data[fld] = $scope[fld];
|
data[fld] = $scope[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.is_superuser = data.is_superuser || false;
|
data.is_superuser = $scope.is_superuser;
|
||||||
|
data.is_system_auditor = $scope.is_system_auditor;
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
@@ -215,14 +248,14 @@ export function UsersAdd($scope, $rootScope, $compile, $location, $log,
|
|||||||
UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log',
|
UsersAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log',
|
||||||
'$stateParams', 'UserForm', 'GenerateForm', 'Rest', 'Alert',
|
'$stateParams', 'UserForm', 'GenerateForm', 'Rest', 'Alert',
|
||||||
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath',
|
'ProcessErrors', 'ReturnToCaller', 'ClearScope', 'GetBasePath',
|
||||||
'LookUpInit', 'OrganizationList', 'ResetForm', 'Wait', '$state'
|
'LookUpInit', 'OrganizationList', 'ResetForm', 'Wait', 'CreateSelect2', '$state'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export function UsersEdit($scope, $rootScope, $location,
|
export function UsersEdit($scope, $rootScope, $location,
|
||||||
$stateParams, UserForm, GenerateForm, Rest, ProcessErrors,
|
$stateParams, UserForm, GenerateForm, Rest, ProcessErrors,
|
||||||
RelatedSearchInit, RelatedPaginateInit, ClearScope,
|
RelatedSearchInit, RelatedPaginateInit, ClearScope,
|
||||||
GetBasePath, ResetForm, Wait, $state) {
|
GetBasePath, ResetForm, Wait, CreateSelect2 ,$state) {
|
||||||
|
|
||||||
ClearScope();
|
ClearScope();
|
||||||
|
|
||||||
@@ -237,6 +270,10 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
generator.inject(form, { mode: 'edit', related: true, scope: $scope });
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
|
$scope.user_type_options = user_type_options;
|
||||||
|
$scope.user_type = user_type_options[0]
|
||||||
|
$scope.$watch('user_type', user_type_sync($scope));
|
||||||
|
|
||||||
var setScopeFields = function(data){
|
var setScopeFields = function(data){
|
||||||
_(data)
|
_(data)
|
||||||
.pick(function(value, key){
|
.pick(function(value, key){
|
||||||
@@ -278,6 +315,8 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
data[key] = $scope[key];
|
data[key] = $scope[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
data.is_superuser = $scope.is_superuser;
|
||||||
|
data.is_system_auditor = $scope.is_system_auditor;
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -292,6 +331,24 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
master.ldap_user = $scope.ldap_user;
|
master.ldap_user = $scope.ldap_user;
|
||||||
$scope.socialAuthUser = (data.auth.length > 0) ? true : false;
|
$scope.socialAuthUser = (data.auth.length > 0) ? true : false;
|
||||||
|
|
||||||
|
$scope.user_type = $scope.user_type_options[0];
|
||||||
|
$scope.is_system_auditor = false;
|
||||||
|
$scope.is_superuser = false;
|
||||||
|
if (data.is_system_auditor) {
|
||||||
|
$scope.user_type = $scope.user_type_options[1];
|
||||||
|
$scope.is_system_auditor = true;
|
||||||
|
}
|
||||||
|
if (data.is_superuser) {
|
||||||
|
$scope.user_type = $scope.user_type_options[2];
|
||||||
|
$scope.is_superuser = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateSelect2({
|
||||||
|
element: '#user_user_type',
|
||||||
|
multiple: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
setScopeFields(data);
|
setScopeFields(data);
|
||||||
setScopeRelated(data, form.related);
|
setScopeRelated(data, form.related);
|
||||||
|
|
||||||
@@ -353,5 +410,5 @@ export function UsersEdit($scope, $rootScope, $location,
|
|||||||
UsersEdit.$inject = ['$scope', '$rootScope', '$location',
|
UsersEdit.$inject = ['$scope', '$rootScope', '$location',
|
||||||
'$stateParams', 'UserForm', 'GenerateForm', 'Rest', 'ProcessErrors',
|
'$stateParams', 'UserForm', 'GenerateForm', 'Rest', 'ProcessErrors',
|
||||||
'RelatedSearchInit', 'RelatedPaginateInit', 'ClearScope', 'GetBasePath',
|
'RelatedSearchInit', 'RelatedPaginateInit', 'ClearScope', 'GetBasePath',
|
||||||
'ResetForm', 'Wait', '$state'
|
'ResetForm', 'Wait', 'CreateSelect2', '$state'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -87,21 +87,13 @@ export default
|
|||||||
associated: 'password',
|
associated: 'password',
|
||||||
autocomplete: false
|
autocomplete: false
|
||||||
},
|
},
|
||||||
is_superuser: {
|
user_type: {
|
||||||
label: 'Superuser <span style="text-transform:none;">(User has full system administration privileges)</span>',
|
label: 'User Type',
|
||||||
type: 'checkbox',
|
type: 'select',
|
||||||
trueValue: 'true',
|
ngOptions: 'item as item.label for item in user_type_options track by item.type',
|
||||||
falseValue: 'false',
|
disableChooseOption: true,
|
||||||
"default": 'false',
|
ngModel: 'user_type',
|
||||||
ngShow: "current_user['is_superuser'] == true",
|
|
||||||
ngModel: 'is_superuser'
|
|
||||||
},
|
},
|
||||||
ldap_user: {
|
|
||||||
label: 'Created by LDAP',
|
|
||||||
type: 'checkbox',
|
|
||||||
readonly: true,
|
|
||||||
awFeature: 'ldap'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
buttons: {
|
buttons: {
|
||||||
|
|||||||
@@ -1101,7 +1101,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
|
|
||||||
html += "<div class=\"Form-dropDownContainer\">\n";
|
html += "<div class=\"Form-dropDownContainer\">\n";
|
||||||
html += "<select ";
|
html += "<select ";
|
||||||
html += "ng-model=\"" + fld + '" ';
|
html += "ng-model=\"" + (field.ngModel ? field.ngModel : fld) + '" ';
|
||||||
html += 'name="' + fld + '" ';
|
html += 'name="' + fld + '" ';
|
||||||
html += "class=\"form-control Form-dropDown";
|
html += "class=\"form-control Form-dropDown";
|
||||||
html += "\" ";
|
html += "\" ";
|
||||||
@@ -1109,6 +1109,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += (field.ngChange) ? this.attr(field, 'ngChange') : "";
|
html += (field.ngChange) ? this.attr(field, 'ngChange') : "";
|
||||||
html += (field.ngDisabled) ? this.attr(field, 'ngDisabled'): "";
|
html += (field.ngDisabled) ? this.attr(field, 'ngDisabled'): "";
|
||||||
html += (field.ngRequired) ? this.attr(field, 'ngRequired') : "";
|
html += (field.ngRequired) ? this.attr(field, 'ngRequired') : "";
|
||||||
|
html += (field.ngInit) ? this.attr(field, 'ngInit') : "";
|
||||||
html += buildId(field, fld, this.form);
|
html += buildId(field, fld, this.form);
|
||||||
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
|
html += (options.mode === 'edit' && field.editRequired) ? "required " : "";
|
||||||
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
|
html += (options.mode === 'add' && field.addRequired) ? "required " : "";
|
||||||
@@ -1121,7 +1122,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += field.awRequiredWhen.alwaysShowAsterisk ? "data-awrequired-always-show-asterisk=true " : "";
|
html += field.awRequiredWhen.alwaysShowAsterisk ? "data-awrequired-always-show-asterisk=true " : "";
|
||||||
}
|
}
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
if(!field.multiSelect){
|
if(!field.multiSelect && !field.disableChooseOption){
|
||||||
html += "<option value=\"\">";
|
html += "<option value=\"\">";
|
||||||
// Add a custom default select 'value' (default text)
|
// Add a custom default select 'value' (default text)
|
||||||
html += (field.defaultText) ? field.defaultText : "Choose a " + field.label.toLowerCase();
|
html += (field.defaultText) ? field.defaultText : "Choose a " + field.label.toLowerCase();
|
||||||
@@ -1469,7 +1470,11 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
|||||||
html += (options.mode === 'edit') ? this.form.editTitle : this.form.addTitle;
|
html += (options.mode === 'edit') ? this.form.editTitle : this.form.addTitle;
|
||||||
if(this.form.name === "user"){
|
if(this.form.name === "user"){
|
||||||
html+= "<span class=\"Form-title--is_superuser\" "+
|
html+= "<span class=\"Form-title--is_superuser\" "+
|
||||||
"ng-if=is_superuser>System Administrator</span>";
|
"ng-show='is_superuser'>Admin</span>";
|
||||||
|
html+= "<span class=\"Form-title--is_system_auditor\" "+
|
||||||
|
"ng-show='is_system_auditor'>Auditor</span>";
|
||||||
|
html+= "<span class=\"Form-title--is_ldap_user\" "+
|
||||||
|
"ng-show='ldap_user'>LDAP</span>";
|
||||||
}
|
}
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
html += "<div class=\"Form-header--fields\">";
|
html += "<div class=\"Form-header--fields\">";
|
||||||
|
|||||||
Reference in New Issue
Block a user