mirror of
https://github.com/ansible/awx.git
synced 2026-02-22 13:36:02 -03:30
Enable management job notications for admins
This commit is contained in:
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
export default
|
export default
|
||||||
[ 'NotificationsList', 'GetBasePath', 'ToggleNotification', 'NotificationsListInit',
|
[ 'NotificationsList', 'GetBasePath', 'ToggleNotification', 'NotificationsListInit',
|
||||||
'$stateParams', 'Dataset', '$scope',
|
'$stateParams', 'Dataset', '$scope', 'isAdmin',
|
||||||
function(
|
function(
|
||||||
NotificationsList, GetBasePath, ToggleNotification, NotificationsListInit,
|
NotificationsList, GetBasePath, ToggleNotification, NotificationsListInit,
|
||||||
$stateParams, Dataset, $scope) {
|
$stateParams, Dataset, $scope, isAdmin) {
|
||||||
var defaultUrl = GetBasePath('system_job_templates'),
|
var defaultUrl = GetBasePath('system_job_templates'),
|
||||||
list = NotificationsList,
|
list = NotificationsList,
|
||||||
id = $stateParams.management_id;
|
id = $stateParams.management_id;
|
||||||
@@ -19,6 +19,8 @@ export default
|
|||||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
||||||
|
|
||||||
|
$scope.sufficientRoleForNotifToggle = isAdmin;
|
||||||
|
|
||||||
NotificationsListInit({
|
NotificationsListInit({
|
||||||
scope: $scope,
|
scope: $scope,
|
||||||
url: defaultUrl,
|
url: defaultUrl,
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ export default {
|
|||||||
let path = `${GetBasePath('system_job_templates')}${$stateParams.management_id}`;
|
let path = `${GetBasePath('system_job_templates')}${$stateParams.management_id}`;
|
||||||
Rest.setUrl(path);
|
Rest.setUrl(path);
|
||||||
return Rest.get(path).then((res) => res.data);
|
return Rest.get(path).then((res) => res.data);
|
||||||
|
}],
|
||||||
|
isAdmin: ['Rest', 'GetBasePath', function(Rest, GetBasePath) {
|
||||||
|
Rest.setUrl(GetBasePath('me'));
|
||||||
|
return Rest.get()
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data && res.data.results && res.data.count && res.data.results[0] && res.data.results[0].is_superuser) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
|
|||||||
Reference in New Issue
Block a user