grafana/public/app/core/services/context_srv.js

35 lines
787 B
JavaScript
Raw Normal View History

define([
'angular',
'lodash',
'../core_module',
2015-10-30 08:19:02 -05:00
'app/core/store',
'app/core/config',
],
function (angular, _, coreModule, store, config) {
'use strict';
2016-01-15 07:42:59 -06:00
coreModule.default.service('contextSrv', function() {
function User() {
if (config.bootData.user) {
_.extend(this, config.bootData.user);
}
}
this.hasRole = function(role) {
return this.user.orgRole === role;
};
this.toggleSideMenu = function() {
this.sidemenu = !this.sidemenu;
2015-05-05 13:59:21 -05:00
};
this.version = config.buildInfo.version;
this.lightTheme = false;
this.user = new User();
this.isSignedIn = this.user.isSignedIn;
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
});
});