diff --git a/src/views/activity.js b/src/views/activity.js index a37a160eb..58828ba61 100644 --- a/src/views/activity.js +++ b/src/views/activity.js @@ -26,6 +26,9 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca { name: 'app.oom', value: 'app.oom' }, { name: 'app.down', value: 'app.down' }, { name: 'app.up', value: 'app.up' }, + { name: 'app.start', value: 'app.start' }, + { name: 'app.stop', value: 'app.stop' }, + { name: 'app.restart', value: 'app.restart' }, { name: 'Apptask Crash', value: 'app.task.crash' }, { name: 'backup.cleanup', value: 'backup.cleanup.start' }, { name: 'backup.cleanup.finish', value: 'backup.cleanup.finish' }, @@ -90,6 +93,9 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca var ACTION_APP_OOM = 'app.oom'; var ACTION_APP_UP = 'app.up'; var ACTION_APP_DOWN = 'app.down'; + var ACTION_APP_START = 'app.start'; + var ACTION_APP_STOP = 'app.stop'; + var ACTION_APP_RESTART = 'app.restart'; var ACTION_BACKUP_FINISH = 'backup.finish'; var ACTION_BACKUP_START = 'backup.start'; @@ -131,7 +137,11 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca var data = eventLog.data; var errorMessage = data.errorMessage; - var details; + var details, app; + + function appName(app) { + return (app.label || app.fqdn || app.location) + ' (' + app.manifest.title + ')'; + } switch (eventLog.action) { case ACTION_ACTIVATE: @@ -143,74 +153,75 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca case ACTION_RESTORE: return 'Cloudron was restored using backup ' + data.backupId; - case ACTION_APP_CONFIGURE: + case ACTION_APP_CONFIGURE: { if (!data.app) return ''; + app = data.app; var q = function (x) { return '"' + x + '"'; }; - var name = (data.app.label || data.app.fqdn || data.app.location) + ' (' + data.app.manifest.title + ')'; if ('accessRestriction' in data) { // since it can be null - return 'Access restriction of ' + name + ' was changed'; + return 'Access restriction of ' + appName(app) + ' was changed'; } else if (data.label) { - return 'Label of ' + name + ' was set to ' + q(data.label); + return 'Label of ' + appName(app) + ' was set to ' + q(data.label); } else if (data.tags) { - return 'Tags of ' + name + ' was set to ' + q(data.tags.join(',')); + return 'Tags of ' + appName(app) + ' was set to ' + q(data.tags.join(',')); } else if (data.icon) { - return 'Icon of ' + name + ' was changed'; + return 'Icon of ' + appName(app) + ' was changed'; } else if (data.memoryLimit) { - return 'Memory limit of ' + name + ' was set to ' + data.memoryLimit; + return 'Memory limit of ' + appName(app) + ' was set to ' + data.memoryLimit; } else if (data.env) { - return 'Env vars of ' + name + ' was changed'; + return 'Env vars of ' + appName(app) + ' was changed'; } else if ('debugMode' in data) { // since it can be null if (data.debugMode) { - return name + ' was placed in repair mode'; + return appName(app) + ' was placed in repair mode'; } else { - return name + ' was taken out of repair mode'; + return appName(app) + ' was taken out of repair mode'; } } else if ('enableBackup' in data) { - return 'Automatic backups of ' + name + ' was ' + (data.enableBackup ? 'enabled' : 'disabled'); + return 'Automatic backups of ' + appName(app) + ' was ' + (data.enableBackup ? 'enabled' : 'disabled'); } else if ('enableAutomaticUpdate' in data) { - return 'Automatic updates of ' + name + ' was ' + (data.enableAutomaticUpdate ? 'enabled' : 'disabled'); + return 'Automatic updates of ' + appName(app) + ' was ' + (data.enableAutomaticUpdate ? 'enabled' : 'disabled'); } else if ('reverseProxyConfig' in data) { - return 'Reverse proxy configuration of ' + name + ' was updated'; + return 'Reverse proxy configuration of ' + appName(app) + ' was updated'; } else if ('cert' in data) { if (data.cert) { - return 'Custom certificate was set for ' + name; + return 'Custom certificate was set for ' + appName(app); } else { - return 'Certificate of ' + name + ' was reset'; + return 'Certificate of ' + appName(app) + ' was reset'; } } else if (data.location) { if (data.fqdn !== data.app.fqdn) { - return 'Location of ' + name + ' was changed to ' + data.fqdn; + return 'Location of ' + appName(app) + ' was changed to ' + data.fqdn; } else if (!angular.equals(data.alternateDomains, data.app.alternateDomains)) { var altFqdns = data.alternateDomains.map(function (a) { return a.fqdn; }); - return 'Alternate domains of ' + name + ' was ' + (altFqdns.length ? 'set to ' + altFqdns.join(', ') : 'reset'); + return 'Alternate domains of ' + appName(app) + ' was ' + (altFqdns.length ? 'set to ' + altFqdns.join(', ') : 'reset'); } else if (!angular.equals(data.portBindings, data.app.portBindings)) { - return 'Port bindings of ' + name + ' was changed'; + return 'Port bindings of ' + appName(app) + ' was changed'; } } else if ('dataDir' in data) { if (data.dataDir) { - return 'Data directory of ' + name + ' was set ' + data.dataDir; + return 'Data directory of ' + appName(app) + ' was set ' + data.dataDir; } else { - return 'Data directory of ' + name + ' was reset'; + return 'Data directory of ' + appName(app) + ' was reset'; } } else if ('icon' in data) { if (data.icon) { - return 'Icon of ' + name + ' was set'; + return 'Icon of ' + appName(app) + ' was set'; } else { - return 'Icon of ' + name + ' was reset'; + return 'Icon of ' + appName(app) + ' was reset'; } } else if (('mailboxName' in data) && data.mailboxName !== data.app.mailboxName) { if (data.mailboxName) { - return 'Mailbox of ' + name + ' was set to ' + q(data.mailboxName); + return 'Mailbox of ' + appName(app) + ' was set to ' + q(data.mailboxName); } else { - return 'Mailbox of ' + name + ' was reset'; + return 'Mailbox of ' + appName(app) + ' was reset'; } } - return data.app.manifest.title + ' was re-configured at ' + (data.app.fqdn || data.app.location); + return appName(app) + ' was re-configured'; + } case ACTION_APP_INSTALL: if (!data.app) return ''; @@ -241,24 +252,37 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca return data.newApp.manifest.title + ' at ' + (data.newApp.fqdn || data.newApp.location) + ' was cloned from ' + (data.oldApp.fqdn || data.oldApp.location) + ' using backup ' + data.backupId + ' with v' + data.oldApp.manifest.version; case ACTION_APP_REPAIR: - return 'App at ' + data.app.fqdn + ' was repaired'; + return 'App ' + appName(data.app) + ' was repaired'; - case ACTION_APP_LOGIN: - var app = Client.getCachedAppSync(data.appId); + case ACTION_APP_LOGIN: { + app = Client.getCachedAppSync(data.appId); if (!app) return ''; return 'App ' + app.fqdn + ' logged in'; + } case ACTION_APP_OOM: if (!data.app) return ''; - return data.app.manifest.title + ' ran out of memory'; + return appName(data.app) + ' ran out of memory'; case ACTION_APP_DOWN: if (!data.app) return ''; - return data.app.manifest.title + ' is down'; + return appName(data.app) + ' is down'; case ACTION_APP_UP: if (!data.app) return ''; - return data.app.manifest.title + ' is back online'; + return appName(data.app) + ' is back online'; + + case ACTION_APP_START: + if (!data.app) return ''; + return appName(data.app) + ' was started'; + + case ACTION_APP_STOP: + if (!data.app) return ''; + return appName(data.app) + ' was stopped'; + + case ACTION_APP_RESTART: + if (!data.app) return ''; + return appName(data.app) + ' was restarted'; case ACTION_BACKUP_START: return 'Backup started';