front-end side privileges
This commit is contained in:
parent
98c745014c
commit
495f1a6b57
3 changed files with 25 additions and 7 deletions
|
@ -52,7 +52,7 @@
|
||||||
<div ng-if="logo.imgURL" class="navbar-brand"><a ng-if="logo.link" href="{{logo.link}}" target="_blank"><img src="{{logo.imgURL}}" /></a></div>
|
<div ng-if="logo.imgURL" class="navbar-brand"><a ng-if="logo.link" href="{{logo.link}}" target="_blank"><img src="{{logo.imgURL}}" /></a></div>
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li ng-class="{active: isActive('/events') || isActive('/event')}"><a ui-sref="events">{{'Events' | translate}}</a></li>
|
<li ng-class="{active: isActive('/events') || isActive('/event')}"><a ui-sref="events">{{'Events' | translate}}</a></li>
|
||||||
<li ng-class="{active: isActive('/persons') || isActive('/person') || isActive('/import/persons')}"><a ui-sref="persons">{{'Persons' | translate}}</a></li>
|
<li ng-if="requires('admin')" ng-class="{active: isActive('/persons') || isActive('/person') || isActive('/import/persons')}"><a ui-sref="persons">{{'Persons' | translate}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="collapse navbar-collapse">
|
<div class="collapse navbar-collapse">
|
||||||
|
|
26
angular_app/js/app.js
vendored
26
angular_app/js/app.js
vendored
|
@ -28,8 +28,8 @@ var eventManApp = angular.module('eventManApp', [
|
||||||
|
|
||||||
|
|
||||||
/* Add some utilities to the global scope. */
|
/* Add some utilities to the global scope. */
|
||||||
eventManApp.run(['$rootScope', '$state', '$stateParams', '$log',
|
eventManApp.run(['$rootScope', '$state', '$stateParams', '$log', 'Info',
|
||||||
function($rootScope, $state, $stateParams, $log) {
|
function($rootScope, $state, $stateParams, $log, Info) {
|
||||||
$rootScope.app_uuid = guid();
|
$rootScope.app_uuid = guid();
|
||||||
$log.debug('App UUID: ' + $rootScope.app_uuid);
|
$log.debug('App UUID: ' + $rootScope.app_uuid);
|
||||||
$rootScope.$state = $state;
|
$rootScope.$state = $state;
|
||||||
|
@ -37,6 +37,10 @@ eventManApp.run(['$rootScope', '$state', '$stateParams', '$log',
|
||||||
|
|
||||||
$rootScope.error = {error: false};
|
$rootScope.error = {error: false};
|
||||||
|
|
||||||
|
Info.get({}, function(data) {
|
||||||
|
$rootScope.info = data || {};
|
||||||
|
});
|
||||||
|
|
||||||
$rootScope.errorHandler = function(response) {
|
$rootScope.errorHandler = function(response) {
|
||||||
$log.debug('Handling error message:');
|
$log.debug('Handling error message:');
|
||||||
$log.debug(response);
|
$log.debug(response);
|
||||||
|
@ -52,6 +56,24 @@ eventManApp.run(['$rootScope', '$state', '$stateParams', '$log',
|
||||||
$rootScope.error.error = false;
|
$rootScope.error.error = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Check GUI privileges. */
|
||||||
|
$rootScope.requires = function(permission) {
|
||||||
|
if (!($rootScope.info && $rootScope.info.user &&
|
||||||
|
$rootScope.info.user.username && $rootScope.info.user.privileges)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var accepted = false;
|
||||||
|
angular.forEach($rootScope.info.user.privileges || [],
|
||||||
|
function(value, idx) {
|
||||||
|
if (value === permission) {
|
||||||
|
accepted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return accepted;
|
||||||
|
};
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
4
angular_app/js/controllers.js
vendored
4
angular_app/js/controllers.js
vendored
|
@ -21,10 +21,6 @@ eventManControllers.controller('NavigationCtrl', ['$scope', '$rootScope', '$loca
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Info.get({}, function(data) {
|
|
||||||
$rootScope.info = data || {};
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.isActive = function(view) {
|
$scope.isActive = function(view) {
|
||||||
if (view === $location.path()) {
|
if (view === $location.path()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue