mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'kairosdb-metric-text' of https://github.com/masaori335/grafana into kariosdb
This commit is contained in:
commit
87007994af
@ -18,7 +18,6 @@ function (angular, _, kbn) {
|
|||||||
this.url = datasource.url;
|
this.url = datasource.url;
|
||||||
this.name = datasource.name;
|
this.name = datasource.name;
|
||||||
this.supportMetrics = true;
|
this.supportMetrics = true;
|
||||||
this.grafanaDB = datasource.grafanaDB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once per panel (graph)
|
// Called once per panel (graph)
|
||||||
@ -85,11 +84,11 @@ function (angular, _, kbn) {
|
|||||||
method : 'GET'
|
method : 'GET'
|
||||||
};
|
};
|
||||||
|
|
||||||
return $http(options).then(function(results) {
|
return $http(options).then(function(response) {
|
||||||
if (!results.data) {
|
if (!response.data) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return results.data.results;
|
return response.data.results;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,14 +38,15 @@
|
|||||||
Metric
|
Metric
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<select style="width: 20em"
|
<input type="text"
|
||||||
class="input-medium tight-form-input"
|
class="input-large tight-form-input"
|
||||||
ng-change="targetBlur()"
|
ng-model="target.metric"
|
||||||
ng-model="metric.value"
|
spellcheck="false"
|
||||||
bs-tooltip="metricValue.length > 40 ? metricValue : ''"
|
bs-typeahead="suggestMetrics"
|
||||||
ng-options="f for f in metric.list" >
|
placeholder="metric name"
|
||||||
<option value="">--select metric--</option>
|
data-min-length=0 data-items=100
|
||||||
</select>
|
ng-blur="targetBlur()"
|
||||||
|
>
|
||||||
<a bs-tooltip="target.errors.metric"
|
<a bs-tooltip="target.errors.metric"
|
||||||
style="color: rgb(229, 189, 28)"
|
style="color: rgb(229, 189, 28)"
|
||||||
ng-show="target.errors.metric">
|
ng-show="target.errors.metric">
|
||||||
|
@ -6,15 +6,12 @@ function (angular, _) {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
var metricList = null;
|
var metricList = [];
|
||||||
|
var targetLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'];
|
||||||
|
|
||||||
module.controller('KairosDBQueryCtrl', function($scope) {
|
module.controller('KairosDBQueryCtrl', function($scope) {
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.metric = {
|
|
||||||
list: ["Loading..."],
|
|
||||||
value: "Loading..."
|
|
||||||
};
|
|
||||||
$scope.panel.stack = false;
|
$scope.panel.stack = false;
|
||||||
if (!$scope.panel.downsampling) {
|
if (!$scope.panel.downsampling) {
|
||||||
$scope.panel.downsampling = 'avg';
|
$scope.panel.downsampling = 'avg';
|
||||||
@ -23,12 +20,12 @@ function (angular, _) {
|
|||||||
$scope.target.downsampling = $scope.panel.downsampling;
|
$scope.target.downsampling = $scope.panel.downsampling;
|
||||||
$scope.target.sampling = $scope.panel.sampling;
|
$scope.target.sampling = $scope.panel.sampling;
|
||||||
}
|
}
|
||||||
|
$scope.targetLetters = targetLetters;
|
||||||
$scope.updateMetricList();
|
$scope.updateMetricList();
|
||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.targetBlur = function() {
|
$scope.targetBlur = function() {
|
||||||
$scope.target.metric = $scope.metric.value;
|
|
||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) {
|
if (!_.isEqual($scope.oldTarget, $scope.target) && _.isEmpty($scope.target.errors)) {
|
||||||
$scope.oldTarget = angular.copy($scope.target);
|
$scope.oldTarget = angular.copy($scope.target);
|
||||||
@ -53,22 +50,16 @@ function (angular, _) {
|
|||||||
_.move($scope.panel.targets, fromIndex, toIndex);
|
_.move($scope.panel.targets, fromIndex, toIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fetch metric list
|
$scope.suggestMetrics = function(query, callback) {
|
||||||
$scope.updateMetricList = function() {
|
if (!_.isEmpty(metricList)) {
|
||||||
$scope.metricListLoading = true;
|
|
||||||
metricList = [];
|
|
||||||
$scope.datasource.performMetricSuggestQuery().then(function(series) {
|
|
||||||
metricList = series;
|
|
||||||
$scope.metric.list = series;
|
|
||||||
if ($scope.target.metric) {
|
|
||||||
$scope.metric.value = $scope.target.metric;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scope.metric.value = "";
|
|
||||||
}
|
|
||||||
$scope.metricListLoading = false;
|
|
||||||
return metricList;
|
return metricList;
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
$scope.datasource.performMetricSuggestQuery().then(function(result) {
|
||||||
|
metricList = result;
|
||||||
|
callback(metricList);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.suggestTagKeys = function(query, callback) {
|
$scope.suggestTagKeys = function(query, callback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user