Commit 3b5c813b by Torkel Ödegaard

worked on user frontend state, state like favorites, etc

parent 9d0982f2
......@@ -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;
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;
$scope.init = function() {
$scope._ = _;
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}} &nbsp;&nbsp;
Grafana version: {{grafana.version}} &nbsp;&nbsp;
</span>
<span grafana-version-check>
</span>
......
......@@ -2,6 +2,7 @@ define([
'./alertSrv',
'./utilSrv',
'./datasourceSrv',
'./userSrv',
'./timer',
'./keyboardManager',
'./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