mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Use other variable dependencies in regex filter for datasource variable (#7547)
This commit is contained in:
parent
a37a2259b3
commit
70c2586c80
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import kbn from 'app/core/utils/kbn';
|
import kbn from 'app/core/utils/kbn';
|
||||||
import {Variable, assignModelProperties, variableTypes} from './variable';
|
import {Variable, containsVariable, assignModelProperties, variableTypes} from './variable';
|
||||||
import {VariableSrv} from './variable_srv';
|
import {VariableSrv} from './variable_srv';
|
||||||
|
|
||||||
export class DatasourceVariable implements Variable {
|
export class DatasourceVariable implements Variable {
|
||||||
@ -25,7 +25,7 @@ export class DatasourceVariable implements Variable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** @ngInject **/
|
/** @ngInject **/
|
||||||
constructor(private model, private datasourceSrv, private variableSrv) {
|
constructor(private model, private datasourceSrv, private variableSrv, private templateSrv) {
|
||||||
assignModelProperties(this, model, this.defaults);
|
assignModelProperties(this, model, this.defaults);
|
||||||
this.refresh = 1;
|
this.refresh = 1;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,8 @@ export class DatasourceVariable implements Variable {
|
|||||||
var regex;
|
var regex;
|
||||||
|
|
||||||
if (this.regex) {
|
if (this.regex) {
|
||||||
regex = kbn.stringToJsRegex(this.regex);
|
regex = this.templateSrv.replace(this.regex, null, 'regex');
|
||||||
|
regex = kbn.stringToJsRegex(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < sources.length; i++) {
|
for (var i = 0; i < sources.length; i++) {
|
||||||
@ -74,6 +75,9 @@ export class DatasourceVariable implements Variable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependsOn(variable) {
|
dependsOn(variable) {
|
||||||
|
if (this.regex) {
|
||||||
|
return containsVariable(this.regex, variable.name);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user