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.

feat(proxmox): auto-hide empty source columns on the coverage table

rcourtman8fe58bde48c8
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index d327ec80d7..15af72799b 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -1011,6 +1011,24 @@ export const ProxmoxBackupsTable: Component<{
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),
+ );
+ const coverageHasArchive = createMemo(() =>
+ recoveryModel().coverageRows.some((row) => Boolean(row.latestArchive) || row.archiveCount > 0),
+ );
+ const coverageHasSnapshot = createMemo(() =>
+ recoveryModel().coverageRows.some(
+ (row) => Boolean(row.latestSnapshot) || row.snapshotCount > 0,
+ ),
+ );
+ const coverageHasTask = createMemo(() =>
+ recoveryModel().coverageRows.some((row) => Boolean(row.latestTask)),
+ );
+
// 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
@@ -1562,6 +1580,10 @@ export const ProxmoxBackupsTable: Component<{
onSort={handleCoverageSort}
expandedKeys={expandedCoverageRows()}
onToggleExpand={toggleCoverageExpansion}
+ showPbsColumn={coverageHasPbs()}
+ showArchiveColumn={coverageHasArchive()}
+ showSnapshotColumn={coverageHasSnapshot()}
+ showTaskColumn={coverageHasTask()}
/>
</Show>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index 39931bc7a1..17bf7ae34f 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -59,7 +59,30 @@ export function ProxmoxCoverageTable(props: {
onSort: (key: CoverageSortKey) => void;
expandedKeys: ReadonlySet<string>;
onToggleExpand: (key: string) => void;
+ // Source columns auto-hide when no workload anywhere has that data (e.g. a
+ // PBS-only fleet drops the Archive and Snapshot columns), matching how the
+ // source-detail tables already drop their conditional columns.
+ showPbsColumn: boolean;
+ showArchiveColumn: boolean;
+ showSnapshotColumn: boolean;
+ showTaskColumn: boolean;
}) {
+ // Weighted column set; the conditional source/task columns drop out when
+ // empty fleet-wide, and table-fixed re-normalizes the rest.
+ const visibleColumns = () => [
+ { id: 'workload', weight: 17 },
+ { id: 'vmid', weight: 7 },
+ { id: 'node', weight: 11 },
+ { id: 'posture', weight: 11 },
+ { id: 'latest', weight: 13 },
+ ...(props.showPbsColumn ? [{ id: 'pbs', weight: 11 }] : []),
+ ...(props.showArchiveColumn ? [{ id: 'archive', weight: 11 }] : []),
+ ...(props.showSnapshotColumn ? [{ id: 'snapshot', weight: 11 }] : []),
+ ...(props.showTaskColumn ? [{ id: 'task', weight: 11 }] : []),
+ ];
+ const totalColumnWeight = () => visibleColumns().reduce((sum, c) => sum + c.weight, 0);
+ const columnCount = () => visibleColumns().length;
+
return (
<Show
when={props.rows.length > 0}
@@ -82,15 +105,11 @@ export function ProxmoxCoverageTable(props: {
<TableCard class={PLATFORM_TABLE_CARD_CLASS}>
<Table class="min-w-[1200px] table-fixed text-xs">
<colgroup>
- <col style={{ width: '17%' }} />
- <col style={{ width: '7%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '13%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '11%' }} />
- <col style={{ width: '9%' }} />
- <col style={{ width: '10%' }} />
+ <For each={visibleColumns()}>
+ {(column) => (
+ <col style={{ width: `${(column.weight / totalColumnWeight()) * 100}%` }} />
+ )}
+ </For>
</colgroup>
<TableHeader>
<TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
@@ -123,42 +142,50 @@ export function ProxmoxCoverageTable(props: {
align="right"
headClass={getPlatformTableHeadClassForKind('numeric-value')}
/>
- <SortableHead
- label="PBS"
- sortKey="pbs"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Archive"
- sortKey="archive"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Snapshot"
- sortKey="snapshot"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
- <SortableHead
- label="Latest task"
- sortKey="task"
- currentSort={props.sortKey}
- direction={props.sortDirection}
- onSort={props.onSort}
- align="left"
- headClass={getPlatformTableHeadClassForKind('text')}
- />
+ <Show when={props.showPbsColumn}>
+ <SortableHead
+ label="PBS"
+ sortKey="pbs"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ </Show>
+ <Show when={props.showArchiveColumn}>
+ <SortableHead
+ label="Archive"
+ sortKey="archive"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ </Show>
+ <Show when={props.showSnapshotColumn}>
+ <SortableHead
+ label="Snapshot"
+ sortKey="snapshot"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ </Show>
+ <Show when={props.showTaskColumn}>
+ <SortableHead
+ label="Latest task"
+ sortKey="task"
+ currentSort={props.sortKey}
+ direction={props.sortDirection}
+ onSort={props.onSort}
+ align="left"
+ headClass={getPlatformTableHeadClassForKind('text')}
+ />
+ </Show>
</TableRow>
</TableHeader>
<TableBody class={PLATFORM_TABLE_BODY_CLASS}>
@@ -228,63 +255,80 @@ export function ProxmoxCoverageTable(props: {
{(artifact) => formatRelativeTime(artifact().createdAt, { compact: true })}
</Show>
</TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show when={row.latestPBS} fallback={<span class="text-muted">No PBS</span>}>
- {(artifact) => formatRelativeTime(artifact().createdAt, { compact: true })}
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={row.latestArchive}
- fallback={<span class="text-muted">No archive</span>}
+ <Show when={props.showPbsColumn}>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
- {(artifact) => formatRelativeTime(artifact().createdAt, { compact: true })}
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={row.latestSnapshot}
- fallback={<span class="text-muted">No snapshot</span>}
+ <Show
+ when={row.latestPBS}
+ fallback={<span class="text-muted">No PBS</span>}
+ >
+ {(artifact) =>
+ formatRelativeTime(artifact().createdAt, { compact: true })
+ }
+ </Show>
+ </TableCell>
+ </Show>
+ <Show when={props.showArchiveColumn}>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
- {(artifact) => formatRelativeTime(artifact().createdAt, { compact: true })}
- </Show>
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
- >
- <Show
- when={row.latestTask}
- fallback={<span class="text-muted">No recent task</span>}
+ <Show
+ when={row.latestArchive}
+ fallback={<span class="text-muted">No archive</span>}
+ >
+ {(artifact) =>
+ formatRelativeTime(artifact().createdAt, { compact: true })
+ }
+ </Show>
+ </TableCell>
+ </Show>
+ <Show when={props.showSnapshotColumn}>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
- {(task) => (
- <div class="flex items-center gap-2">
- <StatusDot
- size="sm"
- variant={
- task().label === 'Failed'
- ? 'danger'
- : task().label === 'OK'
- ? 'success'
- : 'warning'
- }
- title={task().label}
- ariaHidden
- />
- <span class="truncate">{task().label}</span>
- </div>
- )}
- </Show>
- </TableCell>
+ <Show
+ when={row.latestSnapshot}
+ fallback={<span class="text-muted">No snapshot</span>}
+ >
+ {(artifact) =>
+ formatRelativeTime(artifact().createdAt, { compact: true })
+ }
+ </Show>
+ </TableCell>
+ </Show>
+ <Show when={props.showTaskColumn}>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <Show
+ when={row.latestTask}
+ fallback={<span class="text-muted">No recent task</span>}
+ >
+ {(task) => (
+ <div class="flex items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={
+ task().label === 'Failed'
+ ? 'danger'
+ : task().label === 'OK'
+ ? 'success'
+ : 'warning'
+ }
+ title={task().label}
+ ariaHidden
+ />
+ <span class="truncate">{task().label}</span>
+ </div>
+ )}
+ </Show>
+ </TableCell>
+ </Show>
</TableRow>
<Show when={isExpanded()}>
<TableRow class="bg-surface-alt/40">
- <TableCell class="px-3 py-2" colspan={9}>
+ <TableCell class="px-3 py-2" colspan={columnCount()}>
<Show
when={evidence().length > 0}
fallback={
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
new file mode 100644
index 0000000000..7b174b8e63
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxCoverageTable.test.tsx
@@ -0,0 +1,65 @@
+import { cleanup, render } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it } from 'vitest';
+import type { Accessor } from 'solid-js';
+
+import { ProxmoxCoverageTable } from '../ProxmoxCoverageTable';
+import type { WorkloadCoverageRow } from '../proxmoxBackupRecoveryModel';
+import type { CoverageSortKey } from '../proxmoxBackupsTableModel';
+
+const row = {
+ key: 'w1',
+ workload: {
+ key: 'w1',
+ type: 'vm',
+ typeLabel: 'VM',
+ vmid: '100',
+ label: 'web (VM 100)',
+ name: 'web',
+ node: 'pve1',
+ },
+ artifacts: [],
+ pbsCount: 1,
+ archiveCount: 0,
+ snapshotCount: 0,
+ posture: 'current',
+ postureRank: 0,
+} as unknown as WorkloadCoverageRow;
+
+const headerTexts = () =>
+ [...document.querySelectorAll('thead th')].map((th) => th.textContent?.trim() ?? '');
+
+afterEach(cleanup);
+
+describe('ProxmoxCoverageTable column visibility', () => {
+ it('renders only the source columns whose show flag is true', () => {
+ render(() => (
+ <ProxmoxCoverageTable
+ rows={[row]}
+ hasAnyRows
+ emptyIcon={<span />}
+ emptyTitle=""
+ emptyDescription=""
+ sortKey={(() => 'posture') as Accessor<CoverageSortKey>}
+ sortDirection={() => 'asc'}
+ onSort={() => {}}
+ expandedKeys={new Set<string>()}
+ onToggleExpand={() => {}}
+ showPbsColumn={true}
+ showArchiveColumn={false}
+ showSnapshotColumn={true}
+ showTaskColumn={false}
+ />
+ ));
+
+ const headers = headerTexts();
+ // Always-on columns.
+ expect(headers).toContain('Workload');
+ expect(headers).toContain('VMID');
+ expect(headers).toContain('Node');
+ // Source columns gate on their flags.
+ expect(headers).toContain('PBS');
+ expect(headers).toContain('Snapshot');
+ expect(headers).not.toContain('Archive');
+ expect(headers).not.toContain('Latest task');
+ });
+});