Просмотр исходного кода

fix(opentsdb): fixed templating issue for OpenTSDB, fixes #4312, fixes #4311

Torkel Ödegaard 9 лет назад
Родитель
Сommit
4aba3bc62b
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      public/app/features/templating/templateSrv.js

+ 7 - 3
public/app/features/templating/templateSrv.js

@@ -43,6 +43,9 @@ function (angular, _) {
     }
     }
 
 
     this.formatValue = function(value, format, variable) {
     this.formatValue = function(value, format, variable) {
+      // for some scopedVars there is no variable
+      variable = variable || {};
+
       if (typeof format === 'function') {
       if (typeof format === 'function') {
         return format(value, variable, this.formatValue);
         return format(value, variable, this.formatValue);
       }
       }
@@ -126,9 +129,6 @@ function (angular, _) {
 
 
       return target.replace(this._regex, function(match, g1, g2) {
       return target.replace(this._regex, function(match, g1, g2) {
         variable = self._index[g1 || g2];
         variable = self._index[g1 || g2];
-        if (!variable) {
-          return match;
-        }
 
 
         if (scopedVars) {
         if (scopedVars) {
           value = scopedVars[g1 || g2];
           value = scopedVars[g1 || g2];
@@ -137,6 +137,10 @@ function (angular, _) {
           }
           }
         }
         }
 
 
+        if (!variable) {
+          return match;
+        }
+
         systemValue = self._grafanaVariables[variable.current.value];
         systemValue = self._grafanaVariables[variable.current.value];
         if (systemValue) {
         if (systemValue) {
           return self.formatValue(systemValue, format, variable);
           return self.formatValue(systemValue, format, variable);