diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 105e0849e5d..f7e974db17a 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -102,8 +102,9 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro datasources[ds.Name] = dsMap } + // add datasources that are built in (meaning they are not added via data sources page, nor have any entry in datasource table) for _, ds := range plugins.DataSources { - if ds.AlwaysDisplay { + if ds.BuiltIn { datasources[ds.Name] = map[string]interface{}{ "type": ds.Type, "name": ds.Name, diff --git a/pkg/plugins/datasource_plugin.go b/pkg/plugins/datasource_plugin.go index 8427a1e8633..aa092c2bc20 100644 --- a/pkg/plugins/datasource_plugin.go +++ b/pkg/plugins/datasource_plugin.go @@ -4,13 +4,12 @@ import "encoding/json" type DataSourcePlugin struct { FrontendPluginBase - Annotations bool `json:"annotations"` - Metrics bool `json:"metrics"` - Alerting bool `json:"alerting"` - BuiltIn bool `json:"builtIn"` - Mixed bool `json:"mixed"` - AlwaysDisplay bool `json:"alwaysDisplay"` - App string `json:"app"` + Annotations bool `json:"annotations"` + Metrics bool `json:"metrics"` + Alerting bool `json:"alerting"` + BuiltIn bool `json:"builtIn"` + Mixed bool `json:"mixed"` + App string `json:"app"` } func (p *DataSourcePlugin) Load(decoder *json.Decoder, pluginDir string) error { diff --git a/public/app/core/services/datasource_srv.js b/public/app/core/services/datasource_srv.js index e722aae355b..d31a8a0f399 100644 --- a/public/app/core/services/datasource_srv.js +++ b/public/app/core/services/datasource_srv.js @@ -101,18 +101,16 @@ function (angular, _, coreModule, config) { } metricSources.sort(function(a, b) { - if (a.meta.builtIn) { + // these two should always be at the bottom + if (a.meta.id === "mixed" || a.meta.id === "grafana") { return 1; } - - if (b.meta.builtIn) { + if (b.meta.id === "mixed" || b.meta.id === "grafana") { return -1; } - if (a.name.toLowerCase() > b.name.toLowerCase()) { return 1; } - if (a.name.toLowerCase() < b.name.toLowerCase()) { return -1; } diff --git a/public/app/features/templating/editor_ctrl.ts b/public/app/features/templating/editor_ctrl.ts index 7d0a0a5465a..da1425cb9e0 100644 --- a/public/app/features/templating/editor_ctrl.ts +++ b/public/app/features/templating/editor_ctrl.ts @@ -36,7 +36,7 @@ export class VariableEditorCtrl { $scope.mode = 'list'; $scope.datasources = _.filter(datasourceSrv.getMetricSources(), function(ds) { - return !ds.meta.builtIn && ds.value !== null; + return !ds.meta.mixed && ds.value !== null; }); $scope.datasourceTypes = _($scope.datasources).uniqBy('meta.id').map(function(ds) { diff --git a/public/app/plugins/datasource/grafana/datasource.ts b/public/app/plugins/datasource/grafana/datasource.ts index c1c0ce6388a..aec46ac7bfe 100644 --- a/public/app/plugins/datasource/grafana/datasource.ts +++ b/public/app/plugins/datasource/grafana/datasource.ts @@ -5,38 +5,16 @@ import _ from 'lodash'; class GrafanaDatasource { /** @ngInject */ - constructor(private backendSrv) {} + constructor(private backendSrv, private $q) {} query(options) { - return this.backendSrv.post('/api/tsdb/query', { - from: options.range.from.valueOf().toString(), - to: options.range.to.valueOf().toString(), - queries: [ - { - "refId": "A", - "scenarioId": "random_walk", - "intervalMs": options.intervalMs, - "maxDataPoints": options.maxDataPoints, - } - ] - }).then(res => { - - var data = []; - if (res.results) { - _.forEach(res.results, queryRes => { - for (let series of queryRes.series) { - data.push({ - target: series.name, - datapoints: series.points - }); - } - }); - } - - return {data: data}; - }); + return this.$q.when({data: []}); } + metricFindQuery() { + return this.$q.when([]); + }; + annotationQuery(options) { return this.backendSrv.get('/api/annotations', { from: options.range.from.valueOf(), diff --git a/public/app/plugins/datasource/grafana/plugin.json b/public/app/plugins/datasource/grafana/plugin.json index 69522e6e63a..d7d957ec01a 100644 --- a/public/app/plugins/datasource/grafana/plugin.json +++ b/public/app/plugins/datasource/grafana/plugin.json @@ -5,6 +5,5 @@ "builtIn": true, "annotations": true, - "alwaysDisplay": true, "metrics": true } diff --git a/public/app/plugins/datasource/mixed/plugin.json b/public/app/plugins/datasource/mixed/plugin.json index 632d8a8e079..658e24c5e03 100644 --- a/public/app/plugins/datasource/mixed/plugin.json +++ b/public/app/plugins/datasource/mixed/plugin.json @@ -5,6 +5,5 @@ "builtIn": true, "mixed": true, - "alwaysDisplay": true, "metrics": true } diff --git a/public/test/specs/datasource_srv_specs.js b/public/test/specs/datasource_srv_specs.js index be7c054acaa..e6b38384239 100644 --- a/public/test/specs/datasource_srv_specs.js +++ b/public/test/specs/datasource_srv_specs.js @@ -24,9 +24,13 @@ define([ type: 'test-db', meta: { metrics: {m: 1} } }, + '--Grafana--': { + type: 'grafana', + meta: {builtIn: true, metrics: {m: 1}, id: "grafana"} + }, '--Mixed--': { type: 'test-db', - meta: {builtIn: true, metrics: {m: 1} } + meta: {builtIn: true, metrics: {m: 1}, id: "mixed"} }, 'ZZZ': { type: 'test-db', @@ -51,7 +55,8 @@ define([ expect(metricSources[1].name).to.be('BBB'); expect(metricSources[2].name).to.be('mmm'); expect(metricSources[3].name).to.be('ZZZ'); - expect(metricSources[4].name).to.be('--Mixed--'); + expect(metricSources[4].name).to.be('--Grafana--'); + expect(metricSources[5].name).to.be('--Mixed--'); }); }); });