| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- define([
- 'angular',
- 'lodash',
- 'store',
- ],
- function (angular, _, store) {
- 'use strict';
- var module = angular.module('grafana.services');
- module.service('contextSrv', function(grafanaVersion, $rootScope, $timeout) {
- var self = this;
- function User() {
- if (window.grafanaBootData.user) {
- _.extend(this, window.grafanaBootData.user);
- }
- }
- this.version = grafanaVersion;
- 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);
- };
- });
- });
|