mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
35 lines
787 B
JavaScript
35 lines
787 B
JavaScript
define([
|
|
'angular',
|
|
'lodash',
|
|
'../core_module',
|
|
'app/core/store',
|
|
'app/core/config',
|
|
],
|
|
function (angular, _, coreModule, store, config) {
|
|
'use strict';
|
|
|
|
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;
|
|
};
|
|
|
|
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');
|
|
});
|
|
});
|