Commit 41820ccb by Torkel Ödegaard

Dashboard Snapshot sharing: singlestat panel now works, #1623

parent 4d13a5bf
......@@ -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;
});
};
});
......
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
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