added datasource filtering based on datasource abilities

pull/638/head
Torkel Ödegaard 11 years ago
parent fa3b84a615
commit 5a25b0885c
  1. 2
      src/app/panels/graph/module.js
  2. 39
      src/app/services/datasourceSrv.js
  3. 1
      src/app/services/elasticsearch/es-datasource.js
  4. 1
      src/app/services/graphite/graphiteDatasource.js
  5. 1
      src/app/services/influxdb/influxdbDatasource.js

@ -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';
}

Loading…
Cancel
Save