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.

Converge platform uptime values

rcourtman15eed88ed1c3
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 32235b02fb..32947afe29 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2606,9 +2606,10 @@ declaring local `compactList` or `summarizeValues` helpers.
Platform table uptime formatting follows that rule too.
`formatPlatformTableUptimeValue` owns the repeated one-unit uptime label plus
canonical empty-cell marker behavior for dense platform table cells. Docker /
-Podman hosts, Kubernetes nodes, Proxmox Mail Gateway instances, Standalone
-machines, and TrueNAS systems must compose that helper instead of declaring
-local `formatUptime` helpers for the same days/hours/minutes fallback.
+Podman hosts, Kubernetes nodes, Proxmox backup server rows, Proxmox Mail
+Gateway instance and drawer node rows, Standalone machines, and TrueNAS systems
+must compose that helper instead of declaring local `formatUptime` helpers for
+the same days/hours/minutes fallback.
Platform table byte-size formatting follows the same rule.
`formatPlatformTableBytesValue` owns the repeated positive-byte formatting plus
canonical empty-cell marker behavior for dense platform table cells. Docker /
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7988d8cc30..954b50675a 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -146,6 +146,10 @@ which datastore usage percentage is meaningful for backup-health risk, while
frontend-primitives owns one-decimal percent presentation through
`PlatformTablePercentValue` and `formatPlatformTablePercentValue` instead of
local rounded `%` strings.
+PBS server uptime follows the same split: storage/recovery owns whether the
+server uptime belongs on the backup-health row, while frontend-primitives owns
+the one-unit uptime label through `formatPlatformTableUptimeValue` instead of
+local `formatUptime` calls.
Those Proxmox backup workflows own recovery semantics, source-specific
empty-state copy, and retry/filter actions, but their table empty-state frame
must compose the frontend-primitives-owned `PlatformTableEmptyState` shell
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 989380f494..53a5bf9724 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -241,9 +241,10 @@ labels, full title text, and normalized value lists instead of recreating local
`compactList` or `summarizeValues` helpers.
One-unit platform table uptime labels follow the same boundary:
unified-resource consumers own which uptime field is displayed, but platform
-tables, including Standalone machines, must use
-`formatPlatformTableUptimeValue` instead of recreating local days/hours/minutes
-`formatUptime` helpers for dense table cells.
+tables and platform-owned drawers, including Standalone machines, Proxmox
+backup servers, and Proxmox Mail Gateway node rows, must use
+`formatPlatformTableUptimeValue` instead of recreating local
+days/hours/minutes `formatUptime` helpers for dense table cells.
Platform byte-size table cells follow that boundary too: unified-resource
consumers own whether a capacity, memory, disk, or requested-size field is the
right source-specific value, while dense platform table cells must use
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 39bcbf1b29..365a41ec88 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1304,6 +1304,8 @@
"requiredConsumers": [
{ "path": "src/features/docker/DockerHostsTable.tsx" },
{ "path": "src/features/kubernetes/KubernetesNodesTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxBackupServersTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxMailGatewayDrawer.tsx" },
{ "path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx" },
{ "path": "src/features/standalone/AgentsMachinesTable.tsx" },
{ "path": "src/features/truenas/TrueNASSystemsTable.tsx" }
@@ -1317,6 +1319,18 @@
"path": "src/features/kubernetes/KubernetesNodesTable.tsx",
"patterns": ["const formatUptime"]
},
+ {
+ "path": "src/features/proxmox/ProxmoxBackupServersTable.tsx",
+ "patterns": ["formatUptime(row.uptimeSeconds ?? 0)"]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxMailGatewayDrawer.tsx",
+ "patterns": [
+ "function formatUptime",
+ "const days = Math.floor(seconds / 86_400);",
+ "return `${mins}m`"
+ ]
+ },
{
"path": "src/features/proxmox/ProxmoxMailGatewayTable.tsx",
"patterns": ["const formatUptime"]
@@ -2267,6 +2281,36 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-local-uptime-function-helper",
+ "category": "platform-table-text-value",
+ "summary": "Platform tables and drawers must not recreate function-based one-unit formatUptime helpers for uptime label fallback.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTableUptimeValue"
+ },
+ "scopes": [
+ "src/features/docker",
+ "src/features/kubernetes",
+ "src/features/proxmox",
+ "src/features/standalone",
+ "src/features/truenas"
+ ],
+ "extensions": [".tsx"],
+ "allPatterns": [
+ "function formatUptime",
+ "const days = Math.floor(seconds / 86_400);",
+ "return `${mins}m`"
+ ],
+ "legacyReason": "Retired migration debt. Platform table uptime labels must use formatPlatformTableUptimeValue for the shared one-unit uptime fallback.",
+ "allowedPaths": [],
+ "ignoredPaths": [],
+ "proof": [
+ "src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/features/platformPage/__tests__/sharedPlatformPage.test.ts",
+ "scripts/shared-template-audit.mjs"
+ ]
+ },
{
"id": "platform-table-local-bytes-helper",
"category": "platform-table-text-value",
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 5da277a6ee..22ab4c4515 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -3616,9 +3616,14 @@ describe('shared primitive guardrails', () => {
const localHelperGuard = registry.patternGuards?.find(
(guard) => guard.id === 'platform-table-local-uptime-helper',
);
+ const functionHelperGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-uptime-function-helper',
+ );
const platformUptimeConsumers: Array<[string, string]> = [
['src/features/docker/DockerHostsTable.tsx', dockerHostsTableSource],
['src/features/kubernetes/KubernetesNodesTable.tsx', kubernetesNodesTableSource],
+ ['src/features/proxmox/ProxmoxBackupServersTable.tsx', proxmoxBackupServersTableSource],
+ ['src/features/proxmox/ProxmoxMailGatewayDrawer.tsx', proxmoxMailGatewayDrawerSource],
['src/features/proxmox/ProxmoxMailGatewayTable.tsx', proxmoxMailGatewayTableSource],
['src/features/standalone/AgentsMachinesTable.tsx', agentsMachinesTableSource],
['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
@@ -3632,12 +3637,31 @@ describe('shared primitive guardrails', () => {
expect(registeredRule?.requiredConsumers?.map((consumer) => consumer.path)).toEqual(
platformUptimeConsumerPaths,
);
- expect(registeredRule?.forbiddenPatterns).toEqual(
- platformUptimeConsumerPaths.map((path) => ({
- path,
+ expect(registeredRule?.forbiddenPatterns).toEqual([
+ { path: 'src/features/docker/DockerHostsTable.tsx', patterns: ['const formatUptime'] },
+ {
+ path: 'src/features/kubernetes/KubernetesNodesTable.tsx',
patterns: ['const formatUptime'],
- })),
- );
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxBackupServersTable.tsx',
+ patterns: ['formatUptime(row.uptimeSeconds ?? 0)'],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxMailGatewayDrawer.tsx',
+ patterns: [
+ 'function formatUptime',
+ 'const days = Math.floor(seconds / 86_400);',
+ 'return `${mins}m`',
+ ],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxMailGatewayTable.tsx',
+ patterns: ['const formatUptime'],
+ },
+ { path: 'src/features/standalone/AgentsMachinesTable.tsx', patterns: ['const formatUptime'] },
+ { path: 'src/features/truenas/TrueNASSystemsTable.tsx', patterns: ['const formatUptime'] },
+ ]);
expect(localHelperGuard?.canonical?.path).toBe(
'src/features/platformPage/sharedPlatformPage.tsx',
);
@@ -3656,6 +3680,24 @@ describe('shared primitive guardrails', () => {
]);
expect(localHelperGuard?.allowedPaths ?? []).toHaveLength(0);
expect(localHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
+ expect(functionHelperGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(functionHelperGuard?.canonical?.export).toBe('formatPlatformTableUptimeValue');
+ expect(functionHelperGuard?.allPatterns).toEqual([
+ 'function formatUptime',
+ 'const days = Math.floor(seconds / 86_400);',
+ 'return `${mins}m`',
+ ]);
+ expect(functionHelperGuard?.scopes).toEqual([
+ 'src/features/docker',
+ 'src/features/kubernetes',
+ 'src/features/proxmox',
+ 'src/features/standalone',
+ 'src/features/truenas',
+ ]);
+ expect(functionHelperGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(functionHelperGuard?.ignoredPaths ?? []).toHaveLength(0);
expect(sharedPlatformPageSource).toContain('export const formatPlatformTableUptimeValue');
expect(sharedPlatformPageSource).toContain('formatUptime(seconds, true)');
@@ -3663,7 +3705,8 @@ describe('shared primitive guardrails', () => {
for (const [, source] of platformUptimeConsumers) {
expect(source).toContain('formatPlatformTableUptimeValue');
expect(source).not.toContain('const formatUptime');
- expect(source).not.toContain('seconds / 86_400');
+ expect(source).not.toContain('function formatUptime');
+ expect(source).not.toContain('const days = Math.floor(seconds / 86_400);');
expect(source).not.toContain('return `${mins}m`');
}
});
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
index 41a7cf2143..46aab9d956 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
@@ -2,10 +2,11 @@ import { For, Show, type JSX } from 'solid-js';
import { StatusDot } from '@/components/shared/StatusDot';
import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
-import { formatBytes, formatUptime } from '@/utils/format';
+import { formatBytes } from '@/utils/format';
import {
formatPlatformTableIntegerValue,
formatPlatformTablePercentValue,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableNumberValue,
@@ -246,7 +247,7 @@ export function ProxmoxBackupServersTable(props: {
when={row.online && (row.uptimeSeconds ?? 0) > 0}
fallback={<span class="text-muted">—</span>}
>
- {formatUptime(row.uptimeSeconds ?? 0)}
+ {formatPlatformTableUptimeValue(row.uptimeSeconds)}
</Show>
</TableCell>
<TableCell
diff --git a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
index eff813c9ad..bd2d69a6a4 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
@@ -16,6 +16,7 @@ import {
PLATFORM_TABLE_HEADER_ROW_CLASS,
formatPlatformTableIntegerValue,
formatPlatformTablePercentValue,
+ formatPlatformTableUptimeValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableNumberValue,
@@ -71,16 +72,6 @@ function classifyNode(node: PMGNodeStatus): { variant: StatusIndicatorVariant; l
return { variant: 'muted', label: raw || '—' };
}
-function formatUptime(seconds: number | undefined): string {
- if (!seconds || seconds <= 0) return '—';
- const days = Math.floor(seconds / 86_400);
- if (days > 0) return `${days}d`;
- const hours = Math.floor(seconds / 3_600);
- if (hours > 0) return `${hours}h`;
- const mins = Math.floor(seconds / 60);
- return `${mins}m`;
-}
-
function formatAge(seconds: number): string {
if (!seconds || seconds <= 0) return '—';
if (seconds < 60) return `${seconds}s`;
@@ -526,7 +517,7 @@ export const ProxmoxMailGatewayDrawer: Component<{
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
- {formatUptime(node.uptime)}
+ {formatPlatformTableUptimeValue(node.uptime)}
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums text-[11px]`}
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 4b82c61dec..a9d63c7b27 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -288,20 +288,23 @@ describe('ProxmoxBackupsTable', () => {
);
});
- it('keeps PBS backup count cells on the shared platform integer primitive', () => {
+ it('keeps PBS backup count and uptime cells on shared platform primitives', () => {
const directLocaleCountCall = 'row.backupCount.' + 'toLocale' + 'String()';
const directCpuPercentRound = 'Math.round(row.cpuPercent ?? 0)}' + '%';
const directMemoryPercentRound = 'Math.round(row.memoryPercent ?? 0)}' + '%';
const directDatastorePercentRound = 'Math.round(pct() ?? 0)}' + '%';
+ const directUptimeCall = 'formatUptime(row.uptimeSeconds ?? 0)';
expect(proxmoxBackupServersTableSource).toContain('PlatformTableNumberValue');
expect(proxmoxBackupServersTableSource).toContain('formatPlatformTableIntegerValue');
expect(proxmoxBackupServersTableSource).toContain('PlatformTablePercentValue');
expect(proxmoxBackupServersTableSource).toContain('formatPlatformTablePercentValue');
+ expect(proxmoxBackupServersTableSource).toContain('formatPlatformTableUptimeValue');
expect(proxmoxBackupServersTableSource).not.toContain(directLocaleCountCall);
expect(proxmoxBackupServersTableSource).not.toContain(directCpuPercentRound);
expect(proxmoxBackupServersTableSource).not.toContain(directMemoryPercentRound);
expect(proxmoxBackupServersTableSource).not.toContain(directDatastorePercentRound);
+ expect(proxmoxBackupServersTableSource).not.toContain(directUptimeCall);
});
it('keeps backup coverage fed by Proxmox VM/LXC guests when Overview demotes app containers', () => {