mirror of
https://github.com/grafana/grafana.git
synced 2025-01-09 23:53:25 -06:00
Made opentsdb query_ctrl robust
This commit is contained in:
parent
a883424d25
commit
18c57ea230
@ -224,7 +224,7 @@ function (angular, _, dateMath) {
|
||||
this.getAggregators = function() {
|
||||
if (aggregatorsPromise) { return aggregatorsPromise; }
|
||||
|
||||
aggregatorsPromise = this._get('/api/aggregators').then(function(result) {
|
||||
aggregatorsPromise = this._get('/api/aggregators').then(function(result) {
|
||||
if (result.data && _.isArray(result.data)) {
|
||||
return result.data.sort();
|
||||
}
|
||||
@ -233,6 +233,19 @@ function (angular, _, dateMath) {
|
||||
return aggregatorsPromise;
|
||||
};
|
||||
|
||||
var filterTypesPromise = null;
|
||||
this.getFilterTypes = function() {
|
||||
if (filterTypesPromise) { return filterTypesPromise; }
|
||||
|
||||
filterTypesPromise = this._get('/api/config/filters').then(function(result) {
|
||||
if (result.data) {
|
||||
return Object.keys(result.data).sort();
|
||||
}
|
||||
return [];
|
||||
});
|
||||
return filterTypesPromise;
|
||||
};
|
||||
|
||||
function transformMetricData(md, groupByTags, target, options) {
|
||||
var metricLabel = createMetricLabel(md, target, groupByTags, options);
|
||||
var dps = [];
|
||||
|
@ -45,7 +45,15 @@ export class OpenTsQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
this.datasource.getAggregators().then((aggs) => {
|
||||
this.aggregators = aggs;
|
||||
if (aggs.length !== 0) {
|
||||
this.aggregators = aggs;
|
||||
}
|
||||
});
|
||||
|
||||
this.datasource.getFilterTypes().then((filterTypes) => {
|
||||
if (filterTypes.length !== 0) {
|
||||
this.filterTypes = filterTypes;
|
||||
}
|
||||
});
|
||||
|
||||
// needs to be defined here as it is called from typeahead
|
||||
@ -135,7 +143,7 @@ export class OpenTsQueryCtrl extends QueryCtrl {
|
||||
}
|
||||
|
||||
if (!this.target.currentFilterType) {
|
||||
this.target.currentFilterType = 'literal_or';
|
||||
this.target.currentFilterType = 'iliteral_or';
|
||||
}
|
||||
|
||||
if (!this.target.currentFilterGroupBy) {
|
||||
|
@ -17,6 +17,7 @@ describe('OpenTsQueryCtrl', function() {
|
||||
ctx.panelCtrl = {panel: {}};
|
||||
ctx.panelCtrl.refresh = sinon.spy();
|
||||
ctx.datasource.getAggregators = sinon.stub().returns(ctx.$q.when([]));
|
||||
ctx.datasource.getFilterTypes = sinon.stub().returns(ctx.$q.when([]));
|
||||
|
||||
ctx.ctrl = $controller(OpenTsQueryCtrl, {$scope: ctx.scope}, {
|
||||
panelCtrl: ctx.panelCtrl,
|
||||
|
Loading…
Reference in New Issue
Block a user