Commit 3b5c813b by Torkel Ödegaard

worked on user frontend state, state like favorites, etc

parent 9d0982f2
...@@ -10,17 +10,17 @@ function (angular, config, _, $, store) { ...@@ -10,17 +10,17 @@ function (angular, config, _, $, store) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller) { module.controller('GrafanaCtrl', function($scope, alertSrv, utilSrv, grafanaVersion, $rootScope, $controller, userSrv) {
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
$scope.init = function() {
$scope.grafana = {}; $scope.grafana = {};
$scope.grafana.version = grafanaVersion;
$scope._ = _;
$rootScope.profilingEnabled = store.getBool('profilingEnabled'); $rootScope.profilingEnabled = store.getBool('profilingEnabled');
$rootScope.performance = { loadStart: new Date().getTime() }; $rootScope.performance = { loadStart: new Date().getTime() };
$rootScope.appSubUrl = config.appSubUrl; $rootScope.appSubUrl = config.appSubUrl;
$scope.init = function() {
$scope._ = _;
if ($rootScope.profilingEnabled) { $scope.initProfiling(); } if ($rootScope.profilingEnabled) { $scope.initProfiling(); }
alertSrv.init(); alertSrv.init();
...@@ -28,16 +28,8 @@ function (angular, config, _, $, store) { ...@@ -28,16 +28,8 @@ function (angular, config, _, $, store) {
$scope.dashAlerts = alertSrv; $scope.dashAlerts = alertSrv;
$scope.grafana.style = 'dark'; $scope.grafana.style = 'dark';
$scope.grafana.user = {}; $scope.grafana.user = userSrv.getSignedInUser();
if (window.grafanaBackend) {
$scope.initBackendFeatures();
}
};
$scope.initBackendFeatures = function() {
$scope.grafana.sidemenu = store.getBool('grafana.sidemenu'); $scope.grafana.sidemenu = store.getBool('grafana.sidemenu');
$scope.grafana.user = window.grafanaBootData.user;
$scope.onAppEvent('logged-out', function() { $scope.onAppEvent('logged-out', function() {
$scope.grafana.sidemenu = false; $scope.grafana.sidemenu = false;
......
...@@ -18,17 +18,17 @@ function (angular, _, kbn) { ...@@ -18,17 +18,17 @@ function (angular, _, kbn) {
this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html'; this.editorSrc = 'app/features/grafanaDatasource/partials/query.editor.html';
} }
GrafanaDatasource.prototype.getDashboard = function(id, isTemp) { GrafanaDatasource.prototype.getDashboard = function(slug, isTemp) {
var url = '/dashboard/' + id; var url = '/dashboard/' + slug;
if (isTemp) { if (isTemp) {
url = '/temp/' + id; url = '/temp/' + slug;
} }
return backendSrv.get('/api/dashboard/' + id) return backendSrv.get('/api/dashboard/' + slug)
.then(function(data) { .then(function(data) {
if (data) { if (data && data.dashboard) {
return angular.fromJson(data); return data.dashboard;
} else { } else {
return false; return false;
} }
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<div class="dashboard-editor-footer"> <div class="dashboard-editor-footer">
<div class="grafana-version-info" ng-show="editor.index === 0"> <div class="grafana-version-info" ng-show="editor.index === 0">
<span class="editor-option small"> <span class="editor-option small">
Grafana version: {{grafanaVersion}} &nbsp;&nbsp; Grafana version: {{grafana.version}} &nbsp;&nbsp;
</span> </span>
<span grafana-version-check> <span grafana-version-check>
</span> </span>
......
...@@ -2,6 +2,7 @@ define([ ...@@ -2,6 +2,7 @@ define([
'./alertSrv', './alertSrv',
'./utilSrv', './utilSrv',
'./datasourceSrv', './datasourceSrv',
'./userSrv',
'./timer', './timer',
'./keyboardManager', './keyboardManager',
'./popoverSrv', './popoverSrv',
......
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();
};
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment