Commit 012d1378 by Mitsuhiro Tanda

snapshot annotation

parent a9aaa5ad
...@@ -38,10 +38,19 @@ define([ ...@@ -38,10 +38,19 @@ define([
var rangeRaw = timeSrv.timeRange(false); var rangeRaw = timeSrv.timeRange(false);
var promises = _.map(annotations, function(annotation) { var promises = _.map(annotations, function(annotation) {
if (annotation.snapshotData) {
self.receiveAnnotationResults(annotation.snapshotData);
return;
}
return datasourceSrv.get(annotation.datasource).then(function(datasource) { return datasourceSrv.get(annotation.datasource).then(function(datasource) {
var query = {range: range, rangeRaw: rangeRaw, annotation: annotation}; var query = {range: range, rangeRaw: rangeRaw, annotation: annotation};
return datasource.annotationQuery(query) return datasource.annotationQuery(query)
.then(self.receiveAnnotationResults) .then(self.receiveAnnotationResults)
.then(function(options) {
if (dashboard.snapshot) {
annotation.snapshotData = angular.copy(options);
}
})
.then(null, errorHandler); .then(null, errorHandler);
}, this); }, this);
}); });
...@@ -58,6 +67,8 @@ define([ ...@@ -58,6 +67,8 @@ define([
for (var i = 0; i < results.length; i++) { for (var i = 0; i < results.length; i++) {
self.addAnnotation(results[i]); self.addAnnotation(results[i]);
} }
return results;
}; };
this.addAnnotation = function(options) { this.addAnnotation = function(options) {
......
...@@ -101,8 +101,14 @@ function (angular, _) { ...@@ -101,8 +101,14 @@ function (angular, _) {
panel.links = []; panel.links = [];
panel.datasource = null; panel.datasource = null;
}); });
// remove annotations // remove annotation queries
dash.annotations.list = []; dash.annotations.list = _.map(dash.annotations.list, function(annotation) {
return {
name: annotation.name,
enable: annotation.enable,
snapshotData: annotation.snapshotData
};
});
// remove template queries // remove template queries
_.each(dash.templating.list, function(variable) { _.each(dash.templating.list, function(variable) {
variable.query = ""; variable.query = "";
...@@ -122,6 +128,9 @@ function (angular, _) { ...@@ -122,6 +128,9 @@ function (angular, _) {
$scope.dashboard.forEachPanel(function(panel) { $scope.dashboard.forEachPanel(function(panel) {
delete panel.snapshotData; delete panel.snapshotData;
}); });
_.each($scope.dashboard.annotations.list, function(annotation) {
delete annotation.snapshotData;
});
}; };
$scope.deleteSnapshot = function() { $scope.deleteSnapshot = function() {
......
...@@ -21,7 +21,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) { ...@@ -21,7 +21,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) {
}; };
}); });
module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper, $q) { module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper) {
$scope.panelMeta = new PanelMeta({ $scope.panelMeta = new PanelMeta({
panelName: 'Graph', panelName: 'Graph',
...@@ -144,7 +144,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) { ...@@ -144,7 +144,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) {
$scope.loadSnapshot = function(snapshotData) { $scope.loadSnapshot = function(snapshotData) {
panelHelper.updateTimeRange($scope); panelHelper.updateTimeRange($scope);
$scope.annotationsPromise = $q.when([]); $scope.annotationsPromise = annotationsSrv.getAnnotations($scope.dashboard);
$scope.dataHandler(snapshotData); $scope.dataHandler(snapshotData);
}; };
......
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