From 7a8851c5ab75a4c1c0154a7c31fa6681a8c29fe5 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Fri, 1 May 2015 17:02:00 +0800 Subject: [PATCH 1/4] default sidemenu to open #54 --- public/app/services/contextSrv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/services/contextSrv.js b/public/app/services/contextSrv.js index 99bbcccf156..700b7f7390c 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/services/contextSrv.js @@ -45,7 +45,7 @@ function (angular, _, store, config) { this.user = new User(); this.isSignedIn = this.user.isSignedIn; this.isGrafanaAdmin = this.user.isGrafanaAdmin; - this.sidemenu = store.getBool('grafana.sidemenu'); + this.sidemenu = store.getBool('grafana.sidemenu', true); this.isEditor = this.hasRole('Editor') || this.hasRole('Admin'); }); }); From 8aef297e715358edd34ebb9c386ae7d79f2107ce Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Tue, 5 May 2015 10:43:19 +0800 Subject: [PATCH 2/4] show sidemenu when admin user logs in the first time. #54 --- public/app/controllers/loginCtrl.js | 2 +- public/app/routes/dashLoadControllers.js | 4 +++- public/app/services/contextSrv.js | 14 +++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/public/app/controllers/loginCtrl.js b/public/app/controllers/loginCtrl.js index c8856df0690..4a1b46a481c 100644 --- a/public/app/controllers/loginCtrl.js +++ b/public/app/controllers/loginCtrl.js @@ -14,7 +14,7 @@ function (angular, config) { password: '', }; - contextSrv.setSideMenuState(false); + contextSrv.sidemenu = false; $scope.googleAuthEnabled = config.googleAuthEnabled; $scope.githubAuthEnabled = config.githubAuthEnabled; diff --git a/public/app/routes/dashLoadControllers.js b/public/app/routes/dashLoadControllers.js index f85cee09d84..566669312f8 100644 --- a/public/app/routes/dashLoadControllers.js +++ b/public/app/routes/dashLoadControllers.js @@ -36,7 +36,9 @@ function (angular, _, kbn, moment, $) { }); - module.controller('DashFromSnapshotCtrl', function($scope, $routeParams, backendSrv) { + module.controller('DashFromSnapshotCtrl', function($scope, $routeParams, backendSrv, contextSrv) { + //don't show the sidemenu in snapshots. + contextSrv.sidemenu = false; backendSrv.get('/api/snapshots/' + $routeParams.key).then(function(result) { $scope.initDashboard(result, $scope); }, function() { diff --git a/public/app/services/contextSrv.js b/public/app/services/contextSrv.js index 700b7f7390c..f08dff56db8 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/services/contextSrv.js @@ -45,7 +45,19 @@ function (angular, _, store, config) { this.user = new User(); this.isSignedIn = this.user.isSignedIn; this.isGrafanaAdmin = this.user.isGrafanaAdmin; - this.sidemenu = store.getBool('grafana.sidemenu', true); + var sidemenuDefault = false; + if (this.hasRole('Admin')) { + sidemenuDefault = true; + } + this.sidemenu = store.getBool('grafana.sidemenu', sidemenuDefault); + if (this.isSignedIn && !store.exists('grafana.sidemenu')) { + // If the sidemnu has never been set before, set it to false. + // This will result in this.sidemenu and the localStorage grafana.sidemenu + // to be out of sync if the user has an admin role. But this is + // intentional and results in the user seeing the sidemenu only on + // their first login. + store.set('grafana.sidemenu', false); + } this.isEditor = this.hasRole('Editor') || this.hasRole('Admin'); }); }); From b915bb98fb4a287ba1bd30ccab7874430d0755d0 Mon Sep 17 00:00:00 2001 From: Anthony Woods Date: Tue, 5 May 2015 16:21:37 +0800 Subject: [PATCH 3/4] fix whitespace --- public/app/services/contextSrv.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/services/contextSrv.js b/public/app/services/contextSrv.js index f08dff56db8..c7d1afda522 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/services/contextSrv.js @@ -53,7 +53,7 @@ function (angular, _, store, config) { if (this.isSignedIn && !store.exists('grafana.sidemenu')) { // If the sidemnu has never been set before, set it to false. // This will result in this.sidemenu and the localStorage grafana.sidemenu - // to be out of sync if the user has an admin role. But this is + // to be out of sync if the user has an admin role. But this is // intentional and results in the user seeing the sidemenu only on // their first login. store.set('grafana.sidemenu', false); From 8149381f01ffdc559fd173b9266fbd75a634fa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 5 May 2015 20:59:21 +0200 Subject: [PATCH 4/4] minor refactoring and markup fix --- public/app/partials/login.html | 8 ++++---- public/app/services/contextSrv.js | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/public/app/partials/login.html b/public/app/partials/login.html index c0fb9e9e990..8db858dac8d 100644 --- a/public/app/partials/login.html +++ b/public/app/partials/login.html @@ -23,7 +23,7 @@ User
  • - +
  • @@ -34,7 +34,7 @@ Password
  • - +
  • @@ -46,7 +46,7 @@ Email
  • - +
  • @@ -58,7 +58,7 @@ Password
  • - +
  • diff --git a/public/app/services/contextSrv.js b/public/app/services/contextSrv.js index c7d1afda522..b3f8a1ed164 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/services/contextSrv.js @@ -40,24 +40,26 @@ function (angular, _, store, config) { }, 50); }; + this.getSidemenuDefault = function() { + return this.hasRole('Admin'); + }; + this.version = config.buildInfo.version; this.lightTheme = false; this.user = new User(); this.isSignedIn = this.user.isSignedIn; this.isGrafanaAdmin = this.user.isGrafanaAdmin; - var sidemenuDefault = false; - if (this.hasRole('Admin')) { - sidemenuDefault = true; - } - this.sidemenu = store.getBool('grafana.sidemenu', sidemenuDefault); + this.sidemenu = store.getBool('grafana.sidemenu', this.getSidemenuDefault()); + if (this.isSignedIn && !store.exists('grafana.sidemenu')) { - // If the sidemnu has never been set before, set it to false. + // If the sidemenu has never been set before, set it to false. // This will result in this.sidemenu and the localStorage grafana.sidemenu // to be out of sync if the user has an admin role. But this is // intentional and results in the user seeing the sidemenu only on // their first login. store.set('grafana.sidemenu', false); } + this.isEditor = this.hasRole('Editor') || this.hasRole('Admin'); }); });