Commit 5a25b088 by Torkel Ödegaard

added datasource filtering based on datasource abilities

parent fa3b84a6
...@@ -220,7 +220,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -220,7 +220,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.editorTabs = _.pluck($scope.panelMeta.fullEditorTabs,'title'); $scope.editorTabs = _.pluck($scope.panelMeta.fullEditorTabs,'title');
$scope.hiddenSeries = {}; $scope.hiddenSeries = {};
$scope.datasources = datasourceSrv.listOptions(); $scope.datasources = datasourceSrv.getMetricSources();
$scope.setDatasource($scope.panel.datasource); $scope.setDatasource($scope.panel.datasource);
if ($scope.panel.targets.length === 0) { if ($scope.panel.targets.length === 0) {
......
...@@ -14,6 +14,8 @@ function (angular, _, config) { ...@@ -14,6 +14,8 @@ function (angular, _, config) {
module.service('datasourceSrv', function($q, filterSrv, $http, $injector) { module.service('datasourceSrv', function($q, filterSrv, $http, $injector) {
var datasources = {}; var datasources = {};
var metricSources = [];
var annotationSources = [];
this.init = function() { this.init = function() {
_.each(config.datasources, function(value, key) { _.each(config.datasources, function(value, key) {
...@@ -27,6 +29,23 @@ function (angular, _, config) { ...@@ -27,6 +29,23 @@ function (angular, _, config) {
this.default = datasources[_.keys(datasources)[0]]; this.default = datasources[_.keys(datasources)[0]];
this.default.default = true; 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) { this.datasourceFactory = function(ds) {
...@@ -56,25 +75,11 @@ function (angular, _, config) { ...@@ -56,25 +75,11 @@ function (angular, _, config) {
}; };
this.getAnnotationSources = function() { this.getAnnotationSources = function() {
var results = []; return annotationSources;
_.each(datasources, function(value, key) {
if (value.supportAnnotations) {
results.push({
name: key,
editorSrc: value.annotationEditorSrc,
});
}
});
return results;
}; };
this.listOptions = function() { this.getMetricSources = function() {
return _.map(config.datasources, function(value, key) { return metricSources;
return {
name: value.default ? key + ' (default)' : key,
value: value.default ? null : key
};
});
}; };
this.init(); this.init();
......
...@@ -19,6 +19,7 @@ function (angular, _, $, config, kbn, moment) { ...@@ -19,6 +19,7 @@ function (angular, _, $, config, kbn, moment) {
this.url = datasource.url; this.url = datasource.url;
this.name = datasource.name; this.name = datasource.name;
this.supportAnnotations = true; this.supportAnnotations = true;
this.supportMetrics = false;
this.index = datasource.index; this.index = datasource.index;
this.annotationEditorSrc = 'app/partials/elasticsearch/annotation_editor.html'; this.annotationEditorSrc = 'app/partials/elasticsearch/annotation_editor.html';
} }
......
...@@ -21,6 +21,7 @@ function (angular, _, $, config, kbn, moment) { ...@@ -21,6 +21,7 @@ function (angular, _, $, config, kbn, moment) {
this.name = datasource.name; this.name = datasource.name;
this.render_method = datasource.render_method || 'POST'; this.render_method = datasource.render_method || 'POST';
this.supportAnnotations = true; this.supportAnnotations = true;
this.supportMetrics = true;
this.annotationEditorSrc = 'app/partials/graphite/annotation_editor.html'; this.annotationEditorSrc = 'app/partials/graphite/annotation_editor.html';
this.cacheTimeout = datasource.cacheTimeout; this.cacheTimeout = datasource.cacheTimeout;
} }
......
...@@ -23,6 +23,7 @@ function (angular, _, kbn, InfluxSeries) { ...@@ -23,6 +23,7 @@ function (angular, _, kbn, InfluxSeries) {
}; };
this.supportAnnotations = true; this.supportAnnotations = true;
this.supportMetrics = true;
this.annotationEditorSrc = 'app/partials/influxdb/annotation_editor.html'; 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