2016-07-26 23:08:18 +00:00
|
|
|
angular.module('events', [])
|
2017-04-12 19:47:22 +00:00
|
|
|
.controller('EventsController', ['$scope', 'Notifications', 'Events', 'Pagination',
|
|
|
|
function ($scope, Notifications, Events, Pagination) {
|
2016-07-26 23:08:18 +00:00
|
|
|
$scope.state = {};
|
2017-01-24 01:28:40 +00:00
|
|
|
$scope.state.pagination_count = Pagination.getPaginationCount('events');
|
2016-07-26 23:08:18 +00:00
|
|
|
$scope.sortType = 'Time';
|
|
|
|
$scope.sortReverse = true;
|
|
|
|
|
|
|
|
$scope.order = function(sortType) {
|
|
|
|
$scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
|
|
|
|
$scope.sortType = sortType;
|
|
|
|
};
|
|
|
|
|
2017-01-24 01:28:40 +00:00
|
|
|
$scope.changePaginationCount = function() {
|
|
|
|
Pagination.setPaginationCount('events', $scope.state.pagination_count);
|
|
|
|
};
|
|
|
|
|
2016-07-26 23:08:18 +00:00
|
|
|
var from = moment().subtract(24, 'hour').unix();
|
|
|
|
var to = moment().unix();
|
|
|
|
|
|
|
|
Events.query({since: from, until: to},
|
|
|
|
function(d) {
|
|
|
|
$scope.events = d.map(function (item) {
|
|
|
|
return new EventViewModel(item);
|
|
|
|
});
|
|
|
|
$('#loadEventsSpinner').hide();
|
|
|
|
},
|
|
|
|
function (e) {
|
|
|
|
$('#loadEventsSpinner').hide();
|
2017-04-12 19:47:22 +00:00
|
|
|
Notifications.error("Failure", e, "Unable to load events");
|
2016-07-26 23:08:18 +00:00
|
|
|
});
|
|
|
|
}]);
|