mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 00:08:10 -05:00
added typeahead / autocomplete to influxdb series name, #103
This commit is contained in:
@@ -6,12 +6,38 @@ function (angular) {
|
||||
|
||||
var module = angular.module('kibana.controllers');
|
||||
|
||||
module.controller('InfluxTargetCtrl', function($scope) {
|
||||
var seriesList = null;
|
||||
|
||||
module.controller('InfluxTargetCtrl', function($scope, $timeout) {
|
||||
|
||||
$scope.init = function() {
|
||||
if (!$scope.target.function) {
|
||||
$scope.target.function = 'mean';
|
||||
}
|
||||
|
||||
if (!seriesList) {
|
||||
seriesList = [];
|
||||
$scope.datasource.listSeries().then(function(series) {
|
||||
seriesList = series;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.oldSeris = $scope.target.series;
|
||||
$scope.$on('typeahead-updated', function(){
|
||||
$timeout($scope.get_data);
|
||||
});
|
||||
};
|
||||
|
||||
// Cannot use typeahead and ng-change on blur at the same time
|
||||
$scope.seriesBlur = function() {
|
||||
if ($scope.oldSeris !== $scope.target.series) {
|
||||
$scope.oldSeris = $scope.target.series;
|
||||
$scope.get_data();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.listSeries = function() {
|
||||
return seriesList;
|
||||
};
|
||||
|
||||
$scope.duplicate = function() {
|
||||
|
||||
@@ -51,8 +51,11 @@
|
||||
class="input-medium grafana-target-segment-input"
|
||||
ng-model="target.series"
|
||||
spellcheck='false'
|
||||
bs-typeahead="listSeries"
|
||||
placeholder="series name"
|
||||
ng-model-onblur ng-change="get_data()" >
|
||||
data-min-length=0 data-items=100
|
||||
ng-blur="seriesBlur()"
|
||||
>
|
||||
</li>
|
||||
<li class="grafana-target-segment">
|
||||
select
|
||||
|
||||
@@ -54,6 +54,18 @@ function (angular, _, kbn) {
|
||||
|
||||
};
|
||||
|
||||
InfluxDatasource.prototype.listSeries = function() {
|
||||
return this.doInfluxRequest('list series').then(function(results) {
|
||||
if (!results.data) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return _.map(results.data, function(series) {
|
||||
return series.name;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
InfluxDatasource.prototype.doInfluxRequest = function(query) {
|
||||
var params = {
|
||||
u: this.username,
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -569,4 +569,5 @@ div.flot-text {
|
||||
td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
@dropdownLinkColorHover: @white;
|
||||
@dropdownLinkColorActive: @white;
|
||||
|
||||
@dropdownLinkBackgroundActive: @linkColor;
|
||||
@dropdownLinkBackgroundActive: @blue;
|
||||
@dropdownLinkBackgroundHover: @blue;
|
||||
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
@dropdownLinkColorActive: @white;
|
||||
|
||||
@dropdownLinkBackgroundActive: @blue;
|
||||
@dropdownLinkBackgroundHover: @dropdownLinkBackgroundActive;
|
||||
@dropdownLinkBackgroundHover: @blue;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user