Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
import type { FilterOption } from '#lib/components/arcane-table/index.js';
import type { IconType } from '#lib/icons/index.js';
import {
ClockIcon,
ContainersIcon,
EnvironmentsIcon,
EventsIcon,
GitBranchIcon,
GlobeIcon,
ImagesIcon,
NetworksIcon,
NotificationsIcon,
ProjectsIcon,
SettingsIcon,
UserIcon,
VolumesIcon
} from '#lib/icons/index.js';
import { m } from '#lib/paraglide/messages.js';
export type EventBadgeVariant = 'blue' | 'green' | 'amber' | 'red';
export function eventSeverityVariant(severity: string): EventBadgeVariant {
switch (severity) {
case 'success':
return 'green';
case 'error':
return 'red';
case 'warning':
return 'amber';
case 'info':
default:
return 'blue';
}
}
export function eventSeverityLabel(severity: string): string {
switch (severity) {
case 'success':
return m.common_success();
case 'error':
return m.common_error();
case 'warning':
return m.warning();
case 'info':
default:
return m.info();
}
}
export function eventSeverityIconVariant(severity: string): 'emerald' | 'red' | 'amber' | 'blue' {
switch (eventSeverityVariant(severity)) {
case 'green':
return 'emerald';
case 'red':
return 'red';
case 'amber':
return 'amber';
default:
return 'blue';
}
}
function eventTypeCategory(type: string): string {
return type.split('.')[0] ?? '';
}
const categoryLabels: Record<string, () => string> = {
container: m.container,
image: m.common_image,
project: m.project,
git: m.git,
volume: m.resource_volume_cap,
network: m.resource_network_cap,
environment: m.resource_environment_cap,
user: m.common_user,
system: m.system,
webhook: m.events_category_webhook,
notification: m.events_category_notification,
lifecycle: m.lifecycle
};
function eventTypeCategoryLabel(category: string): string {
return categoryLabels[category]?.() ?? humanize(category);
}
const categoryIcons: Record<string, IconType> = {
container: ContainersIcon,
image: ImagesIcon,
project: ProjectsIcon,
git: GitBranchIcon,
volume: VolumesIcon,
network: NetworksIcon,
environment: EnvironmentsIcon,
user: UserIcon,
system: SettingsIcon,
webhook: GlobeIcon,
notification: NotificationsIcon,
lifecycle: ClockIcon
};
export function eventTypeIcon(type: string): IconType {
return categoryIcons[eventTypeCategory(type)] ?? EventsIcon;
}
const actionLabels: Record<string, () => string> = {
start: m.common_started,
stop: m.common_stopped,
restart: m.events_action_restart,
kill: m.events_action_kill,
pause: m.paused,
unpause: m.events_action_unpause,
die: m.containers_status_exited,
oom: m.events_action_oom,
rename: m.events_action_rename,
unhealthy: m.events_action_unhealthy,
create: m.common_created,
delete: m.events_action_delete,
update: m.common_updated,
deploy: m.events_action_deploy,
pull: m.events_action_pull,
tag: m.events_action_tag,
untag: m.images_untagged,
load: m.events_action_load,
import: m.events_action_import,
scan: m.events_action_scan,
error: m.common_error,
login: m.events_action_login,
logout: m.common_logout,
send: m.events_action_send,
execute: m.events_action_execute,
run: m.webhook_action_type_run,
prune: m.events_action_prune
};
function humanize(value: string): string {
const words = value.replace(/[._]/g, ' ').trim();
return words ? words.charAt(0).toUpperCase() + words.slice(1) : value;
}
export function eventTypeLabel(type: string): string {
const [category, ...rest] = type.split('.');
const tail = rest.join('.');
if (!category || !tail) {
return humanize(type);
}
const action = actionLabels[tail]?.() ?? humanize(tail);
return `${eventTypeCategoryLabel(category)} · ${action}`;
}
export const eventTypeFilters: FilterOption[] = Object.keys(categoryLabels).map((category) => ({
value: category,
label: eventTypeCategoryLabel(category),
icon: categoryIcons[category]
}));