2014-03-01 05:02:55 -06:00
|
|
|
define([
|
|
|
|
'angular'
|
|
|
|
],
|
|
|
|
function (angular) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('kibana.controllers');
|
|
|
|
|
2014-03-02 11:24:15 -06:00
|
|
|
var seriesList = null;
|
|
|
|
|
|
|
|
module.controller('InfluxTargetCtrl', function($scope, $timeout) {
|
2014-03-01 05:02:55 -06:00
|
|
|
|
|
|
|
$scope.init = function() {
|
|
|
|
if (!$scope.target.function) {
|
|
|
|
$scope.target.function = 'mean';
|
|
|
|
}
|
2014-03-02 11:24:15 -06:00
|
|
|
|
2014-03-23 14:20:18 -05:00
|
|
|
$scope.functions = ['count', 'mean', 'sum', 'min', 'max', 'mode', 'distinct', 'median', 'derivative', 'stddev', 'first', 'last'];
|
2014-03-05 05:43:44 -06:00
|
|
|
$scope.oldSeries = $scope.target.series;
|
2014-03-02 11:24:15 -06:00
|
|
|
$scope.$on('typeahead-updated', function(){
|
|
|
|
$timeout($scope.get_data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Cannot use typeahead and ng-change on blur at the same time
|
|
|
|
$scope.seriesBlur = function() {
|
2014-03-05 05:43:44 -06:00
|
|
|
if ($scope.oldSeries !== $scope.target.series) {
|
|
|
|
$scope.oldSeries = $scope.target.series;
|
2014-03-02 11:24:15 -06:00
|
|
|
$scope.get_data();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-03-05 05:43:44 -06:00
|
|
|
// called outside of digest
|
|
|
|
$scope.listColumns = function(query, callback) {
|
|
|
|
if (!$scope.columnList) {
|
|
|
|
$scope.$apply(function() {
|
|
|
|
$scope.datasource.listColumns($scope.target.series).then(function(columns) {
|
|
|
|
$scope.columnList = columns;
|
|
|
|
callback(columns);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $scope.columnList;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.listSeries = function(query, callback) {
|
|
|
|
if (!seriesList) {
|
|
|
|
seriesList = [];
|
|
|
|
$scope.datasource.listSeries().then(function(series) {
|
|
|
|
seriesList = series;
|
|
|
|
callback(seriesList);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return seriesList;
|
|
|
|
}
|
2014-03-01 05:02:55 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.duplicate = function() {
|
|
|
|
var clone = angular.copy($scope.target);
|
|
|
|
$scope.panel.targets.push(clone);
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|