mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
Permissions for org admin
The series of events for checking a user's access level was happening out of order for loading the permissions page/form. I added a callback so that the access level can be checked first and then a secondary action (like filling a form as readonly or not) could happen next.
This commit is contained in:
@@ -215,13 +215,16 @@ function PermissionsEdit($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
|
|
||||||
CheckAccess({ scope: $scope });
|
|
||||||
|
|
||||||
$scope.selectCategory = function (resetIn) {
|
$scope.selectCategory = function (resetIn) {
|
||||||
var reset = (resetIn === false) ? false : true;
|
var reset = (resetIn === false) ? false : true;
|
||||||
PermissionCategoryChange({ scope: $scope, reset: reset });
|
PermissionCategoryChange({ scope: $scope, reset: reset });
|
||||||
};
|
};
|
||||||
|
if ($scope.removeFillForm) {
|
||||||
|
$scope.removeFillForm();
|
||||||
|
}
|
||||||
|
$scope.removeFillForm = $scope.$on('FillForm', function () {
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
@@ -286,7 +289,12 @@ function PermissionsEdit($scope, $rootScope, $compile, $location, $log, $routePa
|
|||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
msg: 'Failed to retrieve Permission: ' + id + '. GET status: ' + status });
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
CheckAccess({
|
||||||
|
scope: $scope,
|
||||||
|
callback: 'FillForm'
|
||||||
|
});
|
||||||
|
|
||||||
// Save changes to the parent
|
// Save changes to the parent
|
||||||
$scope.formSave = function () {
|
$scope.formSave = function () {
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ angular.module('AccessHelper', ['RestServices', 'Utilities'])
|
|||||||
return function (params) {
|
return function (params) {
|
||||||
// set PermissionAddAllowed to true or false based on user access. admins and org admins are granted
|
// set PermissionAddAllowed to true or false based on user access. admins and org admins are granted
|
||||||
// accesss.
|
// accesss.
|
||||||
var scope = params.scope, me;
|
var scope = params.scope,
|
||||||
|
callback = params.callback || undefined,
|
||||||
|
me;
|
||||||
|
|
||||||
// uer may have refreshed the browser, in which case retrieve current user info from session cookie
|
// uer may have refreshed the browser, in which case retrieve current user info from session cookie
|
||||||
me = ($rootScope.current_user) ? $rootScope.current_user : $cookieStore.get('current_user');
|
me = ($rootScope.current_user) ? $rootScope.current_user : $cookieStore.get('current_user');
|
||||||
@@ -37,6 +39,7 @@ angular.module('AccessHelper', ['RestServices', 'Utilities'])
|
|||||||
} else {
|
} else {
|
||||||
scope.PermissionAddAllowed = false;
|
scope.PermissionAddAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors(scope, data, status, null, {
|
ProcessErrors(scope, data, status, null, {
|
||||||
@@ -47,6 +50,9 @@ angular.module('AccessHelper', ['RestServices', 'Utilities'])
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(callback){
|
||||||
|
scope.$emit(callback);
|
||||||
|
}
|
||||||
//if (!access) {
|
//if (!access) {
|
||||||
// Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
// Alert('Access Denied', 'You do not have access to this function. Please contact your system administrator.');
|
||||||
//}
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user