From 6080e097da21c8e1d53f28d59d358fa8838385a3 Mon Sep 17 00:00:00 2001 From: Kevan Ahlquist Date: Fri, 27 Mar 2015 16:25:30 -0500 Subject: [PATCH] Added date ranges to events. --- app/components/events/events.html | 51 +++++++++++++++-------- app/components/events/eventsController.js | 39 +++++++++++++---- 2 files changed, 63 insertions(+), 27 deletions(-) diff --git a/app/components/events/events.html b/app/components/events/events.html index ccbfd38f4..7d1c896d3 100644 --- a/app/components/events/events.html +++ b/app/components/events/events.html @@ -1,18 +1,33 @@ -

Events

- - - - - - - - - - - - -
EventFromIDTime
- - - -
+
+
+

Events

+
+
+ + +
+
+ + +
+ +
+
+ + + + + + + + + + + +
EventFromIDTime
+ + + +
+
+
diff --git a/app/components/events/eventsController.js b/app/components/events/eventsController.js index c5b579140..e0dc5d213 100644 --- a/app/components/events/eventsController.js +++ b/app/components/events/eventsController.js @@ -1,10 +1,31 @@ angular.module('events', []) -.controller('EventsController', ['Settings', '$scope', function(Settings, $scope) { - var yesterday = Math.floor(Date.now() / 1000) - 86400; // Today's date minus 24 hours. - $scope.dockerEvents = []; - oboe(Settings.url + '/events' + '?since=' + yesterday) - .done(function(node) { - $scope.dockerEvents.push(node); - $scope.$apply(); - }); -}]); + .controller('EventsController', ['Settings', '$scope', function(Settings, $scope) { + $scope.updateEvents = function() { + $scope.dockerEvents = []; + + // TODO: Clean up URL building + var url = Settings.url + '/events?'; + + if ($scope.model.since) { + var sinceSecs = Math.floor($scope.model.since.getTime() / 1000); + url += 'since=' + sinceSecs + '&'; + } + if ($scope.model.until) { + var untilSecs = Math.floor($scope.model.until.getTime() / 1000); + url += 'until=' + untilSecs; + } + + oboe(url) + .done(function(node) { + $scope.dockerEvents.push(node); + $scope.$apply(); + }); + }; + + // Init + $scope.model = {}; + $scope.model.since = new Date(Date.now() - 86400000); // 24 hours in the past + $scope.model.until = new Date(); + $scope.updateEvents(); + + }]); \ No newline at end of file