Преглед изворни кода

Use other variable dependencies in regex filter for datasource variable (#7547)

Ross Lodge пре 8 година
родитељ
комит
70c2586c80
1 измењених фајлова са 7 додато и 3 уклоњено
  1. 7 3
      public/app/features/templating/datasource_variable.ts

+ 7 - 3
public/app/features/templating/datasource_variable.ts

@@ -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;
   }
   }