Commit 0e035f93 by Rashid Khan

Changed behavior of home saving. Added deprecation notice

parent faa15d0a
...@@ -26,7 +26,7 @@ function (angular, $, _, appLevelRequire) { ...@@ -26,7 +26,7 @@ function (angular, $, _, appLevelRequire) {
// features if we define them after boot time // features if we define them after boot time
register_fns = {}; register_fns = {};
app.constant('kibanaVersion',"3.0.0pre5"); app.constant('version',"3.0.0pre5");
// Use this for cache busting partials // Use this for cache busting partials
app.constant('cacheBust',"cache-bust="+Date.now()); app.constant('cacheBust',"cache-bust="+Date.now());
......
...@@ -7,7 +7,7 @@ function (angular, _) { ...@@ -7,7 +7,7 @@ function (angular, _) {
var module = angular.module('kibana.controllers'); 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.loader = dashboard.current.loader;
$scope.init = function() { $scope.init = function() {
...@@ -35,8 +35,8 @@ function (angular, _) { ...@@ -35,8 +35,8 @@ function (angular, _) {
}; };
$scope.set_default = function() { $scope.set_default = function() {
if(dashboard.set_default()) { if(dashboard.set_default($location.path())) {
alertSrv.set('Local Default Set',dashboard.current.title+' has been set as your local default','success',5000); alertSrv.set('Home Set','This page has been set as your default Kibana dashboard','success',5000);
} else { } else {
alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000);
} }
...@@ -44,7 +44,8 @@ function (angular, _) { ...@@ -44,7 +44,8 @@ function (angular, _) {
$scope.purge_default = function() { $scope.purge_default = function() {
if(dashboard.purge_default()) { 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 { } else {
alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000); alertSrv.set('Incompatible Browser','Sorry, your browser is too old for this feature','error',5000);
} }
......
...@@ -101,20 +101,29 @@ function (angular, $, kbn, _, config, moment, Modernizr) { ...@@ -101,20 +101,29 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
case('script'): case('script'):
self.script_load(_id); self.script_load(_id);
break; break;
case('local'):
self.local_load();
break;
default: default:
$location.path(config.default_route); $location.path(config.default_route);
} }
// No dashboard in the URL // No dashboard in the URL
} else { } else {
// Check if browser supports localstorage, and if there's a dashboard // Check if browser supports localstorage, and if there's an old dashboard. If there is,
if (Modernizr.localstorage && // inform the user that they should save their dashboard to Elasticsearch and then set that
!(_.isUndefined(window.localStorage['dashboard'])) && // as their default
window.localStorage['dashboard'] !== '' if (Modernizr.localstorage) {
) { if(!(_.isUndefined(window.localStorage['dashboard'])) && window.localStorage['dashboard'] !== '') {
var dashboard = JSON.parse(window.localStorage['dashboard']); console.log(window.localStorage['dashboard']);
self.dash_load(dashboard); $location.path(config.default_route);
// No? Ok, grab default.json, its all we have now alertSrv.set('Saving to browser storage has been replaced',' with saving to Elasticsearch.'+
' Click <a href="#/dashboard/local/deprecated">here</a> 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 { } else {
$location.path(config.default_route); $location.path(config.default_route);
} }
...@@ -230,10 +239,14 @@ function (angular, $, kbn, _, config, moment, Modernizr) { ...@@ -230,10 +239,14 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
return true; return true;
}; };
this.set_default = function(dashboard) { this.set_default = function(route) {
console.log(route);
if (Modernizr.localstorage) { if (Modernizr.localstorage) {
window.localStorage['dashboard'] = angular.toJson(dashboard || self.current); // Purge any old dashboards
$location.path('/dashboard'); if(!_.isUndefined(window.localStorage['dashboard'])) {
delete window.localStorage['dashboard'];
}
window.localStorage.kibanaDashboardDefault = route;
return true; return true;
} else { } else {
return false; return false;
...@@ -242,7 +255,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) { ...@@ -242,7 +255,12 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
this.purge_default = function() { this.purge_default = function() {
if (Modernizr.localstorage) { 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; return true;
} else { } else {
return false; return false;
...@@ -273,6 +291,31 @@ function (angular, $, kbn, _, config, moment, Modernizr) { ...@@ -273,6 +291,31 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
return _r; 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 <h4>Good news!</h4> Kibana'+
' now stores saved dashboards in Elasticsearch. Click the <i class="icon-save"></i> '+
'button in the top left to save this dashboard. Then select "Set as Home" from'+
' the "advanced" sub menu to automatically use the stored dashboard as your Kibana '+
'landing page afterwards'+
'<br><br><strong>Tip:</strong> You may with to remove this row before saving!'
}
]
});
self.dash_load(dashboard);
};
this.file_load = function(file) { this.file_load = function(file) {
return $http({ return $http({
url: "app/dashboards/"+file.replace(/\.(?!json)/,"/")+'?' + new Date().getTime(), url: "app/dashboards/"+file.replace(/\.(?!json)/,"/")+'?' + new Date().getTime(),
......
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