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
|
|
|
|
|
|
|
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;
|
2014-03-01 05:02:55 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.duplicate = function() {
|
|
|
|
var clone = angular.copy($scope.target);
|
|
|
|
$scope.panel.targets.push(clone);
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|