diff --git a/public/app/controllers/loginCtrl.js b/public/app/controllers/loginCtrl.js index cda5a085fd3..767f788cea3 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/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/routes/dashLoadControllers.js b/public/app/routes/dashLoadControllers.js index d26827248ce..c88f89bbf7f 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 99bbcccf156..b3f8a1ed164 100644 --- a/public/app/services/contextSrv.js +++ b/public/app/services/contextSrv.js @@ -40,12 +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; - this.sidemenu = store.getBool('grafana.sidemenu'); + this.sidemenu = store.getBool('grafana.sidemenu', this.getSidemenuDefault()); + + if (this.isSignedIn && !store.exists('grafana.sidemenu')) { + // 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'); }); });