diff --git a/src/app/features/panel/panelHelper.js b/src/app/features/panel/panelHelper.js index c2842fb225e..62982f69438 100644 --- a/src/app/features/panel/panelHelper.js +++ b/src/app/features/panel/panelHelper.js @@ -70,7 +70,13 @@ function (angular, _, kbn, $) { cacheTimeout: scope.panel.cacheTimeout }; - return datasource.query(metricsQuery); + return datasource.query(metricsQuery).then(function(results) { + if (scope.dashboard.snapshot) { + scope.panel.snapshotData = results; + } + + return results; + }); }; }); diff --git a/src/app/features/panel/panelSrv.js b/src/app/features/panel/panelSrv.js index 7ce3d69b376..8113194dfaf 100644 --- a/src/app/features/panel/panelSrv.js +++ b/src/app/features/panel/panelSrv.js @@ -93,6 +93,13 @@ function (angular, _, config) { $scope.get_data = function() { if ($scope.otherPanelInFullscreenMode()) { return; } + if ($scope.panel.snapshotData) { + if ($scope.loadSnapshot) { + $scope.loadSnapshot($scope.panel.snapshotData); + } + return; + } + delete $scope.panelMeta.error; $scope.panelMeta.loading = true; diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 966e1f9aa23..c7612c7cc9f 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -130,12 +130,6 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.refreshData = function(datasource) { panelHelper.updateTimeRange($scope); - if ($scope.panel.snapshotData) { - $scope.annotationsPromise = $q.when([]); - $scope.dataHandler($scope.panel.snapshotData); - return; - } - $scope.annotationsPromise = annotationsSrv.getAnnotations($scope.rangeUnparsed, $scope.dashboard); return panelHelper.issueMetricQuery($scope, datasource) @@ -146,10 +140,13 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { }); }; + $scope.loadSnapshot = function(snapshotData) { + panelHelper.updateTimeRange($scope); + $scope.annotationsPromise = $q.when([]); + $scope.dataHandler(snapshotData); + }; + $scope.dataHandler = function(results) { - if ($scope.dashboard.snapshot) { - $scope.panel.snapshotData = results; - } // png renderer returns just a url if (_.isString(results)) { $scope.render(results); diff --git a/src/app/panels/singlestat/module.js b/src/app/panels/singlestat/module.js index 81167a83a7d..8f33ce57cae 100644 --- a/src/app/panels/singlestat/module.js +++ b/src/app/panels/singlestat/module.js @@ -87,6 +87,11 @@ function (angular, app, _, TimeSeries, kbn, PanelMeta) { }); }; + $scope.loadSnapshot = function(snapshotData) { + panelHelper.updateTimeRange($scope); + $scope.dataHandler(snapshotData); + }; + $scope.dataHandler = function(results) { $scope.series = _.map(results.data, $scope.seriesHandler); $scope.render();