diff --git a/dashboard/src/components/app/Eventlog.vue b/dashboard/src/components/app/Eventlog.vue index d2f193106..889c5b0bd 100644 --- a/dashboard/src/components/app/Eventlog.vue +++ b/dashboard/src/components/app/Eventlog.vue @@ -2,27 +2,28 @@ import EventlogList from '../EventlogList.vue'; import AppsModel from '../../models/AppsModel.js'; +import { EVENTS } from '../../constants.js'; const appsModel = AppsModel.create(); const props = defineProps([ 'app' ]); const availableActions = [ - { id: 'app.backup', label: 'Backup started' }, - { id: 'app.backup.finish', label: 'Backup finished' }, - { id: 'app.configure', label: 'Reconfigured' }, - { id: 'app.install', label: 'Installed' }, - { id: 'app.restore', label: 'Restored' }, - { id: 'app.uninstall', label: 'Uninstalled' }, - { id: 'app.update', label: 'Update started' }, - { id: 'app.update.finish', label: 'Update finished' }, - { id: 'app.login', label: 'Log in' }, - { id: 'app.oom', label: 'Out of memory' }, - { id: 'app.down', label: 'Down' }, - { id: 'app.up', label: 'Up' }, - { id: 'app.start', label: 'Started' }, - { id: 'app.stop', label: 'Stopped' }, - { id: 'app.restart', label: 'Restarted' }, + { id: EVENTS.APP_BACKUP, label: 'Backup started' }, + { id: EVENTS.APP_BACKUP_FINISH, label: 'Backup finished' }, + { id: EVENTS.APP_CONFIGURE, label: 'Reconfigured' }, + { id: EVENTS.APP_INSTALL, label: 'Installed' }, + { id: EVENTS.APP_RESTORE, label: 'Restored' }, + { id: EVENTS.APP_UNINSTALL, label: 'Uninstalled' }, + { id: EVENTS.APP_UPDATE, label: 'Update started' }, + { id: EVENTS.APP_UPDATE_FINISH, label: 'Update finished' }, + { id: EVENTS.APP_LOGIN, label: 'Log in' }, + { id: EVENTS.APP_OOM, label: 'Out of memory' }, + { id: EVENTS.APP_DOWN, label: 'Down' }, + { id: EVENTS.APP_UP, label: 'Up' }, + { id: EVENTS.APP_START, label: 'Started' }, + { id: EVENTS.APP_STOP, label: 'Stopped' }, + { id: EVENTS.APP_RESTART, label: 'Restarted' }, ]; async function fetchPage(filter, page, perPage) { diff --git a/dashboard/src/constants.js b/dashboard/src/constants.js index 4eee09edb..64f734bba 100644 --- a/dashboard/src/constants.js +++ b/dashboard/src/constants.js @@ -338,6 +338,113 @@ const RELAY_PROVIDERS = [ { provider: 'noop', name: 'Disable outgoing email' }, ]; +// keep in sync with src/eventlog.js +const EVENTS = Object.freeze({ + ACTIVATE: 'cloudron.activate', + PROVISION: 'cloudron.provision', + RESTORE: 'cloudron.restore', + START: 'cloudron.start', + UPDATE: 'cloudron.update', + UPDATE_FINISH: 'cloudron.update.finish', + INSTALL_FINISH: 'cloudron.install.finish', + + APP_CLONE: 'app.clone', + APP_CONFIGURE: 'app.configure', + APP_REPAIR: 'app.repair', + APP_INSTALL: 'app.install', + APP_RESTORE: 'app.restore', + APP_IMPORT: 'app.import', + APP_UNINSTALL: 'app.uninstall', + APP_UPDATE: 'app.update', + APP_UPDATE_FINISH: 'app.update.finish', + APP_BACKUP: 'app.backup', + APP_BACKUP_FINISH: 'app.backup.finish', + APP_LOGIN: 'app.login', + APP_OOM: 'app.oom', + APP_UP: 'app.up', + APP_DOWN: 'app.down', + APP_START: 'app.start', + APP_STOP: 'app.stop', + APP_RESTART: 'app.restart', + + ARCHIVES_ADD: 'archives.add', + ARCHIVES_DEL: 'archives.del', + + BACKUP_FINISH: 'backup.finish', + BACKUP_START: 'backup.start', + BACKUP_CLEANUP_START: 'backup.cleanup.start', + BACKUP_CLEANUP_FINISH: 'backup.cleanup.finish', + BACKUP_INTEGRITY_START: 'backup.integrity.start', + BACKUP_INTEGRITY_FINISH: 'backup.integrity.finish', + + BACKUP_SITE_ADD: 'backupsite.add', + BACKUP_SITE_REMOVE: 'backupsite.remove', + BACKUP_SITE_UPDATE: 'backupsite.update', + + BRANDING_NAME: 'branding.name', + BRANDING_FOOTER: 'branding.footer', + BRANDING_AVATAR: 'branding.avatar', + + CERTIFICATE_NEW: 'certificate.new', + CERTIFICATE_RENEWAL: 'certificate.renew', + CERTIFICATE_CLEANUP: 'certificate.cleanup', + + DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update', + + DIRECTORY_SERVER_CONFIGURE: 'directoryserver.configure', + + DOMAIN_ADD: 'domain.add', + DOMAIN_UPDATE: 'domain.update', + DOMAIN_REMOVE: 'domain.remove', + + EXTERNAL_LDAP_CONFIGURE: 'externalldap.configure', + + GROUP_ADD: 'group.add', + GROUP_REMOVE: 'group.remove', + GROUP_UPDATE: 'group.update', + GROUP_MEMBERSHIP: 'group.membership', + + MAIL_LOCATION: 'mail.location', + MAIL_ENABLED: 'mail.enabled', + MAIL_DISABLED: 'mail.disabled', + MAIL_MAILBOX_ADD: 'mail.box.add', + MAIL_MAILBOX_REMOVE: 'mail.box.remove', + MAIL_MAILBOX_UPDATE: 'mail.box.update', + MAIL_LIST_ADD: 'mail.list.add', + MAIL_LIST_REMOVE: 'mail.list.remove', + MAIL_LIST_UPDATE: 'mail.list.update', + + REGISTRY_ADD: 'registry.add', + REGISTRY_UPDATE: 'registry.update', + REGISTRY_DEL: 'registry.del', + + SERVICE_CONFIGURE: 'service.configure', + SERVICE_REBUILD: 'service.rebuild', + SERVICE_RESTART: 'service.restart', + + USER_ADD: 'user.add', + USER_LOGIN: 'user.login', + USER_LOGIN_GHOST: 'user.login.ghost', + USER_LOGOUT: 'user.logout', + USER_REMOVE: 'user.remove', + USER_UPDATE: 'user.update', + USER_TRANSFER: 'user.transfer', + + USER_DIRECTORY_PROFILE_CONFIG_UPDATE: 'userdirectory.profileconfig.update', + + VOLUME_ADD: 'volume.add', + VOLUME_UPDATE: 'volume.update', + VOLUME_REMOUNT: 'volume.remount', + VOLUME_REMOVE: 'volume.remove', + + DYNDNS_UPDATE: 'dyndns.update', + + SUPPORT_TICKET: 'support.ticket', + SUPPORT_SSH: 'support.ssh', + + PROCESS_CRASH: 'system.crash', +}); + // named exports export { API_ORIGIN, @@ -367,6 +474,7 @@ export { REGIONS_HETZNER, REGIONS_WASABI, REGIONS_S3, + EVENTS, RELAY_PROVIDERS, }; @@ -399,5 +507,6 @@ export default { REGIONS_HETZNER, REGIONS_WASABI, REGIONS_S3, + EVENTS, RELAY_PROVIDERS, }; diff --git a/dashboard/src/utils.js b/dashboard/src/utils.js index fcac3a969..d0b1e69d8 100644 --- a/dashboard/src/utils.js +++ b/dashboard/src/utils.js @@ -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: diff --git a/dashboard/src/views/EventlogView.vue b/dashboard/src/views/EventlogView.vue index eb4967a02..041eafa2e 100644 --- a/dashboard/src/views/EventlogView.vue +++ b/dashboard/src/views/EventlogView.vue @@ -3,88 +3,89 @@ import { onMounted, onUnmounted, useTemplateRef } from 'vue'; import EventlogList from '../components/EventlogList.vue'; import EventlogsModel from '../models/EventlogsModel.js'; +import { EVENTS } from '../constants.js'; const eventlogsModel = EventlogsModel.create(); const eventlogList = useTemplateRef('eventlogList'); const availableActions = [ { separator: true, label: 'App' }, - { id: 'app.backup', label: 'Backup started' }, - { id: 'app.backup.finish', label: 'Backup finished' }, - { id: 'app.configure', label: 'Reconfigured' }, - { id: 'app.install', label: 'Installed' }, - { id: 'app.restore', label: 'Restored' }, - { id: 'app.uninstall', label: 'Uninstalled' }, - { id: 'app.update', label: 'Update started' }, - { id: 'app.update.finish', label: 'Update finished' }, - { id: 'app.login', label: 'Log in' }, - { id: 'app.oom', label: 'Out of memory' }, - { id: 'app.down', label: 'Down' }, - { id: 'app.up', label: 'Up' }, - { id: 'app.start', label: 'Started' }, - { id: 'app.stop', label: 'Stopped' }, - { id: 'app.restart', label: 'Restarted' }, + { id: EVENTS.APP_BACKUP, label: 'Backup started' }, + { id: EVENTS.APP_BACKUP_FINISH, label: 'Backup finished' }, + { id: EVENTS.APP_CONFIGURE, label: 'Reconfigured' }, + { id: EVENTS.APP_INSTALL, label: 'Installed' }, + { id: EVENTS.APP_RESTORE, label: 'Restored' }, + { id: EVENTS.APP_UNINSTALL, label: 'Uninstalled' }, + { id: EVENTS.APP_UPDATE, label: 'Update started' }, + { id: EVENTS.APP_UPDATE_FINISH, label: 'Update finished' }, + { id: EVENTS.APP_LOGIN, label: 'Log in' }, + { id: EVENTS.APP_OOM, label: 'Out of memory' }, + { id: EVENTS.APP_DOWN, label: 'Down' }, + { id: EVENTS.APP_UP, label: 'Up' }, + { id: EVENTS.APP_START, label: 'Started' }, + { id: EVENTS.APP_STOP, label: 'Stopped' }, + { id: EVENTS.APP_RESTART, label: 'Restarted' }, { separator: true, label: 'Platform backup' }, - { id: 'backup.cleanup', label: 'Cleanup started' }, - { id: 'backup.cleanup.finish', label: 'Cleanup finished' }, - { id: 'backup.start', label: 'Started' }, - { id: 'backup.finish', label: 'Finished' }, - { id: 'backup.integrity.start', label: 'Integrity check started' }, - { id: 'backup.integrity.finish', label: 'Integrity check finished' }, - { id: 'backuptarget.add', label: 'Site added' }, - { id: 'backuptarget.remove', label: 'Site removed' }, + { id: EVENTS.BACKUP_CLEANUP_START, label: 'Cleanup started' }, + { id: EVENTS.BACKUP_CLEANUP_FINISH, label: 'Cleanup finished' }, + { id: EVENTS.BACKUP_START, label: 'Started' }, + { id: EVENTS.BACKUP_FINISH, label: 'Finished' }, + { id: EVENTS.BACKUP_INTEGRITY_START, label: 'Integrity check started' }, + { id: EVENTS.BACKUP_INTEGRITY_FINISH, label: 'Integrity check finished' }, + { id: EVENTS.BACKUP_SITE_ADD, label: 'Site added' }, + { id: EVENTS.BACKUP_SITE_REMOVE, label: 'Site removed' }, { separator: true, label: 'Certificates' }, - { id: 'certificate.new', label: 'Obtained' }, - { id: 'certificate.renew', label: 'Renewed' }, - { id: 'certificate.cleanup', label: 'Cleaned up' }, + { id: EVENTS.CERTIFICATE_NEW, label: 'Obtained' }, + { id: EVENTS.CERTIFICATE_RENEWAL, label: 'Renewed' }, + { id: EVENTS.CERTIFICATE_CLEANUP, label: 'Cleaned up' }, { separator: true, label: 'Domains' }, - { id: 'domain.add', label: 'Added' }, - { id: 'domain.update', label: 'Updated' }, - { id: 'domain.remove', label: 'Removed' }, + { id: EVENTS.DOMAIN_ADD, label: 'Added' }, + { id: EVENTS.DOMAIN_UPDATE, label: 'Updated' }, + { id: EVENTS.DOMAIN_REMOVE, label: 'Removed' }, { separator: true, label: 'Email' }, - { id: 'mail.location', label: 'Location changed' }, - { id: 'mail.enabled', label: 'Enabled/Disabled' }, - { id: 'mail.box.add', label: 'Mailbox added' }, - { id: 'mail.box.update', label: 'Mailbox updated' }, - { id: 'mail.box.remove', label: 'Mailbox removed' }, - { id: 'mail.list.add', label: 'Mailinglist added' }, - { id: 'mail.list.update', label: 'Mailinglist updated' }, - { id: 'mail.list.remove', label: 'Mailinglist removed' }, + { id: EVENTS.MAIL_LOCATION, label: 'Location changed' }, + { id: EVENTS.MAIL_ENABLED, label: 'Enabled/Disabled' }, + { id: EVENTS.MAIL_MAILBOX_ADD, label: 'Mailbox added' }, + { id: EVENTS.MAIL_MAILBOX_UPDATE, label: 'Mailbox updated' }, + { id: EVENTS.MAIL_MAILBOX_REMOVE, label: 'Mailbox removed' }, + { id: EVENTS.MAIL_LIST_ADD, label: 'Mailinglist added' }, + { id: EVENTS.MAIL_LIST_UPDATE, label: 'Mailinglist updated' }, + { id: EVENTS.MAIL_LIST_REMOVE, label: 'Mailinglist removed' }, { separator: true, label: 'Services' }, - { id: 'service.configure', label: 'Configured' }, - { id: 'service.rebuild', label: 'Rebuilt' }, - { id: 'service.restart', label: 'Restarted' }, + { id: EVENTS.SERVICE_CONFIGURE, label: 'Configured' }, + { id: EVENTS.SERVICE_REBUILD, label: 'Rebuilt' }, + { id: EVENTS.SERVICE_RESTART, label: 'Restarted' }, { separator: true, label: 'Users' }, - { id: 'user.add', label: 'Added' }, - { id: 'user.update', label: 'Updated' }, - { id: 'user.remove', label: 'Removed' }, - { id: 'user.login', label: 'Logged in' }, - { id: 'user.login.ghost', label: 'Ghost logged in' }, - { id: 'user.logout', label: 'Logged out' }, + { id: EVENTS.USER_ADD, label: 'Added' }, + { id: EVENTS.USER_UPDATE, label: 'Updated' }, + { id: EVENTS.USER_REMOVE, label: 'Removed' }, + { id: EVENTS.USER_LOGIN, label: 'Logged in' }, + { id: EVENTS.USER_LOGIN_GHOST, label: 'Ghost logged in' }, + { id: EVENTS.USER_LOGOUT, label: 'Logged out' }, { separator: true, label: 'Groups' }, - { id: 'group.add', label: 'Added' }, - { id: 'group.update', label: 'Updated' }, - { id: 'group.remove', label: 'Removed' }, + { id: EVENTS.GROUP_ADD, label: 'Added' }, + { id: EVENTS.GROUP_UPDATE, label: 'Updated' }, + { id: EVENTS.GROUP_REMOVE, label: 'Removed' }, { separator: true, label: 'Volumes' }, - { id: 'volume.add', label: 'Added' }, - { id: 'volume.update', label: 'Updated' }, - { id: 'volume.remove', label: 'Removed' }, + { id: EVENTS.VOLUME_ADD, label: 'Added' }, + { id: EVENTS.VOLUME_UPDATE, label: 'Updated' }, + { id: EVENTS.VOLUME_REMOVE, label: 'Removed' }, { separator: true, label: 'Branding' }, - { id: 'branding.avatar', label: 'Avatar changed' }, - { id: 'branding.footer', label: 'Footer changed' }, - { id: 'branding.name', label: 'Name started' }, + { id: EVENTS.BRANDING_AVATAR, label: 'Avatar changed' }, + { id: EVENTS.BRANDING_FOOTER, label: 'Footer changed' }, + { id: EVENTS.BRANDING_NAME, label: 'Name started' }, { separator: true, label: 'Cloudron' }, - { id: 'cloudron.activate', label: 'Activated' }, - { id: 'cloudron.provision', label: 'Provisioned' }, - { id: 'cloudron.restore', label: 'Restored' }, - { id: 'cloudron.start', label: 'Started' }, - { id: 'cloudron.update', label: 'Update started' }, - { id: 'cloudron.update.finish', label: 'Update finished' }, - { id: 'dashboard.domain.update', label: 'Dashboard domain updated' }, - { id: 'dyndns.update', label: 'DynDNS changed' }, - { id: 'directoryserver.configure', label: 'LDAP configured ' }, - { id: 'externalldap.configure', label: 'External LDAP configured' }, - { id: 'userdirectory.profileconfig.update', label: 'Profile config changed' }, + { id: EVENTS.ACTIVATE, label: 'Activated' }, + { id: EVENTS.PROVISION, label: 'Provisioned' }, + { id: EVENTS.RESTORE, label: 'Restored' }, + { id: EVENTS.START, label: 'Started' }, + { id: EVENTS.UPDATE, label: 'Update started' }, + { id: EVENTS.UPDATE_FINISH, label: 'Update finished' }, + { id: EVENTS.DASHBOARD_DOMAIN_UPDATE, label: 'Dashboard domain updated' }, + { id: EVENTS.DYNDNS_UPDATE, label: 'DynDNS changed' }, + { id: EVENTS.DIRECTORY_SERVER_CONFIGURE, label: 'LDAP configured ' }, + { id: EVENTS.EXTERNAL_LDAP_CONFIGURE, label: 'External LDAP configured' }, + { id: EVENTS.USER_DIRECTORY_PROFILE_CONFIG_UPDATE, label: 'Profile config changed' }, ]; async function fetchPage(filter, page, perPage) {