diff --git a/public/app.js b/public/app.js index 106d9cc596f3d..5890f18865044 100644 --- a/public/app.js +++ b/public/app.js @@ -40,13 +40,13 @@ require('ui/routes') } }); -app.controller('timelion', function ($scope, $http, timefilter, AppState, courier, $route, $routeParams, kbnUrl, Notifier, config) { +app.controller('timelion', function ( + $scope, $http, timefilter, AppState, courier, $route, $routeParams, kbnUrl, Notifier, config, $timeout) { timefilter.enabled = true; var notify = new Notifier({ location: 'Timelion' }); - var defaultExpression = '.es(*)'; var savedSheet = $route.current.locals.savedSheet; var blankSheet = [defaultExpression]; @@ -92,6 +92,20 @@ app.controller('timelion', function ($scope, $http, timefilter, AppState, courie }; }; + var refresher; + $scope.$watchCollection('timefilter.refreshInterval', function (interval) { + if (refresher) $timeout.cancel(refresher); + if (interval.value > 0 && !interval.pause) { + function startRefresh() { + refresher = $timeout(function () { + if (!$scope.running) $scope.search(); + startRefresh(); + }, interval.value); + }; + startRefresh(); + } + }); + $scope.toggle = function (property) { console.log(property); $scope[property] = !$scope[property]; @@ -151,7 +165,6 @@ app.controller('timelion', function ($scope, $http, timefilter, AppState, courie $scope.safeSearch = _.debounce($scope.search, 500); - function save() { savedSheet.id = savedSheet.title; savedSheet.timelion_sheet = $scope.state.sheet;