mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(templating): more work on new variable handling code, #6048
This commit is contained in:
@@ -13,17 +13,20 @@ export class IntervalVariable implements Variable {
|
||||
query: string;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private model, private timeSrv, private templateSrv) {
|
||||
constructor(private model, private timeSrv, private templateSrv, private variableSrv) {
|
||||
_.extend(this, model);
|
||||
}
|
||||
|
||||
setValue(option) {
|
||||
if (this.auto) {
|
||||
this.updateAutoValue();
|
||||
}
|
||||
this.updateAutoValue();
|
||||
this.variableSrv.setOptionAsCurrent(this, option);
|
||||
}
|
||||
|
||||
updateAutoValue() {
|
||||
if (!this.auto) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add auto option if missing
|
||||
if (this.options.length && this.options[0].text !== 'auto') {
|
||||
this.options.unshift({ text: 'auto', value: '$__auto_interval' });
|
||||
@@ -44,9 +47,14 @@ export class IntervalVariable implements Variable {
|
||||
}
|
||||
}
|
||||
|
||||
dependsOn(variableName) {
|
||||
dependsOn(variable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setValueFromUrl(urlValue) {
|
||||
this.updateAutoValue();
|
||||
return this.variableSrv.setOptionFromUrl(this, urlValue);
|
||||
}
|
||||
}
|
||||
|
||||
variableConstructorMap['interval'] = IntervalVariable;
|
||||
|
||||
Reference in New Issue
Block a user