Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Lift Docker status mappers into the page model
rcourtman9332397b7c8b
diff --git a/frontend-modern/src/features/docker/DockerContainersTable.tsx b/frontend-modern/src/features/docker/DockerContainersTable.tsxindex cc8eb748a2..45cf30a640 100644--- a/frontend-modern/src/features/docker/DockerContainersTable.tsx+++ b/frontend-modern/src/features/docker/DockerContainersTable.tsx@@ -1,4 +1,4 @@-import { For, Show, type Component } from 'solid-js';+import { For, Show, createMemo, type Component } from 'solid-js';import { TableCard } from '@/components/shared/TableCard';import { TableCardHeader } from '@/components/shared/TableCardHeader';import {@@ -31,6 +31,7 @@ import {dockerTextValue,type DockerNativeTableProps,} from './DockerNativeTableShared';+import { compareDockerContainers, mapDockerContainerStatus } from './dockerPageModel';import type { Resource } from '@/types/resource';type DockerPort = NonNullable<NonNullable<Resource['docker']>['ports']>[number];@@ -195,6 +196,7 @@ export const DockerContainersTable: Component<DockerNativeTableProps> = (props)initialStatus: 'all' as PlatformResourceStatusFilter,filter: filterDockerContainerResources,});+ const sortedRows = createMemo(() => [...tableState.filtered()].sort(compareDockerContainers));return (<Show@@ -287,8 +289,9 @@ export const DockerContainersTable: Component<DockerNativeTableProps> = (props)</TableRow></TableHeader><TableBody class={PLATFORM_TABLE_BODY_CLASS}>- <For each={tableState.filtered()}>+ <For each={sortedRows()}>{(resource) => {+ const indicator = mapDockerContainerStatus(resource);const image = () => dockerTextValue(resource.docker?.image);const state = () => containerState(resource);const health = () => dockerTextValue(resource.docker?.health);@@ -305,7 +308,7 @@ export const DockerContainersTable: Component<DockerNativeTableProps> = (props)class="text-[11px] sm:text-xs"data-docker-container-row={resource.id}>- <DockerResourceNameCell resource={resource} />+ <DockerResourceNameCell resource={resource} indicator={indicator} /><TableCellclass={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}>diff --git a/frontend-modern/src/features/docker/DockerNativeTableShared.tsx b/frontend-modern/src/features/docker/DockerNativeTableShared.tsxindex bc1ce0a646..8531787fa9 100644--- a/frontend-modern/src/features/docker/DockerNativeTableShared.tsx+++ b/frontend-modern/src/features/docker/DockerNativeTableShared.tsx@@ -2,7 +2,7 @@ import { type Component, type JSX } from 'solid-js';import { StatusDot } from '@/components/shared/StatusDot';import { TableCell } from '@/components/shared/Table';import { formatBytes } from '@/utils/format';-import { getSimpleStatusIndicator } from '@/utils/status';+import { getSimpleStatusIndicator, type StatusIndicator } from '@/utils/status';import { asTrimmedString } from '@/utils/stringUtils';import { getPlatformTableCellClassForKind } from '@/features/platformPage/sharedPlatformPage';import type { Resource } from '@/types/resource';@@ -55,8 +55,15 @@ export const dockerHostName = (resource: Resource): string =>const dockerResourceName = (resource: Resource): string =>asTrimmedString(resource.name) || asTrimmedString(resource.displayName) || resource.id;-export const DockerResourceNameCell: Component<{ resource: Resource }> = (props) => {- const indicator = () => getSimpleStatusIndicator(props.resource.status);+export const DockerResourceNameCell: Component<{+ resource: Resource;+ // When set, the row pulls its StatusDot variant and tooltip text from a+ // domain-specific mapper (mapDockerContainerStatus, mapDockerTaskStatus,+ // etc.) rather than from the generic resource.status triad.+ indicator?: StatusIndicator;+}> = (props) => {+ const resolvedIndicator = (): StatusIndicator =>+ props.indicator ?? getSimpleStatusIndicator(props.resource.status);const name = () => dockerResourceName(props.resource);return (@@ -64,8 +71,8 @@ export const DockerResourceNameCell: Component<{ resource: Resource }> = (props)<div class="flex min-w-0 items-center gap-2"><StatusDotsize="sm"- variant={indicator().variant}- title={props.resource.status || 'unknown'}+ variant={resolvedIndicator().variant}+ title={resolvedIndicator().label}ariaHidden/><span class="truncate font-semibold text-base-content" title={name()}>diff --git a/frontend-modern/src/features/docker/DockerServicesTable.tsx b/frontend-modern/src/features/docker/DockerServicesTable.tsxindex 2be66097f0..ec735b0bcd 100644--- a/frontend-modern/src/features/docker/DockerServicesTable.tsx+++ b/frontend-modern/src/features/docker/DockerServicesTable.tsx@@ -1,4 +1,4 @@-import { For, Show, type Component, type JSX } from 'solid-js';+import { For, Show, createMemo, type Component, type JSX } from 'solid-js';import { StatusDot } from '@/components/shared/StatusDot';import { TableCard } from '@/components/shared/TableCard';import { TableCardHeader } from '@/components/shared/TableCardHeader';@@ -10,7 +10,6 @@ import {TableHeader,TableRow,} from '@/components/shared/Table';-import { getSimpleStatusIndicator } from '@/utils/status';import { asTrimmedString } from '@/utils/stringUtils';import {PLATFORM_TABLE_BODY_CLASS,@@ -26,6 +25,7 @@ import {type PlatformResourceStatusFilter,} from '@/features/platformPage/sharedPlatformPage';import type { Resource } from '@/types/resource';+import { compareDockerServices, mapDockerServiceStatus } from './dockerPageModel';// Docker Swarm services are cluster-scoped declarations, not running// processes — they have no CPU / Memory / Disk / Disk I/O / Uptime /@@ -92,6 +92,7 @@ export const DockerServicesTable: Component<{initialStatus: 'all' as PlatformResourceStatusFilter,filter: filterPlatformResources,});+ const sortedRows = createMemo(() => [...tableState.filtered()].sort(compareDockerServices));const hasFilteredSourceRows = () => (props.sourceCount ?? props.resources.length) > 0;@@ -189,13 +190,13 @@ export const DockerServicesTable: Component<{</TableRow></TableHeader><TableBody class={PLATFORM_TABLE_BODY_CLASS}>- <For each={tableState.filtered()}>+ <For each={sortedRows()}>{(service) => {const name = () => asTrimmedString(service.name) || service.id;const image = () => asTrimmedString(service.docker?.image) || '—';const mode = () => asTrimmedString(service.docker?.mode) || '—';const host = () => asTrimmedString(service.docker?.hostname) || '—';- const indicator = () => getSimpleStatusIndicator(service.status);+ const indicator = () => mapDockerServiceStatus(service);const update = () => formatServiceUpdate(service.docker?.serviceUpdate);return (<TableRow class="text-[11px] sm:text-xs" data-docker-service-row={service.id}>@@ -204,7 +205,7 @@ export const DockerServicesTable: Component<{<StatusDotsize="sm"variant={indicator().variant}- title={service.status || 'unknown'}+ title={indicator().label}ariaHidden/><span class="truncate font-semibold text-base-content" title={name()}>diff --git a/frontend-modern/src/features/docker/DockerSwarmNodesTable.tsx b/frontend-modern/src/features/docker/DockerSwarmNodesTable.tsxindex 8410a41130..11e0b1bd56 100644--- a/frontend-modern/src/features/docker/DockerSwarmNodesTable.tsx+++ b/frontend-modern/src/features/docker/DockerSwarmNodesTable.tsx@@ -1,4 +1,4 @@-import { For, Show, type Component } from 'solid-js';+import { For, Show, createMemo, type Component } from 'solid-js';import { TableCard } from '@/components/shared/TableCard';import { TableCardHeader } from '@/components/shared/TableCardHeader';import {@@ -29,6 +29,7 @@ import {dockerTextValue,type DockerNativeTableProps,} from './DockerNativeTableShared';+import { compareDockerSwarmNodes, mapDockerSwarmNodeStatus } from './dockerPageModel';export const DockerSwarmNodesTable: Component<DockerNativeTableProps> = (props) => {const tableState = createPlatformTableFilterState({@@ -36,6 +37,7 @@ export const DockerSwarmNodesTable: Component<DockerNativeTableProps> = (props)initialStatus: 'all' as PlatformResourceStatusFilter,filter: filterPlatformResources,});+ const sortedRows = createMemo(() => [...tableState.filtered()].sort(compareDockerSwarmNodes));return (<Show@@ -115,7 +117,7 @@ export const DockerSwarmNodesTable: Component<DockerNativeTableProps> = (props)</TableRow></TableHeader><TableBody class={PLATFORM_TABLE_BODY_CLASS}>- <For each={tableState.filtered()}>+ <For each={sortedRows()}>{(resource) => {const managerReachability = () =>dockerTextValue(@@ -127,7 +129,10 @@ export const DockerSwarmNodesTable: Component<DockerNativeTableProps> = (props)class="text-[11px] sm:text-xs"data-docker-swarm-node-row={resource.id}>- <DockerResourceNameCell resource={resource} />+ <DockerResourceNameCell+ resource={resource}+ indicator={mapDockerSwarmNodeStatus(resource)}+ /><TableCellclass={`${getPlatformTableCellClassForKind('text')} text-base-content`}>diff --git a/frontend-modern/src/features/docker/DockerTasksTable.tsx b/frontend-modern/src/features/docker/DockerTasksTable.tsxindex 9ec58b3591..7ff2dcf76a 100644--- a/frontend-modern/src/features/docker/DockerTasksTable.tsx+++ b/frontend-modern/src/features/docker/DockerTasksTable.tsx@@ -1,4 +1,4 @@-import { For, Show, type Component } from 'solid-js';+import { For, Show, createMemo, type Component } from 'solid-js';import { TableCard } from '@/components/shared/TableCard';import { TableCardHeader } from '@/components/shared/TableCardHeader';import {@@ -28,6 +28,7 @@ import {dockerTextValue,type DockerNativeTableProps,} from './DockerNativeTableShared';+import { compareDockerTasks, mapDockerTaskStatus } from './dockerPageModel';export const DockerTasksTable: Component<DockerNativeTableProps> = (props) => {const tableState = createPlatformTableFilterState({@@ -35,6 +36,7 @@ export const DockerTasksTable: Component<DockerNativeTableProps> = (props) => {initialStatus: 'all' as PlatformResourceStatusFilter,filter: filterPlatformResources,});+ const sortedRows = createMemo(() => [...tableState.filtered()].sort(compareDockerTasks));return (<Show@@ -109,10 +111,13 @@ export const DockerTasksTable: Component<DockerNativeTableProps> = (props) => {</TableRow></TableHeader><TableBody class={PLATFORM_TABLE_BODY_CLASS}>- <For each={tableState.filtered()}>+ <For each={sortedRows()}>{(resource) => (<TableRow class="text-[11px] sm:text-xs" data-docker-task-row={resource.id}>- <DockerResourceNameCell resource={resource} />+ <DockerResourceNameCell+ resource={resource}+ indicator={mapDockerTaskStatus(resource)}+ /><TableCellclass={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}>diff --git a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsxindex f282b13cd5..5bb5884401 100644--- a/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx+++ b/frontend-modern/src/features/docker/__tests__/DockerNativeTables.test.tsx@@ -96,6 +96,49 @@ describe('Docker native tables', () => {expect(screen.getByText('Available')).toBeInTheDocument();});+ it('renders container rows with status mapped from containerState + health + exitCode, attention rows first', () => {+ render(() => (+ <DockerContainersTable+ resources={[+ makeResource({+ id: 'happy',+ type: 'app-container',+ docker: { containerState: 'running', health: 'healthy' },+ }),+ makeResource({+ id: 'dead',+ type: 'app-container',+ docker: { containerState: 'dead' },+ }),+ makeResource({+ id: 'restart',+ type: 'app-container',+ docker: { containerState: 'restarting' },+ }),+ makeResource({+ id: 'exited',+ type: 'app-container',+ docker: { containerState: 'exited', exitCode: 137 },+ }),+ ]}+ emptyIcon={<span />}+ emptyTitle="No containers"+ emptyDescription="No containers"+ showToolbar={false}+ />+ ));++ const rows = Array.from(+ document.querySelectorAll('[data-docker-container-row]'),+ ).map((row) => row.getAttribute('data-docker-container-row'));+ // Two danger rows tied -> name-sorted; then warning; then success.+ expect(rows).toEqual(['dead', 'exited', 'restart', 'happy']);+ expect(screen.getByTitle('Dead')).toHaveClass('bg-red-500');+ expect(screen.getByTitle('Exited (137)')).toHaveClass('bg-red-500');+ expect(screen.getByTitle('Restarting')).toHaveClass('bg-amber-500');+ expect(screen.getByTitle('Healthy')).toHaveClass('bg-emerald-500');+ });+it('renders Docker image API fields', () => {render(() => (<DockerImagesTablediff --git a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.tsindex 5b532d913a..95b4f37bb2 100644--- a/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts+++ b/frontend-modern/src/features/docker/__tests__/dockerPageModel.test.ts@@ -4,11 +4,19 @@ import type { Resource } from '@/types/resource';import {DOCKER_TAB_SPECS,buildDockerPageModel,+ compareDockerContainers,+ compareDockerServices,+ compareDockerSwarmNodes,+ compareDockerTasks,getDockerHostSystemBadge,getDockerPageTabSpecs,hasDockerEngineStorageUsage,hasDockerSwarmEvidence,hasDockerSwarmInventory,+ mapDockerContainerStatus,+ mapDockerServiceStatus,+ mapDockerSwarmNodeStatus,+ mapDockerTaskStatus,resolveDockerPageTabId,} from '../dockerPageModel';@@ -269,4 +277,358 @@ describe('dockerPageModel', () => {),).toBe(true);});++ describe('mapDockerContainerStatus', () => {+ it('escalates dead, OOMKilled, and unhealthy containers to danger', () => {+ expect(+ mapDockerContainerStatus(+ makeResource({ id: 'c-dead', type: 'app-container', docker: { containerState: 'dead' } }),+ ).variant,+ ).toBe('danger');+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-oom',+ type: 'app-container',+ docker: { containerState: 'oomkilled' },+ }),+ ),+ ).toEqual({ variant: 'danger', label: 'OOMKilled' });+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-unhealthy',+ type: 'app-container',+ docker: { containerState: 'running', health: 'unhealthy' },+ }),+ ),+ ).toEqual({ variant: 'danger', label: 'Unhealthy' });+ });++ it('flags exited containers with non-zero exit codes as danger', () => {+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-exit-1',+ type: 'app-container',+ docker: { containerState: 'exited', exitCode: 137 },+ }),+ ),+ ).toEqual({ variant: 'danger', label: 'Exited (137)' });+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-exit-0',+ type: 'app-container',+ docker: { containerState: 'exited', exitCode: 0 },+ }),+ ),+ ).toEqual({ variant: 'muted', label: 'Exited' });+ });++ it('treats restarting and health=starting as warning', () => {+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-restart',+ type: 'app-container',+ docker: { containerState: 'restarting' },+ }),+ ).variant,+ ).toBe('warning');+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-starting',+ type: 'app-container',+ docker: { containerState: 'running', health: 'starting' },+ }),+ ).variant,+ ).toBe('warning');+ });++ it('returns success for healthy running containers', () => {+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-ok',+ type: 'app-container',+ docker: { containerState: 'running', health: 'healthy' },+ }),+ ),+ ).toEqual({ variant: 'success', label: 'Healthy' });+ expect(+ mapDockerContainerStatus(+ makeResource({+ id: 'c-no-health',+ type: 'app-container',+ docker: { containerState: 'running' },+ }),+ ),+ ).toEqual({ variant: 'success', label: 'Running' });+ });+ });++ describe('mapDockerServiceStatus', () => {+ it('classifies services by running vs desired tasks', () => {+ expect(+ mapDockerServiceStatus(+ makeResource({+ id: 'svc-ok',+ type: 'docker-service',+ docker: { desiredTasks: 3, runningTasks: 3 },+ }),+ ).variant,+ ).toBe('success');+ expect(+ mapDockerServiceStatus(+ makeResource({+ id: 'svc-partial',+ type: 'docker-service',+ docker: { desiredTasks: 3, runningTasks: 1 },+ }),+ ),+ ).toEqual({ variant: 'warning', label: '1 / 3 running' });+ expect(+ mapDockerServiceStatus(+ makeResource({+ id: 'svc-zero',+ type: 'docker-service',+ docker: { desiredTasks: 3, runningTasks: 0 },+ }),+ ),+ ).toEqual({ variant: 'danger', label: '0 / 3 running' });+ expect(+ mapDockerServiceStatus(+ makeResource({+ id: 'svc-scaled',+ type: 'docker-service',+ docker: { desiredTasks: 0, runningTasks: 0 },+ }),+ ).variant,+ ).toBe('muted');+ });++ it('flags paused rollbacks as warning even when replicas match', () => {+ expect(+ mapDockerServiceStatus(+ makeResource({+ id: 'svc-rollback',+ type: 'docker-service',+ docker: {+ desiredTasks: 3,+ runningTasks: 3,+ serviceUpdate: { state: 'paused' },+ },+ }),+ ),+ ).toEqual({ variant: 'warning', label: 'Rollback paused' });+ });+ });++ describe('mapDockerTaskStatus', () => {+ it('classifies tasks by current state', () => {+ expect(+ mapDockerTaskStatus(+ makeResource({ id: 't-run', type: 'docker-task', docker: { currentState: 'running' } }),+ ).variant,+ ).toBe('success');+ expect(+ mapDockerTaskStatus(+ makeResource({ id: 't-fail', type: 'docker-task', docker: { currentState: 'failed' } }),+ ).variant,+ ).toBe('danger');+ expect(+ mapDockerTaskStatus(+ makeResource({+ id: 't-prep',+ type: 'docker-task',+ docker: { currentState: 'preparing' },+ }),+ ).variant,+ ).toBe('warning');+ expect(+ mapDockerTaskStatus(+ makeResource({+ id: 't-shutdown',+ type: 'docker-task',+ docker: { currentState: 'shutdown', desiredState: 'shutdown' },+ }),+ ).variant,+ ).toBe('muted');+ });+ });++ describe('mapDockerSwarmNodeStatus', () => {+ it('flags unreachable managers as danger', () => {+ expect(+ mapDockerSwarmNodeStatus(+ makeResource({+ id: 'n-mgr-down',+ type: 'docker-swarm-node',+ docker: { nodeRole: 'manager', managerReachability: 'unreachable' },+ }),+ ),+ ).toEqual({ variant: 'danger', label: 'Manager unreachable' });+ });++ it('treats drain as warning and pause as muted', () => {+ expect(+ mapDockerSwarmNodeStatus(+ makeResource({+ id: 'n-drain',+ type: 'docker-swarm-node',+ docker: { availability: 'drain' },+ }),+ ).variant,+ ).toBe('warning');+ expect(+ mapDockerSwarmNodeStatus(+ makeResource({+ id: 'n-pause',+ type: 'docker-swarm-node',+ docker: { availability: 'pause' },+ }),+ ).variant,+ ).toBe('muted');+ });++ it('marks leader nodes with a Leader label', () => {+ expect(+ mapDockerSwarmNodeStatus(+ makeResource({+ id: 'n-leader',+ type: 'docker-swarm-node',+ status: 'online',+ docker: { availability: 'active', leader: true },+ }),+ ),+ ).toEqual({ variant: 'success', label: 'Leader' });+ });+ });++ describe('rank comparators float attention rows above healthy rows', () => {+ it('orders containers danger → warning → muted → success', () => {+ const healthy = makeResource({+ id: 'happy',+ type: 'app-container',+ docker: { containerState: 'running', health: 'healthy' },+ });+ const restarting = makeResource({+ id: 'restarting',+ type: 'app-container',+ docker: { containerState: 'restarting' },+ });+ const dead = makeResource({+ id: 'dead',+ type: 'app-container',+ docker: { containerState: 'dead' },+ });+ const stopped = makeResource({+ id: 'stopped',+ type: 'app-container',+ docker: { containerState: 'exited', exitCode: 0 },+ });+ expect(+ [healthy, restarting, dead, stopped].sort(compareDockerContainers).map((r) => r.id),+ ).toEqual(['dead', 'restarting', 'stopped', 'happy']);+ });++ it('orders Swarm services by replica health', () => {+ const ok = makeResource({+ id: 'svc-ok',+ type: 'docker-service',+ docker: { desiredTasks: 2, runningTasks: 2 },+ });+ const partial = makeResource({+ id: 'svc-partial',+ type: 'docker-service',+ docker: { desiredTasks: 2, runningTasks: 1 },+ });+ const down = makeResource({+ id: 'svc-down',+ type: 'docker-service',+ docker: { desiredTasks: 2, runningTasks: 0 },+ });+ expect([ok, partial, down].sort(compareDockerServices).map((r) => r.id)).toEqual([+ 'svc-down',+ 'svc-partial',+ 'svc-ok',+ ]);+ });++ it('orders tasks failed → preparing → running', () => {+ const run = makeResource({+ id: 't-run',+ type: 'docker-task',+ docker: { currentState: 'running' },+ });+ const prep = makeResource({+ id: 't-prep',+ type: 'docker-task',+ docker: { currentState: 'preparing' },+ });+ const fail = makeResource({+ id: 't-fail',+ type: 'docker-task',+ docker: { currentState: 'failed' },+ });+ expect([run, prep, fail].sort(compareDockerTasks).map((r) => r.id)).toEqual([+ 't-fail',+ 't-prep',+ 't-run',+ ]);+ });++ it('orders Swarm nodes by manager reachability and availability', () => {+ const ok = makeResource({+ id: 'n-ok',+ type: 'docker-swarm-node',+ status: 'online',+ docker: { availability: 'active', managerReachability: 'reachable' },+ });+ const drain = makeResource({+ id: 'n-drain',+ type: 'docker-swarm-node',+ status: 'online',+ docker: { availability: 'drain' },+ });+ const down = makeResource({+ id: 'n-mgr-down',+ type: 'docker-swarm-node',+ docker: { nodeRole: 'manager', managerReachability: 'unreachable' },+ });+ expect([ok, drain, down].sort(compareDockerSwarmNodes).map((r) => r.id)).toEqual([+ 'n-mgr-down',+ 'n-drain',+ 'n-ok',+ ]);+ });++ it('emits pre-sorted buckets from buildDockerPageModel', () => {+ const happy = makeResource({+ id: 'c-happy',+ type: 'app-container',+ docker: { containerState: 'running' },+ });+ const dead = makeResource({+ id: 'c-dead',+ type: 'app-container',+ docker: { containerState: 'dead' },+ });+ const svcOk = makeResource({+ id: 'svc-ok',+ type: 'docker-service',+ docker: { desiredTasks: 2, runningTasks: 2 },+ });+ const svcDown = makeResource({+ id: 'svc-down',+ type: 'docker-service',+ docker: { desiredTasks: 2, runningTasks: 0 },+ });+ const model = buildDockerPageModel([happy, dead, svcOk, svcDown]);+ expect(model.containers.map((r) => r.id)).toEqual(['c-dead', 'c-happy']);+ expect(model.services.map((r) => r.id)).toEqual(['svc-down', 'svc-ok']);+ });+ });});diff --git a/frontend-modern/src/features/docker/dockerPageModel.ts b/frontend-modern/src/features/docker/dockerPageModel.tsindex 5012a58d83..5af41a5dd6 100644--- a/frontend-modern/src/features/docker/dockerPageModel.ts+++ b/frontend-modern/src/features/docker/dockerPageModel.ts@@ -1,5 +1,6 @@import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';import type { DockerStorageUsageMeta, Resource, ResourceType } from '@/types/resource';+import type { StatusIndicator, StatusIndicatorVariant } from '@/utils/status';import {getInfrastructureSystemIdentityBadges,type ResourceBadge,@@ -65,6 +66,149 @@ export const resolveDockerPageTabId = (segment: string | undefined): DockerPageTconst isDockerPlatform = (resource: Resource): boolean =>resolveResourcePlatformType(resource) === 'docker';+// `containerState` reasons that mean the container will not stay up on its+// own. Distinct from `exited` with exit code 0, which is just a stopped+// container, and from `restarting`, which is in-flight.+const FATAL_CONTAINER_STATES = new Set([+ 'dead',+ 'removing',+ 'oomkilled',+]);++// Container states that read as deliberately stopped rather than as a+// problem. Pulse should surface these as muted, not as success or danger.+const STOPPED_CONTAINER_STATES = new Set([+ 'created',+ 'paused',+ 'stopped',+ 'exited',+]);++const normalizeDockerToken = (value: unknown): string =>+ typeof value === 'string' ? value.trim().toLowerCase().replace(/[\s_-]/g, '') : '';++const dockerDisplayName = (resource: Resource): string =>+ asTrimmedString(resource.displayName) ||+ asTrimmedString(resource.name) ||+ asTrimmedString(resource.docker?.serviceName) ||+ asTrimmedString(resource.docker?.nodeName) ||+ resource.id;++export function mapDockerContainerStatus(resource: Resource): StatusIndicator {+ const state = normalizeDockerToken(resource.docker?.containerState || resource.status);+ const health = normalizeDockerToken(resource.docker?.health);+ const exitCode = resource.docker?.exitCode;++ if (FATAL_CONTAINER_STATES.has(state)) {+ return { variant: 'danger', label: state === 'oomkilled' ? 'OOMKilled' : titleCase(state) };+ }+ if (health === 'unhealthy') return { variant: 'danger', label: 'Unhealthy' };+ if (state === 'exited' && typeof exitCode === 'number' && exitCode !== 0) {+ return { variant: 'danger', label: `Exited (${exitCode})` };+ }+ if (state === 'restarting') return { variant: 'warning', label: 'Restarting' };+ if (state === 'running' && health === 'starting') {+ return { variant: 'warning', label: 'Starting' };+ }+ if (state === 'running') {+ return { variant: 'success', label: health === 'healthy' ? 'Healthy' : 'Running' };+ }+ if (STOPPED_CONTAINER_STATES.has(state)) {+ return { variant: 'muted', label: titleCase(state) };+ }+ if (!state) return { variant: 'muted', label: 'Unknown' };+ return { variant: 'muted', label: titleCase(state) };+}++export function mapDockerServiceStatus(resource: Resource): StatusIndicator {+ const desired = resource.docker?.desiredTasks ?? 0;+ const running = resource.docker?.runningTasks ?? 0;+ const updateState = normalizeDockerToken(resource.docker?.serviceUpdate?.state);+ if (updateState === 'paused' || updateState === 'rollbackstarted') {+ return { variant: 'warning', label: 'Rollback paused' };+ }+ if (desired <= 0) return { variant: 'muted', label: 'Scaled to 0' };+ if (running >= desired) return { variant: 'success', label: 'Healthy' };+ if (running <= 0) return { variant: 'danger', label: `0 / ${desired} running` };+ return { variant: 'warning', label: `${running} / ${desired} running` };+}++export function mapDockerTaskStatus(resource: Resource): StatusIndicator {+ const current = normalizeDockerToken(resource.docker?.currentState);+ const desired = normalizeDockerToken(resource.docker?.desiredState);+ if (current === 'failed' || current === 'rejected' || current === 'orphaned') {+ return { variant: 'danger', label: titleCase(current) };+ }+ if (current === 'running') return { variant: 'success', label: 'Running' };+ if (current === 'complete') return { variant: 'success', label: 'Complete' };+ if (current === 'shutdown' && desired === 'shutdown') {+ return { variant: 'muted', label: 'Shutdown' };+ }+ if (+ current === 'preparing' ||+ current === 'starting' ||+ current === 'pending' ||+ current === 'assigned' ||+ current === 'accepted' ||+ current === 'ready'+ ) {+ return { variant: 'warning', label: titleCase(current) };+ }+ if (!current) return { variant: 'muted', label: 'Unknown' };+ return { variant: 'muted', label: titleCase(current) };+}++export function mapDockerSwarmNodeStatus(resource: Resource): StatusIndicator {+ const availability = normalizeDockerToken(resource.docker?.availability);+ const reachability = normalizeDockerToken(resource.docker?.managerReachability);+ const role = normalizeDockerToken(resource.docker?.nodeRole);+ const status = normalizeDockerToken(resource.status);++ if (role === 'manager' && reachability === 'unreachable') {+ return { variant: 'danger', label: 'Manager unreachable' };+ }+ if (status === 'offline' || status === 'stopped' || status === 'failed') {+ return { variant: 'danger', label: 'Down' };+ }+ if (availability === 'drain') return { variant: 'warning', label: 'Drained' };+ if (availability === 'pause') return { variant: 'muted', label: 'Paused' };+ if (status === 'degraded' || status === 'warning') {+ return { variant: 'warning', label: 'Degraded' };+ }+ if (availability === 'active' || status === 'online' || status === 'running') {+ return { variant: 'success', label: resource.docker?.leader ? 'Leader' : 'Ready' };+ }+ return { variant: 'muted', label: 'Unknown' };+}++const titleCase = (value: string): string =>+ value ? value.charAt(0).toUpperCase() + value.slice(1) : '';++// Attention-first ordering: rows that need an operator's eye float to the+// top of the table. Tie-broken by display name for stable rendering.+const STATUS_VARIANT_RANK: Record<StatusIndicatorVariant, number> = {+ danger: 0,+ warning: 1,+ muted: 2,+ success: 3,+};++const compareByDockerStatus = (+ mapper: (resource: Resource) => StatusIndicator,+): ((left: Resource, right: Resource) => number) => {+ return (left, right) => {+ const rankDelta =+ STATUS_VARIANT_RANK[mapper(left).variant] - STATUS_VARIANT_RANK[mapper(right).variant];+ if (rankDelta !== 0) return rankDelta;+ return dockerDisplayName(left).localeCompare(dockerDisplayName(right));+ };+};++export const compareDockerContainers = compareByDockerStatus(mapDockerContainerStatus);+export const compareDockerServices = compareByDockerStatus(mapDockerServiceStatus);+export const compareDockerTasks = compareByDockerStatus(mapDockerTaskStatus);+export const compareDockerSwarmNodes = compareByDockerStatus(mapDockerSwarmNodeStatus);+export function hasDockerSwarmEvidence(resource: Resource): boolean {const swarm = resource.docker?.swarm;if (!swarm) return false;@@ -154,15 +298,21 @@ export function buildDockerPageModel(resources: Resource[]): DockerPageModel {const hosts = dockerResources.filter((resource) => DOCKER_HOST_TYPES.has(resource.type) && isDockerPlatform(resource),);- const containers = dockerResources.filter(- (resource) => DOCKER_CONTAINER_TYPES.has(resource.type) && isDockerPlatform(resource),- );- const services = dockerResources.filter((resource) => DOCKER_SERVICE_TYPES.has(resource.type));+ const containers = dockerResources+ .filter((resource) => DOCKER_CONTAINER_TYPES.has(resource.type) && isDockerPlatform(resource))+ .sort(compareDockerContainers);+ const services = dockerResources+ .filter((resource) => DOCKER_SERVICE_TYPES.has(resource.type))+ .sort(compareDockerServices);const images = dockerResources.filter((resource) => DOCKER_IMAGE_TYPES.has(resource.type));const volumes = dockerResources.filter((resource) => DOCKER_VOLUME_TYPES.has(resource.type));const networks = dockerResources.filter((resource) => DOCKER_NETWORK_TYPES.has(resource.type));- const nodes = dockerResources.filter((resource) => DOCKER_SWARM_NODE_TYPES.has(resource.type));- const tasks = dockerResources.filter((resource) => DOCKER_TASK_TYPES.has(resource.type));+ const nodes = dockerResources+ .filter((resource) => DOCKER_SWARM_NODE_TYPES.has(resource.type))+ .sort(compareDockerSwarmNodes);+ const tasks = dockerResources+ .filter((resource) => DOCKER_TASK_TYPES.has(resource.type))+ .sort(compareDockerTasks);const secrets = dockerResources.filter((resource) => DOCKER_SECRET_TYPES.has(resource.type));const configs = dockerResources.filter((resource) => DOCKER_CONFIG_TYPES.has(resource.type));