|
|
@@ -14,6 +14,8 @@ function (angular, _, config) {
|
|
|
|
|
|
module.service('datasourceSrv', function($q, filterSrv, $http, $injector) {
|
|
|
var datasources = {};
|
|
|
+ var metricSources = [];
|
|
|
+ var annotationSources = [];
|
|
|
|
|
|
this.init = function() {
|
|
|
_.each(config.datasources, function(value, key) {
|
|
|
@@ -27,6 +29,23 @@ function (angular, _, config) {
|
|
|
this.default = datasources[_.keys(datasources)[0]];
|
|
|
this.default.default = true;
|
|
|
}
|
|
|
+
|
|
|
+ // create list of different source types
|
|
|
+ _.each(datasources, function(value, key) {
|
|
|
+ if (value.supportMetrics) {
|
|
|
+ metricSources.push({
|
|
|
+ name: value.name,
|
|
|
+ value: value.default ? null : key,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (value.supportAnnotations) {
|
|
|
+ annotationSources.push({
|
|
|
+ name: key,
|
|
|
+ editorSrc: value.annotationEditorSrc,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
};
|
|
|
|
|
|
this.datasourceFactory = function(ds) {
|
|
|
@@ -56,25 +75,11 @@ function (angular, _, config) {
|
|
|
};
|
|
|
|
|
|
this.getAnnotationSources = function() {
|
|
|
- var results = [];
|
|
|
- _.each(datasources, function(value, key) {
|
|
|
- if (value.supportAnnotations) {
|
|
|
- results.push({
|
|
|
- name: key,
|
|
|
- editorSrc: value.annotationEditorSrc,
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- return results;
|
|
|
+ return annotationSources;
|
|
|
};
|
|
|
|
|
|
- this.listOptions = function() {
|
|
|
- return _.map(config.datasources, function(value, key) {
|
|
|
- return {
|
|
|
- name: value.default ? key + ' (default)' : key,
|
|
|
- value: value.default ? null : key
|
|
|
- };
|
|
|
- });
|
|
|
+ this.getMetricSources = function() {
|
|
|
+ return metricSources;
|
|
|
};
|
|
|
|
|
|
this.init();
|