Skip to content

Commit 66f7a2b

Browse files
committed
Merge branch 'snapshot_annotation' of https://github.com/mtanda/grafana into mtanda-snapshot_annotation
2 parents 908b2d1 + d3bc522 commit 66f7a2b

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

public/app/features/annotations/annotationsSrv.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,19 @@ define([
3838
var rangeRaw = timeSrv.timeRange(false);
3939

4040
var promises = _.map(annotations, function(annotation) {
41+
if (annotation.snapshotData) {
42+
self.receiveAnnotationResults(annotation.snapshotData);
43+
return;
44+
}
4145
return datasourceSrv.get(annotation.datasource).then(function(datasource) {
4246
var query = {range: range, rangeRaw: rangeRaw, annotation: annotation};
4347
return datasource.annotationQuery(query)
4448
.then(self.receiveAnnotationResults)
49+
.then(function(results) {
50+
if (dashboard.snapshot) {
51+
annotation.snapshotData = angular.copy(results);
52+
}
53+
})
4554
.then(null, errorHandler);
4655
}, this);
4756
});
@@ -58,6 +67,8 @@ define([
5867
for (var i = 0; i < results.length; i++) {
5968
self.addAnnotation(results[i]);
6069
}
70+
71+
return results;
6172
};
6273

6374
this.addAnnotation = function(options) {

public/app/features/dashboard/shareSnapshotCtrl.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,18 @@ function (angular, _) {
101101
panel.links = [];
102102
panel.datasource = null;
103103
});
104-
// remove annotations
105-
dash.annotations.list = [];
104+
// remove annotation queries
105+
dash.annotations.list = _.chain(dash.annotations.list)
106+
.filter(function(annotation) {
107+
return annotation.enable;
108+
})
109+
.map(function(annotation) {
110+
return {
111+
name: annotation.name,
112+
enable: annotation.enable,
113+
snapshotData: annotation.snapshotData
114+
};
115+
}).value();
106116
// remove template queries
107117
_.each(dash.templating.list, function(variable) {
108118
variable.query = "";
@@ -122,6 +132,9 @@ function (angular, _) {
122132
$scope.dashboard.forEachPanel(function(panel) {
123133
delete panel.snapshotData;
124134
});
135+
_.each($scope.dashboard.annotations.list, function(annotation) {
136+
delete annotation.snapshotData;
137+
});
125138
};
126139

127140
$scope.deleteSnapshot = function() {

public/app/plugins/panels/graph/module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) {
2121
};
2222
});
2323

24-
module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper, $q) {
24+
module.controller('GraphCtrl', function($scope, $rootScope, panelSrv, annotationsSrv, panelHelper) {
2525

2626
$scope.panelMeta = new PanelMeta({
2727
panelName: 'Graph',
@@ -144,7 +144,7 @@ function (angular, _, moment, kbn, TimeSeries, PanelMeta) {
144144

145145
$scope.loadSnapshot = function(snapshotData) {
146146
panelHelper.updateTimeRange($scope);
147-
$scope.annotationsPromise = $q.when([]);
147+
$scope.annotationsPromise = annotationsSrv.getAnnotations($scope.dashboard);
148148
$scope.dataHandler(snapshotData);
149149
};
150150

0 commit comments

Comments
 (0)