1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

Added date ranges to events.

This commit is contained in:
Kevan Ahlquist 2015-03-27 16:25:30 -05:00
parent 14bfc57870
commit 6080e097da
2 changed files with 63 additions and 27 deletions

View file

@ -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();
}]);