2016-04-30 18:57:55 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('Application').controller('ActivityController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
|
|
|
|
|
$scope.config = Client.getConfig();
|
|
|
|
|
|
2016-05-06 17:23:39 +02:00
|
|
|
$scope.busy = false;
|
2016-04-30 18:57:55 -07:00
|
|
|
$scope.eventLogs = [ ];
|
|
|
|
|
|
2016-05-06 17:23:39 +02:00
|
|
|
// TODO sync this with the eventlog filter
|
2016-05-06 17:18:47 +02:00
|
|
|
$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' }
|
|
|
|
|
];
|
|
|
|
|
|
2016-05-02 11:36:20 -07:00
|
|
|
$scope.currentPage = 1;
|
|
|
|
|
$scope.pageItems = 20;
|
2016-05-06 17:18:47 +02:00
|
|
|
$scope.action = '';
|
|
|
|
|
$scope.search = '';
|
2016-05-02 11:36:20 -07:00
|
|
|
|
2016-04-30 18:57:55 -07:00
|
|
|
function fetchEventLogs() {
|
2016-05-02 11:36:20 -07:00
|
|
|
$scope.busy = true;
|
|
|
|
|
|
2016-05-06 17:18:47 +02:00
|
|
|
Client.getEventLogs($scope.action ? $scope.action.value : null, $scope.search || null, $scope.currentPage, $scope.pageItems, function (error, eventLogs) {
|
2016-05-02 11:36:20 -07:00
|
|
|
$scope.busy = false;
|
|
|
|
|
|
2016-04-30 18:57:55 -07:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
$scope.eventLogs = eventLogs;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-02 11:36:20 -07:00
|
|
|
$scope.showNextPage = function () {
|
|
|
|
|
$scope.currentPage++;
|
|
|
|
|
fetchEventLogs();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.showPrevPage = function () {
|
|
|
|
|
if ($scope.currentPage > 1) $scope.currentPage--;
|
|
|
|
|
else $scope.currentPage = 1;
|
|
|
|
|
|
|
|
|
|
fetchEventLogs();
|
|
|
|
|
};
|
2016-05-06 17:18:47 +02:00
|
|
|
|
|
|
|
|
$scope.updateFilter = function () {
|
|
|
|
|
fetchEventLogs();
|
|
|
|
|
};
|
2016-07-27 16:34:36 +02:00
|
|
|
|
|
|
|
|
Client.onReady(function () {
|
|
|
|
|
fetchEventLogs();
|
|
|
|
|
});
|
2016-04-30 18:57:55 -07:00
|
|
|
}]);
|