diff --git a/src/app/app.js b/src/app/app.js index e602580203c..41905a92955 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -26,7 +26,7 @@ function (angular, $, _, appLevelRequire) { // features if we define them after boot time register_fns = {}; - app.constant('kibanaVersion',"3.0.0pre5"); + app.constant('version',"3.0.0pre5"); // Use this for cache busting partials app.constant('cacheBust',"cache-bust="+Date.now()); diff --git a/src/app/controllers/dashLoader.js b/src/app/controllers/dashLoader.js index 210b4ae9e98..fbecc69ce72 100644 --- a/src/app/controllers/dashLoader.js +++ b/src/app/controllers/dashLoader.js @@ -7,7 +7,7 @@ function (angular, _) { var module = angular.module('kibana.controllers'); - module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv) { + module.controller('dashLoader', function($scope, $http, timer, dashboard, alertSrv, $location) { $scope.loader = dashboard.current.loader; $scope.init = function() { @@ -35,8 +35,8 @@ function (angular, _) { }; $scope.set_default = function() { - if(dashboard.set_default()) { - alertSrv.set('Local Default Set',dashboard.current.title+' has been set as your local default','success',5000); + if(dashboard.set_default($location.path())) { + alertSrv.set('Home Set','This page has been set as your default Kibana dashboard','success',5000); } else { alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); } @@ -44,7 +44,8 @@ function (angular, _) { $scope.purge_default = function() { if(dashboard.purge_default()) { - alertSrv.set('Local Default Clear','Your local default dashboard has been cleared','success',5000); + alertSrv.set('Local Default Clear','Your Kibana default dashboard has been reset to the default', + 'success',5000); } else { alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); } diff --git a/src/app/services/dashboard.js b/src/app/services/dashboard.js index 772d2e1b81e..768a3cbac62 100644 --- a/src/app/services/dashboard.js +++ b/src/app/services/dashboard.js @@ -101,20 +101,29 @@ function (angular, $, kbn, _, config, moment, Modernizr) { case('script'): self.script_load(_id); break; + case('local'): + self.local_load(); + break; default: $location.path(config.default_route); } - // No dashboard in the URL } else { - // Check if browser supports localstorage, and if there's a dashboard - if (Modernizr.localstorage && - !(_.isUndefined(window.localStorage['dashboard'])) && - window.localStorage['dashboard'] !== '' - ) { - var dashboard = JSON.parse(window.localStorage['dashboard']); - self.dash_load(dashboard); - // No? Ok, grab default.json, its all we have now + // Check if browser supports localstorage, and if there's an old dashboard. If there is, + // inform the user that they should save their dashboard to Elasticsearch and then set that + // as their default + if (Modernizr.localstorage) { + if(!(_.isUndefined(window.localStorage['dashboard'])) && window.localStorage['dashboard'] !== '') { + console.log(window.localStorage['dashboard']); + $location.path(config.default_route); + alertSrv.set('Saving to browser storage has been replaced',' with saving to Elasticsearch.'+ + ' Click here to load your old dashboard anyway.'); + } else if(!(_.isUndefined(window.localStorage.kibanaDashboardDefault))) { + $location.path(window.localStorage.kibanaDashboardDefault); + } else { + $location.path(config.default_route); + } + // No? Ok, grab the default route, its all we have now } else { $location.path(config.default_route); } @@ -230,10 +239,14 @@ function (angular, $, kbn, _, config, moment, Modernizr) { return true; }; - this.set_default = function(dashboard) { + this.set_default = function(route) { + console.log(route); if (Modernizr.localstorage) { - window.localStorage['dashboard'] = angular.toJson(dashboard || self.current); - $location.path('/dashboard'); + // Purge any old dashboards + if(!_.isUndefined(window.localStorage['dashboard'])) { + delete window.localStorage['dashboard']; + } + window.localStorage.kibanaDashboardDefault = route; return true; } else { return false; @@ -242,7 +255,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) { this.purge_default = function() { if (Modernizr.localstorage) { - window.localStorage['dashboard'] = ''; + // Purge any old dashboards + if(!_.isUndefined(window.localStorage['dashboard'])) { + + delete window.localStorage['dashboard']; + } + delete window.localStorage.kibanaDashboardDefault; return true; } else { return false; @@ -273,6 +291,31 @@ function (angular, $, kbn, _, config, moment, Modernizr) { return _r; }; + this.local_load = function() { + var dashboard = JSON.parse(window.localStorage['dashboard']); + dashboard.rows.unshift({ + height: "30", + title: "Deprecation Notice", + panels: [ + { + title: 'WARNING: Legacy dashboard', + type: 'text', + span: 12, + mode: 'html', + content: 'This dashboard has been loaded from the browsers local cache. If you use '+ + 'another brower or computer you will not be able to access it! '+ + '\n\n