mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parent
c48df8522a
commit
d46e612cb1
@ -49,6 +49,10 @@ function (angular, $, config, _) {
|
||||
|
||||
dashboardKeybindings.shortcuts($scope);
|
||||
|
||||
if ($scope.dashboard.$state.panelId) {
|
||||
$rootScope.fullscreen = true;
|
||||
}
|
||||
|
||||
$scope.emitAppEvent("dashboard-loaded", $scope.dashboard);
|
||||
};
|
||||
|
||||
|
@ -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.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);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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');
|
||||
});
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user