Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Collapse Proxmox backups surface to a guest-centric coverage view

rcourtmancfa9283c9876
diff --git a/frontend-modern/src/features/proxmox/BackupActivityChart.tsx b/frontend-modern/src/features/proxmox/BackupActivityChart.tsx
deleted file mode 100644
index b59d10a3a9..0000000000
--- a/frontend-modern/src/features/proxmox/BackupActivityChart.tsx
+++ /dev/null
@@ -1,371 +0,0 @@
-import { createSignal, For, Show } from 'solid-js';
-import type { Accessor, Component } from 'solid-js';
-
-import { TooltipPortal } from '@/components/shared/TooltipPortal';
-import {
- SUMMARY_CHART_PLOT_AREA_CLASS,
- SUMMARY_CHART_SLOT_COMPACT_CLASS,
-} from '@/components/shared/summaryChartLayout';
-import {
- getRecoveryCompactAxisLabel,
- getRecoveryPrettyDateLabel,
-} from '@/utils/recoveryDatePresentation';
-import {
- getRecoveryTimelineAxisLabelClass,
- getRecoveryTimelineAxisTicks,
- getRecoveryTimelineChartGapPx,
- getRecoveryTimelineChartMinWidthPx,
- RECOVERY_TIMELINE_LEGEND_ITEM_CLASS,
-} from '@/utils/recoveryTimelineChartPresentation';
-import {
- getRecoveryTimelineBarMarkerClass,
- getRecoveryTimelineColumnButtonClass,
- getRecoveryTimelineEmptyMarkerClass,
-} from '@/utils/recoveryTimelinePresentation';
-
-import {
- BACKUP_ACTIVITY_RANGE_DAYS,
- getBackupActivityAxisLabel,
- getBackupActivityColumnAriaLabel,
- getBackupActivityDayFilterStateLabel,
- getBackupActivityPointTotalLabel,
- getBackupActivitySegmentPresentation,
- getBackupActivityTooltipRows,
- type BackupActivityMetricMode,
- type BackupActivityNoun,
- type BackupActivityPoint,
- type BackupActivityRangeDays,
- type BackupActivitySegmentKind,
- type BackupActivityTimeline,
-} from './proxmoxBackupActivityPresentation';
-
-interface TooltipState {
- dateLabel: string;
- point: BackupActivityPoint;
- x: number;
- y: number;
-}
-
-export interface BackupActivityChartMetricToggle {
- mode: Accessor<BackupActivityMetricMode>;
- onChange: (mode: BackupActivityMetricMode) => void;
-}
-
-interface BackupActivityChartProps {
- title: string;
- noun: BackupActivityNoun;
- segmentKinds: readonly BackupActivitySegmentKind[];
- range: Accessor<BackupActivityRangeDays>;
- onRangeChange: (days: BackupActivityRangeDays) => void;
- timeline: Accessor<BackupActivityTimeline>;
- selectedDateKey: Accessor<string | null>;
- onToggleDay: (key: string) => void;
- metricMode?: Accessor<BackupActivityMetricMode>;
- metricToggle?: BackupActivityChartMetricToggle;
-}
-
-export const BackupActivityChart: Component<BackupActivityChartProps> = (props) => {
- const [tooltip, setTooltip] = createSignal<TooltipState | null>(null);
-
- const points = () => props.timeline().points;
- const axisMax = () => props.timeline().axisMax;
- const hasSelection = () => props.selectedDateKey() !== null;
- const metricMode = (): BackupActivityMetricMode =>
- props.metricMode?.() ?? props.metricToggle?.mode() ?? 'count';
-
- const axisTicks = () =>
- getRecoveryTimelineAxisTicks(points().length, false, props.timeline().labelEvery);
-
- const chartMinWidthStyle = () => {
- const minWidth = getRecoveryTimelineChartMinWidthPx(false, props.range(), points().length);
- return minWidth > 0 ? `${minWidth}px` : '100%';
- };
-
- const chartGapStyle = () => `${getRecoveryTimelineChartGapPx(props.range())}px`;
-
- const showTooltip = (target: HTMLElement, point: BackupActivityPoint, dateLabel: string) => {
- const rect = target.getBoundingClientRect();
- setTooltip({
- dateLabel,
- point,
- x: rect.left + rect.width / 2,
- y: rect.top,
- });
- };
- const hideTooltip = () => setTooltip(null);
-
- return (
- <div class="rounded-lg border border-border-subtle bg-surface-alt/25 px-2 py-2">
- <div class="mb-2 flex flex-col gap-1.5 lg:flex-row lg:items-center lg:justify-between">
- <div class="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted">
- <div class="font-semibold uppercase tracking-[0.18em] text-muted">{props.title}</div>
- <Show when={props.segmentKinds.length > 1}>
- <For each={props.segmentKinds}>
- {(kind) => {
- const presentation = getBackupActivitySegmentPresentation(kind);
- return (
- <span class={RECOVERY_TIMELINE_LEGEND_ITEM_CLASS}>
- <span class={`h-2.5 w-2.5 rounded ${presentation.swatchClassName}`} />
- {presentation.label}
- </span>
- );
- }}
- </For>
- </Show>
- </div>
- <div class="flex flex-wrap items-center gap-2 text-[11px]">
- <Show when={props.metricToggle}>
- <div
- role="group"
- aria-label="Activity metric"
- class="inline-flex shrink-0 rounded border border-border bg-surface p-0.5"
- >
- <For each={['count', 'volume'] as const}>
- {(mode) => {
- const selected = () => props.metricToggle?.mode() === mode;
- return (
- <button
- type="button"
- class={`rounded px-2 py-1 font-medium transition-colors ${
- selected()
- ? 'bg-surface-hover text-base-content'
- : 'text-muted hover:bg-surface-hover hover:text-base-content'
- }`}
- aria-pressed={selected() ? 'true' : 'false'}
- onClick={() => props.metricToggle?.onChange(mode)}
- >
- {mode === 'count' ? 'Count' : 'Volume'}
- </button>
- );
- }}
- </For>
- </div>
- </Show>
- <div
- role="group"
- aria-label="Activity range"
- class="inline-flex shrink-0 rounded border border-border bg-surface p-0.5"
- >
- <For each={BACKUP_ACTIVITY_RANGE_DAYS}>
- {(days) => {
- const selected = () => props.range() === days;
- return (
- <button
- type="button"
- class={`rounded px-2 py-1 font-medium transition-colors ${
- selected()
- ? 'bg-surface-hover text-base-content'
- : 'text-muted hover:bg-surface-hover hover:text-base-content'
- }`}
- aria-pressed={selected() ? 'true' : 'false'}
- onClick={() => props.onRangeChange(days)}
- >
- {days === 365 ? '1y' : `${days}d`}
- </button>
- );
- }}
- </For>
- </div>
- </div>
- </div>
-
- <Show
- when={points().length > 0}
- fallback={
- <div class="flex h-24 items-center justify-center text-xs text-muted">
- No activity in the selected window.
- </div>
- }
- >
- <div class="relative">
- <div class="grid grid-cols-[auto_minmax(0,1fr)] gap-2">
- <div
- class={`flex ${SUMMARY_CHART_PLOT_AREA_CLASS} flex-col justify-between text-[10px] text-muted tabular-nums`}
- >
- <For each={[0, 1, 2]}>
- {(step) => {
- const value = () => (axisMax() * (2 - step)) / 2;
- return <span>{getBackupActivityAxisLabel(value(), metricMode())}</span>;
- }}
- </For>
- </div>
-
- <div class="overflow-x-auto overscroll-x-contain pb-1">
- <div
- class={`relative ${SUMMARY_CHART_SLOT_COMPACT_CLASS}`}
- style={{ 'min-width': chartMinWidthStyle() }}
- >
- <div
- class="absolute inset-x-0 bottom-4 top-0 flex items-stretch"
- style={{ gap: chartGapStyle() }}
- >
- <For each={points()}>
- {(point) => {
- const total = () => point.total;
- const heightPct = () =>
- axisMax() > 0 ? Math.min(100, (total() / axisMax()) * 100) : 0;
- const isSelected = () => props.selectedDateKey() === point.key;
- const dateLabel = getRecoveryPrettyDateLabel(point.key);
-
- return (
- <div class="min-w-[3px] flex-1 self-stretch">
- <button
- type="button"
- class={`h-full w-full ${getRecoveryTimelineColumnButtonClass(
- isSelected(),
- hasSelection(),
- )}`}
- aria-label={getBackupActivityColumnAriaLabel(
- dateLabel,
- total(),
- isSelected(),
- props.noun,
- metricMode(),
- )}
- aria-pressed={isSelected() ? 'true' : 'false'}
- onClick={() => props.onToggleDay(point.key)}
- onMouseEnter={(event) =>
- showTooltip(event.currentTarget, point, dateLabel)
- }
- onMouseLeave={hideTooltip}
- onFocus={(event) => showTooltip(event.currentTarget, point, dateLabel)}
- onBlur={hideTooltip}
- >
- <div class="relative h-full w-full overflow-hidden rounded-sm">
- <Show
- when={total() > 0}
- fallback={
- <div
- class={getRecoveryTimelineEmptyMarkerClass(
- isSelected(),
- hasSelection(),
- )}
- />
- }
- >
- <div
- class={getRecoveryTimelineBarMarkerClass(
- isSelected(),
- hasSelection(),
- )}
- style={{ height: `${heightPct()}%` }}
- >
- <For each={props.segmentKinds}>
- {(kind) => {
- const count = () => point.counts[kind] ?? 0;
- const segmentPct = () =>
- total() > 0 ? (count() / total()) * 100 : 0;
- return (
- <Show when={segmentPct() > 0}>
- <div
- class={`w-full ${getBackupActivitySegmentPresentation(kind).segmentClassName}`}
- style={{ height: `${segmentPct()}%` }}
- />
- </Show>
- );
- }}
- </For>
- </div>
- </Show>
- </div>
- </button>
- </div>
- );
- }}
- </For>
- </div>
-
- <div class="pointer-events-none absolute inset-x-0 bottom-0 h-4">
- <For each={axisTicks()}>
- {(tick) => {
- const point = points()[tick.index];
- const isSelected = () =>
- point ? props.selectedDateKey() === point.key : false;
- const alignmentClass =
- tick.align === 'start'
- ? 'left-0 text-left'
- : tick.align === 'end'
- ? 'left-full -translate-x-full text-right'
- : '-translate-x-1/2 text-center';
- return (
- <Show when={point}>
- <span
- class={`absolute bottom-0 whitespace-nowrap text-[9px] ${getRecoveryTimelineAxisLabelClass(isSelected())} ${alignmentClass}`}
- style={{ left: `${tick.positionPct}%` }}
- >
- {getRecoveryCompactAxisLabel(point!.key, props.range())}
- </span>
- </Show>
- );
- }}
- </For>
- </div>
- </div>
- </div>
- </div>
-
- <TooltipPortal
- when={tooltip() !== null}
- x={tooltip()?.x ?? 0}
- y={tooltip()?.y ?? 0}
- align="center"
- direction="up"
- maxWidth={240}
- >
- <Show when={tooltip()}>
- {(t) => (
- <div class="min-w-[180px]">
- <div class="flex items-start justify-between gap-3 border-b border-border pb-1">
- <div class="min-w-0">
- <div class="truncate text-[11px] font-semibold text-base-content">
- {t().dateLabel}
- </div>
- <div class="mt-0.5 text-[10px] text-muted">
- {getBackupActivityPointTotalLabel(
- t().point.total,
- props.noun,
- metricMode(),
- )}
- </div>
- </div>
- <div class="shrink-0 rounded border border-border bg-surface-alt px-1.5 py-0.5 text-[9px] font-medium text-muted">
- {getBackupActivityDayFilterStateLabel(
- props.selectedDateKey() === t().point.key,
- hasSelection(),
- )}
- </div>
- </div>
- <ul class="mt-1.5 space-y-1">
- <For
- each={getBackupActivityTooltipRows(
- t().point,
- props.segmentKinds,
- metricMode(),
- )}
- >
- {(row) => (
- <li
- class={`flex items-center justify-between gap-4 ${
- row.muted ? 'text-muted/70' : 'text-base-content'
- }`}
- >
- <span class="flex min-w-0 items-center gap-1.5">
- <span class={`h-2 w-2 shrink-0 rounded-sm ${row.segmentClassName}`} />
- <span class="truncate">{row.label}</span>
- </span>
- <span class="shrink-0 font-mono tabular-nums">{row.value}</span>
- </li>
- )}
- </For>
- </ul>
- </div>
- )}
- </Show>
- </TooltipPortal>
- </div>
- </Show>
- </div>
- );
-};
-
-export default BackupActivityChart;
diff --git a/frontend-modern/src/features/proxmox/ProxmoxArchivesTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxArchivesTable.tsx
deleted file mode 100644
index c5906a7de4..0000000000
--- a/frontend-modern/src/features/proxmox/ProxmoxArchivesTable.tsx
+++ /dev/null
@@ -1,273 +0,0 @@
-import { For, Show, type Accessor, type JSX } from 'solid-js';
-
-import { Card } from '@/components/shared/Card';
-import { EmptyState } from '@/components/shared/EmptyState';
-import {
- Table,
- TableBody,
- TableCell,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
-import { TableCard } from '@/components/shared/TableCard';
-import { formatBytes, formatRelativeTime } from '@/utils/format';
-import {
- PLATFORM_TABLE_BODY_CLASS,
- PLATFORM_TABLE_CARD_CLASS,
- PLATFORM_TABLE_HEADER_ROW_CLASS,
- getPlatformTableCellClassForKind,
- getPlatformTableHeadClassForKind,
-} from '@/features/platformPage/sharedPlatformPage';
-import type { StorageBackup } from '@/types/api';
-
-import { classifyArchiveRowAge } from './proxmoxBackupSummaryPresentation';
-import { guestLabel, type ArchiveSortKey } from './proxmoxBackupsTableModel';
-import { RowMetricBar, SortableHead } from './proxmoxBackupsTableShared';
-
-// "Source details > Archives" table: vzdump / storage backup files with
-// volume, guest, storage, age swatch, size, and (when any archive carries PBS
-// metadata) protection + verification columns. Presentational — the parent
-// owns the filtered+sorted memo, shared filters, and the size/now scales.
-// table-fixed + a weighted colgroup keeps the columns from ballooning on wide
-// viewports, accounting for the conditional PBS columns.
-export function ProxmoxArchivesTable(props: {
- archives: StorageBackup[];
- hasAnyArchives: boolean;
- emptyIcon: JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
- sortKey: Accessor<ArchiveSortKey>;
- sortDirection: Accessor<'asc' | 'desc'>;
- onSort: (key: ArchiveSortKey) => void;
- showPBSColumns: boolean;
- sizeMaxBytes: number;
- nowMs: number;
-}) {
- const visibleColumns = () => [
- { id: 'volume', weight: 18 },
- { id: 'guest', weight: 9 },
- { id: 'storage', weight: 11 },
- { id: 'node', weight: 10 },
- { id: 'format', weight: 8 },
- { id: 'created', weight: 12 },
- { id: 'size', weight: 14 },
- ...(props.showPBSColumns
- ? [
- { id: 'protected', weight: 9 },
- { id: 'verified', weight: 9 },
- ]
- : []),
- ];
- const totalColumnWeight = () =>
- visibleColumns().reduce((sum, column) => sum + column.weight, 0);
-
- return (
- <Show
- when={props.archives.length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={!props.hasAnyArchives ? props.emptyTitle : 'No archives match current filters'}
- description={
- !props.hasAnyArchives
- ? props.emptyDescription
- : 'Adjust the search or status filter to see more archives.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[1050px] table-fixed text-xs">
- <colgroup>
- <For each={visibleColumns()}>
- {(column) => (
- <col style={{ width: `${(column.weight / totalColumnWeight()) * 100}%` }} />
- )}
- </For>
- </colgroup>
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Volume"
- sortKey="volume"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('name')}
- />
- <SortableHead
- label="Guest"
- sortKey="guest"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Storage"
- sortKey="storage"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Node"
- sortKey="node"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Format"
- sortKey="format"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Created"
- sortKey="created"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Size"
- sortKey="size"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="center"
- headClass={getPlatformTableHeadClassForKind('metric-bar')}
- />
- <Show when={props.showPBSColumns}>
- <SortableHead
- label="Protection"
- sortKey="protected"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Verified"
- sortKey="verified"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- </Show>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={props.archives}>
- {(arc) => (
- <TableRow class="hover:bg-surface-hover">
- <TableCell
- class={`${getPlatformTableCellClassForKind('name')} text-base-content font-mono text-[11px]`}
- >
- <span class="inline-block max-w-[18rem] truncate" title={arc.volid}>
- {arc.volid}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {guestLabel(arc.type, arc.vmid)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {arc.storage || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content font-mono text-[11px]`}
- >
- {arc.node || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content uppercase text-[10px]`}
- >
- {arc.format || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- <div class="flex items-center justify-end gap-2">
- {(() => {
- const age = classifyArchiveRowAge(arc.time, props.nowMs);
- return (
- <span
- class={`h-1.5 w-1.5 shrink-0 rounded-full ${age.swatchClass}`}
- aria-hidden="true"
- title={`Coverage: ${age.label}`}
- />
- );
- })()}
- <span>{formatRelativeTime(arc.time, { compact: true })}</span>
- </div>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
- >
- <RowMetricBar
- valuePct={props.sizeMaxBytes > 0 ? (arc.size / props.sizeMaxBytes) * 100 : 0}
- fillClass="bg-blue-500/40 dark:bg-blue-500/40"
- label={formatBytes(arc.size)}
- tooltip={`${formatBytes(arc.size)} (relative to largest file in view)`}
- />
- </TableCell>
- <Show when={props.showPBSColumns}>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={arc.protected}
- fallback={<span class="text-muted">Unprotected</span>}
- >
- <span class="inline-flex items-center rounded-sm bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-200">
- Protected
- </span>
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={arc.verified}
- fallback={
- <Show when={arc.isPBS} fallback={<span class="text-muted">n/a</span>}>
- <span class="text-muted">Pending</span>
- </Show>
- }
- >
- <span class="inline-flex items-center rounded-sm bg-emerald-100 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200">
- Verified
- </span>
- </Show>
- </TableCell>
- </Show>
- </TableRow>
- )}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
- );
-}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
new file mode 100644
index 0000000000..a938410cd6
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
@@ -0,0 +1,214 @@
+import { For, Show, type JSX } from 'solid-js';
+
+import { StatusDot } from '@/components/shared/StatusDot';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import { TableCard } from '@/components/shared/TableCard';
+import { formatBytes } from '@/utils/format';
+import {
+ PLATFORM_TABLE_BODY_CLASS,
+ PLATFORM_TABLE_CARD_CLASS,
+ PLATFORM_TABLE_HEADER_ROW_CLASS,
+ getPlatformTableCellClassForKind,
+ getPlatformTableHeadClassForKind,
+} from '@/features/platformPage/sharedPlatformPage';
+import type { Resource, ResourcePBSDatastore } from '@/types/resource';
+import type { StatusIndicatorVariant } from '@/utils/status';
+
+// "Backup servers" answers the two questions the coverage table can't: is my
+// PBS reachable, and is its datastore about to fill? Datastore fill is the
+// headline backup risk — a full datastore silently fails every future backup —
+// so it lives here on the Backups page, not buried on the platform Storage tab
+// where the rows read as generic "PVE" storage. One row per datastore, labelled
+// by its server; a server with no datastore data still gets a reachability row.
+
+interface BackupServerRow {
+ key: string;
+ serverName: string;
+ online: boolean;
+ connectionLabel: string;
+ version?: string;
+ datastore?: ResourcePBSDatastore;
+}
+
+function serverIsOnline(resource: Resource): boolean {
+ const status = (resource.status ?? '').toLowerCase();
+ const conn = (resource.pbs?.connectionHealth ?? '').toLowerCase();
+ if (conn) return conn === 'healthy' || conn === 'ok';
+ return status === 'online' || status === 'running';
+}
+
+function connectionLabel(resource: Resource): string {
+ const conn = resource.pbs?.connectionHealth?.trim();
+ if (conn) return conn.charAt(0).toUpperCase() + conn.slice(1);
+ return serverIsOnline(resource) ? 'Online' : 'Offline';
+}
+
+function usagePercent(datastore: ResourcePBSDatastore): number | undefined {
+ if (typeof datastore.usagePercent === 'number') return datastore.usagePercent;
+ if (datastore.total > 0) return (datastore.used / datastore.total) * 100;
+ return undefined;
+}
+
+// >=90% is the silent-backup-failure danger zone; >=75% is the early warning.
+function usageVariant(pct: number | undefined): StatusIndicatorVariant {
+ if (pct === undefined) return 'muted';
+ if (pct >= 90) return 'danger';
+ if (pct >= 75) return 'warning';
+ return 'success';
+}
+
+function usageToneClass(pct: number | undefined): string {
+ if (pct === undefined) return 'text-muted';
+ if (pct >= 90) return 'text-red-600 dark:text-red-300';
+ if (pct >= 75) return 'text-amber-600 dark:text-amber-300';
+ return 'text-base-content';
+}
+
+export function buildBackupServerRows(servers: readonly Resource[]): BackupServerRow[] {
+ const rows: BackupServerRow[] = [];
+ // `model().pbs` is scope-filtered (proxmox-pbs), which also catches PBS
+ // *datastore* storage resources (type 'storage', sources ['pbs']). This table
+ // is about the server, so keep only actual PBS server instances — otherwise a
+ // datastore renders as a phantom offline "server" row.
+ for (const server of servers.filter((resource) => resource.type === 'pbs')) {
+ const datastores = server.pbs?.datastores ?? [];
+ if (datastores.length === 0) {
+ rows.push({
+ key: server.id,
+ serverName: server.name,
+ online: serverIsOnline(server),
+ connectionLabel: connectionLabel(server),
+ version: server.pbs?.version,
+ });
+ continue;
+ }
+ for (const datastore of datastores) {
+ rows.push({
+ key: `${server.id}:${datastore.name}`,
+ serverName: server.name,
+ online: serverIsOnline(server),
+ connectionLabel: connectionLabel(server),
+ version: server.pbs?.version,
+ datastore,
+ });
+ }
+ }
+ return rows;
+}
+
+export function ProxmoxBackupServersTable(props: {
+ servers: readonly Resource[];
+ emptyIcon?: JSX.Element;
+}) {
+ const rows = () => buildBackupServerRows(props.servers);
+
+ return (
+ <Show when={rows().length > 0}>
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <Table class="min-w-[760px] table-fixed text-xs">
+ <colgroup>
+ <col style={{ width: '22%' }} />
+ <col style={{ width: '14%' }} />
+ <col style={{ width: '12%' }} />
+ <col style={{ width: '20%' }} />
+ <col style={{ width: '22%' }} />
+ <col style={{ width: '10%' }} />
+ </colgroup>
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <TableHead class={getPlatformTableHeadClassForKind('name')}>Backup server</TableHead>
+ <TableHead class={getPlatformTableHeadClassForKind('text')}>Status</TableHead>
+ <TableHead class={getPlatformTableHeadClassForKind('text')}>Version</TableHead>
+ <TableHead class={getPlatformTableHeadClassForKind('text')}>Datastore</TableHead>
+ <TableHead class={getPlatformTableHeadClassForKind('numeric-value')}>Used</TableHead>
+ <TableHead class={getPlatformTableHeadClassForKind('numeric-value')}>Dedup</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={rows()}>
+ {(row) => {
+ const pct = () => (row.datastore ? usagePercent(row.datastore) : undefined);
+ return (
+ <TableRow class="hover:bg-surface-hover">
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('name')} text-base-content truncate font-medium`}
+ >
+ {row.serverName}
+ </TableCell>
+ <TableCell class={getPlatformTableCellClassForKind('text')}>
+ <div class="flex items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={row.online ? 'success' : 'danger'}
+ title={row.connectionLabel}
+ ariaHidden
+ />
+ <span class="truncate text-[11px] text-base-content">
+ {row.connectionLabel}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-muted truncate text-[11px]`}
+ >
+ {row.version || '—'}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content truncate font-mono text-[11px]`}
+ >
+ {row.datastore?.name ?? '—'}
+ </TableCell>
+ <TableCell class={getPlatformTableCellClassForKind('numeric-value')}>
+ <Show
+ when={row.datastore}
+ fallback={<span class="text-muted">No datastore data</span>}
+ >
+ {(datastore) => (
+ <div class="flex items-center justify-end gap-2">
+ <StatusDot
+ size="sm"
+ variant={usageVariant(pct())}
+ title={`Datastore ${Math.round(pct() ?? 0)}% used`}
+ ariaHidden
+ />
+ <span class={`tabular-nums font-medium ${usageToneClass(pct())}`}>
+ <Show when={pct() !== undefined} fallback="—">
+ {Math.round(pct() ?? 0)}%
+ </Show>
+ </span>
+ <span class="text-[10px] text-muted tabular-nums">
+ {formatBytes(datastore().used)} / {formatBytes(datastore().total)}
+ </span>
+ </div>
+ )}
+ </Show>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums text-[11px]`}
+ >
+ <Show
+ when={row.datastore?.deduplicationFactor}
+ fallback={<span class="text-muted">—</span>}
+ >
+ {(factor) => <>{factor().toFixed(1)}×</>}
+ </Show>
+ </TableCell>
+ </TableRow>
+ );
+ }}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ );
+}
+
+export default ProxmoxBackupServersTable;
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 15af72799b..49fa2f6467 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -1,30 +1,18 @@
import {
- For,
Show,
- createEffect,
createMemo,
createResource,
createSignal,
type Component,
type JSX,
} from 'solid-js';
-import ArchiveIcon from 'lucide-solid/icons/archive';
-import CameraIcon from 'lucide-solid/icons/camera';
-import ActivityIcon from 'lucide-solid/icons/activity';
-import DatabaseIcon from 'lucide-solid/icons/database';
-import ServerIcon from 'lucide-solid/icons/server';
-import ShieldCheckIcon from 'lucide-solid/icons/shield-check';
+import ChevronRightIcon from 'lucide-solid/icons/chevron-right';
import { Card } from '@/components/shared/Card';
import { EmptyState } from '@/components/shared/EmptyState';
import { useSearchParams } from '@solidjs/router';
import { FilterBar, type FilterDef, type FilterSelectOption } from '@/components/shared/FilterBar';
import { useBreakpoint } from '@/hooks/useBreakpoint';
import { apiFetch } from '@/utils/apiClient';
-import { formatBytes } from '@/utils/format';
-import {
- recoveryDateKeyFromTimestamp,
- getRecoveryFilterDateLabel,
-} from '@/utils/recoveryDatePresentation';
import type {
BackupTask,
GuestSnapshot,
@@ -36,164 +24,37 @@ import type {
StorageBackup,
} from '@/types/api';
import type { Resource } from '@/types/resource';
-import { BackupActivityChart } from './BackupActivityChart';
-import {
- buildBackupActivityTimeline,
- type BackupActivityMetricMode,
- type BackupActivityRangeDays,
- type BackupActivitySegmentKind,
-} from './proxmoxBackupActivityPresentation';
-import {
- buildArchiveCoverageSummary,
- buildSnapshotCoverageSummary,
- buildTaskOutcomeSummary,
- computeMedianTaskDurationSeconds,
- getBackupAgeBucketPresentation,
- guestKey,
- taskDurationSeconds,
-} from './proxmoxBackupSummaryPresentation';
import {
buildProxmoxBackupRecoveryModel,
coverageRowMatchesSearch,
isCoverageAttention,
- recoverableArtifactMatchesSearch,
- type RecoverableArtifact,
} from './proxmoxBackupRecoveryModel';
import {
- ARCHIVE_SORT_DEFAULT_DIRECTION,
COVERAGE_SORT_DEFAULT_DIRECTION,
- PBS_SORT_DEFAULT_DIRECTION,
- RECOVERABLE_SORT_DEFAULT_DIRECTION,
- SNAPSHOT_SORT_DEFAULT_DIRECTION,
- TASK_SORT_DEFAULT_DIRECTION,
- classifyTaskStatus,
- cmpBool,
cmpNumber,
cmpString,
- formatDurationFromSeconds,
- guestLabel,
- pbsRepositoryLabel,
- pbsWorkloadLabel,
- type ArchiveSortKey,
- type BackupTabId,
type CoverageFilterValue,
type CoverageSortKey,
- type PBSSortKey,
- type RecoverableFilterValue,
- type RecoverableSortKey,
- type SnapshotFilterValue,
- type SnapshotGuestRow,
- type SnapshotSortKey,
- type SourceDetailTabId,
- type TaskSortKey,
} from './proxmoxBackupsTableModel';
-import {
- ARCHIVE_STATUS_FILTERS,
- COVERAGE_FILTERS,
- PBS_STATUS_FILTERS,
- RECOVERABLE_FILTERS,
- SNAPSHOT_FILTERS,
- TASK_STATUS_FILTERS,
- artifactStateLabel,
-} from './proxmoxBackupsTableShared';
-import { ProxmoxArchivesTable } from './ProxmoxArchivesTable';
+import { COVERAGE_FILTERS } from './proxmoxBackupsTableShared';
import { ProxmoxBackupsCoverageStrip } from './ProxmoxBackupsCoverageStrip';
+import { ProxmoxBackupServersTable } from './ProxmoxBackupServersTable';
import { ProxmoxCoverageTable } from './ProxmoxCoverageTable';
-import { ProxmoxPbsTable } from './ProxmoxPbsTable';
-import { ProxmoxRecoverableTable } from './ProxmoxRecoverableTable';
-import { ProxmoxSnapshotsTable } from './ProxmoxSnapshotsTable';
-import { ProxmoxTasksTable } from './ProxmoxTasksTable';
-
-// Proxmox backups are intentionally organized around operator questions, not
-// storage-source mechanics:
-// - Workload coverage answers "does this workload have a backup?" by default.
-// - Restore points answers "what exactly can I restore?" across every source.
-// - Source details keeps PBS/PVE evidence available without making those
-// implementation-specific tables equal-weight primary destinations.
-// - Job history shows whether backup jobs are actually running successfully.
-
-interface BackupTabSpec {
- id: BackupTabId;
- label: string;
- icon: () => JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
-}
-
-const TABS: BackupTabSpec[] = [
- {
- id: 'coverage',
- label: 'Workload coverage',
- icon: () => <ShieldCheckIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No workload coverage',
- emptyDescription: 'VM and container restore posture will appear here once backup data exists.',
- },
- {
- id: 'recoverable',
- label: 'Restore points',
- icon: () => <DatabaseIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No recoverable artifacts',
- emptyDescription: 'PBS artifacts, PVE backup files, and snapshots will appear here.',
- },
- {
- id: 'sources',
- label: 'Source details',
- icon: () => <ServerIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No source artifacts',
- emptyDescription: 'PBS artifacts, PVE backup files, and guest snapshots will appear here.',
- },
- {
- id: 'tasks',
- label: 'Job history',
- icon: () => <ActivityIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No recent backup tasks',
- emptyDescription: 'Backup-job task results from the past few days will appear here.',
- },
-];
-
-function tabSpecFor(id: BackupTabId): BackupTabSpec {
- return TABS.find((spec) => spec.id === id)!;
-}
-
-interface SourceDetailTabSpec {
- id: SourceDetailTabId;
- label: string;
- icon: () => JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
-}
-const SOURCE_DETAIL_TABS: SourceDetailTabSpec[] = [
- {
- id: 'pbs',
- label: 'PBS artifacts',
- icon: () => <ServerIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No PBS artifacts',
- emptyDescription: 'Deduplicated backup snapshots from Proxmox Backup Server will appear here.',
- },
- {
- id: 'snapshots',
- label: 'Snapshots',
- icon: () => <CameraIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No guest snapshots',
- emptyDescription: 'qm/pct snapshots taken on PVE hosts will appear here.',
- },
- {
- id: 'archives',
- label: 'Backup files',
- icon: () => <ArchiveIcon class="h-4 w-4" aria-hidden="true" />,
- emptyTitle: 'No backup archives',
- emptyDescription: 'vzdump archives written to PVE-attached storage will appear here.',
- },
-];
-
-function sourceDetailSpecFor(id: SourceDetailTabId): SourceDetailTabSpec {
- return SOURCE_DETAIL_TABS.find((spec) => spec.id === id)!;
-}
+// The Proxmox backups surface answers one operator question: "is every guest
+// backed up, recently, and did the last job work?" That question IS the whole
+// surface — one row per workload, a posture dot, the latest restore point, and
+// the per-source evidence (PBS snapshots, PVE archives, guest snapshots) tucked
+// into each row's expansion for anyone who wants to drill in.
+//
+// The earlier per-source browsers (PBS artifacts / Snapshots / Backup files),
+// the "Restore points" and "Job history" tabs, and the per-day activity charts
+// were removed deliberately. A monitor is not a console: the live PBS and PVE
+// web UIs already own the forensic per-artifact view, and reproducing it
+// read-only here only buried the one question a backup monitor exists to
+// answer. Nothing was deleted that a power user needs — the evidence lives in
+// the row expansion (demote, not delete).
-// Replication colours the per-row status word to match its dot (emerald
-// text for Healthy, red for Failed, etc.). Mirror that here so the
-// Recent tasks STATUS column reads the same way — dot + same-tone word.
async function fetchPVEBackups(): Promise<PVEBackupsPayload> {
const response = await apiFetch('/api/backups/pve');
if (!response.ok) {
@@ -220,42 +81,29 @@ async function fetchPBSBackups(): Promise<PBSBackupsPayload> {
export const ProxmoxBackupsTable: Component<{
emptyIcon: JSX.Element;
- hasPBS?: boolean;
workloads?: readonly Resource[];
+ servers?: readonly Resource[];
}> = (props) => {
const [backups, { refetch }] = createResource<PVEBackupsPayload>(fetchPVEBackups);
- const [pbsBackups, { refetch: refetchPBS }] = createResource<PBSBackupsPayload>(fetchPBSBackups);
+ const [pbsBackups] = createResource<PBSBackupsPayload>(fetchPBSBackups);
const { isMobile } = useBreakpoint();
- // The structured scope filters (node, type) live in the URL so views are
- // shareable, survive reload, and can be captured by FilterBar saved views
- // (which persist the URL query string). Search, status facets, and the chart
- // day stay ephemeral signals.
+
+ // Structured scope filters (node, type) live in the URL so the view is
+ // shareable, survives reload, and can be captured by FilterBar saved views.
+ // Search and the posture facet stay ephemeral signals.
const [searchParams, setSearchParams] = useSearchParams();
- const [tab, setTab] = createSignal<BackupTabId>('coverage');
- const [sourceDetailTab, setSourceDetailTab] = createSignal<SourceDetailTabId>('pbs');
const [search, setSearch] = createSignal('');
const [coverageFilter, setCoverageFilter] = createSignal<CoverageFilterValue>('all');
- const [recoverableFilter, setRecoverableFilter] = createSignal<RecoverableFilterValue>('all');
- const [pbsFilter, setPBSFilter] = createSignal<'all' | 'protected' | 'verified' | 'unverified'>(
- 'all',
- );
- const [archiveFilter, setArchiveFilter] = createSignal<
- 'all' | 'protected' | 'verified' | 'unverified'
- >('all');
- const [taskFilter, setTaskFilter] = createSignal<'all' | 'ok' | 'failed' | 'running'>('all');
- const [snapshotFilter, setSnapshotFilter] = createSignal<SnapshotFilterValue>('all');
- // Cross-tab scope filter: an empty value means "all nodes". Applied as a
- // predicate in each tab's filter memo (PBS artifacts carry no node).
+
const nodeFilter = (): string => (typeof searchParams.node === 'string' ? searchParams.node : '');
const setNodeFilter = (value: string): void => setSearchParams({ node: value || null });
const nodeMatches = (node: string | undefined): boolean => {
const selected = nodeFilter();
return !selected || node === selected;
};
- // Type scope filter. The backups data mixes vocabularies (recovery model and
- // PBS backupType use vm/ct/host; raw PVE tasks/archives/snapshots use
- // qemu/lxc), so normalize each shape's type to a canonical vm/ct/host before
- // comparing. Applies to every tab, PBS included (via backupType).
+
+ // Type scope normalizes vm/qemu and ct/lxc to a canonical token before
+ // comparing, since the recovery model uses vm/ct/host.
const typeFilter = (): string => (typeof searchParams.type === 'string' ? searchParams.type : '');
const setTypeFilter = (value: string): void => setSearchParams({ type: value || null });
const canonicalGuestType = (raw: string | undefined): string => {
@@ -269,45 +117,22 @@ export const ProxmoxBackupsTable: Component<{
const selected = typeFilter();
return !selected || canonicalGuestType(raw) === selected;
};
- // VM / Container / Host, applied via canonicalGuestType across every tab.
const typeFilterOptions: FilterSelectOption[] = [
{ value: '', label: 'All types' },
{ value: 'vm', label: 'VMs' },
{ value: 'ct', label: 'Containers' },
{ value: 'host', label: 'Hosts' },
];
- const [chartRange, setChartRange] = createSignal<BackupActivityRangeDays>(30);
- const [selectedDateKey, setSelectedDateKey] = createSignal<string | null>(null);
- const [recoverableMetricMode, setRecoverableMetricMode] =
- createSignal<BackupActivityMetricMode>('count');
- const [pbsMetricMode, setPBSMetricMode] = createSignal<BackupActivityMetricMode>('count');
- const [archiveMetricMode, setArchiveMetricMode] = createSignal<BackupActivityMetricMode>('count');
- const [expandedGuests, setExpandedGuests] = createSignal<ReadonlySet<string>>(new Set<string>());
- const [expandedCoverageRows, setExpandedCoverageRows] = createSignal<ReadonlySet<string>>(
- new Set<string>(),
- );
const [coverageSortKey, setCoverageSortKey] = createSignal<CoverageSortKey>('posture');
const [coverageSortDirection, setCoverageSortDirection] = createSignal<'asc' | 'desc'>('asc');
- const [recoverableSortKey, setRecoverableSortKey] = createSignal<RecoverableSortKey>('created');
- const [recoverableSortDirection, setRecoverableSortDirection] = createSignal<'asc' | 'desc'>(
- 'desc',
+ const [expandedCoverageRows, setExpandedCoverageRows] = createSignal<ReadonlySet<string>>(
+ new Set<string>(),
);
- const [pbsSortKey, setPBSSortKey] = createSignal<PBSSortKey>('created');
- const [pbsSortDirection, setPBSSortDirection] = createSignal<'asc' | 'desc'>('desc');
- const [snapshotSortKey, setSnapshotSortKey] = createSignal<SnapshotSortKey>('latest');
- const [snapshotSortDirection, setSnapshotSortDirection] = createSignal<'asc' | 'desc'>('desc');
- const [archiveSortKey, setArchiveSortKey] = createSignal<ArchiveSortKey>('created');
- const [archiveSortDirection, setArchiveSortDirection] = createSignal<'asc' | 'desc'>('desc');
- const [taskSortKey, setTaskSortKey] = createSignal<TaskSortKey>('started');
- const [taskSortDirection, setTaskSortDirection] = createSignal<'asc' | 'desc'>('desc');
-
- const activeTabs = createMemo(() => TABS);
- createEffect(() => {
- if (!activeTabs().some((spec) => spec.id === tab())) {
- setTab(activeTabs()[0]?.id ?? 'coverage');
- }
- });
+ // Orphaned backups (records whose guest no longer exists in inventory) are
+ // collapsed by default so the main table is the user's live guests, not a
+ // pile of nameless dead records sorted to the top.
+ const [showOrphaned, setShowOrphaned] = createSignal(false);
const handleCoverageSort = (key: CoverageSortKey) => {
if (coverageSortKey() === key) {
@@ -317,55 +142,6 @@ export const ProxmoxBackupsTable: Component<{
setCoverageSortDirection(COVERAGE_SORT_DEFAULT_DIRECTION[key]);
}
};
- const handleRecoverableSort = (key: RecoverableSortKey) => {
- if (recoverableSortKey() === key) {
- setRecoverableSortDirection(recoverableSortDirection() === 'asc' ? 'desc' : 'asc');
- } else {
- setRecoverableSortKey(key);
- setRecoverableSortDirection(RECOVERABLE_SORT_DEFAULT_DIRECTION[key]);
- }
- };
- const handlePBSSort = (key: PBSSortKey) => {
- if (pbsSortKey() === key) {
- setPBSSortDirection(pbsSortDirection() === 'asc' ? 'desc' : 'asc');
- } else {
- setPBSSortKey(key);
- setPBSSortDirection(PBS_SORT_DEFAULT_DIRECTION[key]);
- }
- };
- const handleSnapshotSort = (key: SnapshotSortKey) => {
- if (snapshotSortKey() === key) {
- setSnapshotSortDirection(snapshotSortDirection() === 'asc' ? 'desc' : 'asc');
- } else {
- setSnapshotSortKey(key);
- setSnapshotSortDirection(SNAPSHOT_SORT_DEFAULT_DIRECTION[key]);
- }
- };
- const handleArchiveSort = (key: ArchiveSortKey) => {
- if (archiveSortKey() === key) {
- setArchiveSortDirection(archiveSortDirection() === 'asc' ? 'desc' : 'asc');
- } else {
- setArchiveSortKey(key);
- setArchiveSortDirection(ARCHIVE_SORT_DEFAULT_DIRECTION[key]);
- }
- };
- const handleTaskSort = (key: TaskSortKey) => {
- if (taskSortKey() === key) {
- setTaskSortDirection(taskSortDirection() === 'asc' ? 'desc' : 'asc');
- } else {
- setTaskSortKey(key);
- setTaskSortDirection(TASK_SORT_DEFAULT_DIRECTION[key]);
- }
- };
- const toggleDay = (key: string) =>
- setSelectedDateKey((current) => (current === key ? null : key));
- const toggleGuestExpansion = (key: string) =>
- setExpandedGuests((current) => {
- const next = new Set(current);
- if (next.has(key)) next.delete(key);
- else next.add(key);
- return next;
- });
const toggleCoverageExpansion = (key: string) =>
setExpandedCoverageRows((current) => {
const next = new Set(current);
@@ -378,30 +154,11 @@ export const ProxmoxBackupsTable: Component<{
const snapshots = createMemo<GuestSnapshot[]>(() => backups()?.guestSnapshots ?? []);
const archives = createMemo<StorageBackup[]>(() => backups()?.storageBackups ?? []);
const tasks = createMemo<BackupTask[]>(() => backups()?.backupTasks ?? []);
- const activeSourceDetailTabs = createMemo(() =>
- props.hasPBS ? SOURCE_DETAIL_TABS : SOURCE_DETAIL_TABS.filter((spec) => spec.id !== 'pbs'),
- );
- createEffect(() => {
- if (!activeSourceDetailTabs().some((spec) => spec.id === sourceDetailTab())) {
- setSourceDetailTab(activeSourceDetailTabs()[0]?.id ?? 'snapshots');
- }
- });
- const sourceDetailTotal = (id: SourceDetailTabId): number => {
- if (id === 'pbs') return pbsArtifacts().length;
- if (id === 'snapshots') return snapshots().length;
- return archives().length;
- };
- const totalSourceArtifacts = createMemo(
- () => (props.hasPBS ? pbsArtifacts().length : 0) + snapshots().length + archives().length,
- );
- // Render-time `now` used for age bucketing. We snapshot once per render
- // so all comparisons within a single render share a reference moment;
- // not reactive to ticking time (good enough for sysadmin grouping).
+
+ // Render-time `now` snapshot so all age comparisons within a render share a
+ // reference moment; not reactive to ticking time (fine for sysadmin grouping).
const nowMs = createMemo(() => Date.now());
- const snapshotCoverage = createMemo(() => buildSnapshotCoverageSummary(snapshots(), nowMs()));
- const archiveCoverage = createMemo(() => buildArchiveCoverageSummary(archives(), nowMs()));
- const taskOutcome = createMemo(() => buildTaskOutcomeSummary(tasks()));
const recoveryModel = createMemo(() =>
buildProxmoxBackupRecoveryModel({
workloads: props.workloads ?? [],
@@ -412,437 +169,49 @@ export const ProxmoxBackupsTable: Component<{
nowMs: nowMs(),
}),
);
- const pbsCoverage = createMemo(() => {
- const backups = pbsArtifacts();
- const namespaces = new Set<string>();
- let totalBytes = 0;
- let protectedCount = 0;
- let verifiedCount = 0;
- for (const backup of backups) {
- namespaces.add(pbsRepositoryLabel(backup));
- if (typeof backup.size === 'number' && backup.size > 0) totalBytes += backup.size;
- if (backup.protected) protectedCount += 1;
- if (backup.verified) verifiedCount += 1;
+
+ // Node options for the scope filter: the distinct nodes across the workload
+ // set, "All nodes" first. PBS artifacts carry no node, so this scopes the
+ // node-bearing rows only.
+ const nodeOptions = createMemo<FilterSelectOption[]>(() => {
+ const nodes = new Set<string>();
+ for (const row of recoveryModel().coverageRows) {
+ const node = row.workload.node?.trim();
+ if (node) nodes.add(node);
}
- return {
- total: backups.length,
- totalBytes,
- protectedCount,
- verifiedCount,
- unverifiedCount: backups.length - verifiedCount,
- namespaceCount: namespaces.size,
- };
+ return [
+ { value: '', label: 'All nodes' },
+ ...[...nodes].sort((a, b) => a.localeCompare(b)).map((node) => ({ value: node, label: node })),
+ ];
});
- const pbsTimestampMs = (backup: PBSBackup): number | undefined => {
- const ms = Date.parse(backup.backupTime ?? '');
- return Number.isFinite(ms) ? ms : undefined;
- };
- const archiveTimestampMs = (arc: StorageBackup): number | undefined => {
- const ms = Date.parse(arc.time ?? '');
- return Number.isFinite(ms) ? ms : undefined;
- };
- const taskTimestampMs = (task: BackupTask): number | undefined => {
- const ms = Date.parse(task.startTime ?? '');
- return Number.isFinite(ms) ? ms : undefined;
- };
- const snapshotTimestampMs = (snap: GuestSnapshot): number | undefined => {
- const ms = Date.parse(snap.time ?? '');
- return Number.isFinite(ms) ? ms : undefined;
- };
- const classifyTaskSegment = (task: BackupTask): BackupActivitySegmentKind | null => {
- const variant = classifyTaskStatus(task.status).variant;
- if (variant === 'success') return 'ok';
- if (variant === 'danger') return 'failed';
- if (variant === 'warning') return 'running';
- return null;
- };
-
- const archiveTimeline = createMemo(() =>
- buildBackupActivityTimeline<StorageBackup>(
- chartRange(),
- archives(),
- archiveTimestampMs,
- () => 'archive',
- {
- getValue:
- archiveMetricMode() === 'volume' ? (arc) => (arc.size > 0 ? arc.size : 0) : undefined,
- },
- ),
- );
- const taskTimeline = createMemo(() =>
- buildBackupActivityTimeline<BackupTask>(
- chartRange(),
- tasks(),
- taskTimestampMs,
- classifyTaskSegment,
- ),
+ // Source columns auto-hide when no workload anywhere has that data (computed
+ // over the full set so columns don't flicker as filters change). A PBS-only
+ // fleet drops the Archive and Snapshot columns.
+ const coverageHasPbs = createMemo(() =>
+ recoveryModel().coverageRows.some((row) => Boolean(row.latestPBS) || row.pbsCount > 0),
);
- const snapshotTimeline = createMemo(() =>
- buildBackupActivityTimeline<GuestSnapshot>(
- chartRange(),
- snapshots(),
- snapshotTimestampMs,
- () => 'snapshot',
- ),
+ const coverageHasArchive = createMemo(() =>
+ recoveryModel().coverageRows.some((row) => Boolean(row.latestArchive) || row.archiveCount > 0),
);
-
- const ARCHIVE_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['archive'];
- const TASK_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['ok', 'failed', 'running'];
- const SNAPSHOT_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['snapshot'];
- const PBS_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = ['pbs'];
- const RECOVERABLE_SEGMENT_KINDS: readonly BackupActivitySegmentKind[] = [
- 'pbs',
- 'archive',
- 'snapshot',
- ];
-
- const pbsTimeline = createMemo(() =>
- buildBackupActivityTimeline<PBSBackup>(
- chartRange(),
- pbsArtifacts(),
- pbsTimestampMs,
- () => 'pbs',
- {
- getValue:
- pbsMetricMode() === 'volume'
- ? (backup) => (backup.size > 0 ? backup.size : 0)
- : undefined,
- },
+ const coverageHasSnapshot = createMemo(() =>
+ recoveryModel().coverageRows.some(
+ (row) => Boolean(row.latestSnapshot) || row.snapshotCount > 0,
),
);
-
- const recoverableTimeline = createMemo(() =>
- buildBackupActivityTimeline<RecoverableArtifact>(
- chartRange(),
- recoveryModel().recoverableArtifacts,
- (artifact) => artifact.createdMs,
- (artifact) =>
- artifact.sourceKind === 'pbs'
- ? 'pbs'
- : artifact.sourceKind === 'archive'
- ? 'archive'
- : 'snapshot',
- {
- getValue:
- recoverableMetricMode() === 'volume'
- ? (artifact) => (artifact.size && artifact.size > 0 ? artifact.size : 0)
- : undefined,
- },
- ),
+ const coverageHasTask = createMemo(() =>
+ recoveryModel().coverageRows.some((row) => Boolean(row.latestTask)),
);
- const snapshotMatchesSearch = (snap: GuestSnapshot, term: string): boolean => {
- if (!term) return true;
- return [snap.name, snap.node, snap.instance, snap.description, String(snap.vmid)]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- .includes(term);
- };
-
- const pbsMatchesSearch = (backup: PBSBackup, term: string): boolean => {
- if (!term) return true;
- return [
- pbsWorkloadLabel(backup),
- pbsRepositoryLabel(backup),
- backup.instance,
- backup.datastore,
- backup.namespace,
- backup.backupType,
- backup.vmid,
- backup.comment,
- backup.owner,
- ...(backup.files ?? []),
- ]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- .includes(term);
- };
-
- const filteredPBSBackups = createMemo(() => {
- const term = search().trim().toLowerCase();
- const filter = pbsFilter();
- const dateKey = selectedDateKey();
- const list = pbsArtifacts().filter((backup) => {
- if (!typeMatches(backup.backupType)) return false;
- if (filter === 'protected' && !backup.protected) return false;
- if (filter === 'verified' && !backup.verified) return false;
- if (filter === 'unverified' && backup.verified) return false;
- if (dateKey) {
- const ms = pbsTimestampMs(backup);
- if (ms === undefined || recoveryDateKeyFromTimestamp(ms) !== dateKey) return false;
- }
- return pbsMatchesSearch(backup, term);
- });
- const sortKey = pbsSortKey();
- const direction = pbsSortDirection();
- list.sort((a, b) => {
- switch (sortKey) {
- case 'workload':
- return cmpString(pbsWorkloadLabel(a), pbsWorkloadLabel(b), direction);
- case 'repository':
- return cmpString(pbsRepositoryLabel(a), pbsRepositoryLabel(b), direction);
- case 'created':
- return cmpNumber(pbsTimestampMs(a), pbsTimestampMs(b), direction);
- case 'size':
- return cmpNumber(a.size, b.size, direction);
- case 'protected':
- return cmpBool(a.protected, b.protected, direction);
- case 'verified':
- return cmpBool(a.verified, b.verified, direction);
- }
- });
- return list;
- });
-
- const filteredSnapshots = createMemo(() => {
- const term = search().trim().toLowerCase();
- const dateKey = selectedDateKey();
- return snapshots().filter((snap) => {
- if (dateKey) {
- const ms = snapshotTimestampMs(snap);
- if (ms === undefined || recoveryDateKeyFromTimestamp(ms) !== dateKey) return false;
- }
- return snapshotMatchesSearch(snap, term);
- });
- });
-
- const filteredSnapshotGuests = createMemo<SnapshotGuestRow[]>(() => {
- const term = search().trim().toLowerCase();
- const dateKey = selectedDateKey();
- const filter = snapshotFilter();
- const now = nowMs();
- const byGuest = new Map<string, SnapshotGuestRow>();
- for (const snap of snapshots()) {
- const matchesSnapshot = snapshotMatchesSearch(snap, term);
- if (!matchesSnapshot && !term) {
- // no term means everything matches; fall through.
- } else if (!matchesSnapshot && term) {
- // guest stays out of the matched set unless its identifiers match;
- // we re-evaluate that below if no snapshot inside matched.
- }
- const passesDate = (() => {
- if (!dateKey) return true;
- const ms = snapshotTimestampMs(snap);
- return ms !== undefined && recoveryDateKeyFromTimestamp(ms) === dateKey;
- })();
- if (!passesDate) continue;
- const key = guestKey(snap);
- let row = byGuest.get(key);
- if (!row) {
- row = {
- key,
- type: snap.type,
- vmid: snap.vmid,
- instance: snap.instance,
- node: snap.node,
- snapshots: [],
- count: 0,
- withRamCount: 0,
- newestMs: undefined,
- totalBytes: 0,
- isStale: true,
- };
- byGuest.set(key, row);
- }
- row.snapshots.push(snap);
- row.count += 1;
- if (snap.vmstate) row.withRamCount += 1;
- if (typeof snap.sizeBytes === 'number' && snap.sizeBytes > 0)
- row.totalBytes += snap.sizeBytes;
- const ms = snapshotTimestampMs(snap);
- if (ms !== undefined && (row.newestMs === undefined || ms > row.newestMs)) {
- row.newestMs = ms;
- }
- }
- // Search-on-guest-identity: if the search term matches the guest's
- // identifying fields (node/vmid/type), every snapshot under it is
- // considered relevant even if individual snapshot text did not match.
- const searchedByGuestIdentity = (row: SnapshotGuestRow): boolean => {
- if (!term) return true;
- return [`${row.type} ${row.vmid}`, row.node, row.instance, String(row.vmid)]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- .includes(term);
- };
- const rows: SnapshotGuestRow[] = [];
- for (const row of byGuest.values()) {
- if (!nodeMatches(row.node)) continue;
- if (!typeMatches(row.type)) continue;
- const matchesByIdentity = searchedByGuestIdentity(row);
- const snapshotsMatching = term
- ? row.snapshots.filter((snap) => snapshotMatchesSearch(snap, term))
- : row.snapshots;
- if (!matchesByIdentity && snapshotsMatching.length === 0) continue;
- const visibleSnapshots = matchesByIdentity ? row.snapshots : snapshotsMatching;
- visibleSnapshots.sort((a, b) => {
- const av = Date.parse(a.time);
- const bv = Date.parse(b.time);
- return (Number.isFinite(bv) ? bv : 0) - (Number.isFinite(av) ? av : 0);
- });
- const enriched: SnapshotGuestRow = {
- ...row,
- snapshots: visibleSnapshots,
- count: visibleSnapshots.length,
- withRamCount: visibleSnapshots.reduce((sum, s) => sum + (s.vmstate ? 1 : 0), 0),
- totalBytes: visibleSnapshots.reduce(
- (sum, s) => sum + (typeof s.sizeBytes === 'number' && s.sizeBytes > 0 ? s.sizeBytes : 0),
- 0,
- ),
- newestMs: visibleSnapshots.reduce<number | undefined>((newest, s) => {
- const ms = snapshotTimestampMs(s);
- if (ms === undefined) return newest;
- if (newest === undefined) return ms;
- return ms > newest ? ms : newest;
- }, undefined),
- isStale: ((): boolean => {
- const newest = visibleSnapshots[0] ? snapshotTimestampMs(visibleSnapshots[0]) : undefined;
- if (newest === undefined) return true;
- return now - newest > 30 * 24 * 60 * 60 * 1000;
- })(),
- };
- if (filter === 'recent' && enriched.isStale) continue;
- if (filter === 'stale' && !enriched.isStale) continue;
- if (filter === 'with-ram' && enriched.withRamCount === 0) continue;
- rows.push(enriched);
- }
- const sortKey = snapshotSortKey();
- const direction = snapshotSortDirection();
- rows.sort((a, b) => {
- switch (sortKey) {
- case 'guest':
- return cmpString(guestLabel(a.type, a.vmid), guestLabel(b.type, b.vmid), direction);
- case 'node':
- return cmpString(a.node, b.node, direction);
- case 'latest':
- return cmpNumber(a.newestMs, b.newestMs, direction);
- case 'count':
- return cmpNumber(a.count, b.count, direction);
- case 'size':
- return cmpNumber(a.totalBytes, b.totalBytes, direction);
- }
- });
- return rows;
- });
-
- const filteredArchives = createMemo(() => {
- const term = search().trim().toLowerCase();
- const filter = archiveFilter();
- const dateKey = selectedDateKey();
- const list = archives().filter((arc) => {
- if (!nodeMatches(arc.node)) return false;
- if (!typeMatches(arc.type)) return false;
- if (filter === 'protected' && !arc.protected) return false;
- if (filter === 'verified' && !arc.verified) return false;
- if (filter === 'unverified' && arc.verified) return false;
- if (dateKey) {
- const ms = archiveTimestampMs(arc);
- if (ms === undefined || recoveryDateKeyFromTimestamp(ms) !== dateKey) return false;
- }
- if (!term) return true;
- return [arc.storage, arc.node, arc.instance, arc.volid, arc.notes, String(arc.vmid)]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- .includes(term);
- });
- const sortKey = archiveSortKey();
- const direction = archiveSortDirection();
- list.sort((a, b) => {
- switch (sortKey) {
- case 'volume':
- return cmpString(a.volid, b.volid, direction);
- case 'guest':
- return cmpString(guestLabel(a.type, a.vmid), guestLabel(b.type, b.vmid), direction);
- case 'storage':
- return cmpString(a.storage, b.storage, direction);
- case 'node':
- return cmpString(a.node, b.node, direction);
- case 'format':
- return cmpString(a.format, b.format, direction);
- case 'created':
- return cmpNumber(archiveTimestampMs(a), archiveTimestampMs(b), direction);
- case 'size':
- return cmpNumber(a.size, b.size, direction);
- case 'protected':
- return cmpBool(a.protected, b.protected, direction);
- case 'verified':
- return cmpBool(a.verified, b.verified, direction);
- }
- });
- return list;
- });
-
- const filteredTasks = createMemo(() => {
- const term = search().trim().toLowerCase();
- const filter = taskFilter();
- const dateKey = selectedDateKey();
- const list = tasks().filter((task) => {
- if (!nodeMatches(task.node)) return false;
- if (!typeMatches(task.type)) return false;
- const classify = classifyTaskStatus(task.status);
- if (filter === 'ok' && classify.variant !== 'success') return false;
- if (filter === 'failed' && classify.variant !== 'danger') return false;
- if (filter === 'running' && classify.variant !== 'warning') return false;
- if (dateKey) {
- const ms = taskTimestampMs(task);
- if (ms === undefined || recoveryDateKeyFromTimestamp(ms) !== dateKey) return false;
- }
- if (!term) return true;
- return [task.node, task.instance, task.status, task.error, String(task.vmid)]
- .filter(Boolean)
- .join(' ')
- .toLowerCase()
- .includes(term);
- });
- const sortKey = taskSortKey();
- const direction = taskSortDirection();
- list.sort((a, b) => {
- switch (sortKey) {
- case 'status':
- return cmpString(
- classifyTaskStatus(a.status).label,
- classifyTaskStatus(b.status).label,
- direction,
- );
- case 'guest':
- return cmpString(guestLabel(a.type, a.vmid), guestLabel(b.type, b.vmid), direction);
- case 'node':
- return cmpString(a.node, b.node, direction);
- case 'started':
- return cmpNumber(taskTimestampMs(a), taskTimestampMs(b), direction);
- case 'duration':
- return cmpNumber(taskDurationSeconds(a), taskDurationSeconds(b), direction);
- case 'size':
- return cmpNumber(a.size, b.size, direction);
- }
- });
- return list;
- });
-
const filteredCoverageRows = createMemo(() => {
const term = search().trim().toLowerCase();
const filter = coverageFilter();
- const dateKey = selectedDateKey();
const list = recoveryModel().coverageRows.filter((row) => {
if (!nodeMatches(row.workload.node)) return false;
if (!typeMatches(row.workload.type)) return false;
if (filter === 'attention' && !isCoverageAttention(row.posture)) return false;
if (filter === 'current' && row.posture !== 'current') return false;
if (filter === 'uncovered' && row.posture !== 'uncovered') return false;
- if (
- dateKey &&
- !row.artifacts.some(
- (artifact) =>
- artifact.createdMs !== undefined &&
- recoveryDateKeyFromTimestamp(artifact.createdMs) === dateKey,
- )
- ) {
- return false;
- }
return coverageRowMatchesSearch(row, term);
});
const sortKey = coverageSortKey();
@@ -868,213 +237,48 @@ export const ProxmoxBackupsTable: Component<{
return list;
});
- const filteredRecoverableArtifacts = createMemo(() => {
- const term = search().trim().toLowerCase();
- const filter = recoverableFilter();
- const dateKey = selectedDateKey();
- const list = recoveryModel().recoverableArtifacts.filter((artifact) => {
- if (!nodeMatches(artifact.workload.node)) return false;
- if (!typeMatches(artifact.workload.type)) return false;
- if (
- (filter === 'pbs' || filter === 'archive' || filter === 'snapshot') &&
- artifact.sourceKind !== filter
- ) {
- return false;
- }
- if (filter === 'verified' && artifact.verified !== true) return false;
- if (filter === 'unverified' && artifact.verified !== false) return false;
- if (
- dateKey &&
- (artifact.createdMs === undefined ||
- recoveryDateKeyFromTimestamp(artifact.createdMs) !== dateKey)
- ) {
- return false;
- }
- return recoverableArtifactMatchesSearch(artifact, term);
- });
- const sortKey = recoverableSortKey();
- const direction = recoverableSortDirection();
- list.sort((a, b) => {
- switch (sortKey) {
- case 'workload':
- return cmpString(a.workload.label, b.workload.label, direction);
- case 'source':
- return cmpString(a.sourceLabel, b.sourceLabel, direction);
- case 'location':
- return cmpString(a.location, b.location, direction);
- case 'created':
- return cmpNumber(a.createdMs, b.createdMs, direction);
- case 'size':
- return cmpNumber(a.size, b.size, direction);
- case 'state':
- return cmpString(artifactStateLabel(a), artifactStateLabel(b), direction);
- }
- });
- return list;
- });
-
- const showSnapshotSizeColumn = createMemo(() =>
- snapshots().some((snap) => typeof snap.sizeBytes === 'number' && snap.sizeBytes > 0),
- );
- const showSnapshotRAMColumn = createMemo(() => snapshots().some((snap) => snap.vmstate));
- const snapshotColumnCount = createMemo(
- () => 4 + (showSnapshotSizeColumn() ? 1 : 0) + (showSnapshotRAMColumn() ? 1 : 0),
- );
- const showArchivePBSColumns = createMemo(() =>
- archives().some((arc) => arc.isPBS || arc.protected || arc.verified || !!arc.verification),
- );
- const showTaskSizeColumn = createMemo(() =>
- tasks().some((task) => typeof task.size === 'number' && task.size > 0),
- );
- const showTaskErrorColumn = createMemo(() => tasks().some((task) => !!task.error?.trim()));
-
- const totalForTab = createMemo<number>(() => {
- switch (tab()) {
- case 'coverage':
- return recoveryModel().coverageRows.length;
- case 'recoverable':
- return recoveryModel().recoverableArtifacts.length;
- case 'sources':
- return sourceDetailTotal(sourceDetailTab());
- case 'tasks':
- return tasks().length;
- default:
- return 0;
- }
- });
-
- const visibleForTab = createMemo<number>(() => {
- switch (tab()) {
- case 'coverage':
- return filteredCoverageRows().length;
- case 'recoverable':
- return filteredRecoverableArtifacts().length;
- case 'sources':
- if (sourceDetailTab() === 'pbs') return filteredPBSBackups().length;
- if (sourceDetailTab() === 'snapshots') return filteredSnapshots().length;
- return filteredArchives().length;
- case 'tasks':
- return filteredTasks().length;
- default:
- return 0;
- }
- });
-
- // Used to scale the inline duration bar on Recent tasks. A typical task
- // sits at ~50% of the bar, outliers extend toward the right edge. The
- // baseline is recomputed against the *filtered* set so the bar stays
- // useful when the user narrows the view to a single guest.
- const taskDurationBaselineSeconds = createMemo(() =>
- computeMedianTaskDurationSeconds(filteredTasks()),
- );
-
- // The largest PBS artifact in the filtered set anchors the size bar.
- const pbsSizeMaxBytes = createMemo(() => {
- let max = 0;
- for (const backup of filteredPBSBackups()) {
- if (backup.size > max) max = backup.size;
- }
- return max;
- });
-
- // The largest archive in the filtered set anchors the size bar.
- const archiveSizeMaxBytes = createMemo(() => {
- let max = 0;
- for (const arc of filteredArchives()) {
- if (arc.size > max) max = arc.size;
- }
- return max;
- });
-
- const recoverableSizeMaxBytes = createMemo(() => {
- let max = 0;
- for (const artifact of filteredRecoverableArtifacts()) {
- if (artifact.size && artifact.size > max) max = artifact.size;
- }
- return max;
- });
-
- const activeTabNoun = createMemo(() => {
- switch (tab()) {
- case 'coverage':
- return 'workloads';
- case 'recoverable':
- return 'restore points';
- case 'sources':
- if (sourceDetailTab() === 'pbs') return 'PBS artifacts';
- if (sourceDetailTab() === 'snapshots') return 'snapshots';
- return 'backup files';
- case 'tasks':
- return 'tasks';
- }
- });
-
- const visibleSnapshotGuestCount = createMemo(() => filteredSnapshotGuests().length);
-
- // Coverage source columns auto-hide when no workload anywhere has that data
- // (computed over the full set, not the filtered view, so columns don't
- // flicker as filters change). A PBS-only fleet drops Archive + Snapshot.
- const coverageHasPbs = createMemo(() =>
- recoveryModel().coverageRows.some((row) => Boolean(row.latestPBS) || row.pbsCount > 0),
+ // The main table is the user's live inventory guests; orphaned backup records
+ // (guest no longer exists) are partitioned out into their own collapsed
+ // section so they don't dominate the top of the list with nameless rows.
+ const liveCoverageRows = createMemo(() =>
+ filteredCoverageRows().filter((row) => !row.isOrphaned),
);
- const coverageHasArchive = createMemo(() =>
- recoveryModel().coverageRows.some((row) => Boolean(row.latestArchive) || row.archiveCount > 0),
+ const orphanedCoverageRows = createMemo(() =>
+ filteredCoverageRows().filter((row) => row.isOrphaned),
);
- const coverageHasSnapshot = createMemo(() =>
- recoveryModel().coverageRows.some(
- (row) => Boolean(row.latestSnapshot) || row.snapshotCount > 0,
- ),
+ const liveTotalCount = createMemo(
+ () => recoveryModel().coverageRows.filter((row) => !row.isOrphaned).length,
);
- const coverageHasTask = createMemo(() =>
- recoveryModel().coverageRows.some((row) => Boolean(row.latestTask)),
+ const visibleLiveCount = createMemo(() => liveCoverageRows().length);
+ const orphanedTotalCount = createMemo(
+ () => recoveryModel().coverageRows.filter((row) => row.isOrphaned).length,
);
- // Node options for the scope filter: the distinct nodes across the workload
- // set, "All nodes" first. Used by every node-bearing view (not PBS, whose
- // artifacts live on the backup server and carry no node). The Node filter is
- // non-inline, so it appears in the FilterBar "+ Filter" menu.
- const nodeOptions = createMemo<FilterSelectOption[]>(() => {
- const nodes = new Set<string>();
- for (const row of recoveryModel().coverageRows) {
- const node = row.workload.node?.trim();
- if (node) nodes.add(node);
- }
- return [
- { value: '', label: 'All nodes' },
- ...[...nodes].sort((a, b) => a.localeCompare(b)).map((node) => ({ value: node, label: node })),
- ];
+ // Health strip counts live guests only — orphaned records are all stale and
+ // would otherwise inflate the "attention" segment with dead data.
+ const liveHealthSummary = createMemo(() => {
+ const live = recoveryModel().coverageRows.filter((row) => !row.isOrphaned);
+ return {
+ current: live.filter((row) => row.posture === 'current').length,
+ attention: live.filter((row) => isCoverageAttention(row.posture)).length,
+ uncovered: live.filter((row) => row.posture === 'uncovered').length,
+ };
});
- // FilterBar catalog for the active view: a Node scope filter (in the
- // "+ Filter" menu) on every node-bearing view, plus the view's status facet
- // as an inline segmented control. Matches the overview/workloads/storage
- // pages. Type and source/property filters land in follow-on commits.
- const buildBackupsFilters = (): FilterDef[] => {
- const statusFilter = (
- id: string,
- label: string,
- options: FilterDef['options'],
- value: FilterDef['value'],
- setValue: FilterDef['setValue'],
- ): FilterDef => ({ id, label, group: 'status', inline: true, options, value, setValue, defaultValue: 'all' });
-
- const filters: FilterDef[] = [];
- const t = tab();
- const sd = sourceDetailTab();
- const isPbs = t === 'sources' && sd === 'pbs';
-
- if (!isPbs) {
- filters.push({
- id: 'node',
- label: 'Node',
- group: 'scope',
- options: nodeOptions,
- value: nodeFilter,
- setValue: setNodeFilter,
- defaultValue: '',
- });
- }
- filters.push({
+ // FilterBar catalog: Node + Type scope filters (in the "+ Filter" menu) and
+ // the posture facet as an inline segmented control, matching the overview /
+ // workloads / storage pages.
+ const buildBackupsFilters = (): FilterDef[] => [
+ {
+ id: 'node',
+ label: 'Node',
+ group: 'scope',
+ options: nodeOptions,
+ value: nodeFilter,
+ setValue: setNodeFilter,
+ defaultValue: '',
+ },
+ {
id: 'type',
label: 'Type',
group: 'scope',
@@ -1082,48 +286,18 @@ export const ProxmoxBackupsTable: Component<{
value: typeFilter,
setValue: setTypeFilter,
defaultValue: '',
- });
-
- if (t === 'coverage') {
- filters.push(
- statusFilter('posture', 'Posture', () => COVERAGE_FILTERS, coverageFilter, (v) =>
- setCoverageFilter(v as CoverageFilterValue),
- ),
- );
- } else if (t === 'recoverable') {
- filters.push(
- statusFilter('source', 'Source', () => RECOVERABLE_FILTERS, recoverableFilter, (v) =>
- setRecoverableFilter(v as RecoverableFilterValue),
- ),
- );
- } else if (t === 'tasks') {
- filters.push(
- statusFilter('task-status', 'Status', () => TASK_STATUS_FILTERS, taskFilter, (v) =>
- setTaskFilter(v as 'all' | 'ok' | 'failed' | 'running'),
- ),
- );
- } else if (isPbs) {
- filters.push(
- statusFilter('pbs-status', 'Status', () => PBS_STATUS_FILTERS, pbsFilter, (v) =>
- setPBSFilter(v as 'all' | 'protected' | 'verified' | 'unverified'),
- ),
- );
- } else if (t === 'sources' && sd === 'snapshots') {
- filters.push(
- statusFilter('snapshot', 'Snapshots', () => SNAPSHOT_FILTERS, snapshotFilter, (v) =>
- setSnapshotFilter(v as SnapshotFilterValue),
- ),
- );
- } else if (t === 'sources' && sd === 'archives' && showArchivePBSColumns()) {
- filters.push(
- statusFilter('archive-status', 'Status', () => ARCHIVE_STATUS_FILTERS, archiveFilter, (v) =>
- setArchiveFilter(v as 'all' | 'protected' | 'verified' | 'unverified'),
- ),
- );
- }
-
- return filters;
- };
+ },
+ {
+ id: 'posture',
+ label: 'Posture',
+ group: 'status',
+ inline: true,
+ options: () => COVERAGE_FILTERS,
+ value: coverageFilter,
+ setValue: (v) => setCoverageFilter(v as CoverageFilterValue),
+ defaultValue: 'all',
+ },
+ ];
return (
<Show
@@ -1160,356 +334,49 @@ export const ProxmoxBackupsTable: Component<{
}
>
<div class="space-y-3">
- <div class="flex flex-wrap items-center gap-1 rounded-md border border-border bg-surface p-1">
- <For each={activeTabs()}>
- {(spec) => (
- <button
- type="button"
- onClick={() => setTab(spec.id)}
- class={`inline-flex min-h-9 items-center gap-1.5 rounded-sm px-3 text-xs font-medium transition-colors ${
- tab() === spec.id
- ? 'bg-surface-hover text-base-content'
- : 'text-muted hover:text-base-content'
- }`}
- aria-pressed={tab() === spec.id}
- >
- {spec.icon()}
- <span>{spec.label}</span>
- <span class="text-[10px] text-muted tabular-nums">
- {spec.id === 'coverage'
- ? recoveryModel().coverageRows.length
- : spec.id === 'recoverable'
- ? recoveryModel().recoverableArtifacts.length
- : spec.id === 'sources'
- ? totalSourceArtifacts()
- : tasks().length}
- </span>
- </button>
- )}
- </For>
- </div>
-
- <Show when={tab() === 'sources'}>
- <div class="flex flex-wrap items-center gap-1 rounded-md border border-border bg-surface p-1">
- <For each={activeSourceDetailTabs()}>
- {(spec) => (
- <button
- type="button"
- onClick={() => setSourceDetailTab(spec.id)}
- class={`inline-flex min-h-8 items-center gap-1.5 rounded-sm px-2.5 text-xs font-medium transition-colors ${
- sourceDetailTab() === spec.id
- ? 'bg-surface-hover text-base-content'
- : 'text-muted hover:text-base-content'
- }`}
- aria-pressed={sourceDetailTab() === spec.id}
- >
- {spec.icon()}
- <span>{spec.label}</span>
- <span class="text-[10px] text-muted tabular-nums">
- {sourceDetailTotal(spec.id)}
- </span>
- </button>
- )}
- </For>
- </div>
- </Show>
-
- <Show when={tab() === 'coverage'}>
- <ProxmoxBackupsCoverageStrip
- title="Workload restore posture"
- tail={
- <span>
- {recoveryModel().coverageSummary.totalWorkloads} workloads ·{' '}
- {recoveryModel().coverageSummary.recoverableArtifacts} recoverable artifacts
- <Show when={recoveryModel().coverageSummary.withPBS > 0}>
- {' · '}
- {recoveryModel().coverageSummary.withPBS} with PBS
- </Show>
- </span>
- }
- segments={[
- {
- key: 'current',
- value: recoveryModel().coverageSummary.current,
- label: 'current',
- toneClass: 'bg-emerald-500',
- },
- {
- key: 'attention',
- value: recoveryModel().coverageSummary.attention,
- label: 'attention',
- toneClass: 'bg-amber-500',
- muted: recoveryModel().coverageSummary.attention === 0,
- },
- {
- key: 'uncovered',
- value: recoveryModel().coverageSummary.uncovered,
- label: 'uncovered',
- toneClass: 'bg-red-500',
- muted: recoveryModel().coverageSummary.uncovered === 0,
- },
- ]}
- />
+ <Show when={(props.servers?.length ?? 0) > 0}>
+ <ProxmoxBackupServersTable servers={props.servers ?? []} />
</Show>
- <Show when={tab() === 'recoverable' && recoveryModel().recoverableArtifacts.length > 0}>
- <BackupActivityChart
- title={
- recoverableMetricMode() === 'volume'
- ? 'Recoverable volume per day'
- : 'Recoverable artifacts per day'
- }
- noun="artifact"
- segmentKinds={RECOVERABLE_SEGMENT_KINDS}
- range={chartRange}
- onRangeChange={setChartRange}
- timeline={recoverableTimeline}
- selectedDateKey={selectedDateKey}
- onToggleDay={toggleDay}
- metricToggle={{ mode: recoverableMetricMode, onChange: setRecoverableMetricMode }}
- />
- <ProxmoxBackupsCoverageStrip
- title="Restore inventory"
- tail={
- <span>
- {recoveryModel().coverageSummary.recoverableArtifacts} artifacts ·{' '}
- {formatBytes(recoveryModel().coverageSummary.totalBytes)} logical
- </span>
- }
- segments={[
- {
- key: 'pbs',
- value: recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'pbs')
- .length,
- label: 'PBS',
- toneClass: 'bg-cyan-500',
- },
- {
- key: 'archives',
- value: recoveryModel().recoverableArtifacts.filter(
- (a) => a.sourceKind === 'archive',
- ).length,
- label: 'archives',
- toneClass: 'bg-blue-500',
- muted:
- recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'archive')
- .length === 0,
- },
- {
- key: 'snapshots',
- value: recoveryModel().recoverableArtifacts.filter(
- (a) => a.sourceKind === 'snapshot',
- ).length,
- label: 'snapshots',
- toneClass: 'bg-violet-500',
- muted:
- recoveryModel().recoverableArtifacts.filter((a) => a.sourceKind === 'snapshot')
- .length === 0,
- },
- ]}
- />
- </Show>
-
- <Show
- when={tab() === 'sources' && sourceDetailTab() === 'pbs' && pbsArtifacts().length > 0}
- >
- <BackupActivityChart
- title={
- pbsMetricMode() === 'volume' ? 'PBS backup volume per day' : 'PBS backups per day'
- }
- noun="artifact"
- segmentKinds={PBS_SEGMENT_KINDS}
- range={chartRange}
- onRangeChange={setChartRange}
- timeline={pbsTimeline}
- selectedDateKey={selectedDateKey}
- onToggleDay={toggleDay}
- metricToggle={{ mode: pbsMetricMode, onChange: setPBSMetricMode }}
- />
- <ProxmoxBackupsCoverageStrip
- title="PBS verification"
- tail={
- <span>
- {pbsCoverage().total} artifacts · {formatBytes(pbsCoverage().totalBytes)} logical
- <Show when={pbsCoverage().namespaceCount > 0}>
- {' · '}
- {pbsCoverage().namespaceCount} namespaces
- </Show>
- <Show when={pbsCoverage().protectedCount > 0}>
- {' · '}
- {pbsCoverage().protectedCount} protected
- </Show>
- </span>
- }
- segments={[
- {
- key: 'verified',
- value: pbsCoverage().verifiedCount,
- label: 'verified',
- toneClass: 'bg-emerald-500',
- },
- {
- key: 'unverified',
- value: pbsCoverage().unverifiedCount,
- label: 'unverified',
- toneClass: 'bg-amber-500',
- muted: pbsCoverage().unverifiedCount === 0,
- },
- ]}
- />
- </Show>
-
- <Show
- when={
- tab() === 'sources' && sourceDetailTab() === 'snapshots' && snapshots().length > 0
+ <ProxmoxBackupsCoverageStrip
+ title="Backup health"
+ tail={
+ <span>
+ {liveTotalCount()} guests ·{' '}
+ {recoveryModel().coverageSummary.recoverableArtifacts} restore points
+ <Show when={recoveryModel().coverageSummary.withPBS > 0}>
+ {' · '}
+ {recoveryModel().coverageSummary.withPBS} with PBS
+ </Show>
+ <Show when={orphanedTotalCount() > 0}>
+ {' · '}
+ {orphanedTotalCount()} orphaned
+ </Show>
+ </span>
}
- >
- <BackupActivityChart
- title="Snapshots per day"
- noun="snapshot"
- segmentKinds={SNAPSHOT_SEGMENT_KINDS}
- range={chartRange}
- onRangeChange={setChartRange}
- timeline={snapshotTimeline}
- selectedDateKey={selectedDateKey}
- onToggleDay={toggleDay}
- />
- <ProxmoxBackupsCoverageStrip
- title="Snapshot coverage"
- tail={
- <span>
- {snapshotCoverage().totalGuests} guests · {snapshotCoverage().totalSnapshots}{' '}
- snapshots
- <Show when={snapshotCoverage().withRamGuests > 0}>
- {' · '}
- {snapshotCoverage().withRamGuests} with RAM
- </Show>
- </span>
- }
- segments={[
- {
- key: 'recent',
- value:
- snapshotCoverage().totalGuests -
- snapshotCoverage().staleGuests -
- snapshotCoverage().ancientGuests,
- label: 'recent (≤30d)',
- toneClass: getBackupAgeBucketPresentation('recent').swatchClass,
- },
- {
- key: 'stale',
- value: snapshotCoverage().staleGuests,
- label: 'stale (30–90d)',
- toneClass: getBackupAgeBucketPresentation('stale').swatchClass,
- muted: snapshotCoverage().staleGuests === 0,
- },
- {
- key: 'ancient',
- value: snapshotCoverage().ancientGuests,
- label: 'ancient (>90d)',
- toneClass: getBackupAgeBucketPresentation('ancient').swatchClass,
- muted: snapshotCoverage().ancientGuests === 0,
- },
- ]}
- />
- </Show>
- <Show when={tab() === 'sources' && sourceDetailTab() === 'archives'}>
- <BackupActivityChart
- title={
- archiveMetricMode() === 'volume' ? 'Backup volume per day' : 'Backup files per day'
- }
- noun="archive"
- segmentKinds={ARCHIVE_SEGMENT_KINDS}
- range={chartRange}
- onRangeChange={setChartRange}
- timeline={archiveTimeline}
- selectedDateKey={selectedDateKey}
- onToggleDay={toggleDay}
- metricToggle={{ mode: archiveMetricMode, onChange: setArchiveMetricMode }}
- />
- <Show when={archiveCoverage().totalGuests > 0}>
- <ProxmoxBackupsCoverageStrip
- title="Backup coverage"
- tail={
- <span>
- {archiveCoverage().totalGuests} guests with archives ·{' '}
- {formatBytes(archiveCoverage().totalBytes)} stored
- </span>
- }
- segments={[
- {
- key: 'current',
- value: archiveCoverage().currentGuests,
- label: 'current (≤7d)',
- toneClass: 'bg-emerald-500',
- },
- {
- key: 'stale',
- value: archiveCoverage().staleGuests,
- label: 'stale (7–30d)',
- toneClass: 'bg-amber-500',
- muted: archiveCoverage().staleGuests === 0,
- },
- {
- key: 'uncovered',
- value: archiveCoverage().uncoveredGuests,
- label: 'uncovered (>30d)',
- toneClass: 'bg-red-500',
- muted: archiveCoverage().uncoveredGuests === 0,
- },
- ]}
- />
- </Show>
- </Show>
- <Show when={tab() === 'tasks'}>
- <BackupActivityChart
- title="Backup tasks per day"
- noun="task"
- segmentKinds={TASK_SEGMENT_KINDS}
- range={chartRange}
- onRangeChange={setChartRange}
- timeline={taskTimeline}
- selectedDateKey={selectedDateKey}
- onToggleDay={toggleDay}
- />
- <Show when={taskOutcome().total > 0}>
- <ProxmoxBackupsCoverageStrip
- title="Task outcomes"
- tail={
- <Show when={taskDurationBaselineSeconds() > 0}>
- <span>
- median duration{' '}
- <span class="font-mono tabular-nums text-base-content">
- {formatDurationFromSeconds(taskDurationBaselineSeconds())}
- </span>
- </span>
- </Show>
- }
- segments={[
- {
- key: 'ok',
- value: taskOutcome().ok,
- label: 'OK',
- toneClass: 'bg-emerald-500',
- },
- {
- key: 'failed',
- value: taskOutcome().failed,
- label: 'failed',
- toneClass: 'bg-red-500',
- muted: taskOutcome().failed === 0,
- },
- {
- key: 'running',
- value: taskOutcome().running,
- label: 'running',
- toneClass: 'bg-amber-500',
- muted: taskOutcome().running === 0,
- },
- ]}
- />
- </Show>
- </Show>
+ segments={[
+ {
+ key: 'current',
+ value: liveHealthSummary().current,
+ label: 'current',
+ toneClass: 'bg-emerald-500',
+ },
+ {
+ key: 'attention',
+ value: liveHealthSummary().attention,
+ label: 'attention',
+ toneClass: 'bg-amber-500',
+ muted: liveHealthSummary().attention === 0,
+ },
+ {
+ key: 'uncovered',
+ value: liveHealthSummary().uncovered,
+ label: 'uncovered',
+ toneClass: 'bg-red-500',
+ muted: liveHealthSummary().uncovered === 0,
+ },
+ ]}
+ />
<FilterBar
role="group"
@@ -1518,155 +385,80 @@ export const ProxmoxBackupsTable: Component<{
search={{
value: search,
setValue: setSearch,
- placeholder: 'Search backups by workload, node, source, or status',
+ placeholder: 'Search backups by workload, node, or status',
}}
filters={buildBackupsFilters()}
savedViewsKey="proxmox-backups"
- searchTrailing={
- <Show when={selectedDateKey() !== null}>
- <button
- type="button"
- onClick={() => setSelectedDateKey(null)}
- class="inline-flex items-center gap-1 rounded-full border border-blue-300 bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700 transition-colors hover:bg-blue-100 dark:border-blue-700 dark:bg-blue-900/30 dark:text-blue-200 dark:hover:bg-blue-900/50"
- aria-label="Clear date filter"
- >
- <span class="uppercase tracking-wide text-[9px] text-blue-600 dark:text-blue-300">
- Date
- </span>
- <span class="font-mono tabular-nums">
- {getRecoveryFilterDateLabel(selectedDateKey()!)}
- </span>
- <span aria-hidden="true">×</span>
- </button>
- </Show>
- }
viewOptionsTrailing={
<span class="whitespace-nowrap text-xs font-medium text-muted">
<Show
- when={tab() === 'sources' && sourceDetailTab() === 'snapshots'}
- fallback={
- <Show
- when={visibleForTab() !== totalForTab()}
- fallback={
- <>
- {totalForTab()} {activeTabNoun()}
- </>
- }
- >
- {visibleForTab()} of {totalForTab()} {activeTabNoun()}
- </Show>
- }
+ when={visibleLiveCount() !== liveTotalCount()}
+ fallback={<>{liveTotalCount()} guests</>}
>
- <Show
- when={visibleSnapshotGuestCount() !== snapshotCoverage().totalGuests}
- fallback={<>{snapshotCoverage().totalGuests} guests</>}
- >
- {visibleSnapshotGuestCount()} of {snapshotCoverage().totalGuests} guests
- </Show>
+ {visibleLiveCount()} of {liveTotalCount()} guests
</Show>
</span>
}
/>
- <Show when={tab() === 'coverage'}>
- <ProxmoxCoverageTable
- rows={filteredCoverageRows()}
- hasAnyRows={recoveryModel().coverageRows.length > 0}
- emptyIcon={props.emptyIcon}
- emptyTitle={tabSpecFor('coverage').emptyTitle}
- emptyDescription={tabSpecFor('coverage').emptyDescription}
- sortKey={coverageSortKey}
- sortDirection={coverageSortDirection}
- onSort={handleCoverageSort}
- expandedKeys={expandedCoverageRows()}
- onToggleExpand={toggleCoverageExpansion}
- showPbsColumn={coverageHasPbs()}
- showArchiveColumn={coverageHasArchive()}
- showSnapshotColumn={coverageHasSnapshot()}
- showTaskColumn={coverageHasTask()}
- />
- </Show>
-
- <Show when={tab() === 'recoverable'}>
- <ProxmoxRecoverableTable
- artifacts={filteredRecoverableArtifacts()}
- hasAnyArtifacts={recoveryModel().recoverableArtifacts.length > 0}
- emptyIcon={props.emptyIcon}
- emptyTitle={tabSpecFor('recoverable').emptyTitle}
- emptyDescription={tabSpecFor('recoverable').emptyDescription}
- sortKey={recoverableSortKey}
- sortDirection={recoverableSortDirection}
- onSort={handleRecoverableSort}
- sizeMaxBytes={recoverableSizeMaxBytes()}
- />
- </Show>
-
- <Show when={tab() === 'sources' && sourceDetailTab() === 'pbs'}>
- <ProxmoxPbsTable
- backups={filteredPBSBackups()}
- hasAnyArtifacts={pbsArtifacts().length > 0}
- errorMessage={(pbsBackups.error as Error | undefined)?.message}
- isLoading={pbsBackups() === undefined}
- onRefresh={() => void refetchPBS()}
- emptyIcon={props.emptyIcon}
- emptyTitle={sourceDetailSpecFor('pbs').emptyTitle}
- emptyDescription={sourceDetailSpecFor('pbs').emptyDescription}
- sortKey={pbsSortKey}
- sortDirection={pbsSortDirection}
- onSort={handlePBSSort}
- sizeMaxBytes={pbsSizeMaxBytes()}
- />
- </Show>
-
- <Show when={tab() === 'sources' && sourceDetailTab() === 'snapshots'}>
- <ProxmoxSnapshotsTable
- guests={filteredSnapshotGuests()}
- hasAnySnapshots={snapshots().length > 0}
- emptyIcon={props.emptyIcon}
- emptyTitle={sourceDetailSpecFor('snapshots').emptyTitle}
- emptyDescription={sourceDetailSpecFor('snapshots').emptyDescription}
- sortKey={snapshotSortKey}
- sortDirection={snapshotSortDirection}
- onSort={handleSnapshotSort}
- showSizeColumn={showSnapshotSizeColumn()}
- showRAMColumn={showSnapshotRAMColumn()}
- columnCount={snapshotColumnCount()}
- expandedKeys={expandedGuests()}
- onToggleExpand={toggleGuestExpansion}
- nowMs={nowMs()}
- />
- </Show>
-
- <Show when={tab() === 'sources' && sourceDetailTab() === 'archives'}>
- <ProxmoxArchivesTable
- archives={filteredArchives()}
- hasAnyArchives={archives().length > 0}
- emptyIcon={props.emptyIcon}
- emptyTitle={sourceDetailSpecFor('archives').emptyTitle}
- emptyDescription={sourceDetailSpecFor('archives').emptyDescription}
- sortKey={archiveSortKey}
- sortDirection={archiveSortDirection}
- onSort={handleArchiveSort}
- showPBSColumns={showArchivePBSColumns()}
- sizeMaxBytes={archiveSizeMaxBytes()}
- nowMs={nowMs()}
- />
- </Show>
+ <ProxmoxCoverageTable
+ rows={liveCoverageRows()}
+ hasAnyRows={liveTotalCount() > 0}
+ emptyIcon={props.emptyIcon}
+ emptyTitle="No workload coverage"
+ emptyDescription="VM and container restore posture will appear here once backup data exists."
+ sortKey={coverageSortKey}
+ sortDirection={coverageSortDirection}
+ onSort={handleCoverageSort}
+ expandedKeys={expandedCoverageRows()}
+ onToggleExpand={toggleCoverageExpansion}
+ showPbsColumn={coverageHasPbs()}
+ showArchiveColumn={coverageHasArchive()}
+ showSnapshotColumn={coverageHasSnapshot()}
+ showTaskColumn={coverageHasTask()}
+ />
- <Show when={tab() === 'tasks'}>
- <ProxmoxTasksTable
- tasks={filteredTasks()}
- hasAnyTasks={tasks().length > 0}
- emptyIcon={props.emptyIcon}
- emptyTitle={tabSpecFor('tasks').emptyTitle}
- emptyDescription={tabSpecFor('tasks').emptyDescription}
- sortKey={taskSortKey}
- sortDirection={taskSortDirection}
- onSort={handleTaskSort}
- showSizeColumn={showTaskSizeColumn()}
- showErrorColumn={showTaskErrorColumn()}
- durationBaselineSeconds={taskDurationBaselineSeconds()}
- />
+ <Show when={orphanedTotalCount() > 0}>
+ <div class="rounded-lg border border-border-subtle bg-surface-alt/25">
+ <button
+ type="button"
+ onClick={() => setShowOrphaned((v) => !v)}
+ class="flex w-full items-center justify-between gap-2 px-3 py-2 text-left"
+ aria-expanded={showOrphaned()}
+ >
+ <span class="flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-muted">
+ <ChevronRightIcon
+ class={`h-3.5 w-3.5 transition-transform ${showOrphaned() ? 'rotate-90' : ''}`}
+ aria-hidden="true"
+ />
+ {orphanedTotalCount()} orphaned{' '}
+ {orphanedTotalCount() === 1 ? 'backup' : 'backups'}
+ </span>
+ <span class="text-[11px] text-muted">
+ guest no longer exists in inventory
+ </span>
+ </button>
+ <Show when={showOrphaned()}>
+ <div class="border-t border-border-subtle p-2">
+ <ProxmoxCoverageTable
+ rows={orphanedCoverageRows()}
+ hasAnyRows={orphanedTotalCount() > 0}
+ emptyIcon={props.emptyIcon}
+ emptyTitle="No orphaned backups"
+ emptyDescription="Backups whose guest no longer exists will appear here."
+ sortKey={coverageSortKey}
+ sortDirection={coverageSortDirection}
+ onSort={handleCoverageSort}
+ expandedKeys={expandedCoverageRows()}
+ onToggleExpand={toggleCoverageExpansion}
+ showPbsColumn={coverageHasPbs()}
+ showArchiveColumn={coverageHasArchive()}
+ showSnapshotColumn={coverageHasSnapshot()}
+ showTaskColumn={coverageHasTask()}
+ />
+ </div>
+ </Show>
+ </div>
</Show>
</div>
</Show>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index 17bf7ae34f..670038c7e1 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -43,6 +43,23 @@ const coveragePostureVariant = (
return 'warning';
};
+// Colour marks the exception, not the baseline: healthy rows keep neutral text
+// (the green dot already signals "fine"), while attention/danger words take an
+// amber/red tone so a mixed fleet is scannable at a glance. Matches the
+// datastore-usage tones on the Backup servers table and the status-word colour
+// pattern in the Replication table.
+const statusWordToneClass = (variant: StatusIndicatorVariant): string => {
+ if (variant === 'danger') return 'text-red-600 dark:text-red-300';
+ if (variant === 'warning') return 'text-amber-600 dark:text-amber-300';
+ return 'text-base-content';
+};
+
+const taskWordVariant = (label: string): StatusIndicatorVariant => {
+ if (label === 'Failed') return 'danger';
+ if (label === 'OK') return 'success';
+ return 'warning';
+};
+
// "Workload coverage" table: one row per workload answering "does this have a
// backup?" across PBS / archive / snapshot, each expanding to its restore
// evidence. Presentational — the parent owns the filtered+sorted memo, shared
@@ -240,7 +257,11 @@ export function ProxmoxCoverageTable(props: {
title={getWorkloadRecoveryPostureLabel(row.posture)}
ariaHidden
/>
- <span class="truncate text-[11px] font-medium text-base-content">
+ <span
+ class={`truncate text-[11px] font-medium ${statusWordToneClass(
+ coveragePostureVariant(row.posture),
+ )}`}
+ >
{getWorkloadRecoveryPostureLabel(row.posture)}
</span>
</div>
@@ -319,7 +340,13 @@ export function ProxmoxCoverageTable(props: {
title={task().label}
ariaHidden
/>
- <span class="truncate">{task().label}</span>
+ <span
+ class={`truncate ${statusWordToneClass(
+ taskWordVariant(task().label),
+ )}`}
+ >
+ {task().label}
+ </span>
</div>
)}
</Show>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
index acc26c5a20..3d2666b9f5 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxPageSurface.tsx
@@ -164,8 +164,8 @@ export function ProxmoxPageSurface() {
<Show when={activeTab() === 'backups'}>
<ProxmoxBackupsTable
emptyIcon={<ProxmoxIcon class="h-6 w-6 text-slate-400" />}
- hasPBS={model().pbs.length > 0}
workloads={model().guests}
+ servers={model().pbs}
/>
</Show>
<Show when={activeTab() === 'ceph'}>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxPbsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxPbsTable.tsx
deleted file mode 100644
index e6a162f5de..0000000000
--- a/frontend-modern/src/features/proxmox/ProxmoxPbsTable.tsx
+++ /dev/null
@@ -1,262 +0,0 @@
-import { For, Show, type Accessor, type JSX } from 'solid-js';
-
-import { Card } from '@/components/shared/Card';
-import { EmptyState } from '@/components/shared/EmptyState';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
-import { TableCard } from '@/components/shared/TableCard';
-import { formatBytes, formatRelativeTime } from '@/utils/format';
-import {
- PLATFORM_TABLE_BODY_CLASS,
- PLATFORM_TABLE_CARD_CLASS,
- PLATFORM_TABLE_HEADER_ROW_CLASS,
- getPlatformTableCellClassForKind,
- getPlatformTableHeadClassForKind,
-} from '@/features/platformPage/sharedPlatformPage';
-import type { PBSBackup } from '@/types/api';
-
-import { pbsRepositoryLabel, pbsWorkloadLabel, type PBSSortKey } from './proxmoxBackupsTableModel';
-import { RowMetricBar, SortableHead } from './proxmoxBackupsTableShared';
-
-const hasValidBackupTime = (backup: PBSBackup): boolean =>
- !!backup.backupTime && Number.isFinite(Date.parse(backup.backupTime));
-
-// "Source details > PBS artifacts" table: every Proxmox Backup Server snapshot
-// with repository, age, size, verification, and protection. Presentational —
-// the parent owns the filtered + sorted memo, shared filters, and the PBS
-// resource; this component just renders its error / loading / empty / table
-// states. table-fixed + colgroup keeps columns from ballooning on wide views.
-export function ProxmoxPbsTable(props: {
- backups: PBSBackup[];
- hasAnyArtifacts: boolean;
- errorMessage?: string;
- isLoading: boolean;
- onRefresh: () => void;
- emptyIcon: JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
- sortKey: Accessor<PBSSortKey>;
- sortDirection: Accessor<'asc' | 'desc'>;
- onSort: (key: PBSSortKey) => void;
- sizeMaxBytes: number;
-}) {
- return (
- <Show
- when={!props.errorMessage}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title="Could not load PBS artifacts"
- description={props.errorMessage ?? 'Refresh to retry.'}
- actions={
- <button
- type="button"
- onClick={() => props.onRefresh()}
- class="inline-flex min-h-10 items-center rounded-md border border-border px-3 py-2 text-sm font-medium hover:bg-surface-hover"
- >
- Refresh
- </button>
- }
- />
- </Card>
- }
- >
- <Show
- when={!props.isLoading}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title="Loading PBS artifacts"
- description="Reading deduplicated backup snapshots from Proxmox Backup Server."
- />
- </Card>
- }
- >
- <Show
- when={props.backups.length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={
- !props.hasAnyArtifacts ? props.emptyTitle : 'No PBS artifacts match current filters'
- }
- description={
- !props.hasAnyArtifacts
- ? props.emptyDescription
- : 'Adjust the search or status filter to see more PBS artifacts.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[1050px] table-fixed text-xs">
- <colgroup>
- <col style={{ width: '15%' }} />
- <col style={{ width: '17%' }} />
- <col style={{ width: '13%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '15%' }} />
- <col style={{ width: '10%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '8%' }} />
- </colgroup>
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Workload"
- sortKey="workload"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('name')}
- />
- <SortableHead
- label="Repository"
- sortKey="repository"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <TableHead class={getPlatformTableHeadClassForKind('text')}>Instance</TableHead>
- <SortableHead
- label="Created"
- sortKey="created"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Size"
- sortKey="size"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="center"
- headClass={getPlatformTableHeadClassForKind('metric-bar')}
- />
- <SortableHead
- label="Verified"
- sortKey="verified"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Protection"
- sortKey="protected"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <TableHead class={getPlatformTableHeadClassForKind('text')}>Files</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={props.backups}>
- {(backup) => (
- <TableRow class="hover:bg-surface-hover">
- <TableCell
- class={`${getPlatformTableCellClassForKind('name')} text-base-content truncate font-semibold`}
- >
- {pbsWorkloadLabel(backup)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content truncate font-mono text-[11px]`}
- title={pbsRepositoryLabel(backup)}
- >
- {pbsRepositoryLabel(backup)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content truncate font-mono text-[11px]`}
- title={backup.instance}
- >
- {backup.instance || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- <Show
- when={hasValidBackupTime(backup)}
- fallback={<span class="text-muted">—</span>}
- >
- {formatRelativeTime(backup.backupTime, { compact: true })}
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
- >
- <RowMetricBar
- valuePct={
- props.sizeMaxBytes > 0 ? (backup.size / props.sizeMaxBytes) * 100 : 0
- }
- fillClass="bg-blue-500/40 dark:bg-blue-500/40"
- label={formatBytes(backup.size)}
- tooltip={`${formatBytes(backup.size)} (relative to largest PBS artifact in view)`}
- />
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={backup.verified}
- fallback={
- <span class="text-amber-600 dark:text-amber-300">Unverified</span>
- }
- >
- <span class="inline-flex items-center rounded-sm bg-emerald-100 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-200">
- Verified
- </span>
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={backup.protected}
- fallback={<span class="text-muted">Unprotected</span>}
- >
- <span class="inline-flex items-center rounded-sm bg-blue-100 px-1.5 py-0.5 text-[10px] font-semibold text-blue-700 dark:bg-blue-900/40 dark:text-blue-200">
- Protected
- </span>
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span
- class="inline-block max-w-[16rem] truncate"
- title={(backup.files ?? []).join(', ')}
- >
- {(backup.files ?? []).length > 0 ? `${backup.files.length} files` : '—'}
- </span>
- </TableCell>
- </TableRow>
- )}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
- </Show>
- </Show>
- );
-}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
deleted file mode 100644
index 042f4107ec..0000000000
--- a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
+++ /dev/null
@@ -1,218 +0,0 @@
-import { For, Show, type Accessor, type JSX } from 'solid-js';
-
-import { Card } from '@/components/shared/Card';
-import { EmptyState } from '@/components/shared/EmptyState';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
-import { TableCard } from '@/components/shared/TableCard';
-import { formatBytes, formatRelativeTime } from '@/utils/format';
-import {
- PLATFORM_TABLE_BODY_CLASS,
- PLATFORM_TABLE_CARD_CLASS,
- PLATFORM_TABLE_HEADER_ROW_CLASS,
- getPlatformTableCellClassForKind,
- getPlatformTableHeadClassForKind,
-} from '@/features/platformPage/sharedPlatformPage';
-
-import type { RecoverableArtifact } from './proxmoxBackupRecoveryModel';
-import type { RecoverableSortKey } from './proxmoxBackupsTableModel';
-import {
- ArtifactSourceBadge,
- ArtifactStateBadge,
- RowMetricBar,
- SortableHead,
- artifactStateLabel,
-} from './proxmoxBackupsTableShared';
-
-// "Restore points" table: every recoverable artifact (PBS / archive / snapshot)
-// across sources in one flat, sortable list. Presentational only — the parent
-// owns the filtered + sorted memo and the shared search / day / source filters.
-// Single-line rows: the workload identity (type/vmid) is already in the label.
-export function ProxmoxRecoverableTable(props: {
- artifacts: RecoverableArtifact[];
- hasAnyArtifacts: boolean;
- emptyIcon: JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
- sortKey: Accessor<RecoverableSortKey>;
- sortDirection: Accessor<'asc' | 'desc'>;
- onSort: (key: RecoverableSortKey) => void;
- sizeMaxBytes: number;
-}) {
- return (
- <Show
- when={props.artifacts.length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={
- !props.hasAnyArtifacts
- ? props.emptyTitle
- : 'No recoverable artifacts match current filters'
- }
- description={
- !props.hasAnyArtifacts
- ? props.emptyDescription
- : 'Adjust the search, source filter, or selected day to see more artifacts.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[1150px] table-fixed text-xs">
- {/* table-fixed + colgroup so columns share the row width rather than
- dumping all the slack into the trailing Details column on wide
- viewports. */}
- <colgroup>
- <col style={{ width: '15%' }} />
- <col style={{ width: '7%' }} />
- <col style={{ width: '8%' }} />
- <col style={{ width: '17%' }} />
- <col style={{ width: '10%' }} />
- <col style={{ width: '12%' }} />
- <col style={{ width: '9%' }} />
- <col style={{ width: '22%' }} />
- </colgroup>
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Workload"
- sortKey="workload"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('name')}
- />
- <TableHead class={getPlatformTableHeadClassForKind('numeric-value')}>VMID</TableHead>
- <SortableHead
- label="Source"
- sortKey="source"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Location"
- sortKey="location"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Created"
- sortKey="created"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Size"
- sortKey="size"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="center"
- headClass={getPlatformTableHeadClassForKind('metric-bar')}
- />
- <SortableHead
- label="State"
- sortKey="state"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <TableHead class={getPlatformTableHeadClassForKind('text')}>Details</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={props.artifacts}>
- {(artifact) => (
- <TableRow class="hover:bg-surface-hover">
- <TableCell
- class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
- >
- <div class="min-w-0">
- <div class="truncate font-semibold">
- {artifact.workload.name || artifact.workload.label}
- </div>
- </div>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted font-mono text-[11px] tabular-nums`}
- >
- {artifact.workload.vmid || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <ArtifactSourceBadge artifact={artifact} />
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span class="inline-block max-w-[16rem] truncate" title={artifact.location}>
- {artifact.location}
- </span>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- {formatRelativeTime(artifact.createdAt, { compact: true })}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
- >
- <Show
- when={artifact.size && artifact.size > 0}
- fallback={<span class="text-muted">No size</span>}
- >
- <RowMetricBar
- valuePct={
- props.sizeMaxBytes > 0 && artifact.size
- ? (artifact.size / props.sizeMaxBytes) * 100
- : 0
- }
- fillClass="bg-blue-500/40 dark:bg-blue-500/40"
- label={formatBytes(artifact.size ?? 0)}
- tooltip={`${formatBytes(artifact.size ?? 0)} (relative to largest artifact in view)`}
- />
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <ArtifactStateBadge artifact={artifact} label={artifactStateLabel(artifact)} />
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <span class="inline-block max-w-[20rem] truncate" title={artifact.detail}>
- {artifact.detail || '—'}
- </span>
- </TableCell>
- </TableRow>
- )}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
- );
-}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxSnapshotsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxSnapshotsTable.tsx
deleted file mode 100644
index 92df5718f5..0000000000
--- a/frontend-modern/src/features/proxmox/ProxmoxSnapshotsTable.tsx
+++ /dev/null
@@ -1,318 +0,0 @@
-import { For, Show, type Accessor, type JSX } from 'solid-js';
-import ChevronRightIcon from 'lucide-solid/icons/chevron-right';
-
-import { Card } from '@/components/shared/Card';
-import { EmptyState } from '@/components/shared/EmptyState';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
-import { TableCard } from '@/components/shared/TableCard';
-import { formatBytes, formatRelativeTime } from '@/utils/format';
-import {
- PLATFORM_TABLE_BODY_CLASS,
- PLATFORM_TABLE_CARD_CLASS,
- PLATFORM_TABLE_HEADER_ROW_CLASS,
- getPlatformTableCellClassForKind,
- getPlatformTableHeadClassForKind,
-} from '@/features/platformPage/sharedPlatformPage';
-
-import { classifySnapshotRowAge } from './proxmoxBackupSummaryPresentation';
-import {
- guestLabel,
- type SnapshotGuestRow,
- type SnapshotSortKey,
-} from './proxmoxBackupsTableModel';
-import { SortableHead } from './proxmoxBackupsTableShared';
-
-// "Source details > Snapshots" table: one row per guest with its newest-snapshot
-// age, count, total size, and RAM marker; each row expands to the guest's
-// individual snapshots. Presentational — the parent owns the filtered+sorted
-// memo, shared filters, and the expansion set. table-fixed + a weighted
-// colgroup keeps the outer columns from ballooning (the inner per-snapshot
-// table stays content-sized).
-export function ProxmoxSnapshotsTable(props: {
- guests: SnapshotGuestRow[];
- hasAnySnapshots: boolean;
- emptyIcon: JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
- sortKey: Accessor<SnapshotSortKey>;
- sortDirection: Accessor<'asc' | 'desc'>;
- onSort: (key: SnapshotSortKey) => void;
- showSizeColumn: boolean;
- showRAMColumn: boolean;
- columnCount: number;
- expandedKeys: ReadonlySet<string>;
- onToggleExpand: (key: string) => void;
- nowMs: number;
-}) {
- const visibleColumns = () => [
- { id: 'guest', weight: 24 },
- { id: 'node', weight: 16 },
- { id: 'latest', weight: 18 },
- { id: 'count', weight: 12 },
- ...(props.showSizeColumn ? [{ id: 'size', weight: 16 }] : []),
- ...(props.showRAMColumn ? [{ id: 'ram', weight: 14 }] : []),
- ];
- const totalColumnWeight = () =>
- visibleColumns().reduce((sum, column) => sum + column.weight, 0);
-
- return (
- <Show
- when={props.guests.length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={
- !props.hasAnySnapshots ? props.emptyTitle : 'No snapshots match current filters'
- }
- description={
- !props.hasAnySnapshots
- ? props.emptyDescription
- : 'Adjust the search or filters to see more snapshots.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[900px] table-fixed text-xs">
- <colgroup>
- <For each={visibleColumns()}>
- {(column) => (
- <col style={{ width: `${(column.weight / totalColumnWeight()) * 100}%` }} />
- )}
- </For>
- </colgroup>
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Guest"
- sortKey="guest"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('name')}
- />
- <SortableHead
- label="Node"
- sortKey="node"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Latest"
- sortKey="latest"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Snapshots"
- sortKey="count"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <Show when={props.showSizeColumn}>
- <SortableHead
- label="Total size"
- sortKey="size"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- </Show>
- <Show when={props.showRAMColumn}>
- <TableHead class={getPlatformTableHeadClassForKind('text')}>RAM</TableHead>
- </Show>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={props.guests}>
- {(row) => {
- const isExpanded = () => props.expandedKeys.has(row.key);
- const rowAge = classifySnapshotRowAge(row.newestMs, props.nowMs);
- return (
- <>
- <TableRow
- class="cursor-pointer hover:bg-surface-hover"
- onClick={() => props.onToggleExpand(row.key)}
- >
- <TableCell
- class={`${getPlatformTableCellClassForKind('name')} text-base-content`}
- >
- <div class="flex items-center gap-2">
- <ChevronRightIcon
- class={`h-3.5 w-3.5 shrink-0 text-muted transition-transform ${
- isExpanded() ? 'rotate-90' : ''
- }`}
- aria-hidden="true"
- />
- <span class="font-semibold">{guestLabel(row.type, row.vmid)}</span>
- </div>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content font-mono text-[11px]`}
- >
- {row.node || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- <Show
- when={row.newestMs !== undefined}
- fallback={<span class="text-muted">—</span>}
- >
- <div class="flex items-center justify-end gap-2">
- <span
- class={`h-1.5 w-1.5 shrink-0 rounded-full ${rowAge.swatchClass}`}
- aria-hidden="true"
- title={`Newest snapshot: ${rowAge.label}`}
- />
- <span>{formatRelativeTime(row.newestMs, { compact: true })}</span>
- </div>
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
- >
- {row.count}
- </TableCell>
- <Show when={props.showSizeColumn}>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
- >
- <Show
- when={row.totalBytes > 0}
- fallback={<span class="text-muted">—</span>}
- >
- {formatBytes(row.totalBytes)}
- </Show>
- </TableCell>
- </Show>
- <Show when={props.showRAMColumn}>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={row.withRamCount > 0}
- fallback={<span class="text-muted">—</span>}
- >
- <span class="inline-flex items-center rounded-sm bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold text-violet-700 dark:bg-violet-900/40 dark:text-violet-200">
- {row.withRamCount} with RAM
- </span>
- </Show>
- </TableCell>
- </Show>
- </TableRow>
- <Show when={isExpanded()}>
- <TableRow class="bg-surface-alt/40">
- <TableCell class="px-2 py-2" colspan={props.columnCount}>
- <div class="overflow-hidden">
- <table class="w-full text-[11px]">
- <thead>
- <tr class="bg-surface-alt text-muted">
- <th class="px-2 py-0.5 text-left font-medium">Name</th>
- <th class="px-2 py-0.5 text-left font-medium">Parent</th>
- <th class="px-2 py-0.5 text-right font-medium">Captured</th>
- <Show when={props.showSizeColumn}>
- <th class="px-2 py-0.5 text-right font-medium">Size</th>
- </Show>
- <Show when={props.showRAMColumn}>
- <th class="px-2 py-0.5 text-left font-medium">RAM</th>
- </Show>
- </tr>
- </thead>
- <tbody class="divide-y divide-border-subtle">
- <For each={row.snapshots}>
- {(snap) => {
- const age = classifySnapshotRowAge(snap.time, props.nowMs);
- return (
- <tr class="hover:bg-surface-hover">
- <td class="px-2 py-1">
- <div class="flex items-center gap-2">
- <span
- class={`h-1.5 w-1.5 shrink-0 rounded-full ${age.swatchClass}`}
- aria-hidden="true"
- title={`Age: ${age.label}`}
- />
- <div class="min-w-0">
- <div class="font-medium text-base-content">
- {snap.name || '—'}
- </div>
- <Show when={!!snap.description?.trim()}>
- <div
- class="truncate max-w-[24rem] text-[10px] text-muted"
- title={snap.description}
- >
- {snap.description}
- </div>
- </Show>
- </div>
- </div>
- </td>
- <td class="px-2 py-1 font-mono text-[10px] text-muted">
- {snap.parent?.trim() || '—'}
- </td>
- <td class="px-2 py-1 text-right text-base-content">
- {formatRelativeTime(snap.time, { compact: true })}
- </td>
- <Show when={props.showSizeColumn}>
- <td class="px-2 py-1 text-right tabular-nums text-base-content">
- <Show
- when={snap.sizeBytes && snap.sizeBytes > 0}
- fallback={<span class="text-muted">—</span>}
- >
- {formatBytes(snap.sizeBytes ?? 0)}
- </Show>
- </td>
- </Show>
- <Show when={props.showRAMColumn}>
- <td class="px-2 py-1">
- <Show
- when={snap.vmstate}
- fallback={<span class="text-muted">—</span>}
- >
- <span class="inline-flex items-center rounded-sm bg-violet-100 px-1.5 py-0.5 text-[10px] font-semibold text-violet-700 dark:bg-violet-900/40 dark:text-violet-200">
- with RAM
- </span>
- </Show>
- </td>
- </Show>
- </tr>
- );
- }}
- </For>
- </tbody>
- </table>
- </div>
- </TableCell>
- </TableRow>
- </Show>
- </>
- );
- }}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
- );
-}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxTasksTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxTasksTable.tsx
deleted file mode 100644
index f18876e4cb..0000000000
--- a/frontend-modern/src/features/proxmox/ProxmoxTasksTable.tsx
+++ /dev/null
@@ -1,264 +0,0 @@
-import { For, Show, type Accessor, type JSX } from 'solid-js';
-
-import { Card } from '@/components/shared/Card';
-import { EmptyState } from '@/components/shared/EmptyState';
-import { StatusDot } from '@/components/shared/StatusDot';
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from '@/components/shared/Table';
-import { TableCard } from '@/components/shared/TableCard';
-import { formatBytes, formatRelativeTime } from '@/utils/format';
-import {
- PLATFORM_TABLE_BODY_CLASS,
- PLATFORM_TABLE_CARD_CLASS,
- PLATFORM_TABLE_HEADER_ROW_CLASS,
- getPlatformTableCellClassForKind,
- getPlatformTableHeadClassForKind,
-} from '@/features/platformPage/sharedPlatformPage';
-import type { BackupTask } from '@/types/api';
-
-import { taskDurationSeconds } from './proxmoxBackupSummaryPresentation';
-import {
- classifyTaskStatus,
- formatDuration,
- formatDurationFromSeconds,
- guestLabel,
- type TaskSortKey,
-} from './proxmoxBackupsTableModel';
-import { RowMetricBar, SortableHead } from './proxmoxBackupsTableShared';
-
-// "Job history" table: one row per backup task with status, guest, node, start
-// time, a median-anchored duration bar, and optional size / error columns.
-// Presentational only — the parent owns the filtered + sorted memo, the shared
-// search / status filters, and the duration baseline.
-export function ProxmoxTasksTable(props: {
- tasks: BackupTask[];
- hasAnyTasks: boolean;
- emptyIcon: JSX.Element;
- emptyTitle: string;
- emptyDescription: string;
- sortKey: Accessor<TaskSortKey>;
- sortDirection: Accessor<'asc' | 'desc'>;
- onSort: (key: TaskSortKey) => void;
- showSizeColumn: boolean;
- showErrorColumn: boolean;
- durationBaselineSeconds: number;
-}) {
- // table-fixed + weighted colgroup so columns share the row width instead of
- // dumping all the slack into the last column (the Error column ballooned to
- // ~440px of blank when no rows had errors). Weights are relative; each
- // visible column resolves to weight / total, matching the platform tables.
- const visibleColumns = () => [
- { id: 'status', weight: 11 },
- { id: 'guest', weight: 13 },
- { id: 'node', weight: 12 },
- { id: 'started', weight: 13 },
- { id: 'duration', weight: 21 },
- ...(props.showSizeColumn ? [{ id: 'size', weight: 12 }] : []),
- ...(props.showErrorColumn ? [{ id: 'error', weight: 18 }] : []),
- ];
- const totalColumnWeight = () =>
- visibleColumns().reduce((sum, column) => sum + column.weight, 0);
-
- return (
- <Show
- when={props.tasks.length > 0}
- fallback={
- <Card padding="lg">
- <EmptyState
- icon={props.emptyIcon}
- title={!props.hasAnyTasks ? props.emptyTitle : 'No tasks match current filters'}
- description={
- !props.hasAnyTasks
- ? props.emptyDescription
- : 'Adjust the search or status filter to see more tasks.'
- }
- />
- </Card>
- }
- >
- <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
- <Table class="min-w-[1000px] table-fixed text-xs">
- <colgroup>
- <For each={visibleColumns()}>
- {(column) => (
- <col style={{ width: `${(column.weight / totalColumnWeight()) * 100}%` }} />
- )}
- </For>
- </colgroup>
- <TableHeader>
- <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
- <SortableHead
- label="Status"
- sortKey="status"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Guest"
- sortKey="guest"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Node"
- sortKey="node"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Started"
- sortKey="started"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- <SortableHead
- label="Duration"
- sortKey="duration"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="center"
- headClass={getPlatformTableHeadClassForKind('metric-bar')}
- />
- <Show when={props.showSizeColumn}>
- <SortableHead
- label="Size"
- sortKey="size"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="right"
- headClass={getPlatformTableHeadClassForKind('numeric-value')}
- />
- </Show>
- <Show when={props.showErrorColumn}>
- <TableHead class={getPlatformTableHeadClassForKind('text')}>Error</TableHead>
- </Show>
- </TableRow>
- </TableHeader>
- <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
- <For each={props.tasks}>
- {(task) => {
- const classify = classifyTaskStatus(task.status);
- const durationSec = taskDurationSeconds(task);
- // Anchor the bar so the median sits at ~50%.
- const durationBarPct = () => {
- const baseline = props.durationBaselineSeconds;
- if (!durationSec || baseline <= 0) return 0;
- return (durationSec / (baseline * 2)) * 100;
- };
- // Canonical Pulse metric tones (60% alpha) — same palette
- // Storage and Ceph row bars use via getMetricColorClass.
- // Cap at `warning` (soft yellow) rather than going to red
- // for the worst case: a slow backup task is a perf
- // outlier, not a failure. Failure is already conveyed by
- // the Status column. Two tiers — normal / slow — keeps
- // the column calm instead of screaming red on every
- // long-running VM backup.
- const durationToneClass = () => {
- const baseline = props.durationBaselineSeconds;
- if (!durationSec || baseline <= 0)
- return 'bg-slate-500/30 dark:bg-slate-500/30';
- const ratio = durationSec / baseline;
- if (ratio >= 1.5) return 'bg-metric-warning-bg dark:bg-metric-warning-bg';
- return 'bg-metric-normal-bg dark:bg-metric-normal-bg';
- };
- return (
- <TableRow class="hover:bg-surface-hover">
- <TableCell class={getPlatformTableCellClassForKind('text')}>
- <div class="flex items-center gap-2">
- <StatusDot
- size="sm"
- variant={classify.variant}
- title={classify.label}
- ariaHidden
- />
- <span class={`text-[11px] font-medium ${classify.toneClass}`}>
- {classify.label}
- </span>
- </div>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- {guestLabel(task.type, task.vmid)}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content font-mono text-[11px]`}
- >
- {task.node || '—'}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
- >
- {formatRelativeTime(task.startTime, { compact: true })}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('metric-bar')} text-base-content`}
- >
- <RowMetricBar
- valuePct={
- props.durationBaselineSeconds > 0 && durationSec ? durationBarPct() : 0
- }
- fillClass={durationToneClass()}
- label={formatDuration(task.startTime, task.endTime)}
- tooltip={`Duration ${formatDuration(task.startTime, task.endTime)} (median ${formatDurationFromSeconds(props.durationBaselineSeconds)})`}
- />
- </TableCell>
- <Show when={props.showSizeColumn}>
- <TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
- >
- <Show
- when={task.size && task.size > 0}
- fallback={<span class="text-muted">—</span>}
- >
- {formatBytes(task.size ?? 0)}
- </Show>
- </TableCell>
- </Show>
- <Show when={props.showErrorColumn}>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={!!task.error?.trim()}
- fallback={<span class="text-muted">—</span>}
- >
- <span
- class="inline-block max-w-[18rem] truncate text-red-600 dark:text-red-300"
- title={task.error}
- >
- {task.error}
- </span>
- </Show>
- </TableCell>
- </Show>
- </TableRow>
- );
- }}
- </For>
- </TableBody>
- </Table>
- </TableCard>
- </Show>
- );
-}
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 8c889d7472..f522eba71f 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -128,90 +128,71 @@ afterEach(() => {
});
describe('ProxmoxBackupsTable', () => {
- it('shows PBS artifacts from the PBS backup endpoint when PBS is present', async () => {
+ it('renders one coverage row per workload with restore posture', async () => {
mockBackupAPIs();
renderInRouter(() => (
- <ProxmoxBackupsTable emptyIcon={<span />} hasPBS workloads={[workloadResource]} />
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
));
expect(await screen.findByText('pbs-docker')).toBeInTheDocument();
+ // The workload has a recent restore point, so its posture reads "Current".
expect(screen.getAllByText('Current').length).toBeGreaterThan(0);
-
- await fireEvent.click(screen.getByRole('button', { name: /source details/i }));
- await fireEvent.click(screen.getByRole('button', { name: /pbs artifacts/i }));
- // The PBS repository (datastore / namespace) shows in the PBS artifacts
- // table; the coverage tab keeps per-source location in the row expansion.
- expect(screen.getByText('main / minipc')).toBeInTheDocument();
- expect(screen.getByText('2 files')).toBeInTheDocument();
- expect(screen.getAllByText('Verified').length).toBeGreaterThan(0);
- expect(screen.getAllByText('Protected').length).toBeGreaterThan(0);
expect(apiFetchMock).toHaveBeenCalledWith('/api/backups/pbs');
expect(apiFetchMock).toHaveBeenCalledWith('/api/backups/pve');
});
- it('omits PVE columns when the source cannot populate them', async () => {
+ it('collapses the surface to a single table — no inner source/job/restore tabs', async () => {
mockBackupAPIs();
- renderInRouter(() => <ProxmoxBackupsTable emptyIcon={<span />} hasPBS={false} />);
-
- await fireEvent.click(await screen.findByRole('button', { name: /source details/i }));
- await fireEvent.click(screen.getByRole('button', { name: 'Snapshots 1' }));
- expect(await screen.findByText('CT 112')).toBeInTheDocument();
- expect(screen.queryByRole('columnheader', { name: /total size/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('columnheader', { name: /^ram$/i })).not.toBeInTheDocument();
-
- await fireEvent.click(screen.getByRole('button', { name: /backup files/i }));
- expect(
- screen.getByText('local:backup/vzdump-lxc-112-2026_05_25-02_00_00.tar.zst'),
- ).toBeInTheDocument();
- expect(screen.queryByRole('columnheader', { name: /protection/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('columnheader', { name: /verified/i })).not.toBeInTheDocument();
-
- await fireEvent.click(screen.getByRole('button', { name: /job history/i }));
- expect(screen.getAllByText('OK').length).toBeGreaterThan(0);
- expect(screen.queryByRole('columnheader', { name: /^size$/i })).not.toBeInTheDocument();
- expect(screen.queryByRole('columnheader', { name: /error/i })).not.toBeInTheDocument();
+ renderInRouter(() => (
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
+ ));
+
+ await screen.findByText('pbs-docker');
+
+ // The old four-tab + sub-tab tree is gone; the surface is the coverage
+ // table alone.
+ expect(screen.queryByRole('button', { name: /workload coverage/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /restore points/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /source details/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /job history/i })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: /pbs artifacts/i })).not.toBeInTheDocument();
});
- it('keeps restore points searchable while moving raw sources behind source details', async () => {
+ it('keeps PBS / archive / snapshot evidence in the row expansion (demote, not delete)', async () => {
mockBackupAPIs();
renderInRouter(() => (
- <ProxmoxBackupsTable emptyIcon={<span />} hasPBS workloads={[workloadResource]} />
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
));
- expect(await screen.findByText('pbs-docker')).toBeInTheDocument();
- expect(screen.queryByRole('button', { name: /pbs artifacts/i })).not.toBeInTheDocument();
+ await screen.findByText('pbs-docker');
- await fireEvent.click(await screen.findByRole('button', { name: /restore points/i }));
+ await fireEvent.click(
+ screen.getByRole('button', { name: /show restore evidence for pbs-docker/i }),
+ );
- expect(screen.getByRole('columnheader', { name: /source/i })).toBeInTheDocument();
+ // The per-source detail that used to live behind Source details is now one
+ // click down, inside the workload's row.
+ expect(screen.getByText('Restore evidence')).toBeInTheDocument();
expect(screen.getAllByText('PBS').length).toBeGreaterThan(0);
- expect(screen.getByText('PVE archive')).toBeInTheDocument();
+ expect(screen.getAllByText('PVE archive').length).toBeGreaterThan(0);
expect(screen.getAllByText('Snapshot').length).toBeGreaterThan(0);
- expect(screen.getAllByText('pbs-docker').length).toBeGreaterThan(0);
-
- await fireEvent.click(screen.getByRole('button', { name: /source details/i }));
- await fireEvent.click(screen.getByRole('button', { name: 'Snapshots 1' }));
- expect(screen.getByRole('columnheader', { name: /snapshots/i })).toBeInTheDocument();
});
- it('expands coverage rows to show inline restore evidence', async () => {
+ it('filters coverage rows by search term', async () => {
mockBackupAPIs();
renderInRouter(() => (
- <ProxmoxBackupsTable emptyIcon={<span />} hasPBS workloads={[workloadResource]} />
+ <ProxmoxBackupsTable emptyIcon={<span />} workloads={[workloadResource]} />
));
await screen.findByText('pbs-docker');
- await fireEvent.click(
- screen.getByRole('button', { name: /show restore evidence for pbs-docker/i }),
- );
+ const searchInput = screen.getByPlaceholderText(/search backups by workload/i);
+ await fireEvent.input(searchInput, { target: { value: 'no-such-guest' } });
- expect(screen.getByText('Restore evidence')).toBeInTheDocument();
- expect(screen.getAllByText('PVE archive').length).toBeGreaterThan(0);
- expect(screen.getAllByText('Snapshot').length).toBeGreaterThan(0);
+ expect(screen.queryByText('pbs-docker')).not.toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts
deleted file mode 100644
index 58d0111d49..0000000000
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupActivityPresentation.test.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import { recoveryDateKeyFromTimestamp } from '@/utils/recoveryDatePresentation';
-import {
- buildBackupActivityTimeline,
- getBackupActivityColumnAriaLabel,
- getBackupActivityTooltipRows,
- type BackupActivitySegmentKind,
-} from '../proxmoxBackupActivityPresentation';
-
-describe('proxmoxBackupActivityPresentation', () => {
- it('buckets backup activity by local day and segment kind', () => {
- const now = new Date(2026, 4, 20, 12);
- const today = new Date(2026, 4, 20, 9).getTime();
- const yesterday = new Date(2026, 4, 19, 9).getTime();
- const outsideWindow = new Date(2026, 4, 10, 9).getTime();
- const future = new Date(2026, 4, 21, 9).getTime();
-
- const timeline = buildBackupActivityTimeline(
- 7,
- [
- { ts: today, kind: 'ok' },
- { ts: today, kind: 'failed' },
- { ts: yesterday, kind: 'ok' },
- { ts: outsideWindow, kind: 'ok' },
- { ts: future, kind: 'running' },
- ],
- (item) => item.ts,
- (item) => item.kind as BackupActivitySegmentKind,
- { now },
- );
-
- const todayPoint = timeline.points.find(
- (point) => point.key === recoveryDateKeyFromTimestamp(today),
- );
- const yesterdayPoint = timeline.points.find(
- (point) => point.key === recoveryDateKeyFromTimestamp(yesterday),
- );
-
- expect(timeline.points).toHaveLength(7);
- expect(todayPoint?.total).toBe(2);
- expect(todayPoint?.counts.ok).toBe(1);
- expect(todayPoint?.counts.failed).toBe(1);
- expect(yesterdayPoint?.total).toBe(1);
- expect(timeline.points.reduce((sum, point) => sum + point.total, 0)).toBe(3);
- expect(timeline.axisMax).toBeGreaterThanOrEqual(2);
- });
-
- it('formats activity labels and tooltip rows from segment totals', () => {
- const point = {
- key: '2026-05-20',
- total: 4,
- counts: { archive: 0, pbs: 0, ok: 3, failed: 1, running: 0, snapshot: 0 },
- };
-
- expect(getBackupActivityColumnAriaLabel('Wed 20 May', point.total, true, 'task')).toBe(
- 'Wed 20 May: 4 tasks, selected',
- );
- expect(getBackupActivityTooltipRows(point, ['ok', 'failed', 'running'])).toMatchObject([
- { kind: 'ok', label: 'OK', value: '3 (75%)', muted: false },
- { kind: 'failed', label: 'Failed', value: '1 (25%)', muted: false },
- { kind: 'running', label: 'Running', value: '0', muted: true },
- ]);
- });
-
- it('accumulates bytes when a value accessor is supplied', () => {
- const now = new Date(2026, 4, 20, 12);
- const today = new Date(2026, 4, 20, 9).getTime();
- const timeline = buildBackupActivityTimeline(
- 7,
- [
- { ts: today, size: 1_000_000_000 },
- { ts: today, size: 500_000_000 },
- ],
- (item) => item.ts,
- () => 'archive' as BackupActivitySegmentKind,
- { now, getValue: (item) => item.size },
- );
- const todayPoint = timeline.points.find(
- (point) => point.key === recoveryDateKeyFromTimestamp(today),
- );
- expect(todayPoint?.total).toBe(1_500_000_000);
- expect(todayPoint?.counts.archive).toBe(1_500_000_000);
- });
-});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
index 2f3b0fc467..06d646e55d 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
@@ -145,6 +145,34 @@ describe('proxmoxBackupRecoveryModel', () => {
expect(model.coverageSummary.uncovered).toBe(1);
});
+ it('flags backups whose guest is absent from inventory as orphaned, live guests as not', () => {
+ const model = buildProxmoxBackupRecoveryModel({
+ // Only VMID 112 exists in inventory; the PBS backup for 999 does not.
+ workloads: [workload({})],
+ pbsBackups: [
+ pbsBackup(),
+ pbsBackup({
+ id: 'pbs-main/main/minipc/ct/999/2026-05-25T01:34:25Z',
+ vmid: '999',
+ }),
+ ],
+ archives: [],
+ snapshots: [],
+ tasks: [],
+ nowMs: Date.parse('2026-05-26T08:00:00Z'),
+ });
+
+ const live = model.coverageRows.find((row) => row.workload.vmid === '112');
+ const orphan = model.coverageRows.find((row) => row.workload.vmid === '999');
+
+ expect(live?.isOrphaned).toBe(false);
+ expect(live?.workload.name).toBe('pbs-docker');
+ expect(orphan?.isOrphaned).toBe(true);
+ // Orphans have no live guest to name them; label falls back to "CT <vmid>".
+ expect(orphan?.workload.name).toBeUndefined();
+ expect(orphan?.workload.label).toBe('CT 999');
+ });
+
it('does not create phantom workload rows from aggregate vzdump jobs', () => {
const model = buildProxmoxBackupRecoveryModel({
workloads: [],
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSummaryPresentation.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSummaryPresentation.test.ts
deleted file mode 100644
index 45db68e630..0000000000
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupSummaryPresentation.test.ts
+++ /dev/null
@@ -1,252 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import type { BackupTask, GuestSnapshot, StorageBackup } from '@/types/api';
-import {
- buildArchiveCoverageSummary,
- buildSnapshotCoverageSummary,
- buildTaskOutcomeSummary,
- classifyArchiveRowAge,
- classifyBackupAge,
- classifySnapshotRowAge,
- computeMedianTaskDurationSeconds,
- guestKey,
-} from '../proxmoxBackupSummaryPresentation';
-
-const DAY_MS = 24 * 60 * 60 * 1000;
-
-function snapshot(overrides: Partial<GuestSnapshot> & { time: string }): GuestSnapshot {
- return {
- id: overrides.id ?? `${overrides.time}-${overrides.vmid ?? 0}`,
- name: overrides.name ?? 'snap',
- node: overrides.node ?? 'pve1',
- instance: overrides.instance ?? 'cluster-a',
- type: overrides.type ?? 'qemu',
- vmid: overrides.vmid ?? 100,
- time: overrides.time,
- description: overrides.description,
- parent: overrides.parent,
- vmstate: overrides.vmstate ?? false,
- sizeBytes: overrides.sizeBytes,
- };
-}
-
-function archive(overrides: Partial<StorageBackup> & { time: string }): StorageBackup {
- return {
- id: overrides.id ?? `${overrides.time}-${overrides.vmid ?? 0}`,
- storage: overrides.storage ?? 'backup-vault',
- node: overrides.node ?? 'pve1',
- instance: overrides.instance ?? 'cluster-a',
- type: overrides.type ?? 'qemu',
- vmid: overrides.vmid ?? 100,
- time: overrides.time,
- ctime: overrides.ctime ?? 0,
- size: overrides.size ?? 0,
- format: overrides.format ?? 'tar.zst',
- notes: overrides.notes,
- protected: overrides.protected ?? false,
- volid: overrides.volid ?? 'vol',
- isPBS: overrides.isPBS ?? false,
- verified: overrides.verified ?? false,
- verification: overrides.verification,
- };
-}
-
-function task(overrides: Partial<BackupTask> & { startTime: string }): BackupTask {
- return {
- id: overrides.id ?? `${overrides.startTime}-${overrides.vmid ?? 0}`,
- node: overrides.node ?? 'pve1',
- instance: overrides.instance ?? 'cluster-a',
- type: overrides.type ?? 'qemu',
- vmid: overrides.vmid ?? 100,
- status: overrides.status ?? 'ok',
- startTime: overrides.startTime,
- endTime: overrides.endTime,
- size: overrides.size,
- error: overrides.error,
- };
-}
-
-describe('proxmoxBackupSummaryPresentation', () => {
- describe('classifyBackupAge', () => {
- const now = Date.parse('2026-05-20T12:00:00Z');
-
- it('buckets by sysadmin-relevant age thresholds', () => {
- expect(classifyBackupAge(now - 1 * DAY_MS, now)).toBe('recent');
- expect(classifyBackupAge(now - 7 * DAY_MS + 1000, now)).toBe('recent');
- expect(classifyBackupAge(now - 20 * DAY_MS, now)).toBe('normal');
- expect(classifyBackupAge(now - 60 * DAY_MS, now)).toBe('stale');
- expect(classifyBackupAge(now - 200 * DAY_MS, now)).toBe('ancient');
- });
-
- it('treats undefined and unparseable timestamps as ancient', () => {
- expect(classifyBackupAge(undefined, now)).toBe('ancient');
- expect(classifyBackupAge('not a date', now)).toBe('ancient');
- });
- });
-
- describe('buildSnapshotCoverageSummary', () => {
- const now = Date.parse('2026-05-20T12:00:00Z');
-
- it('groups snapshots by guest and tallies stale/ancient counts', () => {
- const summary = buildSnapshotCoverageSummary(
- [
- snapshot({ vmid: 100, time: new Date(now - 2 * DAY_MS).toISOString(), vmstate: true }),
- snapshot({ vmid: 100, time: new Date(now - 50 * DAY_MS).toISOString() }),
- snapshot({ vmid: 101, time: new Date(now - 100 * DAY_MS).toISOString() }),
- snapshot({ vmid: 102, time: new Date(now - 40 * DAY_MS).toISOString() }),
- ],
- now,
- );
-
- expect(summary.totalGuests).toBe(3);
- expect(summary.totalSnapshots).toBe(4);
- // vmid 100 newest is 2d (recent), vmid 102 newest is 40d (stale),
- // vmid 101 newest is 100d (ancient).
- expect(summary.staleGuests).toBe(1);
- expect(summary.ancientGuests).toBe(1);
- expect(summary.withRamGuests).toBe(1);
- });
-
- it('sorts guests by newest snapshot descending', () => {
- const summary = buildSnapshotCoverageSummary(
- [
- snapshot({ vmid: 1, time: new Date(now - 30 * DAY_MS).toISOString() }),
- snapshot({ vmid: 2, time: new Date(now - 5 * DAY_MS).toISOString() }),
- snapshot({ vmid: 3, time: new Date(now - 15 * DAY_MS).toISOString() }),
- ],
- now,
- );
-
- expect(summary.guests.map((g) => g.vmid)).toEqual([2, 3, 1]);
- });
-
- it('sorts each guest`s snapshots newest-first', () => {
- const summary = buildSnapshotCoverageSummary(
- [
- snapshot({ vmid: 7, time: new Date(now - 20 * DAY_MS).toISOString(), name: 'old' }),
- snapshot({ vmid: 7, time: new Date(now - 1 * DAY_MS).toISOString(), name: 'new' }),
- snapshot({ vmid: 7, time: new Date(now - 10 * DAY_MS).toISOString(), name: 'mid' }),
- ],
- now,
- );
-
- const guest = summary.guests[0];
- expect(guest.snapshots.map((s) => s.name)).toEqual(['new', 'mid', 'old']);
- });
- });
-
- describe('buildArchiveCoverageSummary', () => {
- const now = Date.parse('2026-05-20T12:00:00Z');
-
- it('splits guests into current/stale/uncovered by newest archive age', () => {
- const summary = buildArchiveCoverageSummary(
- [
- archive({ vmid: 100, time: new Date(now - 1 * DAY_MS).toISOString(), size: 1000 }),
- archive({ vmid: 100, time: new Date(now - 40 * DAY_MS).toISOString(), size: 2000 }),
- archive({ vmid: 200, time: new Date(now - 14 * DAY_MS).toISOString(), size: 3000 }),
- archive({ vmid: 300, time: new Date(now - 50 * DAY_MS).toISOString(), size: 4000 }),
- archive({ vmid: 400, time: new Date(now - 120 * DAY_MS).toISOString(), size: 5000 }),
- ],
- now,
- );
-
- expect(summary.totalGuests).toBe(4);
- expect(summary.totalArchives).toBe(5);
- expect(summary.totalBytes).toBe(15_000);
- // 100 (newest 1d) → current; 200 (14d) → stale-window; 300 (50d) +
- // 400 (120d) → uncovered. The summary collapses the 7–30d "normal"
- // bucket into staleGuests since either way they are not "current".
- expect(summary.currentGuests).toBe(1);
- expect(summary.staleGuests).toBe(1);
- expect(summary.uncoveredGuests).toBe(2);
- });
- });
-
- describe('buildTaskOutcomeSummary', () => {
- it('counts outcomes and flags whether any errors exist', () => {
- const outcome = buildTaskOutcomeSummary([
- task({ startTime: '2026-05-20T01:00:00Z', status: 'OK' }),
- task({ startTime: '2026-05-20T02:00:00Z', status: 'failed', error: 'disk full' }),
- task({ startTime: '2026-05-20T03:00:00Z', status: 'running' }),
- task({ startTime: '2026-05-20T04:00:00Z', status: 'completed' }),
- ]);
-
- expect(outcome.total).toBe(4);
- expect(outcome.ok).toBe(2);
- expect(outcome.failed).toBe(1);
- expect(outcome.running).toBe(1);
- expect(outcome.hasErrors).toBe(true);
- });
-
- it('reports hasErrors=false when no task carries an error message', () => {
- const outcome = buildTaskOutcomeSummary([
- task({ startTime: '2026-05-20T01:00:00Z', status: 'ok' }),
- task({ startTime: '2026-05-20T02:00:00Z', status: 'ok' }),
- ]);
- expect(outcome.hasErrors).toBe(false);
- });
- });
-
- describe('computeMedianTaskDurationSeconds', () => {
- it('returns 0 when no durations are present', () => {
- expect(computeMedianTaskDurationSeconds([])).toBe(0);
- expect(
- computeMedianTaskDurationSeconds([
- task({ startTime: '2026-05-20T01:00:00Z' }), // no endTime
- ]),
- ).toBe(0);
- });
-
- it('computes the median across finite durations', () => {
- const median = computeMedianTaskDurationSeconds([
- task({ startTime: '2026-05-20T01:00:00Z', endTime: '2026-05-20T01:00:10Z' }), // 10s
- task({ startTime: '2026-05-20T01:00:00Z', endTime: '2026-05-20T01:01:00Z' }), // 60s
- task({ startTime: '2026-05-20T01:00:00Z', endTime: '2026-05-20T01:02:00Z' }), // 120s
- ]);
- expect(median).toBe(60);
- });
- });
-
- describe('classifyArchiveRowAge', () => {
- const now = Date.parse('2026-05-20T12:00:00Z');
-
- it('aligns row swatch with the archive coverage strip thresholds (≤7d / 7–30d / >30d)', () => {
- expect(classifyArchiveRowAge(now - 1 * DAY_MS, now).swatchClass).toBe('bg-emerald-500');
- expect(classifyArchiveRowAge(now - 7 * DAY_MS + 1000, now).swatchClass).toBe('bg-emerald-500');
- expect(classifyArchiveRowAge(now - 14 * DAY_MS, now).swatchClass).toBe('bg-amber-500');
- expect(classifyArchiveRowAge(now - 30 * DAY_MS + 1000, now).swatchClass).toBe('bg-amber-500');
- expect(classifyArchiveRowAge(now - 40 * DAY_MS, now).swatchClass).toBe('bg-red-500');
- expect(classifyArchiveRowAge(now - 200 * DAY_MS, now).swatchClass).toBe('bg-red-500');
- });
-
- it('treats undefined as the worst bucket so missing timestamps surface', () => {
- expect(classifyArchiveRowAge(undefined, now).swatchClass).toBe('bg-red-500');
- });
- });
-
- describe('classifySnapshotRowAge', () => {
- const now = Date.parse('2026-05-20T12:00:00Z');
-
- it('aligns row swatch with the snapshot coverage strip thresholds (≤30d / 30–90d / >90d)', () => {
- expect(classifySnapshotRowAge(now - 1 * DAY_MS, now).swatchClass).toBe('bg-emerald-500');
- expect(classifySnapshotRowAge(now - 30 * DAY_MS + 1000, now).swatchClass).toBe(
- 'bg-emerald-500',
- );
- expect(classifySnapshotRowAge(now - 60 * DAY_MS, now).swatchClass).toBe('bg-amber-500');
- expect(classifySnapshotRowAge(now - 90 * DAY_MS + 1000, now).swatchClass).toBe(
- 'bg-amber-500',
- );
- expect(classifySnapshotRowAge(now - 100 * DAY_MS, now).swatchClass).toBe('bg-red-500');
- });
- });
-
- describe('guestKey', () => {
- it('namespaces vmid by instance and type to avoid VM/CT collisions', () => {
- expect(guestKey({ type: 'qemu', instance: 'a', vmid: 100 })).toBe('a:qemu:100');
- expect(guestKey({ type: 'lxc', instance: 'a', vmid: 100 })).toBe('a:lxc:100');
- expect(guestKey({ type: 'qemu', instance: 'a', vmid: 100 })).not.toBe(
- guestKey({ type: 'qemu', instance: 'b', vmid: 100 }),
- );
- });
- });
-});
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts b/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts
deleted file mode 100644
index ffe2757dc8..0000000000
--- a/frontend-modern/src/features/proxmox/proxmoxBackupActivityPresentation.ts
+++ /dev/null
@@ -1,213 +0,0 @@
-import { formatBytes } from '@/utils/format';
-import {
- getRecoveryNiceAxisMax,
- recoveryDateKeyFromTimestamp,
-} from '@/utils/recoveryDatePresentation';
-import { getRecoveryTimelineLabelEvery } from '@/utils/recoveryTimelineChartPresentation';
-import { getRecoveryTimelineDayFilterStateLabel } from '@/utils/recoveryTimelinePresentation';
-
-export type BackupActivityRangeDays = 7 | 30 | 90 | 365;
-
-export const BACKUP_ACTIVITY_RANGE_DAYS = [
- 7, 30, 90, 365,
-] as const satisfies readonly BackupActivityRangeDays[];
-
-// `count` accumulates 1 per item per day (files, snapshots, tasks). `volume`
-// accumulates bytes per item per day (used by Backup files when the user
-// switches the chart from "how many files" to "how much space".)
-export type BackupActivityMetricMode = 'count' | 'volume';
-
-export type BackupActivitySegmentKind =
- | 'archive'
- | 'pbs'
- | 'ok'
- | 'failed'
- | 'running'
- | 'snapshot';
-
-interface BackupActivitySegmentPresentation {
- label: string;
- segmentClassName: string;
- swatchClassName: string;
-}
-
-const SEGMENT_PRESENTATION: Record<BackupActivitySegmentKind, BackupActivitySegmentPresentation> = {
- archive: {
- label: 'Archives',
- segmentClassName: 'bg-blue-500',
- swatchClassName: 'bg-blue-500',
- },
- pbs: {
- label: 'PBS artifacts',
- segmentClassName: 'bg-cyan-500',
- swatchClassName: 'bg-cyan-500',
- },
- ok: {
- label: 'OK',
- segmentClassName: 'bg-emerald-500',
- swatchClassName: 'bg-emerald-500',
- },
- failed: {
- label: 'Failed',
- segmentClassName: 'bg-red-500',
- swatchClassName: 'bg-red-500',
- },
- running: {
- label: 'Running',
- segmentClassName: 'bg-amber-500',
- swatchClassName: 'bg-amber-500',
- },
- snapshot: {
- label: 'Snapshots',
- segmentClassName: 'bg-violet-500',
- swatchClassName: 'bg-violet-500',
- },
-};
-
-export function getBackupActivitySegmentPresentation(
- kind: BackupActivitySegmentKind,
-): BackupActivitySegmentPresentation {
- return SEGMENT_PRESENTATION[kind];
-}
-
-export interface BackupActivityPoint {
- key: string;
- total: number;
- counts: Record<BackupActivitySegmentKind, number>;
-}
-
-export interface BackupActivityTimeline {
- points: BackupActivityPoint[];
- axisMax: number;
- labelEvery: number;
-}
-
-function emptyCounts(): Record<BackupActivitySegmentKind, number> {
- return { archive: 0, pbs: 0, ok: 0, failed: 0, running: 0, snapshot: 0 };
-}
-
-function startOfLocalDayMs(date: Date): number {
- const copy = new Date(date);
- copy.setHours(0, 0, 0, 0);
- return copy.getTime();
-}
-
-export function buildBackupActivityTimeline<T>(
- days: BackupActivityRangeDays,
- items: readonly T[],
- getTimestampMs: (item: T) => number | undefined,
- classify: (item: T) => BackupActivitySegmentKind | null,
- options?: {
- now?: Date;
- // Per-item contribution to the bucket total. Defaults to 1 (count mode).
- // For volume mode, pass `(item) => item.size ?? 0`.
- getValue?: (item: T) => number;
- },
-): BackupActivityTimeline {
- const now = options?.now ?? new Date();
- const getValue = options?.getValue ?? (() => 1);
- const todayStart = startOfLocalDayMs(now);
- const windowStart = todayStart - (days - 1) * 24 * 60 * 60 * 1000;
-
- const buckets = new Map<string, BackupActivityPoint>();
- const orderedKeys: string[] = [];
-
- for (let i = 0; i < days; i += 1) {
- const dayStart = windowStart + i * 24 * 60 * 60 * 1000;
- const key = recoveryDateKeyFromTimestamp(dayStart);
- orderedKeys.push(key);
- buckets.set(key, { key, total: 0, counts: emptyCounts() });
- }
-
- for (const item of items) {
- const ts = getTimestampMs(item);
- if (ts === undefined || !Number.isFinite(ts)) continue;
- if (ts < windowStart) continue;
- if (ts >= todayStart + 24 * 60 * 60 * 1000) continue;
- const kind = classify(item);
- if (!kind) continue;
- const value = getValue(item);
- if (!Number.isFinite(value) || value <= 0) continue;
- const key = recoveryDateKeyFromTimestamp(ts);
- const bucket = buckets.get(key);
- if (!bucket) continue;
- bucket.counts[kind] += value;
- bucket.total += value;
- }
-
- const points = orderedKeys.map((key) => buckets.get(key)!);
- const rawMax = points.reduce((max, p) => (p.total > max ? p.total : max), 0);
- const axisMax = Math.max(2, getRecoveryNiceAxisMax(rawMax));
- const labelEvery = getRecoveryTimelineLabelEvery(points.length);
-
- return { points, axisMax, labelEvery };
-}
-
-export interface BackupActivityTooltipRow {
- kind: BackupActivitySegmentKind;
- label: string;
- count: number;
- value: string;
- segmentClassName: string;
- muted: boolean;
-}
-
-export type BackupActivityNoun = 'archive' | 'artifact' | 'task' | 'snapshot';
-
-function formatActivityValue(value: number, mode: BackupActivityMetricMode): string {
- if (mode === 'volume') return formatBytes(Math.max(0, value));
- return String(Math.max(0, Math.round(value)));
-}
-
-export function getBackupActivityTooltipRows(
- point: BackupActivityPoint,
- kinds: readonly BackupActivitySegmentKind[],
- mode: BackupActivityMetricMode = 'count',
-): BackupActivityTooltipRow[] {
- const total = Math.max(0, point.total);
- return kinds.map((kind) => {
- const presentation = SEGMENT_PRESENTATION[kind];
- const count = Math.max(0, point.counts[kind] ?? 0);
- const percentage = total > 0 && count > 0 ? Math.round((count / total) * 100) : 0;
- const formatted = formatActivityValue(count, mode);
- return {
- kind,
- label: presentation.label,
- count,
- value: percentage > 0 && kinds.length > 1 ? `${formatted} (${percentage}%)` : formatted,
- segmentClassName: presentation.segmentClassName,
- muted: count === 0,
- };
- });
-}
-
-export function getBackupActivityPointTotalLabel(
- total: number,
- noun: BackupActivityNoun,
- mode: BackupActivityMetricMode = 'count',
-): string {
- if (mode === 'volume') {
- return formatBytes(Math.max(0, total));
- }
- const normalized = Math.max(0, Math.round(total));
- if (normalized === 1) return `1 ${noun}`;
- return `${normalized} ${noun}s`;
-}
-
-export function getBackupActivityColumnAriaLabel(
- dateLabel: string,
- total: number,
- selected: boolean,
- noun: BackupActivityNoun,
- mode: BackupActivityMetricMode = 'count',
-): string {
- const countLabel = getBackupActivityPointTotalLabel(total, noun, mode);
- return selected ? `${dateLabel}: ${countLabel}, selected` : `${dateLabel}: ${countLabel}`;
-}
-
-export function getBackupActivityAxisLabel(value: number, mode: BackupActivityMetricMode): string {
- if (mode === 'volume') return formatBytes(Math.max(0, value));
- return String(Math.max(0, Math.round(value)));
-}
-
-export { getRecoveryTimelineDayFilterStateLabel as getBackupActivityDayFilterStateLabel };
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
index f23cac8c40..1a30547d5a 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
@@ -63,6 +63,11 @@ export interface WorkloadCoverageRow {
snapshotCount: number;
posture: WorkloadRecoveryPosture;
postureRank: number;
+ // True when this row exists only because a backup/task referenced a VMID with
+ // no matching live inventory guest — i.e. an orphaned backup for a guest that
+ // no longer exists. Live guests carry a `resource:` key; orphans carry a
+ // `backup:` key and have no real name (label falls back to "CT <vmid>").
+ isOrphaned: boolean;
}
export interface ProxmoxBackupRecoveryModel {
@@ -93,7 +98,7 @@ interface WorkloadCandidate extends WorkloadReference {
instanceKey?: string;
}
-type WorkloadRowDraft = Omit<WorkloadCoverageRow, 'posture' | 'postureRank'>;
+type WorkloadRowDraft = Omit<WorkloadCoverageRow, 'posture' | 'postureRank' | 'isOrphaned'>;
const DAY_MS = 24 * 60 * 60 * 1000;
const CURRENT_RECOVERY_MS = 7 * DAY_MS;
@@ -503,7 +508,12 @@ export function buildProxmoxBackupRecoveryModel(
const coverageRows = Array.from(rows.values()).map((row) => {
const posture = buildPosture(row, input.nowMs);
- return { ...row, posture: posture.posture, postureRank: posture.rank };
+ return {
+ ...row,
+ posture: posture.posture,
+ postureRank: posture.rank,
+ isOrphaned: !row.key.startsWith('resource:'),
+ };
});
coverageRows.sort((left, right) => {
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts b/frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts
deleted file mode 100644
index a74405d360..0000000000
--- a/frontend-modern/src/features/proxmox/proxmoxBackupSummaryPresentation.ts
+++ /dev/null
@@ -1,308 +0,0 @@
-import type { BackupTask, GuestSnapshot, StorageBackup } from '@/types/api';
-
-// Sysadmin-oriented age buckets. These are how the page colour-codes
-// freshness in row encodings and how the coverage strip splits guests.
-//
-// `recent` captured ≤ 7 days ago
-// `normal` captured 7–30 days ago
-// `stale` captured 30–90 days ago
-// `ancient` captured > 90 days ago, or no timestamp
-export type BackupAgeBucket = 'recent' | 'normal' | 'stale' | 'ancient';
-
-export interface BackupAgeBucketPresentation {
- label: string;
- rowAccentClass: string;
- swatchClass: string;
-}
-
-const AGE_BUCKET_PRESENTATION: Record<BackupAgeBucket, BackupAgeBucketPresentation> = {
- recent: {
- label: '≤ 7d',
- rowAccentClass: 'bg-emerald-500',
- swatchClass: 'bg-emerald-500',
- },
- normal: {
- label: '7–30d',
- rowAccentClass: 'bg-sky-500',
- swatchClass: 'bg-sky-500',
- },
- stale: {
- label: '30–90d',
- rowAccentClass: 'bg-amber-500',
- swatchClass: 'bg-amber-500',
- },
- ancient: {
- label: '> 90d',
- rowAccentClass: 'bg-red-500',
- swatchClass: 'bg-red-500',
- },
-};
-
-export function getBackupAgeBucketPresentation(
- bucket: BackupAgeBucket,
-): BackupAgeBucketPresentation {
- return AGE_BUCKET_PRESENTATION[bucket];
-}
-
-const DAY_MS = 24 * 60 * 60 * 1000;
-
-export function classifyBackupAge(
- timestamp: string | number | undefined,
- now: number = Date.now(),
-): BackupAgeBucket {
- if (timestamp === undefined || timestamp === null) return 'ancient';
- const ms = typeof timestamp === 'number' ? timestamp : Date.parse(timestamp);
- if (!Number.isFinite(ms)) return 'ancient';
- const ageDays = (now - ms) / DAY_MS;
- if (ageDays <= 7) return 'recent';
- if (ageDays <= 30) return 'normal';
- if (ageDays <= 90) return 'stale';
- return 'ancient';
-}
-
-// Per-tab row dot semantics that match each coverage strip's bucketing.
-// The shared 4-bucket classifyBackupAge is too granular: a 14-day archive
-// would land in `normal` (sky) in the row but `stale` (amber) in the
-// archive coverage strip, since archives have a 7-day SLA. These helpers
-// keep the row dot, strip segment, and strip label all reading the same
-// colour for the same data.
-
-export interface AgeSwatch {
- label: string;
- swatchClass: string;
-}
-
-export function classifyArchiveRowAge(
- timestamp: string | number | undefined,
- now: number = Date.now(),
-): AgeSwatch {
- if (timestamp === undefined || timestamp === null)
- return { label: 'uncovered (>30d)', swatchClass: 'bg-red-500' };
- const ms = typeof timestamp === 'number' ? timestamp : Date.parse(timestamp);
- if (!Number.isFinite(ms)) return { label: 'uncovered (>30d)', swatchClass: 'bg-red-500' };
- const ageDays = (now - ms) / DAY_MS;
- if (ageDays <= 7) return { label: 'current (≤7d)', swatchClass: 'bg-emerald-500' };
- if (ageDays <= 30) return { label: 'stale (7–30d)', swatchClass: 'bg-amber-500' };
- return { label: 'uncovered (>30d)', swatchClass: 'bg-red-500' };
-}
-
-export function classifySnapshotRowAge(
- timestamp: string | number | undefined,
- now: number = Date.now(),
-): AgeSwatch {
- if (timestamp === undefined || timestamp === null)
- return { label: 'ancient (>90d)', swatchClass: 'bg-red-500' };
- const ms = typeof timestamp === 'number' ? timestamp : Date.parse(timestamp);
- if (!Number.isFinite(ms)) return { label: 'ancient (>90d)', swatchClass: 'bg-red-500' };
- const ageDays = (now - ms) / DAY_MS;
- if (ageDays <= 30) return { label: 'recent (≤30d)', swatchClass: 'bg-emerald-500' };
- if (ageDays <= 90) return { label: 'stale (30–90d)', swatchClass: 'bg-amber-500' };
- return { label: 'ancient (>90d)', swatchClass: 'bg-red-500' };
-}
-
-export function guestKey(guest: { type?: string; instance?: string; vmid: number }): string {
- // instance disambiguates 100@cluster-a vs 100@cluster-b. type narrows
- // VM-100 vs CT-100, which can collide in the same instance.
- const t = (guest.type ?? '').toLowerCase() || '?';
- return `${guest.instance ?? ''}:${t}:${guest.vmid}`;
-}
-
-interface GuestSnapshotStats {
- key: string;
- type: string;
- vmid: number;
- instance: string;
- node: string;
- count: number;
- withRamCount: number;
- newestMs: number | undefined;
- oldestMs: number | undefined;
- totalBytes: number;
- // Newest first.
- snapshots: GuestSnapshot[];
-}
-
-export interface SnapshotCoverageSummary {
- totalGuests: number;
- staleGuests: number; // newest > 30d
- ancientGuests: number; // newest > 90d
- withRamGuests: number;
- totalSnapshots: number;
- // Sorted by newest snapshot descending (stalest at the end).
- guests: GuestSnapshotStats[];
-}
-
-export function buildSnapshotCoverageSummary(
- snapshots: readonly GuestSnapshot[],
- now: number = Date.now(),
-): SnapshotCoverageSummary {
- const byGuest = new Map<string, GuestSnapshotStats>();
- for (const snap of snapshots) {
- const key = guestKey(snap);
- let stats = byGuest.get(key);
- if (!stats) {
- stats = {
- key,
- type: snap.type,
- vmid: snap.vmid,
- instance: snap.instance,
- node: snap.node,
- count: 0,
- withRamCount: 0,
- newestMs: undefined,
- oldestMs: undefined,
- totalBytes: 0,
- snapshots: [],
- };
- byGuest.set(key, stats);
- }
- stats.snapshots.push(snap);
- stats.count += 1;
- if (snap.vmstate) stats.withRamCount += 1;
- if (typeof snap.sizeBytes === 'number' && snap.sizeBytes > 0) {
- stats.totalBytes += snap.sizeBytes;
- }
- const ms = Date.parse(snap.time);
- if (Number.isFinite(ms)) {
- if (stats.newestMs === undefined || ms > stats.newestMs) stats.newestMs = ms;
- if (stats.oldestMs === undefined || ms < stats.oldestMs) stats.oldestMs = ms;
- }
- }
-
- for (const stats of byGuest.values()) {
- stats.snapshots.sort((a, b) => {
- const av = Date.parse(a.time);
- const bv = Date.parse(b.time);
- return (Number.isFinite(bv) ? bv : 0) - (Number.isFinite(av) ? av : 0);
- });
- }
-
- const guests = Array.from(byGuest.values()).sort((a, b) => {
- const av = a.newestMs ?? 0;
- const bv = b.newestMs ?? 0;
- return bv - av;
- });
-
- let staleGuests = 0;
- let ancientGuests = 0;
- let withRamGuests = 0;
- for (const g of guests) {
- const bucket = classifyBackupAge(g.newestMs, now);
- if (bucket === 'stale') staleGuests += 1;
- if (bucket === 'ancient') ancientGuests += 1;
- if (g.withRamCount > 0) withRamGuests += 1;
- }
-
- return {
- totalGuests: guests.length,
- staleGuests,
- ancientGuests,
- withRamGuests,
- totalSnapshots: snapshots.length,
- guests,
- };
-}
-
-export interface ArchiveCoverageSummary {
- // Guests with at least one archive in the last 7d.
- currentGuests: number;
- // Last archive 7–30d (warning territory for daily-backup policies).
- staleGuests: number;
- // Last archive > 30d.
- uncoveredGuests: number;
- // Distinct guests appearing in the archive set.
- totalGuests: number;
- totalArchives: number;
- totalBytes: number;
-}
-
-export function buildArchiveCoverageSummary(
- archives: readonly StorageBackup[],
- now: number = Date.now(),
-): ArchiveCoverageSummary {
- const newestByGuest = new Map<string, number>();
- let totalBytes = 0;
- for (const arc of archives) {
- const key = guestKey(arc);
- const ms = Date.parse(arc.time);
- if (Number.isFinite(ms)) {
- const existing = newestByGuest.get(key);
- if (existing === undefined || ms > existing) newestByGuest.set(key, ms);
- } else if (!newestByGuest.has(key)) {
- newestByGuest.set(key, 0);
- }
- if (typeof arc.size === 'number' && arc.size > 0) totalBytes += arc.size;
- }
-
- // Backup coverage is judged on a 7-day SLA — any guest whose latest
- // archive is older than a week is at least stale. The label semantics
- // on the page (current ≤7d, stale 7–30d, uncovered >30d) reflect that
- // tighter threshold; classifyBackupAge has a coarser bucketing used
- // for row-level age dots, so we split it explicitly here.
- let currentGuests = 0;
- let staleGuests = 0;
- let uncoveredGuests = 0;
- for (const ms of newestByGuest.values()) {
- const bucket = classifyBackupAge(ms, now);
- if (bucket === 'recent') currentGuests += 1;
- else if (bucket === 'normal') staleGuests += 1;
- else uncoveredGuests += 1;
- }
-
- return {
- currentGuests,
- staleGuests,
- uncoveredGuests,
- totalGuests: newestByGuest.size,
- totalArchives: archives.length,
- totalBytes,
- };
-}
-
-export interface TaskOutcomeSummary {
- total: number;
- ok: number;
- failed: number;
- running: number;
- hasErrors: boolean;
-}
-
-export function buildTaskOutcomeSummary(tasks: readonly BackupTask[]): TaskOutcomeSummary {
- let ok = 0;
- let failed = 0;
- let running = 0;
- let hasErrors = false;
- for (const task of tasks) {
- const status = (task.status ?? '').toLowerCase();
- if (status === 'ok' || status === 'success' || status === 'completed') ok += 1;
- else if (status === 'failed' || status === 'error') failed += 1;
- else if (status === 'running') running += 1;
- if (task.error && task.error.trim().length > 0) hasErrors = true;
- }
- return { total: tasks.length, ok, failed, running, hasErrors };
-}
-
-// Median duration in seconds across the supplied set, used as the
-// reference for the "duration vs typical" inline bar on Recent tasks.
-// Returns 0 if no finite durations are present.
-export function computeMedianTaskDurationSeconds(tasks: readonly BackupTask[]): number {
- const durations: number[] = [];
- for (const task of tasks) {
- const start = Date.parse(task.startTime ?? '');
- const end = Date.parse(task.endTime ?? '');
- if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) continue;
- durations.push((end - start) / 1000);
- }
- if (durations.length === 0) return 0;
- durations.sort((a, b) => a - b);
- const mid = Math.floor(durations.length / 2);
- if (durations.length % 2 === 1) return durations[mid];
- return (durations[mid - 1] + durations[mid]) / 2;
-}
-
-export function taskDurationSeconds(task: BackupTask): number | undefined {
- const start = Date.parse(task.startTime ?? '');
- const end = Date.parse(task.endTime ?? '');
- if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) return undefined;
- return (end - start) / 1000;
-}
diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.ts
index a514f731da..4f19ba4adb 100644
--- a/frontend-modern/src/types/resource.ts
+++ b/frontend-modern/src/types/resource.ts
@@ -372,12 +372,26 @@ export interface ResourceStorageMeta {
numMissing?: number;
}
+// A PBS datastore as reported on the live pbs resource payload. Distinct from
+// api.ts `PBSDatastore` (backups-endpoint shape, uses `usage`/`free`): this is
+// the resource-model shape the WebSocket sends, keyed `usagePercent`/`available`.
+export interface ResourcePBSDatastore {
+ name: string;
+ total: number;
+ used: number;
+ available?: number;
+ usagePercent?: number;
+ status?: string;
+ deduplicationFactor?: number;
+}
+
export interface ResourcePBSMeta {
instanceId?: string;
hostname?: string;
version?: string;
uptimeSeconds?: number;
datastoreCount?: number;
+ datastores?: ResourcePBSDatastore[];
backupJobCount?: number;
syncJobCount?: number;
verifyJobCount?: number;