From 795cee13c8b011c8e2ccbf7b0fe12a83de699503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 29 Mar 2015 20:30:42 +0200 Subject: [PATCH] KairosDB data source plugin is messy, needs a lot of clean up & refactoring, please help --- .../plugins/datasource/kairosdb/datasource.js | 2 +- .../plugins/datasource/kairosdb/queryCtrl.js | 26 ++++++------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/public/app/plugins/datasource/kairosdb/datasource.js b/public/app/plugins/datasource/kairosdb/datasource.js index e055c118956..bcce19cb83f 100644 --- a/public/app/plugins/datasource/kairosdb/datasource.js +++ b/public/app/plugins/datasource/kairosdb/datasource.js @@ -217,7 +217,7 @@ function (angular, _, kbn) { if(chosenAggregator.sampling_rate) { returnedAggregator.sampling = KairosDBDatasource.prototype.convertToKairosInterval(chosenAggregator.sampling_rate); returnedAggregator.align_sampling = true; - returnedAggregator.align_start_time=true; + returnedAggregator.align_start_time =true; } if(chosenAggregator.unit) { returnedAggregator.unit = chosenAggregator.unit+'s'; diff --git a/public/app/plugins/datasource/kairosdb/queryCtrl.js b/public/app/plugins/datasource/kairosdb/queryCtrl.js index fef1e4d39f4..73321d3016a 100644 --- a/public/app/plugins/datasource/kairosdb/queryCtrl.js +++ b/public/app/plugins/datasource/kairosdb/queryCtrl.js @@ -53,30 +53,26 @@ function (angular, _) { _.move($scope.panel.targets, fromIndex, toIndex); }; - ////////////////////////////// - // SUGGESTION QUERIES - ////////////////////////////// - + // Fetch metric list $scope.updateMetricList = function() { $scope.metricListLoading = true; metricList = []; $scope.datasource.performMetricSuggestQuery().then(function(series) { metricList = series; $scope.metric.list = series; - if ($scope.target.metric) + if ($scope.target.metric) { $scope.metric.value = $scope.target.metric; - else + } + else { $scope.metric.value = ""; + } $scope.metricListLoading = false; return metricList; }); }; $scope.suggestTagKeys = function(query, callback) { - $scope.updateTimeRange(); - callback($scope.datasource - .performTagSuggestQuery($scope.target.metric,$scope.rangeUnparsed, 'key','')); - + callback($scope.datasource.performTagSuggestQuery($scope.target.metric, $scope.rangeUnparsed, 'key','')); }; $scope.suggestTagValues = function(query, callback) { @@ -84,10 +80,7 @@ function (angular, _) { .performTagSuggestQuery($scope.target.metric,$scope.rangeUnparsed, 'value',$scope.target.currentTagKey)); }; - ////////////////////////////// - // FILTER by TAG - ////////////////////////////// - + // Filter metric by tag $scope.addFilterTag = function() { if (!$scope.addFilterTagMode) { $scope.addFilterTagMode = true; @@ -333,10 +326,7 @@ function (angular, _) { alert(message); }; - ////////////////////////////// - // VALIDATION - ////////////////////////////// - + // Validation function MetricListToObject(MetricList) { var result = {}; var Metric;