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 percent values

rcourtman146676d3383c
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index a6239e7a34..32235b02fb 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2655,11 +2655,14 @@ the consuming table owns only which current/total values, suffix, and warning
tone apply.
One-decimal percent and positive Celsius cells are also shared platform-table
value primitives. `PlatformTablePercentValue` owns percent formatting,
-tabular-number styling, and empty markers, while
+tabular-number styling, and empty markers; `formatPlatformTablePercentValue`
+owns the same one-decimal percent string for overlay labels, titles, and
+sparkline labels, including caller-selected ratio normalization and clamping.
`PlatformTableTemperatureValue` owns finite positive Celsius validation,
one-decimal `°C` formatting, tabular-number styling, and empty markers. Docker
-/ Podman host and TrueNAS system/storage-topology tables must compose those
-primitives instead of carrying local `formatPercent`, `formatTemperature`, or
+/ Podman host, Proxmox backup/Ceph/node/mail-gateway, and TrueNAS
+system/storage-topology tables or drawers must compose those primitives instead
+of carrying local `formatPercent`, `formatPercentLabel`, `toFixed(1)%`, or
temperature label helpers.
Platform table metric fallback rendering is also shared.
`PlatformTableMetricFallback` owns the centered muted empty marker used in
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 8219c61e10..7988d8cc30 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -141,6 +141,11 @@ meaningful for the backup-health row, while dense integer count presentation
belongs to `frontend-primitives`: backup count cells must compose
`PlatformTableNumberValue` with `formatPlatformTableIntegerValue` instead of
reintroducing local `toLocaleString()` formatting.
+PBS server/datastore utilization follows the same split: storage/recovery owns
+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.
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 82e019f171..989380f494 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -281,10 +281,12 @@ and unknown empty-cell markers instead of local `formatInteger`,
Percent and temperature table cells follow the same split: unified-resource
consumers own which usage percentage or temperature source is meaningful for
the row, while dense platform table rendering must use
-`PlatformTablePercentValue` and `PlatformTableTemperatureValue` for one-decimal
-formatting, positive Celsius validation, tabular styling, and empty markers
-instead of local `formatPercent`, `formatTemperature`, or temperature label
-helpers.
+`PlatformTablePercentValue`, `formatPlatformTablePercentValue`, and
+`PlatformTableTemperatureValue` for one-decimal percent formatting, ratio
+normalization/clamping when the source metric requires it, positive Celsius
+validation, tabular styling, and empty markers instead of local
+`formatPercent`, `formatPercentLabel`, `toFixed(1)%`, `formatTemperature`, or
+temperature label helpers.
Metric bar fallbacks follow that split as well: unified-resource consumers own
which CPU or memory value is selected, plus any source-specific fallback reason
such as outdated standalone agent telemetry, while platform tables must use
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index 089354e3a2..39bcbf1b29 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -1600,13 +1600,44 @@
{
"id": "platform-table-percent-value-fallback",
"category": "platform-table-text-value",
- "summary": "Platform tables must use the shared percent-value primitive for one-decimal percent cells, tabular styling, and canonical empty-cell markers instead of recreating local formatPercent helpers.",
+ "summary": "Platform tables and drawers must use the shared percent-value primitive/helper for one-decimal percent cells, overlay labels, tabular styling, ratio normalization, clamping, and canonical empty-cell markers instead of recreating local formatPercent helpers.",
"canonical": {
"path": "src/features/platformPage/sharedPlatformPage.tsx",
"export": "PlatformTablePercentValue"
},
- "requiredConsumers": [{ "path": "src/features/truenas/TrueNASSystemsTable.tsx" }],
+ "requiredConsumers": [
+ { "path": "src/features/proxmox/ProxmoxBackupServersTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxCephClusterDrawer.tsx" },
+ { "path": "src/features/proxmox/ProxmoxCephTable.tsx" },
+ { "path": "src/features/proxmox/ProxmoxMailGatewayDrawer.tsx" },
+ { "path": "src/features/proxmox/ProxmoxNodesTable.tsx" },
+ { "path": "src/features/truenas/TrueNASSystemsTable.tsx" }
+ ],
"forbiddenPatterns": [
+ {
+ "path": "src/features/proxmox/ProxmoxBackupServersTable.tsx",
+ "patterns": [
+ "Math.round(row.cpuPercent ?? 0)}%",
+ "Math.round(row.memoryPercent ?? 0)}%",
+ "Math.round(pct() ?? 0)}%"
+ ]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxCephClusterDrawer.tsx",
+ "patterns": ["clamped.toFixed(1)}%"]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxCephTable.tsx",
+ "patterns": ["pct.toFixed(1)}%"]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxMailGatewayDrawer.tsx",
+ "patterns": ["share.toFixed(1)}%"]
+ },
+ {
+ "path": "src/features/proxmox/ProxmoxNodesTable.tsx",
+ "patterns": ["const formatPercentLabel", "`${Math.round(Math.max(0, normalized))}%`"]
+ },
{
"path": "src/features/truenas/TrueNASSystemsTable.tsx",
"patterns": [
@@ -2523,6 +2554,46 @@
"scripts/shared-template-audit.mjs"
]
},
+ {
+ "id": "platform-table-local-proxmox-percent-tofixed-label",
+ "category": "platform-table-text-value",
+ "summary": "Proxmox platform tables and drawers must not recreate one-decimal percent labels with toFixed.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTablePercentValue"
+ },
+ "scopes": ["src/features/proxmox"],
+ "extensions": [".tsx"],
+ "allPatterns": ["toFixed(1)}%"],
+ "legacyReason": "Retired migration debt. Proxmox platform percent labels must compose formatPlatformTablePercentValue or PlatformTablePercentValue so formatting stays shared.",
+ "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-proxmox-percent-label-helper",
+ "category": "platform-table-text-value",
+ "summary": "Proxmox platform tables must not recreate local percent label helpers for metric cells.",
+ "canonical": {
+ "path": "src/features/platformPage/sharedPlatformPage.tsx",
+ "export": "formatPlatformTablePercentValue"
+ },
+ "scopes": ["src/features/proxmox"],
+ "extensions": [".tsx"],
+ "allPatterns": ["formatPercentLabel"],
+ "legacyReason": "Retired migration debt. Proxmox platform percent metric labels must compose formatPlatformTablePercentValue so ratio normalization, clamping, and empty markers stay shared.",
+ "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-temperature-value-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 f9bbbff4d2..5da277a6ee 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -4312,6 +4312,12 @@ describe('shared primitive guardrails', () => {
const localPercentGuard = registry.patternGuards?.find(
(guard) => guard.id === 'platform-table-local-percent-value-helper',
);
+ const localProxmoxPercentToFixedGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-proxmox-percent-tofixed-label',
+ );
+ const localProxmoxPercentLabelGuard = registry.patternGuards?.find(
+ (guard) => guard.id === 'platform-table-local-proxmox-percent-label-helper',
+ );
const localTemperatureGuard = registry.patternGuards?.find(
(guard) => guard.id === 'platform-table-local-temperature-value-helper',
);
@@ -4319,6 +4325,11 @@ describe('shared primitive guardrails', () => {
(guard) => guard.id === 'platform-table-local-temperature-label-helper',
);
const percentConsumers: Array<[string, string]> = [
+ ['src/features/proxmox/ProxmoxBackupServersTable.tsx', proxmoxBackupServersTableSource],
+ ['src/features/proxmox/ProxmoxCephClusterDrawer.tsx', proxmoxCephClusterDrawerSource],
+ ['src/features/proxmox/ProxmoxCephTable.tsx', proxmoxCephTableSource],
+ ['src/features/proxmox/ProxmoxMailGatewayDrawer.tsx', proxmoxMailGatewayDrawerSource],
+ ['src/features/proxmox/ProxmoxNodesTable.tsx', proxmoxNodesTableSource],
['src/features/truenas/TrueNASSystemsTable.tsx', truenasSystemsTableSource],
];
const temperatureConsumers: Array<[string, string]> = [
@@ -4341,6 +4352,30 @@ describe('shared primitive guardrails', () => {
percentConsumers.map(([path]) => path),
);
expect(percentRule?.forbiddenPatterns).toEqual([
+ {
+ path: 'src/features/proxmox/ProxmoxBackupServersTable.tsx',
+ patterns: [
+ 'Math.round(row.cpuPercent ?? 0)}%',
+ 'Math.round(row.memoryPercent ?? 0)}%',
+ 'Math.round(pct() ?? 0)}%',
+ ],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxCephClusterDrawer.tsx',
+ patterns: ['clamped.toFixed(1)}%'],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxCephTable.tsx',
+ patterns: ['pct.toFixed(1)}%'],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxMailGatewayDrawer.tsx',
+ patterns: ['share.toFixed(1)}%'],
+ },
+ {
+ path: 'src/features/proxmox/ProxmoxNodesTable.tsx',
+ patterns: ['const formatPercentLabel', '`${Math.round(Math.max(0, normalized))}%`'],
+ },
{
path: 'src/features/truenas/TrueNASSystemsTable.tsx',
patterns: localPercentPatterns,
@@ -4377,6 +4412,26 @@ describe('shared primitive guardrails', () => {
expect(localPercentGuard?.scopes).toEqual(['src/features/truenas']);
expect(localPercentGuard?.allowedPaths ?? []).toHaveLength(0);
expect(localPercentGuard?.ignoredPaths ?? []).toHaveLength(0);
+ expect(localProxmoxPercentToFixedGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localProxmoxPercentToFixedGuard?.canonical?.export).toBe(
+ 'formatPlatformTablePercentValue',
+ );
+ expect(localProxmoxPercentToFixedGuard?.allPatterns).toEqual(['toFixed(1)}%']);
+ expect(localProxmoxPercentToFixedGuard?.scopes).toEqual(['src/features/proxmox']);
+ expect(localProxmoxPercentToFixedGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localProxmoxPercentToFixedGuard?.ignoredPaths ?? []).toHaveLength(0);
+ expect(localProxmoxPercentLabelGuard?.canonical?.path).toBe(
+ 'src/features/platformPage/sharedPlatformPage.tsx',
+ );
+ expect(localProxmoxPercentLabelGuard?.canonical?.export).toBe(
+ 'formatPlatformTablePercentValue',
+ );
+ expect(localProxmoxPercentLabelGuard?.allPatterns).toEqual(['formatPercentLabel']);
+ expect(localProxmoxPercentLabelGuard?.scopes).toEqual(['src/features/proxmox']);
+ expect(localProxmoxPercentLabelGuard?.allowedPaths ?? []).toHaveLength(0);
+ expect(localProxmoxPercentLabelGuard?.ignoredPaths ?? []).toHaveLength(0);
expect(localTemperatureGuard?.canonical?.path).toBe(
'src/features/platformPage/sharedPlatformPage.tsx',
);
@@ -4398,12 +4453,12 @@ describe('shared primitive guardrails', () => {
expect(localTemperatureLabelGuard?.ignoredPaths ?? []).toHaveLength(0);
expect(sharedPlatformPageSource).toContain('export function PlatformTablePercentValue');
+ expect(sharedPlatformPageSource).toContain('export const formatPlatformTablePercentValue');
expect(sharedPlatformPageSource).toContain('export function PlatformTableTemperatureValue');
- expect(sharedPlatformPageSource).toContain('formatOneDecimalPercent');
expect(sharedPlatformPageSource).toContain('formatOneDecimalCelsius');
for (const [path, source] of percentConsumers) {
- expect(source).toContain('PlatformTablePercentValue');
+ expect(source).toMatch(/PlatformTablePercentValue|formatPlatformTablePercentValue/);
const forbiddenPatterns =
percentRule?.forbiddenPatterns?.find((entry) => entry.path === path)?.patterns ?? [];
for (const pattern of forbiddenPatterns) {
diff --git a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
index d827769ce7..33b4e09458 100644
--- a/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
+++ b/frontend-modern/src/features/platformPage/__tests__/sharedPlatformPage.test.ts
@@ -15,6 +15,7 @@ import {
formatPlatformTableCountRatioValue,
formatPlatformTableDateTimeValue,
formatPlatformTableIntegerValue,
+ formatPlatformTablePercentValue,
formatPlatformTableTitleCaseValue,
formatPlatformTableUptimeValue,
filterPlatformResources,
@@ -440,6 +441,15 @@ describe('PlatformTableCountRatioValue', () => {
});
describe('PlatformTablePercentValue', () => {
+ it('formats shared percent labels with canonical empty, ratio, and clamp behavior', () => {
+ expect(formatPlatformTablePercentValue(42.345)).toBe('42.3%');
+ expect(formatPlatformTablePercentValue(undefined)).toBe('—');
+ expect(formatPlatformTablePercentValue(Number.NaN, { emptyText: '-' })).toBe('-');
+ expect(formatPlatformTablePercentValue(0.812, { normalizeRatio: true })).toBe('81.2%');
+ expect(formatPlatformTablePercentValue(120, { clamp: true })).toBe('100.0%');
+ expect(formatPlatformTablePercentValue(-3, { clamp: true })).toBe('0.0%');
+ });
+
it('renders finite percentages with one decimal place and shared tabular styling', () => {
const { container } = render(() => PlatformTablePercentValue({ value: 42.345 }));
const marker = container.querySelector('span');
@@ -451,6 +461,14 @@ describe('PlatformTablePercentValue', () => {
render(() => PlatformTablePercentValue({ value: Number.NaN, emptyText: '-' }));
expect(screen.getByText('-')).toBeInTheDocument();
});
+
+ it('passes ratio normalization and clamping through the shared component', () => {
+ const { container } = render(() =>
+ PlatformTablePercentValue({ value: 0.25, normalizeRatio: true, clamp: true }),
+ );
+
+ expect(container.querySelector('span')?.textContent).toBe('25.0%');
+ });
});
describe('PlatformTableTemperatureValue', () => {
diff --git a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
index f0f281ef0d..191b205ac0 100644
--- a/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
+++ b/frontend-modern/src/features/platformPage/sharedPlatformPage.tsx
@@ -356,12 +356,31 @@ export function PlatformTableCountRatioValue(props: {
);
}
-const formatOneDecimalPercent = (value: number): string => `${value.toFixed(1)}%`;
+export type PlatformTablePercentValueOptions = {
+ emptyText?: string;
+ normalizeRatio?: boolean;
+ clamp?: boolean;
+};
+
+export const formatPlatformTablePercentValue = (
+ value: number | null | undefined,
+ options: PlatformTablePercentValueOptions = {},
+): string => {
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
+ return options.emptyText ?? '—';
+ }
+ const normalized = options.normalizeRatio && value <= 1 ? value * 100 : value;
+ const clamped = options.clamp ? Math.max(0, Math.min(100, normalized)) : normalized;
+ return `${clamped.toFixed(1)}%`;
+};
+
const formatOneDecimalCelsius = (value: number): string => `${value.toFixed(1)}°C`;
export function PlatformTablePercentValue(props: {
value: number | null | undefined;
emptyText?: string;
+ normalizeRatio?: boolean;
+ clamp?: boolean;
}) {
const finiteValue = () =>
typeof props.value === 'number' && Number.isFinite(props.value) ? props.value : undefined;
@@ -370,7 +389,13 @@ export function PlatformTablePercentValue(props: {
<PlatformTableNumberValue
value={finiteValue()}
emptyText={props.emptyText}
- format={formatOneDecimalPercent}
+ format={(value) =>
+ formatPlatformTablePercentValue(value, {
+ emptyText: props.emptyText,
+ normalizeRatio: props.normalizeRatio,
+ clamp: props.clamp,
+ })
+ }
/>
);
}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
index 3720707593..41a7cf2143 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupServersTable.tsx
@@ -5,9 +5,11 @@ import { TableCell, TableHead, TableRow } from '@/components/shared/Table';
import { formatBytes, formatUptime } from '@/utils/format';
import {
formatPlatformTableIntegerValue,
+ formatPlatformTablePercentValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableNumberValue,
+ PlatformTablePercentValue,
PlatformTableShell,
} from '@/features/platformPage/sharedPlatformPage';
import type { PBSBackup } from '@/types/api';
@@ -206,13 +208,13 @@ export function ProxmoxBackupServersTable(props: {
{row.version || '—'}
</TableCell>
<TableCell
- class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content tabular-nums`}
+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
<Show
when={row.online && row.cpuPercent !== undefined}
fallback={<span class="text-muted">—</span>}
>
- {Math.round(row.cpuPercent ?? 0)}%
+ <PlatformTablePercentValue value={row.cpuPercent} />
</Show>
</TableCell>
<TableCell class={getPlatformTableCellClassForKind('numeric-value')}>
@@ -221,14 +223,14 @@ export function ProxmoxBackupServersTable(props: {
fallback={<span class="text-muted">—</span>}
>
<span
- class="text-base-content tabular-nums"
+ class="text-base-content"
title={
row.memoryTotal
? `${formatBytes(row.memoryUsed ?? 0)} / ${formatBytes(row.memoryTotal)}`
: undefined
}
>
- {Math.round(row.memoryPercent ?? 0)}%
+ <PlatformTablePercentValue value={row.memoryPercent} />
</span>
<Show when={row.memoryTotal}>
<span class="ml-1 text-[10px] text-muted tabular-nums">
@@ -262,13 +264,11 @@ export function ProxmoxBackupServersTable(props: {
<StatusDot
size="sm"
variant={usageVariant(pct())}
- title={`Datastore ${Math.round(pct() ?? 0)}% used`}
+ title={`Datastore ${formatPlatformTablePercentValue(pct())} used`}
ariaHidden
/>
<span class={`tabular-nums font-medium ${usageToneClass(pct())}`}>
- <Show when={pct() !== undefined} fallback="—">
- {Math.round(pct() ?? 0)}%
- </Show>
+ <PlatformTablePercentValue value={pct()} />
</span>
<span class="text-[10px] text-muted tabular-nums">
{formatBytes(datastore().used)} / {formatBytes(datastore().total)}
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCephClusterDrawer.tsx b/frontend-modern/src/features/proxmox/ProxmoxCephClusterDrawer.tsx
index 247f6eac81..1bbf436a48 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCephClusterDrawer.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCephClusterDrawer.tsx
@@ -16,6 +16,7 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
formatPlatformTableIntegerValue,
+ formatPlatformTablePercentValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableNumberValue,
@@ -74,7 +75,8 @@ function CapacityBar(props: { used: number; total: number; percent: number }) {
fillClass={capacityToneFor(clamped)}
label={
<span class="absolute inset-0 flex items-center justify-center text-[10px] font-semibold text-base-content leading-none tabular-nums">
- {clamped.toFixed(1)}% · {formatBytes(props.used)} / {formatBytes(props.total)}
+ {formatPlatformTablePercentValue(clamped)} · {formatBytes(props.used)} /{' '}
+ {formatBytes(props.total)}
</span>
}
/>
@@ -90,7 +92,7 @@ function PoolUsageBar(props: { percent: number }) {
fillClass={capacityToneFor(clamped)}
label={
<span class="absolute inset-0 flex items-center justify-center text-[10px] font-semibold text-base-content leading-none tabular-nums">
- {clamped.toFixed(1)}%
+ {formatPlatformTablePercentValue(clamped)}
</span>
}
/>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCephTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCephTable.tsx
index 4bf4bc2ccc..b44598ec79 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCephTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCephTable.tsx
@@ -16,6 +16,7 @@ import { formatBytes } from '@/utils/format';
import { asTrimmedString } from '@/utils/stringUtils';
import {
PlatformTableToolbar,
+ formatPlatformTablePercentValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
type PlatformTableFilterOption,
@@ -149,11 +150,12 @@ function capacityLabel(resource: Resource): JSX.Element {
if (typeof total === 'number' && total > 0) {
return (
<span class="tabular-nums">
- {pct.toFixed(1)}%<span class="text-muted text-[10px]"> of {formatBytes(total)}</span>
+ {formatPlatformTablePercentValue(pct)}
+ <span class="text-muted text-[10px]"> of {formatBytes(total)}</span>
</span>
);
}
- return <span class="tabular-nums">{pct.toFixed(1)}%</span>;
+ return <span class="tabular-nums">{formatPlatformTablePercentValue(pct)}</span>;
}
function healthMessageCell(resource: Resource): JSX.Element {
diff --git a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
index 63f7977120..eff813c9ad 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxMailGatewayDrawer.tsx
@@ -15,6 +15,7 @@ import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_HEADER_ROW_CLASS,
formatPlatformTableIntegerValue,
+ formatPlatformTablePercentValue,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
PlatformTableNumberValue,
@@ -144,7 +145,9 @@ function StackedBar(props: { segments: StackedSegment[]; ariaLabel: string }) {
{formatPlatformTableIntegerValue(seg.value)}
</span>
<Show when={total() > 0}>
- <span class="text-muted tabular-nums text-[10px]">{share.toFixed(1)}%</span>
+ <span class="text-muted tabular-nums text-[10px]">
+ {formatPlatformTablePercentValue(share)}
+ </span>
</Show>
</div>
);
diff --git a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
index f2b6110e2b..92b1fb7843 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxNodesTable.tsx
@@ -33,6 +33,7 @@ import {
PlatformTableEmptyState,
PlatformTableMetricFallback,
PlatformTableShell,
+ formatPlatformTablePercentValue,
getPlatformTableFiniteMetric,
getPlatformTableCellClassForKind,
getPlatformTableHeadClassForKind,
@@ -119,13 +120,6 @@ const projectResourceToLegacyNode = (resource: Resource): LegacyNode => {
return projected as unknown as LegacyNode;
};
-const formatPercentLabel = (value: number | null | undefined): string => {
- const finiteValue = typeof value === 'number' ? getPlatformTableFiniteMetric(value) : undefined;
- if (finiteValue === undefined) return '—';
- const normalized = finiteValue <= 1 ? finiteValue * 100 : finiteValue;
- return `${Math.round(Math.max(0, normalized))}%`;
-};
-
type HostSortKey = ProxmoxHostTableColumnId;
const TEXT_SORT_KEYS = new Set<ProxmoxHostTableColumnId>(['node', 'version', 'cluster']);
@@ -441,7 +435,10 @@ export const ProxmoxNodesTable: Component<{
>
<MetricMiniSparkline
series={cpuSeries()}
- valueLabel={formatPercentLabel(cpuPercent())}
+ valueLabel={formatPlatformTablePercentValue(cpuPercent(), {
+ normalizeRatio: true,
+ clamp: true,
+ })}
title={`${name()} CPU history`}
/>
</Show>
@@ -472,7 +469,10 @@ export const ProxmoxNodesTable: Component<{
>
<MetricMiniSparkline
series={memorySeries()}
- valueLabel={formatPercentLabel(memoryPercent())}
+ valueLabel={formatPlatformTablePercentValue(memoryPercent(), {
+ normalizeRatio: true,
+ clamp: true,
+ })}
title={`${name()} memory history`}
/>
</Show>
@@ -500,7 +500,10 @@ export const ProxmoxNodesTable: Component<{
>
<MetricMiniSparkline
series={diskSeries()}
- valueLabel={formatPercentLabel(diskPercent())}
+ valueLabel={formatPlatformTablePercentValue(diskPercent(), {
+ normalizeRatio: true,
+ clamp: true,
+ })}
title={`${name()} disk history`}
/>
</Show>
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index cd1ec46302..4b82c61dec 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -290,10 +290,18 @@ describe('ProxmoxBackupsTable', () => {
it('keeps PBS backup count cells on the shared platform integer primitive', () => {
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)}' + '%';
expect(proxmoxBackupServersTableSource).toContain('PlatformTableNumberValue');
expect(proxmoxBackupServersTableSource).toContain('formatPlatformTableIntegerValue');
+ expect(proxmoxBackupServersTableSource).toContain('PlatformTablePercentValue');
+ expect(proxmoxBackupServersTableSource).toContain('formatPlatformTablePercentValue');
expect(proxmoxBackupServersTableSource).not.toContain(directLocaleCountCall);
+ expect(proxmoxBackupServersTableSource).not.toContain(directCpuPercentRound);
+ expect(proxmoxBackupServersTableSource).not.toContain(directMemoryPercentRound);
+ expect(proxmoxBackupServersTableSource).not.toContain(directDatastorePercentRound);
});
it('keeps backup coverage fed by Proxmox VM/LXC guests when Overview demotes app containers', () => {