Add EVENTS to constants

This commit is contained in:
Girish Ramakrishnan
2026-02-17 15:30:44 +01:00
parent 9949ea364a
commit 2fe31b876f
4 changed files with 274 additions and 264 deletions

View File

@@ -1,6 +1,6 @@
import { prettyBinarySize } from '@cloudron/pankow/utils';
import { RELAY_PROVIDERS, ISTATES, STORAGE_PROVIDERS } from './constants.js';
import { RELAY_PROVIDERS, ISTATES, STORAGE_PROVIDERS, EVENTS } from './constants.js';
import { Marked } from 'marked';
function safeMarked() {
@@ -89,107 +89,6 @@ function prettySiteLocation(site) {
}
function eventlogDetails(eventLog, app = null, appIdContext = '') {
const ACTION_ACTIVATE = 'cloudron.activate';
const ACTION_PROVISION = 'cloudron.provision';
const ACTION_RESTORE = 'cloudron.restore';
const ACTION_APP_CLONE = 'app.clone';
const ACTION_APP_REPAIR = 'app.repair';
const ACTION_APP_CONFIGURE = 'app.configure';
const ACTION_APP_INSTALL = 'app.install';
const ACTION_APP_RESTORE = 'app.restore';
const ACTION_APP_IMPORT = 'app.import';
const ACTION_APP_UNINSTALL = 'app.uninstall';
const ACTION_APP_UPDATE = 'app.update';
const ACTION_APP_UPDATE_FINISH = 'app.update.finish';
const ACTION_APP_BACKUP = 'app.backup';
const ACTION_APP_BACKUP_FINISH = 'app.backup.finish';
const ACTION_APP_LOGIN = 'app.login';
const ACTION_APP_OOM = 'app.oom';
const ACTION_APP_UP = 'app.up';
const ACTION_APP_DOWN = 'app.down';
const ACTION_APP_START = 'app.start';
const ACTION_APP_STOP = 'app.stop';
const ACTION_APP_RESTART = 'app.restart';
const ACTION_ARCHIVES_ADD = 'archives.add';
const ACTION_ARCHIVES_DEL = 'archives.del';
const ACTION_BACKUP_FINISH = 'backup.finish';
const ACTION_BACKUP_START = 'backup.start';
const ACTION_BACKUP_CLEANUP_START = 'backup.cleanup.start';
const ACTION_BACKUP_CLEANUP_FINISH = 'backup.cleanup.finish';
const ACTION_BACKUP_INTEGRITY_START = 'backup.integrity.start';
const ACTION_BACKUP_INTEGRITY_FINISH = 'backup.integrity.finish';
const ACTION_BACKUP_SITE_ADD = 'backupsite.add';
const ACTION_BACKUP_SITE_REMOVE = 'backupsite.remove';
const ACTION_BACKUP_SITE_UPDATE = 'backupsite.update';
const ACTION_BRANDING_AVATAR = 'branding.avatar';
const ACTION_BRANDING_NAME = 'branding.name';
const ACTION_BRANDING_FOOTER = 'branding.footer';
const ACTION_CERTIFICATE_NEW = 'certificate.new';
const ACTION_CERTIFICATE_RENEWAL = 'certificate.renew';
const ACTION_CERTIFICATE_CLEANUP = 'certificate.cleanup';
const ACTION_DASHBOARD_DOMAIN_UPDATE = 'dashboard.domain.update';
const ACTION_DIRECTORY_SERVER_CONFIGURE = 'directoryserver.configure';
const ACTION_DOMAIN_ADD = 'domain.add';
const ACTION_DOMAIN_UPDATE = 'domain.update';
const ACTION_DOMAIN_REMOVE = 'domain.remove';
const ACTION_EXTERNAL_LDAP_CONFIGURE = 'externalldap.configure';
const ACTION_GROUP_ADD = 'group.add';
const ACTION_GROUP_UPDATE = 'group.update';
const ACTION_GROUP_REMOVE = 'group.remove';
const ACTION_GROUP_MEMBERSHIP = 'group.membership';
const ACTION_INSTALL_FINISH = 'cloudron.install.finish';
const ACTION_START = 'cloudron.start';
const ACTION_SERVICE_CONFIGURE = 'service.configure';
const ACTION_SERVICE_REBUILD = 'service.rebuild';
const ACTION_SERVICE_RESTART = 'service.restart';
const ACTION_UPDATE = 'cloudron.update';
const ACTION_UPDATE_FINISH = 'cloudron.update.finish';
const ACTION_USER_ADD = 'user.add';
const ACTION_USER_LOGIN = 'user.login';
const ACTION_USER_LOGIN_GHOST = 'user.login.ghost';
const ACTION_USER_LOGOUT = 'user.logout';
const ACTION_USER_REMOVE = 'user.remove';
const ACTION_USER_UPDATE = 'user.update';
const ACTION_USER_TRANSFER = 'user.transfer';
const ACTION_USER_DIRECTORY_PROFILE_CONFIG_UPDATE = 'userdirectory.profileconfig.update';
const ACTION_MAIL_LOCATION = 'mail.location';
const ACTION_MAIL_ENABLED = 'mail.enabled';
const ACTION_MAIL_DISABLED = 'mail.disabled';
const ACTION_MAIL_MAILBOX_ADD = 'mail.box.add';
const ACTION_MAIL_MAILBOX_UPDATE = 'mail.box.update';
const ACTION_MAIL_MAILBOX_REMOVE = 'mail.box.remove';
const ACTION_MAIL_LIST_ADD = 'mail.list.add';
const ACTION_MAIL_LIST_UPDATE = 'mail.list.update';
const ACTION_MAIL_LIST_REMOVE = 'mail.list.remove';
const ACTION_REGISTRY_ADD = 'registry.add';
const ACTION_REGISTRY_UPDATE ='registry.update';
const ACTION_REGISTRY_DEL = 'registry.del';
const ACTION_SUPPORT_TICKET = 'support.ticket';
const ACTION_SUPPORT_SSH = 'support.ssh';
const ACTION_VOLUME_ADD = 'volume.add';
const ACTION_VOLUME_UPDATE = 'volume.update';
const ACTION_VOLUME_REMOVE = 'volume.remove';
const ACTION_DYNDNS_UPDATE = 'dyndns.update';
const data = eventLog.data;
const errorMessage = data.errorMessage;
let details;
@@ -203,16 +102,16 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
}
switch (eventLog.action) {
case ACTION_ACTIVATE:
case EVENTS.ACTIVATE:
return 'Cloudron was activated';
case ACTION_PROVISION:
case EVENTS.PROVISION:
return 'Cloudron was setup';
case ACTION_RESTORE:
case EVENTS.RESTORE:
return 'Cloudron was restored using backup at ' + data.remotePath;
case ACTION_APP_CONFIGURE: {
case EVENTS.APP_CONFIGURE: {
if (!data.app) return '';
app = data.app;
@@ -274,11 +173,11 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
return appName('', app, 'App ') + 'was re-configured';
}
case ACTION_APP_INSTALL:
case EVENTS.APP_INSTALL:
if (!data.app) return '';
return data.app.manifest.title + ' (package v' + data.app.manifest.version + ') was installed ' + appName('at', data.app);
case ACTION_APP_RESTORE:
case EVENTS.APP_RESTORE:
if (!data.app) return '';
details = appName('', data.app, 'App') + ' was restored';
// older versions (<3.5) did not have these fields
@@ -287,95 +186,95 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
if (data.remotePath) details += ' using backup at ' + data.remotePath;
return details;
case ACTION_APP_IMPORT:
case EVENTS.APP_IMPORT:
if (!data.app) return '';
details = appName('', data.app, 'App') + ' was imported';
if (data.toManifest) details += ' to version ' + data.toManifest.version;
if (data.remotePath) details += ' using backup at ' + data.remotePath;
return details;
case ACTION_APP_UNINSTALL:
case EVENTS.APP_UNINSTALL:
if (!data.app) return '';
return appName('', data.app, 'App') + ' (package v' + data.app.manifest.version + ') was uninstalled';
case ACTION_APP_UPDATE:
case EVENTS.APP_UPDATE:
if (!data.app) return '';
return 'Update ' + appName('of', data.app) + ' started from v' + data.fromManifest.version + ' to v' + data.toManifest.version;
case ACTION_APP_UPDATE_FINISH:
case EVENTS.APP_UPDATE_FINISH:
if (!data.app) return '';
return appName('', data.app, 'App') + ' was updated to v' + data.app.manifest.version;
case ACTION_APP_BACKUP:
case EVENTS.APP_BACKUP:
if (!data.app) return '';
return 'Backup ' + appName('of', data.app) + ' started';
case ACTION_APP_BACKUP_FINISH:
case EVENTS.APP_BACKUP_FINISH:
if (!data.app) return '';
if (errorMessage) return 'Backup ' + appName('of', data.app) + ' failed: ' + errorMessage;
else return 'Backup ' + appName('of', data.app) + ' succeeded';
case ACTION_APP_CLONE:
case EVENTS.APP_CLONE:
if (appIdContext === data.oldAppId) return 'App was cloned to ' + data.newApp.fqdn + ' using backup at ' + data.remotePath;
else if (appIdContext === data.appId) return 'App was cloned from ' + data.oldApp.fqdn + ' using backup at ' + data.remotePath;
else return appName('', data.newApp, 'App') + ' was cloned ' + appName('from', data.oldApp) + ' using backup at ' + data.remotePath;
case ACTION_APP_REPAIR:
case EVENTS.APP_REPAIR:
return appName('', data.app, 'App') + ' was re-configured'; // re-configure of email apps is more common?
case ACTION_APP_LOGIN: {
case EVENTS.APP_LOGIN: {
// const app = getApp(data.appId);
if (!app) return '';
return 'App ' + app.fqdn + ' logged in';
}
case ACTION_APP_OOM:
case EVENTS.APP_OOM:
if (!data.app) return '';
return appName('', data.app, 'App') + ' ran out of memory';
case ACTION_APP_DOWN:
case EVENTS.APP_DOWN:
if (!data.app) return '';
return appName('', data.app, 'App') + ' is down';
case ACTION_APP_UP:
case EVENTS.APP_UP:
if (!data.app) return '';
return appName('', data.app, 'App') + ' is back online';
case ACTION_APP_START:
case EVENTS.APP_START:
if (!data.app) return '';
return appName('', data.app, 'App') + ' was started';
case ACTION_APP_STOP:
case EVENTS.APP_STOP:
if (!data.app) return '';
return appName('', data.app, 'App') + ' was stopped';
case ACTION_APP_RESTART:
case EVENTS.APP_RESTART:
if (!data.app) return '';
return appName('', data.app, 'App') + ' was restarted';
case ACTION_ARCHIVES_ADD:
case EVENTS.ARCHIVES_ADD:
return 'Backup ' + data.backupId + ' added to archive';
case ACTION_ARCHIVES_DEL:
case EVENTS.ARCHIVES_DEL:
return 'Backup ' + data.backupId + ' deleted from archive';
case ACTION_BACKUP_START:
case EVENTS.BACKUP_START:
return `Backup started at site ${data.siteName}`;
case ACTION_BACKUP_FINISH:
case EVENTS.BACKUP_FINISH:
if (!errorMessage) return `Cloudron backup created at site ${data.siteName}`;
else return `Cloudron backup at site ${data.siteName} errored with error: ${errorMessage}`;
case ACTION_BACKUP_CLEANUP_START:
case EVENTS.BACKUP_CLEANUP_START:
return 'Backup cleaner started';
case ACTION_BACKUP_CLEANUP_FINISH:
case EVENTS.BACKUP_CLEANUP_FINISH:
return errorMessage ? 'Backup cleaner errored: ' + errorMessage : 'Backup cleaner removed ' + (data.removedBoxBackupPaths ? data.removedBoxBackupPaths.length : '0') + ' backup(s)';
case ACTION_BACKUP_SITE_ADD:
case EVENTS.BACKUP_SITE_ADD:
return `New backup site ${data.name} added with provider ${data.provider} and format ${data.format}`;
case ACTION_BACKUP_SITE_UPDATE:
case EVENTS.BACKUP_SITE_UPDATE:
if (data.schedule) {
return `Backup site ${data.name} schedule was updated to ${data.schedule}`;
} else if (data.limits) {
@@ -394,140 +293,140 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
return `Backup site ${data.name} was updated`;
}
case ACTION_BACKUP_SITE_REMOVE:
case EVENTS.BACKUP_SITE_REMOVE:
return `Backup site ${data.name} removed`;
case ACTION_BACKUP_INTEGRITY_START:
case EVENTS.BACKUP_INTEGRITY_START:
return `Backup integrity check started for ${data.backupId}`;
case ACTION_BACKUP_INTEGRITY_FINISH:
case EVENTS.BACKUP_INTEGRITY_FINISH:
if (!errorMessage) return `Backup integrity check of ${data.backupId} ${data.status}`;
else return `Backup integrity check of ${data.backupId} errored: ${errorMessage}`;
case ACTION_BRANDING_AVATAR:
case EVENTS.BRANDING_AVATAR:
return 'Cloudron Avatar Changed';
case ACTION_BRANDING_NAME:
case EVENTS.BRANDING_NAME:
return 'Cloudron Name set to ' + data.name;
case ACTION_BRANDING_FOOTER:
case EVENTS.BRANDING_FOOTER:
return 'Cloudron Footer set to ' + data.footer;
case ACTION_CERTIFICATE_NEW:
case EVENTS.CERTIFICATE_NEW:
details = 'Certificate installation for ' + data.domain + (errorMessage ? ' failed' : ' succeeded');
if (data.renewalInfo) details += `. Recommended renewal time is between ${data.renewalInfo.start} and ${data.renewalInfo.end}`;
return details;
case ACTION_CERTIFICATE_RENEWAL:
case EVENTS.CERTIFICATE_RENEWAL:
return 'Certificate renewal for ' + data.domain + (errorMessage ? ' failed' : ' succeeded');
case ACTION_CERTIFICATE_CLEANUP:
case EVENTS.CERTIFICATE_CLEANUP:
return 'Certificate(s) of ' + data.domains.join(',') + ' was cleaned up since they expired 6 months ago';
case ACTION_DASHBOARD_DOMAIN_UPDATE:
case EVENTS.DASHBOARD_DOMAIN_UPDATE:
return 'Dashboard domain set to ' + data.fqdn || (data.subdomain + '.' + data.domain);
case ACTION_DIRECTORY_SERVER_CONFIGURE:
case EVENTS.DIRECTORY_SERVER_CONFIGURE:
if (data.fromEnabled !== data.toEnabled) return 'Directory server was ' + (data.toEnabled ? 'enabled' : 'disabled');
else return 'Directory server configuration was changed';
case ACTION_DOMAIN_ADD:
case EVENTS.DOMAIN_ADD:
return 'Domain ' + data.domain + ' with ' + data.provider + ' provider was added';
case ACTION_DOMAIN_UPDATE:
case EVENTS.DOMAIN_UPDATE:
return 'Domain ' + data.domain + ' with ' + data.provider + ' provider was updated';
case ACTION_DOMAIN_REMOVE:
case EVENTS.DOMAIN_REMOVE:
return 'Domain ' + data.domain + ' was removed';
case ACTION_EXTERNAL_LDAP_CONFIGURE:
case EVENTS.EXTERNAL_LDAP_CONFIGURE:
if (data.config.provider === 'noop') return 'External Directory disabled';
else return 'External Directory set to ' + data.config.url + ' (' + data.config.provider + ')';
case ACTION_GROUP_ADD:
case EVENTS.GROUP_ADD:
return 'Group ' + data.name + ' was added';
case ACTION_GROUP_UPDATE:
case EVENTS.GROUP_UPDATE:
return 'Group name changed from ' + data.oldName + ' to ' + data.group.name;
case ACTION_GROUP_REMOVE:
case EVENTS.GROUP_REMOVE:
return 'Group ' + data.group.name + ' was removed';
case ACTION_GROUP_MEMBERSHIP:
case EVENTS.GROUP_MEMBERSHIP:
return 'Group membership of ' + data.group.name + ' changed. Now was ' + data.userIds.length + ' member(s).';
case ACTION_INSTALL_FINISH:
case EVENTS.INSTALL_FINISH:
return 'Cloudron version ' + data.version + ' installed';
case ACTION_MAIL_LOCATION:
case EVENTS.MAIL_LOCATION:
return 'Mail server location was changed to ' + data.subdomain + (data.subdomain ? '.' : '') + data.domain;
case ACTION_MAIL_ENABLED:
case EVENTS.MAIL_ENABLED:
return 'Mail was enabled for domain ' + data.domain;
case ACTION_MAIL_DISABLED:
case EVENTS.MAIL_DISABLED:
return 'Mail was disabled for domain ' + data.domain;
case ACTION_MAIL_MAILBOX_ADD:
case EVENTS.MAIL_MAILBOX_ADD:
return 'Mailbox ' + data.name + '@' + data.domain + ' was added';
case ACTION_MAIL_MAILBOX_UPDATE:
case EVENTS.MAIL_MAILBOX_UPDATE:
if (data.aliases) return 'Mailbox aliases of ' + data.name + '@' + data.domain + ' was updated';
else return 'Mailbox ' + data.name + '@' + data.domain + ' was updated';
case ACTION_MAIL_MAILBOX_REMOVE:
case EVENTS.MAIL_MAILBOX_REMOVE:
return 'Mailbox ' + data.name + '@' + data.domain + ' was removed';
case ACTION_MAIL_LIST_ADD:
case EVENTS.MAIL_LIST_ADD:
return 'Mail list ' + data.name + '@' + data.domain + 'was added';
case ACTION_MAIL_LIST_UPDATE:
case EVENTS.MAIL_LIST_UPDATE:
return 'Mail list ' + data.name + '@' + data.domain + ' was updated';
case ACTION_MAIL_LIST_REMOVE:
case EVENTS.MAIL_LIST_REMOVE:
return 'Mail list ' + data.name + '@' + data.domain + ' was removed';
case ACTION_REGISTRY_ADD:
case EVENTS.REGISTRY_ADD:
return 'Docker registry ' + data.registry.provider + '@' + data.registry.serverAddress + ' was added';
case ACTION_REGISTRY_UPDATE:
case EVENTS.REGISTRY_UPDATE:
return 'Docker registry updated to ' + data.newRegistry.provider + '@' + data.newRegistry.serverAddress;
case ACTION_REGISTRY_DEL:
case EVENTS.REGISTRY_DEL:
return 'Docker registry ' + data.registry.provider + '@' + data.registry.serverAddress + ' was removed';
case ACTION_START:
case EVENTS.START:
return 'Cloudron started with version ' + data.version;
case ACTION_SERVICE_CONFIGURE:
case EVENTS.SERVICE_CONFIGURE:
return 'Service ' + data.id + ' was configured';
case ACTION_SERVICE_REBUILD:
case EVENTS.SERVICE_REBUILD:
return 'Service ' + data.id + ' was rebuilt';
case ACTION_SERVICE_RESTART:
case EVENTS.SERVICE_RESTART:
return 'Service ' + data.id + ' was restarted';
case ACTION_UPDATE:
case EVENTS.UPDATE:
return 'Cloudron update to version ' + data.boxUpdateInfo.version + ' was started';
case ACTION_UPDATE_FINISH:
case EVENTS.UPDATE_FINISH:
if (errorMessage) return 'Cloudron update errored. Error: ' + errorMessage;
else return 'Cloudron updated to version ' + data.newVersion;
case ACTION_USER_ADD:
case EVENTS.USER_ADD:
return 'User ' + data.email + (data.user.username ? ' (' + data.user.username + ')' : '') + ' was added';
case ACTION_USER_UPDATE:
case EVENTS.USER_UPDATE:
return 'User ' + (data.user ? (data.user.email + (data.user.username ? ' (' + data.user.username + ')' : '')) : data.userId) + ' was updated';
case ACTION_USER_REMOVE:
case EVENTS.USER_REMOVE:
return 'User ' + (data.user ? (data.user.email + (data.user.username ? ' (' + data.user.username + ')' : '')) : data.userId) + ' was removed';
case ACTION_USER_TRANSFER:
case EVENTS.USER_TRANSFER:
return 'Apps of ' + data.oldOwnerId + ' was transferred to ' + data.newOwnerId;
case ACTION_USER_LOGIN:
case EVENTS.USER_LOGIN:
if (data.mailboxId) {
return 'User ' + (data.user ? data.user.username : data.userId) + ' logged in to mailbox ' + data.mailboxId;
} else if (data.appId) {
@@ -537,16 +436,16 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
return 'User ' + (data.user ? data.user.username : data.userId) + ' authenticated';
}
case ACTION_USER_LOGIN_GHOST:
case EVENTS.USER_LOGIN_GHOST:
return 'User ' + (data.user ? data.user.username : data.userId) + ' was impersonated';
case ACTION_USER_LOGOUT:
case EVENTS.USER_LOGOUT:
return 'User ' + (data.user ? data.user.username : data.userId) + ' logged out';
case ACTION_USER_DIRECTORY_PROFILE_CONFIG_UPDATE:
case EVENTS.USER_DIRECTORY_PROFILE_CONFIG_UPDATE:
return 'User directory profile config updated. Mandatory 2FA: ' + (data.config.mandatory2FA) + ' Lock profiles: ' + (data.config.lockUserProfiles);
case ACTION_DYNDNS_UPDATE: {
case EVENTS.DYNDNS_UPDATE: {
details = errorMessage ? 'Error updating DNS. ' : 'Updated DNS. ';
if (data.fromIpv4 !== data.toIpv4) details += 'From IPv4 ' + data.fromIpv4 + ' to ' + data.toIpv4 + '. ';
if (data.fromIpv6 !== data.toIpv6) details += 'From IPv6 ' + data.fromIpv6 + ' to ' + data.toIpv6 + '.';
@@ -554,19 +453,19 @@ function eventlogDetails(eventLog, app = null, appIdContext = '') {
return details;
}
case ACTION_SUPPORT_SSH:
case EVENTS.SUPPORT_SSH:
return 'Remote Support was ' + (data.enable ? 'enabled' : 'disabled');
case ACTION_SUPPORT_TICKET:
case EVENTS.SUPPORT_TICKET:
return 'Support ticket was created';
case ACTION_VOLUME_ADD:
case EVENTS.VOLUME_ADD:
return 'Volume "' + (data.volume || data).name + '" was added';
case ACTION_VOLUME_UPDATE:
case EVENTS.VOLUME_UPDATE:
return 'Volme "' + (data.volume || data).name + '" was updated';
case ACTION_VOLUME_REMOVE:
case EVENTS.VOLUME_REMOVE:
return 'Volume "' + (data.volume || data).name + '" was removed';
default: