diff --git a/src/app/panels/annotations/editor.html b/src/app/panels/annotations/editor.html index 38435b5ebf5..2359036ae91 100644 --- a/src/app/panels/annotations/editor.html +++ b/src/app/panels/annotations/editor.html @@ -32,8 +32,8 @@
- - + +
@@ -53,18 +53,7 @@
-
-
- - -
-
- -
-
- - -
+
@@ -73,4 +62,4 @@ - \ No newline at end of file + diff --git a/src/app/panels/annotations/module.js b/src/app/panels/annotations/module.js index 389a9b05d0c..b09a9fc0e53 100644 --- a/src/app/panels/annotations/module.js +++ b/src/app/panels/annotations/module.js @@ -14,7 +14,7 @@ function (angular, app, _) { var module = angular.module('kibana.panels.annotations', []); app.useModule(module); - module.controller('AnnotationsCtrl', function($scope, dashboard, $rootScope) { + module.controller('AnnotationsCtrl', function($scope, datasourceSrv, $rootScope) { $scope.panelMeta = { status : "Stable", @@ -41,14 +41,20 @@ function (angular, app, _) { $scope.init = function() { $scope.currentAnnnotation = angular.copy(annotationDefaults); $scope.currentIsNew = true; + $scope.datasources = datasourceSrv.getAnnotationSources(); + if ($scope.datasources.length > 0) { + $scope.currentDatasource = $scope.datasources[0]; + } }; $scope.edit = function(annotation) { $scope.currentAnnnotation = annotation; $scope.currentIsNew = false; + $scope.currentDatasource = datasourceSrv.get(annotation.datasource); }; $scope.update = function() { + $scope.currentAnnotation.datasource = $scope.currentDatasource.name; $scope.currentAnnnotation = angular.copy(annotationDefaults); $scope.currentIsNew = true; }; @@ -64,4 +70,4 @@ function (angular, app, _) { }; }); -}); \ No newline at end of file +}); diff --git a/src/app/partials/graphite/annotation_editor.html b/src/app/partials/graphite/annotation_editor.html new file mode 100644 index 00000000000..dc763cc8f12 --- /dev/null +++ b/src/app/partials/graphite/annotation_editor.html @@ -0,0 +1,15 @@ +
+
+ + +
+
+ +
+
+ + +
+
+ + diff --git a/src/app/partials/influxdb/annotation_editor.html b/src/app/partials/influxdb/annotation_editor.html new file mode 100644 index 00000000000..771c50f4661 --- /dev/null +++ b/src/app/partials/influxdb/annotation_editor.html @@ -0,0 +1,7 @@ +
+
+ + +
+
+ diff --git a/src/app/services/datasourceSrv.js b/src/app/services/datasourceSrv.js index cccdaca7ae1..374b26e886f 100644 --- a/src/app/services/datasourceSrv.js +++ b/src/app/services/datasourceSrv.js @@ -12,13 +12,19 @@ function (angular, _, config) { var module = angular.module('kibana.services'); module.service('datasourceSrv', function($q, filterSrv, $http, GraphiteDatasource, InfluxDatasource, OpenTSDBDatasource) { + var datasources = {}; this.init = function() { - var defaultDatasource = _.findWhere(_.values(config.datasources), { default: true }); - if (!defaultDatasource) { - defaultDatasource = config.datasources[_.keys(config.datasources)[0]]; + _.each(config.datasources, function(value, key) { + datasources[key] = this.datasourceFactory(value); + if (value.default) { + this.default = datasources[key]; + } + }, this); + + if (!this.default) { + this.default = datasources[_.keys(datasources)[0]]; } - this.default = this.datasourceFactory(defaultDatasource); }; this.datasourceFactory = function(ds) { @@ -34,15 +40,24 @@ function (angular, _, config) { this.get = function(name) { if (!name) { return this.default; } + if (datasources[name]) { return datasources[name]; } - var ds = config.datasources[name]; - if (!ds) { - return null; - } - - return this.datasourceFactory(ds); + throw "Unable to find datasource: " + name; }; + this.getAnnotationSources = function() { + var results = []; + _.each(datasources, function(value, key) { + if (value.supportAnnotations) { + results.push({ + name: key, + editorSrc: value.annotationEditorSrc + }); + } + }); + return results; + }; + this.listOptions = function() { return _.map(config.datasources, function(value, key) { return { diff --git a/src/app/services/graphite/graphiteDatasource.js b/src/app/services/graphite/graphiteDatasource.js index 1ea4b97b37c..1c1579a72ee 100644 --- a/src/app/services/graphite/graphiteDatasource.js +++ b/src/app/services/graphite/graphiteDatasource.js @@ -20,6 +20,8 @@ function (angular, _, $, config, kbn, moment) { this.editorSrc = 'app/partials/graphite/editor.html'; this.name = datasource.name; this.render_method = datasource.render_method || 'POST'; + this.supportAnnotations = true; + this.annotationEditorSrc = 'app/partials/graphite/annotation_editor.html'; } GraphiteDatasource.prototype.query = function(filterSrv, options) { diff --git a/src/app/services/influxdb/influxdbDatasource.js b/src/app/services/influxdb/influxdbDatasource.js index 4993c3655e3..e15901aeeb1 100644 --- a/src/app/services/influxdb/influxdbDatasource.js +++ b/src/app/services/influxdb/influxdbDatasource.js @@ -21,6 +21,9 @@ function (angular, _, kbn, InfluxSeries) { this.templateSettings = { interpolate : /\[\[([\s\S]+?)\]\]/g, }; + + this.supportAnnotations = true; + this.annotationEditorSrc = 'app/partials/influxdb/annotation_editor.html'; } InfluxDatasource.prototype.query = function(filterSrv, options) {