mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
worked on user frontend state, state like favorites, etc
This commit is contained in:
parent
9d0982f2f7
commit
3b5c813be7
@ -10,17 +10,17 @@ function (angular, config, _, $, store) {
|
||||
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller) {
|
||||
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
|
||||
$scope.grafana = {};
|
||||
|
||||
$rootScope.profilingEnabled = store.getBool('profilingEnabled');
|
||||
$rootScope.performance = { loadStart: new Date().getTime() };
|
||||
$rootScope.appSubUrl = config.appSubUrl;
|
||||
module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller, userSrv) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.grafana = {};
|
||||
$scope.grafana.version = grafanaVersion;
|
||||
$scope._ = _;
|
||||
|
||||
$rootScope.profilingEnabled = store.getBool('profilingEnabled');
|
||||
$rootScope.performance = { loadStart: new Date().getTime() };
|
||||
$rootScope.appSubUrl = config.appSubUrl;
|
||||
|
||||
if ($rootScope.profilingEnabled) { $scope.initProfiling(); }
|
||||
|
||||
alertSrv.init();
|
||||
@ -28,16 +28,8 @@ function (angular, config, _, $, store) {
|
||||
|
||||
$scope.dashAlerts = alertSrv;
|
||||
$scope.grafana.style = 'dark';
|
||||
$scope.grafana.user = {};
|
||||
|
||||
if (window.grafanaBackend) {
|
||||
$scope.initBackendFeatures();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.initBackendFeatures = function() {
|
||||
$scope.grafana.user = userSrv.getSignedInUser();
|
||||
$scope.grafana.sidemenu = store.getBool('grafana.sidemenu');
|
||||
$scope.grafana.user = window.grafanaBootData.user;
|
||||
|
||||
$scope.onAppEvent('logged-out', function() {
|
||||
$scope.grafana.sidemenu = false;
|
||||
|
@ -18,17 +18,17 @@ function (angular, _, kbn) {
|
||||
this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html';
|
||||
}
|
||||
|
||||
GrafanaDatasource.prototype.getDashboard = function(id, isTemp) {
|
||||
var url = '/dashboard/' + id;
|
||||
GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) {
|
||||
var url = '/dashboard/' + slug;
|
||||
|
||||
if (isTemp) {
|
||||
url = '/temp/' + id;
|
||||
url = '/temp/' + slug;
|
||||
}
|
||||
|
||||
return backendSrv.get('/api/dashboard/' + id)
|
||||
return backendSrv.get('/api/dashboard/' + slug)
|
||||
.then(function(data) {
|
||||
if (data) {
|
||||
return angular.fromJson(data);
|
||||
if (data && data.dashboard) {
|
||||
return data.dashboard;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@
|
||||
<div class="dashboard-editor-footer">
|
||||
<div class="grafana-version-info" ng-show="editor.index === 0">
|
||||
<span class="editor-option small">
|
||||
Grafana version: {{grafanaVersion}}
|
||||
Grafana version: {{grafana.version}}
|
||||
</span>
|
||||
<span grafana-version-check>
|
||||
</span>
|
||||
|
@ -2,6 +2,7 @@ define([
|
||||
'./alertSrv',
|
||||
'./utilSrv',
|
||||
'./datasourceSrv',
|
||||
'./userSrv',
|
||||
'./timer',
|
||||
'./keyboardManager',
|
||||
'./popoverSrv',
|
||||
|
24
src/app/services/userSrv.js
Normal file
24
src/app/services/userSrv.js
Normal file
@ -0,0 +1,24 @@
|
||||
define([
|
||||
'angular',
|
||||
'lodash',
|
||||
],
|
||||
function (angular, _) {
|
||||
'use strict';
|
||||
|
||||
var module = angular.module('grafana.services');
|
||||
|
||||
module.service('userSrv', function() {
|
||||
|
||||
function User() {
|
||||
if (window.grafanaBootData.user) {
|
||||
_.extend(this, window.grafanaBootData.user);
|
||||
}
|
||||
}
|
||||
|
||||
this.getSignedInUser = function() {
|
||||
return new User();
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user