2016-07-26 23:08:18 +00:00
|
|
|
angular.module('events', [])
|
|
|
|
.controller('EventsController', ['$scope', 'Settings', 'Messages', 'Events',
|
|
|
|
function ($scope, Settings, Messages, Events) {
|
|
|
|
$scope.state = {};
|
|
|
|
$scope.sortType = 'Time';
|
|
|
|
$scope.sortReverse = true;
|
2016-11-17 12:50:46 +00:00
|
|
|
$scope.pagination_count = Settings.pagination_count;
|
2016-07-26 23:08:18 +00:00
|
|
|
|
|
|
|
$scope.order = function(sortType) {
|
|
|
|
$scope.sortReverse = ($scope.sortType === sortType) ? !$scope.sortReverse : false;
|
|
|
|
$scope.sortType = sortType;
|
|
|
|
};
|
|
|
|
|
|
|
|
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();
|
2016-09-02 05:40:03 +00:00
|
|
|
Messages.error("Failure", e, "Unable to load events");
|
2016-07-26 23:08:18 +00:00
|
|
|
});
|
|
|
|
}]);
|