diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index e40db93fd7e..83a2a0b3b2d 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -49,6 +49,10 @@ function (angular, $, config, _) { dashboardKeybindings.shortcuts($scope); + if ($scope.dashboard.$state.panelId) { + $rootScope.fullscreen = true; + } + $scope.emitAppEvent("dashboard-loaded", $scope.dashboard); }; diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 8daa773c620..3dba7c096cb 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -188,13 +188,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { _.defaults($scope.panel.grid, _d.grid); _.defaults($scope.panel.legend, _d.legend); - $scope.init = function() { - panelSrv.init($scope); - $scope.hiddenSeries = {}; - if (!$scope.skipDataOnInit) { - $scope.get_data(); - } - }; + $scope.hiddenSeries = {}; $scope.updateTimeRange = function () { $scope.range = $scope.filter.timeRange(); @@ -210,10 +204,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { }; $scope.get_data = function() { - delete $scope.panel.error; - - $scope.panelMeta.loading = true; - $scope.updateTimeRange(); var metricsQuery = { @@ -297,10 +287,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { return series; }; - $scope.otherPanelInFullscreenMode = function() { - return $rootScope.fullscreen && !$scope.fullscreen; - }; - $scope.render = function(data) { $scope.$emit('render', data); }; @@ -371,7 +357,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.render(); }; - $scope.init(); + panelSrv.init($scope); }); }); diff --git a/src/app/routes/dashboard-from-db.js b/src/app/routes/dashboard-from-db.js index a2202ef518d..3882c7ca65c 100644 --- a/src/app/routes/dashboard-from-db.js +++ b/src/app/routes/dashboard-from-db.js @@ -8,7 +8,7 @@ function (angular) { module.config(function($routeProvider) { $routeProvider - .when('/dashboard/db/:id', { + .when('/dashboard/db/:id/:panelId?', { templateUrl: 'app/partials/dashboard.html', controller : 'DashFromDBProvider', }) @@ -29,7 +29,13 @@ function (angular) { db.getDashboard($routeParams.id, isTemp) .then(function(dashboard) { + + dashboard.$state = { + panelId: parseInt($routeParams.panelId) + }; + $scope.emitAppEvent('setup-dashboard', dashboard); + }).then(null, function(error) { alertSrv.set('Error', error, 'error'); }); diff --git a/src/app/services/dashboard/dashboardSrv.js b/src/app/services/dashboard/dashboardSrv.js index 002f19cca15..865946ea86b 100644 --- a/src/app/services/dashboard/dashboardSrv.js +++ b/src/app/services/dashboard/dashboardSrv.js @@ -29,6 +29,8 @@ function (angular, $, kbn, _) { this.time = data.time || { from: 'now-6h', to: 'now' }; this.templating = data.templating || { list: [] }; this.refresh = data.refresh; + this.version = data.version || 0; + this.$state = data.$state; if (this.nav.length === 0) { this.nav.push({ type: 'timepicker' }); @@ -75,12 +77,30 @@ function (angular, $, kbn, _) { p.updateSchema = function(old) { var i, j, row, panel; - var isChanged = false; + var oldVersion = this.version; + this.version = 3; - if (this.version === 2) { + if (oldVersion === 3) { return; } + // Version 3 schema changes + // ensure panel ids + var panelId = 1; + for (i = 0; i < this.rows.length; i++) { + row = this.rows[i]; + for (j = 0; j < row.panels.length; j++) { + panel = row.panels[j]; + panel.id = panelId; + panelId += 1; + } + } + + if (oldVersion === 2) { + return; + } + + // Version 2 schema changes if (old.services) { if (old.services.filter) { this.time = old.services.filter.time; @@ -95,7 +115,6 @@ function (angular, $, kbn, _) { panel = row.panels[j]; if (panel.type === 'graphite') { panel.type = 'graph'; - isChanged = true; } if (panel.type === 'graph') { @@ -128,7 +147,7 @@ function (angular, $, kbn, _) { } } - this.version = 2; + this.version = 3; }; return { diff --git a/src/app/services/panelSrv.js b/src/app/services/panelSrv.js index b5d5e8e06d0..c43cf1a89f4 100644 --- a/src/app/services/panelSrv.js +++ b/src/app/services/panelSrv.js @@ -153,6 +153,10 @@ function (angular, _, $) { $scope.enterFullscreenMode({ edit: false }); }; + $scope.otherPanelInFullscreenMode = function() { + return $rootScope.fullscreen && !$scope.fullscreen; + }; + // Post init phase $scope.fullscreen = false; $scope.editor = { index: 1 }; @@ -162,6 +166,25 @@ function (angular, _, $) { $scope.datasources = datasourceSrv.getMetricSources(); $scope.setDatasource($scope.panel.datasource); + +// if ($scope.dashboard.$state.panelId === $scope.panel.id) { +// $scope.enterFullscreenMode({edit: false}); +// } + + if ($scope.get_data) { + var panel_get_data = $scope.get_data; + $scope.get_data = function() { + if ($scope.otherPanelInFullscreenMode()) { return; } + + delete $scope.panel.error; + $scope.panelMeta.loading = true; + + panel_get_data(); + }; + if (!$scope.skipDataOnInit) { + $scope.get_data(); + } + } }; }); diff --git a/src/test/specs/dashboardSrv-specs.js b/src/test/specs/dashboardSrv-specs.js index 6a43845a7d7..c2684cfdae5 100644 --- a/src/test/specs/dashboardSrv-specs.js +++ b/src/test/specs/dashboardSrv-specs.js @@ -73,7 +73,7 @@ define([ }); it('dashboard schema version should be set to latest', function() { - expect(model.version).to.be(2); + expect(model.version).to.be(3); }); });