2015-04-19 06:06:58 +00:00
|
|
|
angular.module('events', ['ngOboe'])
|
2015-08-25 05:59:54 +00:00
|
|
|
.controller('EventsController', ['Settings', '$scope', 'Oboe', 'Messages', '$timeout', function (Settings, $scope, oboe, Messages, $timeout) {
|
|
|
|
$scope.updateEvents = function () {
|
2015-03-27 21:25:30 +00:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2015-04-19 06:06:58 +00:00
|
|
|
oboe({
|
2015-08-25 05:59:54 +00:00
|
|
|
url: url,
|
|
|
|
pattern: '{id status time}'
|
|
|
|
})
|
|
|
|
.then(function (node) {
|
2015-04-19 06:06:58 +00:00
|
|
|
// finished loading
|
2015-08-25 05:59:54 +00:00
|
|
|
$timeout(function () {
|
2015-04-19 06:06:58 +00:00
|
|
|
$scope.$apply();
|
|
|
|
});
|
2015-08-25 05:59:54 +00:00
|
|
|
}, function (error) {
|
2015-04-19 06:06:58 +00:00
|
|
|
// handle errors
|
|
|
|
Messages.error("Failure", error.data);
|
2015-08-25 05:59:54 +00:00
|
|
|
}, function (node) {
|
2015-04-19 06:06:58 +00:00
|
|
|
// node received
|
2015-03-27 21:25:30 +00:00
|
|
|
$scope.dockerEvents.push(node);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Init
|
|
|
|
$scope.model = {};
|
|
|
|
$scope.model.since = new Date(Date.now() - 86400000); // 24 hours in the past
|
|
|
|
$scope.model.until = new Date();
|
|
|
|
$scope.updateEvents();
|
|
|
|
|
|
|
|
}]);
|