Files
cloudron-box/webadmin/src/views/activity.js
Johannes 3bcd255a07 Ugly hack to ensure the modal backdrop is removed when changing views
Couldn't figure a way to make this generic
2016-11-21 13:22:58 +01:00

68 lines
2.1 KiB
JavaScript

'use strict';
angular.module('Application').controller('ActivityController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
$scope.config = Client.getConfig();
$scope.busy = false;
$scope.eventLogs = [ ];
// TODO sync this with the eventlog filter
$scope.actions = [
{ name: 'cloudron.activate', value: 'cloudron.activate' },
{ name: 'app.configure', value: 'app.configure' },
{ name: 'app.install', value: 'app.install' },
{ name: 'app.restore', value: 'app.restore' },
{ name: 'app.uninstall', value: 'app.uninstall' },
{ name: 'app.update', value: 'app.update' },
{ name: 'backup.finish', value: 'backup.finish' },
{ name: 'backup.start', value: 'backup.start' },
{ name: 'certificate.renew', value: 'certificate.renew' },
{ name: 'settings.climode', value: 'settings.climode' },
{ name: 'cloudron.start', value: 'cloudron.start' },
{ name: 'cloudron.update', value: 'cloudron.update' },
{ name: 'user.add', value: 'user.add' },
{ name: 'user.login', value: 'user.login' },
{ name: 'user.remove', value: 'user.remove' },
{ name: 'user.update', value: 'user.update' }
];
$scope.currentPage = 1;
$scope.pageItems = 20;
$scope.action = '';
$scope.search = '';
function fetchEventLogs() {
$scope.busy = true;
Client.getEventLogs($scope.action ? $scope.action.value : null, $scope.search || null, $scope.currentPage, $scope.pageItems, function (error, eventLogs) {
$scope.busy = false;
if (error) return console.error(error);
$scope.eventLogs = eventLogs;
});
}
$scope.showNextPage = function () {
$scope.currentPage++;
fetchEventLogs();
};
$scope.showPrevPage = function () {
if ($scope.currentPage > 1) $scope.currentPage--;
else $scope.currentPage = 1;
fetchEventLogs();
};
$scope.updateFilter = function () {
fetchEventLogs();
};
Client.onReady(function () {
fetchEventLogs();
});
$('.modal-backdrop').remove();
}]);