Commit 5a25b088 by Torkel Ödegaard

added datasource filtering based on datasource abilities

parent fa3b84a6
......@@ -220,7 +220,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.editorTabs = _.pluck($scope.panelMeta.fullEditorTabs,'title');
$scope.hiddenSeries = {};
$scope.datasources = datasourceSrv.listOptions();
$scope.datasources = datasourceSrv.getMetricSources();
$scope.setDatasource($scope.panel.datasource);
if ($scope.panel.targets.length === 0) {
......
......@@ -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();
......
......@@ -19,6 +19,7 @@ function (angular, _, $, config, kbn, moment) {
this.url = datasource.url;
this.name = datasource.name;
this.supportAnnotations = true;
this.supportMetrics = false;
this.index = datasource.index;
this.annotationEditorSrc = 'app/partials/elasticsearch/annotation_editor.html';
}
......
......@@ -21,6 +21,7 @@ function (angular, _, $, config, kbn, moment) {
this.name = datasource.name;
this.render_method = datasource.render_method || 'POST';
this.supportAnnotations = true;
this.supportMetrics = true;
this.annotationEditorSrc = 'app/partials/graphite/annotation_editor.html';
this.cacheTimeout = datasource.cacheTimeout;
}
......
......@@ -23,6 +23,7 @@ function (angular, _, kbn, InfluxSeries) {
};
this.supportAnnotations = true;
this.supportMetrics = true;
this.annotationEditorSrc = 'app/partials/influxdb/annotation_editor.html';
}
......
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