Commit d97f24cf by Espen Fjellvær Olsen

Update QueryController to conform with OpenTSDB Controller

parent 48975e65
...@@ -6,8 +6,6 @@ function (angular, _) { ...@@ -6,8 +6,6 @@ function (angular, _) {
'use strict'; 'use strict';
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
var metricList = [];
var tagList = [];
module.controller('KairosDBQueryCtrl', function($scope) { module.controller('KairosDBQueryCtrl', function($scope) {
...@@ -48,50 +46,26 @@ function (angular, _) { ...@@ -48,50 +46,26 @@ function (angular, _) {
_.move($scope.panel.targets, fromIndex, toIndex); _.move($scope.panel.targets, fromIndex, toIndex);
}; };
$scope.getTextValues = function(metricFindResult) {
return _.map(metricFindResult, function(value) { return value.text; });
};
$scope.suggestMetrics = function(query, callback) { $scope.suggestMetrics = function(query, callback) {
if (!_.isEmpty(metricList)) { $scope.datasource.metricFindQuery('metrics(' + query + ')')
return metricList; .then($scope.getTextValues)
} .then(callback);
else {
$scope.datasource._performMetricSuggestQuery().then(function(result) {
metricList = result;
callback(metricList);
});
}
}; };
$scope.suggestTagKeys = function(query, callback) { $scope.suggestTagKeys = function(query, callback) {
if (!_.isEmpty(tagList)) { $scope.datasource.metricFindQuery('tag_names(' + $scope.target.metric + ')')
var result = _.find(tagList, { name : $scope.target.metric }); .then($scope.getTextValues)
.then(callback);
if (!_.isEmpty(result)) {
return _.keys(result.tags);
}
}
$scope.datasource._performTagSuggestQuery($scope.target.metric).then(function(result) {
if (!_.isEmpty(result)) {
tagList.push(result);
callback(_.keys(result.tags));
}
});
}; };
$scope.suggestTagValues = function(query, callback) { $scope.suggestTagValues = function(query, callback) {
if (!_.isEmpty(tagList)) { $scope.datasource.metricFindQuery('tag_values(' + $scope.target.metric + ',' + $scope.target.currentTagKey + ')')
var result = _.find(tagList, { name : $scope.target.metric }); .then($scope.getTextValues)
.then(callback);
if (!_.isEmpty(result)) {
return result.tags[$scope.target.currentTagKey];
}
}
$scope.datasource.performTagSuggestQuery($scope.target.metric).then(function(result) {
if (!_.isEmpty(result)) {
tagList.push(result);
callback(result.tags[$scope.target.currentTagKey]);
}
});
}; };
// Filter metric by tag // Filter metric by tag
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment