Fix default query type for new queries if data source is not default
This commit is contained in:
@@ -4,7 +4,7 @@ import * as c from './constants';
|
|||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as metricFunctions from './metricFunctions';
|
import * as metricFunctions from './metricFunctions';
|
||||||
import * as migrations from './migrations';
|
import * as migrations from './migrations';
|
||||||
import { ShowProblemTypes, ZabbixMetricsQuery } from './types';
|
import { ShowProblemTypes } from './types';
|
||||||
import { CURRENT_SCHEMA_VERSION } from '../panel-triggers/migrations';
|
import { CURRENT_SCHEMA_VERSION } from '../panel-triggers/migrations';
|
||||||
import { getTemplateSrv, TemplateSrv } from '@grafana/runtime';
|
import { getTemplateSrv, TemplateSrv } from '@grafana/runtime';
|
||||||
|
|
||||||
@@ -218,6 +218,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
// Load default values
|
// Load default values
|
||||||
const targetDefaults = getTargetDefaults();
|
const targetDefaults = getTargetDefaults();
|
||||||
_.defaultsDeep(target, targetDefaults);
|
_.defaultsDeep(target, targetDefaults);
|
||||||
|
this.initDefaultQueryMode(target);
|
||||||
|
|
||||||
if (this.panel.type === c.ZABBIX_PROBLEMS_PANEL_ID) {
|
if (this.panel.type === c.ZABBIX_PROBLEMS_PANEL_ID) {
|
||||||
target.queryType = c.MODE_PROBLEMS;
|
target.queryType = c.MODE_PROBLEMS;
|
||||||
@@ -276,6 +277,17 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initDefaultQueryMode(target) {
|
||||||
|
if (!(target.queryType === c.MODE_METRICS ||
|
||||||
|
target.queryType === c.MODE_TEXT ||
|
||||||
|
target.queryType === c.MODE_ITSERVICE ||
|
||||||
|
target.queryType === c.MODE_ITEMID ||
|
||||||
|
target.queryType === c.MODE_TRIGGERS ||
|
||||||
|
target.queryType === c.MODE_PROBLEMS)) {
|
||||||
|
target.queryType = c.MODE_METRICS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get list of metric names for bs-typeahead directive
|
// Get list of metric names for bs-typeahead directive
|
||||||
getMetricNames(metricList, addAllValue) {
|
getMetricNames(metricList, addAllValue) {
|
||||||
const metrics = _.uniq(_.map(this.metric[metricList], 'name'));
|
const metrics = _.uniq(_.map(this.metric[metricList], 'name'));
|
||||||
|
|||||||
Reference in New Issue
Block a user