| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- define([
- 'angular',
- 'lodash',
- 'store',
- 'config',
- ],
- function (angular, _, store, config) {
- 'use strict';
- var module = angular.module('grafana.services');
- module.service('contextSrv', function($rootScope, $timeout) {
- var self = this;
- function User() {
- if (window.grafanaBootData.user) {
- _.extend(this, window.grafanaBootData.user);
- }
- }
- this.version = config.buildInfo.version;
- this.lightTheme = false;
- this.user = new User();
- this.isSignedIn = this.user.isSignedIn;
- this.isGrafanaAdmin = this.user.isGrafanaAdmin;
- this.sidemenu = store.getBool('grafana.sidemenu');
- // events
- $rootScope.$on('toggle-sidemenu', function() {
- self.toggleSideMenu();
- });
- this.hasRole = function(role) {
- return this.user.orgRole === role;
- };
- this.setSideMenuState = function(state) {
- this.sidemenu = state;
- store.set('grafana.sidemenu', state);
- };
- this.toggleSideMenu = function() {
- this.setSideMenuState(!this.sidemenu);
- $timeout(function() {
- $rootScope.$broadcast("render");
- }, 50);
- };
- });
- });
|