Commit d46e612c by Torkel Ödegaard

Working on linking to panels, #576, #672

parent c48df852
...@@ -49,6 +49,10 @@ function (angular, $, config, _) { ...@@ -49,6 +49,10 @@ function (angular, $, config, _) {
dashboardKeybindings.shortcuts($scope); dashboardKeybindings.shortcuts($scope);
if ($scope.dashboard.$state.panelId) {
$rootScope.fullscreen = true;
}
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard); $scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
}; };
......
...@@ -188,13 +188,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -188,13 +188,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
_.defaults($scope.panel.grid, _d.grid); _.defaults($scope.panel.grid, _d.grid);
_.defaults($scope.panel.legend, _d.legend); _.defaults($scope.panel.legend, _d.legend);
$scope.init = function() { $scope.hiddenSeries = {};
panelSrv.init($scope);
$scope.hiddenSeries = {};
if (!$scope.skipDataOnInit) {
$scope.get_data();
}
};
$scope.updateTimeRange = function () { $scope.updateTimeRange = function () {
$scope.range = $scope.filter.timeRange(); $scope.range = $scope.filter.timeRange();
...@@ -210,10 +204,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -210,10 +204,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}; };
$scope.get_data = function() { $scope.get_data = function() {
delete $scope.panel.error;
$scope.panelMeta.loading = true;
$scope.updateTimeRange(); $scope.updateTimeRange();
var metricsQuery = { var metricsQuery = {
...@@ -297,10 +287,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -297,10 +287,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
return series; return series;
}; };
$scope.otherPanelInFullscreenMode = function() {
return $rootScope.fullscreen && !$scope.fullscreen;
};
$scope.render = function(data) { $scope.render = function(data) {
$scope.$emit('render', data); $scope.$emit('render', data);
}; };
...@@ -371,7 +357,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -371,7 +357,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.render(); $scope.render();
}; };
$scope.init(); panelSrv.init($scope);
}); });
}); });
...@@ -8,7 +8,7 @@ function (angular) { ...@@ -8,7 +8,7 @@ function (angular) {
module.config(function($routeProvider) { module.config(function($routeProvider) {
$routeProvider $routeProvider
.when('/dashboard/db/:id', { .when('/dashboard/db/:id/:panelId?', {
templateUrl: 'app/partials/dashboard.html', templateUrl: 'app/partials/dashboard.html',
controller : 'DashFromDBProvider', controller : 'DashFromDBProvider',
}) })
...@@ -29,7 +29,13 @@ function (angular) { ...@@ -29,7 +29,13 @@ function (angular) {
db.getDashboard($routeParams.id, isTemp) db.getDashboard($routeParams.id, isTemp)
.then(function(dashboard) { .then(function(dashboard) {
dashboard.$state = {
panelId: parseInt($routeParams.panelId)
};
$scope.emitAppEvent('setup-dashboard', dashboard); $scope.emitAppEvent('setup-dashboard', dashboard);
}).then(null, function(error) { }).then(null, function(error) {
alertSrv.set('Error', error, 'error'); alertSrv.set('Error', error, 'error');
}); });
......
...@@ -29,6 +29,8 @@ function (angular, $, kbn, _) { ...@@ -29,6 +29,8 @@ function (angular, $, kbn, _) {
this.time = data.time || { from: 'now-6h', to: 'now' }; this.time = data.time || { from: 'now-6h', to: 'now' };
this.templating = data.templating || { list: [] }; this.templating = data.templating || { list: [] };
this.refresh = data.refresh; this.refresh = data.refresh;
this.version = data.version || 0;
this.$state = data.$state;
if (this.nav.length === 0) { if (this.nav.length === 0) {
this.nav.push({ type: 'timepicker' }); this.nav.push({ type: 'timepicker' });
...@@ -75,12 +77,30 @@ function (angular, $, kbn, _) { ...@@ -75,12 +77,30 @@ function (angular, $, kbn, _) {
p.updateSchema = function(old) { p.updateSchema = function(old) {
var i, j, row, panel; var i, j, row, panel;
var isChanged = false; var oldVersion = this.version;
this.version = 3;
if (this.version === 2) { if (oldVersion === 3) {
return; 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) {
if (old.services.filter) { if (old.services.filter) {
this.time = old.services.filter.time; this.time = old.services.filter.time;
...@@ -95,7 +115,6 @@ function (angular, $, kbn, _) { ...@@ -95,7 +115,6 @@ function (angular, $, kbn, _) {
panel = row.panels[j]; panel = row.panels[j];
if (panel.type === 'graphite') { if (panel.type === 'graphite') {
panel.type = 'graph'; panel.type = 'graph';
isChanged = true;
} }
if (panel.type === 'graph') { if (panel.type === 'graph') {
...@@ -128,7 +147,7 @@ function (angular, $, kbn, _) { ...@@ -128,7 +147,7 @@ function (angular, $, kbn, _) {
} }
} }
this.version = 2; this.version = 3;
}; };
return { return {
......
...@@ -153,6 +153,10 @@ function (angular, _, $) { ...@@ -153,6 +153,10 @@ function (angular, _, $) {
$scope.enterFullscreenMode({ edit: false }); $scope.enterFullscreenMode({ edit: false });
}; };
$scope.otherPanelInFullscreenMode = function() {
return $rootScope.fullscreen && !$scope.fullscreen;
};
// Post init phase // Post init phase
$scope.fullscreen = false; $scope.fullscreen = false;
$scope.editor = { index: 1 }; $scope.editor = { index: 1 };
...@@ -162,6 +166,25 @@ function (angular, _, $) { ...@@ -162,6 +166,25 @@ function (angular, _, $) {
$scope.datasources = datasourceSrv.getMetricSources(); $scope.datasources = datasourceSrv.getMetricSources();
$scope.setDatasource($scope.panel.datasource); $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();
}
}
}; };
}); });
......
...@@ -73,7 +73,7 @@ define([ ...@@ -73,7 +73,7 @@ define([
}); });
it('dashboard schema version should be set to latest', function() { it('dashboard schema version should be set to latest', function() {
expect(model.version).to.be(2); expect(model.version).to.be(3);
}); });
}); });
......
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