2015-02-08 02:00:58 -06:00
|
|
|
define([
|
|
|
|
'angular',
|
|
|
|
'lodash',
|
2015-10-30 09:58:20 -05:00
|
|
|
'../core_module',
|
2015-10-30 08:19:02 -05:00
|
|
|
'app/core/store',
|
|
|
|
'app/core/config',
|
2015-02-08 02:00:58 -06:00
|
|
|
],
|
2015-10-30 09:58:20 -05:00
|
|
|
function (angular, _, coreModule, store, config) {
|
2015-02-08 02:00:58 -06:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-15 07:42:59 -06:00
|
|
|
coreModule.default.service('contextSrv', function() {
|
2015-02-08 02:00:58 -06:00
|
|
|
|
|
|
|
function User() {
|
2015-11-20 02:43:10 -06:00
|
|
|
if (config.bootData.user) {
|
|
|
|
_.extend(this, config.bootData.user);
|
2015-02-08 02:00:58 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.hasRole = function(role) {
|
2015-02-25 01:07:52 -06:00
|
|
|
return this.user.orgRole === role;
|
2015-02-08 02:00:58 -06:00
|
|
|
};
|
|
|
|
|
2016-01-29 14:12:56 -06:00
|
|
|
this.setPinnedState = function(val) {
|
|
|
|
this.pinned = val;
|
|
|
|
store.set('grafana.sidemenu.pinned', val);
|
|
|
|
};
|
|
|
|
|
2015-02-08 02:00:58 -06:00
|
|
|
this.toggleSideMenu = function() {
|
2016-01-16 11:55:13 -06:00
|
|
|
this.sidemenu = !this.sidemenu;
|
2016-01-29 14:12:56 -06:00
|
|
|
if (!this.sidemenu) {
|
|
|
|
this.setPinnedState(false);
|
|
|
|
}
|
2015-05-05 13:59:21 -05:00
|
|
|
};
|
|
|
|
|
2016-01-29 14:12:56 -06:00
|
|
|
this.pinned = store.getBool('grafana.sidemenu.pinned', false);
|
|
|
|
if (this.pinned) {
|
|
|
|
this.sidemenu = true;
|
|
|
|
}
|
|
|
|
|
2015-04-27 03:09:32 -05:00
|
|
|
this.version = config.buildInfo.version;
|
|
|
|
this.lightTheme = false;
|
|
|
|
this.user = new User();
|
|
|
|
this.isSignedIn = this.user.isSignedIn;
|
|
|
|
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
|
2015-06-01 10:01:04 -05:00
|
|
|
this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
|
2015-02-08 02:00:58 -06:00
|
|
|
});
|
|
|
|
});
|