Commit 0e035f93 by Rashid Khan

Changed behavior of home saving. Added deprecation notice

parent faa15d0a
......@@ -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());
......
......@@ -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);
}
......
......@@ -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 <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 {
$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 <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) {
return $http({
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