diff --git a/public/app/directives/variableValueSelect.js b/public/app/directives/variableValueSelect.js index 41f8d5b1322..bdc914c144d 100644 --- a/public/app/directives/variableValueSelect.js +++ b/public/app/directives/variableValueSelect.js @@ -13,7 +13,7 @@ function (angular, app, _) { var vm = this; vm.show = function() { - vm.oldCurrentText = vm.variable.current.text; + vm.oldLinkText = vm.variable.current.text; vm.highlightIndex = -1; var currentValues = vm.variable.current.value; @@ -44,6 +44,9 @@ function (angular, app, _) { vm.updateLinkText = function() { vm.linkText = vm.variable.current.text; + if (vm.oldLinkText && vm.oldLinkText !== vm.linkText) { + vm.onUpdated(); + } }; vm.clearSelections = function() { diff --git a/public/app/features/dashboard/submenuCtrl.js b/public/app/features/dashboard/submenuCtrl.js index 6f423ebbe59..b8e609c061e 100644 --- a/public/app/features/dashboard/submenuCtrl.js +++ b/public/app/features/dashboard/submenuCtrl.js @@ -18,9 +18,7 @@ function (angular, _) { $scope.panel = $scope.pulldown; $scope.row = $scope.pulldown; $scope.annotations = $scope.dashboard.templating.list; - $scope.variables = _.map($scope.dashboard.templating.list, function(variable) { - return variable; - }); + $scope.variables = $scope.dashboard.templating.list; }; $scope.disableAnnotation = function (annotation) { @@ -28,8 +26,8 @@ function (angular, _) { $rootScope.$broadcast('refresh'); }; - $scope.getValuesForTag = function() { - return $q.when(['backend_01', 'backend_02']); + $scope.getValuesForTag = function(variable, tagKey) { + return templateValuesSrv.getValuesForTag(variable, tagKey); }; $scope.variableUpdated = function(variable) { diff --git a/public/app/features/templating/partials/editor.html b/public/app/features/templating/partials/editor.html index 99b50d45866..382790e0f21 100644 --- a/public/app/features/templating/partials/editor.html +++ b/public/app/features/templating/partials/editor.html @@ -228,25 +228,25 @@
-
value groups/tags
-
+
Value groups/tags
+
    -
  • - tags query +
  • + Tags query
  • - +
-
+
    -
  • - tags values query +
  • + Tag values query
  • - +
@@ -254,7 +254,7 @@
  • - +
diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index 2fd17f4aa65..8b61b40688d 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -154,6 +154,17 @@ function (angular, _, kbn) { }); }; + this.getValuesForTag = function(variable, tagKey) { + return datasourceSrv.get(variable.datasource).then(function(datasource) { + var query = variable.tagValuesQuery.replace('$tag', tagKey); + return datasource.metricFindQuery(query).then(function (results) { + return _.map(results, function(value) { + return value.text; + }); + }); + }); + }; + this.metricNamesToVariableValues = function(variable, metricNames) { var regex, options, i, matches; options = {}; // use object hash to remove duplicates diff --git a/public/app/partials/submenu.html b/public/app/partials/submenu.html index 43a5581e0b5..5f5d29e87ba 100644 --- a/public/app/partials/submenu.html +++ b/public/app/partials/submenu.html @@ -6,7 +6,7 @@ {{variable.label || variable.name}}: - +