Added date ranges to events.
parent
14bfc57870
commit
6080e097da
|
@ -1,18 +1,33 @@
|
|||
<h2>Events</h2>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Event</th>
|
||||
<th>From</th>
|
||||
<th>ID</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<tr ng-repeat="event in dockerEvents">
|
||||
<td ng-bind="event.status"/>
|
||||
<td ng-bind="event.from"/>
|
||||
<td ng-bind="event.id"/>
|
||||
<td ng-bind="event.time"/>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h2>Events</h2>
|
||||
<form class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="since">Since:</label>
|
||||
<input id="since" type="datetime-local" ng-model="model.since" class="form-control" step="any"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="until">Until:</label>
|
||||
<input id="until" type="datetime-local" ng-model="model.until" class="form-control" step="any"/>
|
||||
</div>
|
||||
<button ng-click="updateEvents()" class="btn btn-primary">Update</button>
|
||||
</form>
|
||||
<br>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Event</th>
|
||||
<th>From</th>
|
||||
<th>ID</th>
|
||||
<th>Time</th>
|
||||
</tr>
|
||||
<tr ng-repeat="event in dockerEvents">
|
||||
<td ng-bind="event.status"/>
|
||||
<td ng-bind="event.from"/>
|
||||
<td ng-bind="event.id"/>
|
||||
<td ng-bind="event.time * 1000 | date:'medium'"/>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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();
|
||||
|
||||
}]);
|
Loading…
Reference in New Issue