hiding notifcation templates on setup menu

for non org admins
This commit is contained in:
Jared Tabor 2016-06-17 13:43:02 -07:00
parent 283b62e598
commit 3115dd4fee
2 changed files with 28 additions and 2 deletions

View File

@ -36,7 +36,8 @@
Create and edit scripts to dynamically load hosts from any source.
</p>
</a>
<a ui-sref="notifications" class="SetupItem">
<a ui-sref="notifications" class="SetupItem"
ng-if="orgAdmin">
<h4 class="SetupItem-title">Notifications</h4>
<p class="SetupItem-description">
Create templates for sending notifications with Email, HipChat, Slack, and SMS.

View File

@ -6,5 +6,30 @@ export default {
ncyBreadcrumb: {
label: "SETTINGS"
},
templateUrl: templateUrl('setup-menu/setup-menu')
templateUrl: templateUrl('setup-menu/setup-menu'),
resolve: {
org_admin:
['$rootScope', 'ProcessErrors', 'Rest',
function($rootScope, ProcessErrors, Rest){
$rootScope.loginConfig.promise.then(function () {
if($rootScope.current_user.related.admin_of_organizations){
$rootScope.orgAdmin = false;
if ($rootScope.current_user.is_superuser) {
$rootScope.orgAdmin = true;
} else {
Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`);
Rest.get()
.success(function(data) {
$rootScope.orgAdmin = (data.count) ? true : false;
}).error(function (data, status) {
ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status });
});
}
}
else{
return;
}
});
}]
}
};