portainer/app/components/events/eventsController.js

31 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-03-26 19:12:44 +00:00
angular.module('events', [])
2015-03-27 21:25:30 +00:00
.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();
}]);