2016-07-26 23:08:18 +00:00
|
|
|
angular.module('events', [])
|
2017-06-20 11:00:32 +00:00
|
|
|
.controller('EventsController', ['$scope', 'Notifications', 'SystemService', 'Pagination',
|
|
|
|
function ($scope, Notifications, SystemService, 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);
|
|
|
|
};
|
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
function initView() {
|
|
|
|
var from = moment().subtract(24, 'hour').unix();
|
|
|
|
var to = moment().unix();
|
2016-07-26 23:08:18 +00:00
|
|
|
|
2017-06-20 11:00:32 +00:00
|
|
|
$('#loadEventsSpinner').show();
|
|
|
|
SystemService.events(from, to)
|
|
|
|
.then(function success(data) {
|
|
|
|
$scope.events = data;
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
Notifications.error('Failure', err, 'Unable to load events');
|
|
|
|
})
|
|
|
|
.finally(function final() {
|
|
|
|
$('#loadEventsSpinner').hide();
|
2016-07-26 23:08:18 +00:00
|
|
|
});
|
2017-06-20 11:00:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
initView();
|
2016-07-26 23:08:18 +00:00
|
|
|
}]);
|