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.

Split infrastructure summary table runtime owners

rcourtmanb1d7897910d7
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 287f3e451d..5e04b1af63 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -168,6 +168,17 @@ identifier-variant logic.
Those same surfaces also share the trimmed-string helper from
`frontend-modern/src/utils/stringUtils.ts` so shared components do not keep
their own copy of the same whitespace-trimming identity logic.
+The shared infrastructure summary table now also follows the same
+shell/runtime/model shape as the rest of the modernized primitives.
+`frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx` stays
+the table shell, `frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts`
+owns alert wiring, sort state, breakpoint state, and expanded-row lifecycle,
+`frontend-modern/src/components/shared/infrastructureSummaryTableModel.ts`
+owns sorting, count, identity-alias, and linked-agent derivation, and
+`frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx`
+owns the per-row render/runtime surface. Future work should extend those
+owners instead of pushing websocket, alert, or identity plumbing back into the
+shared table shell.
The audit log settings surface now follows that same owner split.
`frontend-modern/src/components/Settings/AuditLogPanel.tsx` stays the canonical
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index f376790246..fe61af827c 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2168,8 +2168,11 @@
"match_prefixes": [],
"match_files": [
"frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx",
+ "frontend-modern/src/components/shared/infrastructureSummaryTableModel.ts",
+ "frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx",
"frontend-modern/src/components/shared/PulseDataGrid.tsx",
- "frontend-modern/src/components/shared/Table.tsx"
+ "frontend-modern/src/components/shared/Table.tsx",
+ "frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts"
],
"allow_same_subsystem_tests": false,
"test_prefixes": [],
diff --git a/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx b/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
index 2f379bddfb..2c5b00fa23 100644
--- a/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
+++ b/frontend-modern/src/components/shared/InfrastructureSummaryTable.tsx
@@ -1,367 +1,24 @@
-import { Component, For, Show, createMemo, createSignal, lazy, Suspense } from 'solid-js';
-import type { Agent, Node, PBSInstance } from '@/types/api';
-import { formatBytes, formatUptime } from '@/utils/format';
-import { useWebSocket } from '@/App';
-import { getAlertStyles } from '@/utils/alerts';
+import { For, Show } from 'solid-js';
+import type { Component } from 'solid-js';
import { Card } from '@/components/shared/Card';
-import { getNodeDisplayName, hasAlternateDisplayName } from '@/utils/nodes';
-import { getCpuTemperature, formatTemperature } from '@/utils/temperature';
-import { useAlertsActivation } from '@/stores/alertsActivation';
-import { buildMetricKey } from '@/utils/metricsKeys';
import {
Table,
- TableHeader,
TableBody,
- TableRow,
TableHead,
- TableCell,
+ TableHeader,
+ TableRow,
} from '@/components/shared/Table';
-import { StatusDot } from '@/components/shared/StatusDot';
-import { getNodeStatusIndicator, getPBSStatusIndicator } from '@/utils/status';
-import { ResponsiveMetricCell } from '@/components/shared/responsive';
-import { StackedMemoryBar } from '@/components/Dashboard/StackedMemoryBar';
-import { StackedDiskBar } from '@/components/Dashboard/StackedDiskBar';
-import { EnhancedCPUBar } from '@/components/Dashboard/EnhancedCPUBar';
-import { TemperatureGauge } from '@/components/shared/TemperatureGauge';
-import { useBreakpoint } from '@/hooks/useBreakpoint';
-import {
- getAgentLikeIdentityAliases,
- getNormalizedIdentityLookupVariants,
-} from '@/utils/resourceIdentity';
-import { asTrimmedString } from '@/utils/stringUtils';
-
-// Lazy load InfrastructureDetailsDrawer to avoid circular dependencies and reduce bundle size
-const InfrastructureDetailsDrawer = lazy(() =>
- import('./InfrastructureDetailsDrawer').then((m) => ({ default: m.InfrastructureDetailsDrawer })),
-);
-
-const asRecord = (value: unknown): Record<string, unknown> | undefined =>
- value && typeof value === 'object' ? (value as Record<string, unknown>) : undefined;
-
-const getAgentLinkedNodeId = (agent: Agent): string | undefined => {
- const agentRecord = agent as unknown as Record<string, unknown>;
- const platformData = asRecord(agentRecord.platformData);
- const platformAgent = asRecord(platformData?.agent);
-
- return (
- asTrimmedString(agent.linkedNodeId) ||
- asTrimmedString(platformData?.linkedNodeId) ||
- asTrimmedString(platformAgent?.linkedNodeId)
- );
-};
-
-interface InfrastructureSummaryTableProps {
- nodes: Node[];
- pbsInstances?: PBSInstance[];
- vmCounts?: Record<string, number>;
- containerCounts?: Record<string, number>;
- storageCounts?: Record<string, number>;
- diskCounts?: Record<string, number>;
- agents?: Agent[];
- backupCounts?: Record<string, number>;
- currentTab: 'dashboard' | 'storage' | 'recovery';
- selectedNode: string | null;
- globalTemperatureMonitoringEnabled?: boolean;
- onNodeClick: (nodeId: string, nodeType: 'pve' | 'pbs') => void;
-}
+import { InfrastructureSummaryTableRow } from './InfrastructureSummaryTableRow';
+import type { InfrastructureSummaryTableProps } from './infrastructureSummaryTableModel';
+import { useInfrastructureSummaryTableState } from './useInfrastructureSummaryTableState';
export const InfrastructureSummaryTable: Component<InfrastructureSummaryTableProps> = (props) => {
- const { activeAlerts } = useWebSocket();
- const alertsActivation = useAlertsActivation();
- const alertsEnabled = createMemo(() => alertsActivation.activationState() === 'active');
- const { isMobile } = useBreakpoint();
-
- // Get user-configured temperature threshold for display coloring
- const temperatureThreshold = createMemo(() => alertsActivation.getTemperatureThreshold());
-
- const isTemperatureMonitoringEnabled = (node: Node): boolean => {
- const globalEnabled = props.globalTemperatureMonitoringEnabled ?? true;
- if (
- node.temperatureMonitoringEnabled !== undefined &&
- node.temperatureMonitoringEnabled !== null
- ) {
- return node.temperatureMonitoringEnabled;
- }
- return globalEnabled;
- };
-
- type TableItem = Node | PBSInstance;
-
- const isPVE = (item: TableItem): item is Node => {
- // Check for pveVersion or the unified agent resource type returned by v6 APIs.
- return (item as Node).pveVersion !== undefined || (item as any).type === 'agent';
- };
-
- type CountSortKey = 'vmCount' | 'containerCount' | 'storageCount' | 'diskCount' | 'backupCount';
- type SortKey =
- | 'default'
- | 'name'
- | 'uptime'
- | 'cpu'
- | 'memory'
- | 'disk'
- | 'temperature'
- | CountSortKey;
-
- const [sortKey, setSortKey] = createSignal<SortKey>('default');
- const [sortDirection, setSortDirection] = createSignal<'asc' | 'desc'>('asc');
-
- const [expandedNodeId, setExpandedNodeId] = createSignal<string | null>(null);
-
- const toggleNodeExpand = (nodeId: string, e: MouseEvent) => {
- e.stopPropagation();
- setExpandedNodeId((prev) => (prev === nodeId ? null : nodeId));
- };
-
- const hasAnyTemperatureData = createMemo(() => {
- return (
- props.nodes?.some(
- (node) => node.temperature?.available || isTemperatureMonitoringEnabled(node),
- ) || false
- );
- });
-
- // Calculate total column count for colspan in expanded rows
- const totalColumnCount = createMemo(() => {
- let count = 6; // Base: Name, Uptime, CPU, Memory, Disk, Link
- if (hasAnyTemperatureData()) count += 1;
- if (props.currentTab === 'dashboard')
- count += 2; // VMs, CTs
- else if (props.currentTab === 'storage')
- count += 2; // Storage, Disks
- else if (props.currentTab === 'recovery') count += 1; // Recovery
- return count;
- });
-
- const getCpuTemperatureValue = (item: TableItem) => {
- if (!isPVE(item)) return null;
- const node = item;
- const value = getCpuTemperature(node.temperature);
- return value !== null ? Math.round(value) : null;
- };
-
- const getDefaultSortDirection = (key: Exclude<SortKey, 'default'>) => {
- switch (key) {
- case 'name':
- return 'asc';
- default:
- return 'desc';
- }
- };
-
- const handleSort = (key: Exclude<SortKey, 'default'>) => {
- if (sortKey() === key) {
- if (sortDirection() === 'asc') {
- setSortDirection('desc');
- } else {
- setSortKey('default');
- setSortDirection('asc');
- }
- } else {
- setSortKey(key);
- setSortDirection(getDefaultSortDirection(key));
- }
- };
-
- const isItemOnline = (item: TableItem) => {
- if (isPVE(item)) {
- const node = item;
- return node.status === 'online' && (node.uptime || 0) > 0;
- }
- const pbs = item;
- return pbs.status === 'healthy' || pbs.status === 'online';
- };
-
- const getPbsTotals = (pbs: PBSInstance) => {
- return (pbs.datastores ?? []).reduce(
- (acc, ds) => {
- acc.used += ds.used || 0;
- acc.total += ds.total || 0;
- return acc;
- },
- { used: 0, total: 0 },
- );
- };
-
- const getCpuPercent = (item: TableItem) => {
- if (isPVE(item)) {
- const node = item;
- return Math.round((node.cpu || 0) * 100);
- }
- const pbs = item;
- return Math.round(pbs.cpu || 0);
- };
-
- const getMemoryPercent = (item: TableItem) => {
- if (isPVE(item)) {
- const node = item;
- return Math.round(node.memory?.usage || 0);
- }
- const pbs = item;
- if (!pbs.memoryTotal) return 0;
- return Math.round((pbs.memoryUsed / pbs.memoryTotal) * 100);
- };
-
- const getDiskPercent = (item: TableItem) => {
- if (isPVE(item)) {
- const node = item;
- if (!node.disk || node.disk.total === 0) return 0;
- return Math.round((node.disk.used / node.disk.total) * 100);
- }
- const pbs = item;
- const totals = getPbsTotals(pbs);
- if (totals.total === 0) return 0;
- return Math.round((totals.used / totals.total) * 100);
- };
-
- const getDiskSublabel = (item: TableItem) => {
- if (isPVE(item)) {
- const node = item;
- if (!node.disk) return undefined;
- return `${formatBytes(node.disk.used)}/${formatBytes(node.disk.total)}`;
- }
- const pbs = item;
- if (!pbs.datastores || pbs.datastores.length === 0) return undefined;
- const totals = getPbsTotals(pbs);
- return `${formatBytes(totals.used)}/${formatBytes(totals.total)}`;
- };
-
- const getTemperatureValue = (item: TableItem) => {
- return getCpuTemperatureValue(item);
- };
-
- const getCountValue = (item: TableItem, key: CountSortKey): number | null => {
- if (!isPVE(item)) {
- const pbs = item;
- if (key === 'backupCount') {
- return props.backupCounts?.[pbs.name] ?? 0;
- }
- return null;
- }
-
- const node = item;
-
- switch (key) {
- case 'vmCount':
- return props.vmCounts?.[node.id] ?? 0;
- case 'containerCount':
- return props.containerCounts?.[node.id] ?? 0;
- case 'storageCount':
- return props.storageCounts?.[node.id] ?? 0;
- case 'diskCount':
- return props.diskCounts?.[node.id] ?? 0;
- case 'backupCount':
- return props.backupCounts?.[node.id] ?? 0;
- default:
- return null;
- }
- };
-
- const getSortValue = (item: TableItem, key: SortKey): number | string | null => {
- switch (key) {
- case 'name':
- return isPVE(item) ? getNodeDisplayName(item) : item.name;
- case 'uptime':
- return isPVE(item) ? (item.uptime ?? 0) : (item.uptime ?? 0);
- case 'cpu':
- return getCpuPercent(item);
- case 'memory':
- return getMemoryPercent(item);
- case 'disk':
- return getDiskPercent(item);
- case 'temperature':
- return getTemperatureValue(item);
- case 'vmCount':
- case 'containerCount':
- case 'storageCount':
- case 'diskCount':
- case 'backupCount':
- return getCountValue(item, key);
- default:
- return null;
- }
- };
-
- const defaultComparison = (a: TableItem, b: TableItem) => {
- const aIsPVE = isPVE(a);
- const bIsPVE = isPVE(b);
- if (aIsPVE !== bIsPVE) return aIsPVE ? -1 : 1;
-
- const aOnline = isItemOnline(a);
- const bOnline = isItemOnline(b);
- if (aOnline !== bOnline) return aOnline ? -1 : 1;
-
- const aName = aIsPVE ? getNodeDisplayName(a) : a.name;
- const bName = bIsPVE ? getNodeDisplayName(b) : b.name;
-
- return aName.localeCompare(bName);
- };
-
- const compareValues = (valueA: number | string | null, valueB: number | string | null) => {
- const aEmpty =
- valueA === null ||
- valueA === undefined ||
- (typeof valueA === 'number' && Number.isNaN(valueA));
- const bEmpty =
- valueB === null ||
- valueB === undefined ||
- (typeof valueB === 'number' && Number.isNaN(valueB));
-
- if (aEmpty && bEmpty) return 0;
- if (aEmpty) return 1;
- if (bEmpty) return -1;
-
- if (typeof valueA === 'number' && typeof valueB === 'number') {
- if (valueA === valueB) return 0;
- return valueA < valueB ? -1 : 1;
- }
-
- const aStr = String(valueA).toLowerCase();
- const bStr = String(valueB).toLowerCase();
-
- if (aStr === bStr) return 0;
- return aStr < bStr ? -1 : 1;
- };
-
- const sortedItems = createMemo(() => {
- const items: TableItem[] = [];
-
- if (props.nodes) items.push(...props.nodes);
- if (props.pbsInstances) items.push(...props.pbsInstances);
-
- const key = sortKey();
- const direction = sortDirection();
-
- return items.sort((a, b) => {
- if (key === 'default') {
- return defaultComparison(a, b);
- }
-
- const valueA = getSortValue(a, key);
- const valueB = getSortValue(b, key);
- const comparison = compareValues(valueA, valueB);
-
- if (comparison !== 0) {
- return direction === 'asc' ? comparison : -comparison;
- }
-
- return defaultComparison(a, b);
- });
- });
-
- const renderSortIndicator = (key: SortKey) => {
- if (sortKey() !== key) return null;
- return sortDirection() === 'asc' ? '▲' : '▼';
- };
+ const table = useInfrastructureSummaryTableState(props);
const thClassBase =
'px-1.5 sm:px-2 py-0.5 text-[11px] sm:text-xs font-medium uppercase tracking-wider cursor-pointer hover:bg-surface-hover whitespace-nowrap';
const thClass = `${thClassBase} text-center`;
- // Cell class constants for consistency
- const tdClass = 'px-2 py-1 align-middle';
- const metricColumnStyle = { 'min-width': '140px', 'max-width': '180px' } as const;
-
return (
<Card padding="none" tone="card" class="mb-4 overflow-hidden">
<Table
@@ -370,619 +27,111 @@ export const InfrastructureSummaryTable: Component<InfrastructureSummaryTablePro
>
<TableHeader>
<TableRow class="bg-surface-alt text-muted border-b border-border">
- <TableHead class={`${thClassBase} text-left pl-3`} onClick={() => handleSort('name')}>
+ <TableHead class={`${thClassBase} text-left pl-3`} onClick={() => table.handleSort('name')}>
{props.currentTab === 'recovery' ? 'Node / PBS' : 'Node'}{' '}
- {renderSortIndicator('name')}
+ {table.renderSortIndicator('name')}
</TableHead>
<TableHead
class={thClass}
style={{ width: '80px', 'min-width': '80px', 'max-width': '80px' }}
- onClick={() => handleSort('uptime')}
+ onClick={() => table.handleSort('uptime')}
>
- Uptime {renderSortIndicator('uptime')}
+ Uptime {table.renderSortIndicator('uptime')}
</TableHead>
<TableHead
class={thClass}
style={
- isMobile()
+ table.isMobile()
? { 'min-width': '80px' }
: { 'min-width': '140px', 'max-width': '180px' }
}
- onClick={() => handleSort('cpu')}
+ onClick={() => table.handleSort('cpu')}
>
- CPU {renderSortIndicator('cpu')}
+ CPU {table.renderSortIndicator('cpu')}
</TableHead>
<TableHead
class={thClass}
style={
- isMobile()
+ table.isMobile()
? { 'min-width': '80px' }
: { 'min-width': '140px', 'max-width': '180px' }
}
- onClick={() => handleSort('memory')}
+ onClick={() => table.handleSort('memory')}
>
- Memory {renderSortIndicator('memory')}
+ Memory {table.renderSortIndicator('memory')}
</TableHead>
<TableHead
class={thClass}
style={
- isMobile()
+ table.isMobile()
? { 'min-width': '80px' }
: { 'min-width': '140px', 'max-width': '180px' }
}
- onClick={() => handleSort('disk')}
+ onClick={() => table.handleSort('disk')}
>
- Disk {renderSortIndicator('disk')}
+ Disk {table.renderSortIndicator('disk')}
</TableHead>
- <Show when={hasAnyTemperatureData()}>
+ <Show when={table.hasAnyTemperatureData()}>
<TableHead
class={thClass}
style={{ width: '60px', 'min-width': '60px', 'max-width': '60px' }}
- onClick={() => handleSort('temperature')}
+ onClick={() => table.handleSort('temperature')}
>
- Temp {renderSortIndicator('temperature')}
+ Temp {table.renderSortIndicator('temperature')}
</TableHead>
</Show>
<Show when={props.currentTab === 'dashboard'}>
<TableHead
class={thClass}
style={{ width: '50px', 'min-width': '50px', 'max-width': '50px' }}
- onClick={() => handleSort('vmCount')}
+ onClick={() => table.handleSort('vmCount')}
>
- VMs {renderSortIndicator('vmCount')}
+ VMs {table.renderSortIndicator('vmCount')}
</TableHead>
<TableHead
class={thClass}
style={{ width: '50px', 'min-width': '50px', 'max-width': '50px' }}
- onClick={() => handleSort('containerCount')}
+ onClick={() => table.handleSort('containerCount')}
>
- CTs {renderSortIndicator('containerCount')}
+ CTs {table.renderSortIndicator('containerCount')}
</TableHead>
</Show>
<Show when={props.currentTab === 'storage'}>
<TableHead
class={thClass}
style={{ width: '70px', 'min-width': '70px', 'max-width': '70px' }}
- onClick={() => handleSort('storageCount')}
+ onClick={() => table.handleSort('storageCount')}
>
- Storage {renderSortIndicator('storageCount')}
+ Storage {table.renderSortIndicator('storageCount')}
</TableHead>
<TableHead
class={thClass}
style={{ width: '60px', 'min-width': '60px', 'max-width': '60px' }}
- onClick={() => handleSort('diskCount')}
+ onClick={() => table.handleSort('diskCount')}
>
- Disks {renderSortIndicator('diskCount')}
+ Disks {table.renderSortIndicator('diskCount')}
</TableHead>
</Show>
<Show when={props.currentTab === 'recovery'}>
<TableHead
class={thClass}
style={{ width: '70px', 'min-width': '70px', 'max-width': '70px' }}
- onClick={() => handleSort('backupCount')}
+ onClick={() => table.handleSort('backupCount')}
>
- Recovery {renderSortIndicator('backupCount')}
+ Recovery {table.renderSortIndicator('backupCount')}
</TableHead>
</Show>
- {/* Link icon column moved to end */}
<TableHead
class={thClass}
style={{ width: '28px', 'min-width': '28px', 'max-width': '28px' }}
- >
- {/* Link icon column */}
- </TableHead>
+ />
</TableRow>
</TableHeader>
- <TableBody class="divide-y divide-border">
- <For each={sortedItems()}>
- {(item) => {
- const isPVEItem = isPVE(item);
- const isPBSItem = !isPVEItem;
- const node = isPVEItem ? (item as Node) : null;
- const pbs = isPBSItem ? (item as PBSInstance) : null;
-
- const online = isItemOnline(item);
- const statusIndicator = createMemo(() =>
- isPVEItem
- ? getNodeStatusIndicator(node as Node)
- : getPBSStatusIndicator(pbs as PBSInstance),
- );
- const cpuPercentValue = getCpuPercent(item);
- const memoryPercentValue = getMemoryPercent(item);
- const diskPercentValue = getDiskPercent(item);
- const diskSublabel = getDiskSublabel(item);
- const cpuTemperatureValue = getCpuTemperatureValue(item);
- const uptimeValue = isPVEItem
- ? (node?.uptime ?? 0)
- : isPBSItem
- ? (pbs?.uptime ?? 0)
- : 0;
- const displayName = () => {
- if (isPVEItem) return getNodeDisplayName(node as Node);
- return (pbs as PBSInstance).name;
- };
- const showActualName = () => isPVEItem && hasAlternateDisplayName(node as Node);
-
- const nodeId = isPVEItem ? node!.id : pbs!.name;
- const isSelected = () => props.selectedNode === nodeId;
- const isExpanded = () => expandedNodeId() === nodeId;
- const resourceId = isPVEItem ? node!.id || node!.name : pbs!.id || pbs!.name;
- const linkedAgentForDrawer = (): Agent | undefined => {
- if (!isPVEItem || !node) return undefined;
- const agents = props.agents ?? [];
-
- const linkedAgentId = node.linkedAgentId;
- if (linkedAgentId) {
- const byId = agents.find((agent) =>
- getAgentLikeIdentityAliases(agent).includes(linkedAgentId),
- );
- if (byId) return byId;
- }
-
- const nodeName = (node.name || '').trim();
- return agents.find((agent) => {
- const linkedNodeId = getAgentLinkedNodeId(agent);
- if (linkedNodeId === node.id) {
- return true;
- }
-
- if (!nodeName) {
- return false;
- }
- const aliases = getAgentLikeIdentityAliases(agent).flatMap((value) =>
- getNormalizedIdentityLookupVariants(value),
- );
- return aliases.includes(nodeName.toLowerCase());
- });
- };
- const metricsKey =
- isPVEItem && node?.linkedAgentId
- ? buildMetricKey('agent', node.linkedAgentId)
- : buildMetricKey('node', resourceId);
- const alertStyles = createMemo(() =>
- getAlertStyles(resourceId, activeAlerts, alertsEnabled()),
- );
- const showAlertHighlight = createMemo(
- () => alertStyles().hasUnacknowledgedAlert && online,
- );
-
- const rowStyle = createMemo(() => {
- const styles: Record<string, string> = {};
- const shadows: string[] = [];
-
- if (showAlertHighlight()) {
- const color = alertStyles().severity === 'critical' ? '#ef4444' : '#eab308';
- shadows.push(`inset 4px 0 0 0 ${color}`);
- }
-
- if (isSelected()) {
- shadows.push('0 0 0 1px rgba(59, 130, 246, 0.5)');
- shadows.push('0 2px 4px -1px rgba(0, 0, 0, 0.1)');
- }
-
- if (shadows.length > 0) {
- styles['box-shadow'] = shadows.join(', ');
- }
- return styles;
- });
-
- const rowClass = createMemo(() => {
- const baseHover =
- 'cursor-pointer transition-all duration-200 relative hover:shadow-sm group';
-
- if (isSelected()) {
- return `cursor-pointer transition-all duration-200 relative hover:shadow-sm z-10 group bg-blue-50 dark:bg-blue-900`;
- }
-
- if (showAlertHighlight()) {
- const alertBg =
- alertStyles().severity === 'critical'
- ? 'bg-red-50 dark:bg-red-950'
- : 'bg-yellow-50 dark:bg-yellow-950';
- return `cursor-pointer transition-all duration-200 relative hover:shadow-sm group ${alertBg}`;
- }
-
- let className = baseHover;
-
- if (props.selectedNode && props.selectedNode !== nodeId) {
- className += ' opacity-50 hover:opacity-80';
- }
-
- if (!online) {
- className += ' opacity-60';
- }
-
- return className;
- });
-
- return (
- <>
- <TableRow
- class={rowClass()}
- style={{ ...rowStyle(), 'min-height': '36px' }}
- onClick={() => props.onNodeClick(nodeId, isPVEItem ? 'pve' : 'pbs')}
- >
- {/* Name */}
- <TableCell
- class={`pr-2 py-1 align-middle overflow-hidden ${showAlertHighlight() ? 'pl-4' : 'pl-3'}`}
- >
- <div class="flex items-center gap-1.5 min-w-0">
- <Show when={isPVEItem}>
- <div
- class={`cursor-pointer transition-transform duration-200 ${isExpanded() ? 'rotate-90' : ''}`}
- onClick={(e) => toggleNodeExpand(nodeId, e)}
- >
- <svg
- class="w-3.5 h-3.5 hover:text-base-content"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M9 5l7 7-7 7"
- />
- </svg>
- </div>
- </Show>
- <StatusDot
- variant={statusIndicator().variant}
- title={statusIndicator().label}
- ariaLabel={statusIndicator().label}
- size="xs"
- />
- <span
- class="font-medium text-[11px] text-base-content whitespace-nowrap select-text"
- title={displayName()}
- >
- {displayName()}
- </span>
- <Show when={showActualName()}>
- <span class="text-[9px] text-muted whitespace-nowrap">
- ({(node as Node).name})
- </span>
- </Show>
- <div class="hidden xl:flex items-center gap-1.5 ml-1 flex-shrink min-w-0 overflow-hidden">
- <Show when={isPVEItem}>
- <span class="text-[9px] px-1 py-0 rounded font-medium bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-400">
- PVE
- </span>
- </Show>
- <Show when={isPVEItem && node!.pveVersion}>
- <span class="text-[9px] text-muted whitespace-nowrap">
- v{node!.pveVersion.split('/')[1] || node!.pveVersion}
- </span>
- </Show>
- <Show when={isPVEItem && node!.isClusterMember !== undefined}>
- <span
- class={`text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap ${
- node!.isClusterMember
- ? 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400'
- : 'bg-surface-alt text-muted'
- }`}
- >
- {node!.isClusterMember ? node!.clusterName : 'Standalone'}
- </span>
- </Show>
- <Show when={isPVEItem && node!.linkedAgentId}>
- <span
- class="text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-400"
- title="Pulse agent installed for enhanced metrics"
- >
- +Agent
- </span>
- </Show>
- <Show
- when={
- isPVEItem &&
- online &&
- node!.pendingUpdates !== undefined &&
- node!.pendingUpdates > 0
- }
- >
- <span
- class={`text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap ${
- (node!.pendingUpdates ?? 0) >= 10
- ? 'bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-400'
- : 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-400'
- }`}
- title={`${node!.pendingUpdates} pending apt update${node!.pendingUpdates !== 1 ? 's' : ''}`}
- >
- {node!.pendingUpdates} updates
- </span>
- </Show>
- <Show when={isPBSItem}>
- <span class="text-[9px] px-1 py-0 rounded font-medium bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-400">
- PBS
- </span>
- </Show>
- <Show when={isPBSItem && pbs!.version}>
- <span class="text-[9px] text-muted whitespace-nowrap">
- v{pbs!.version}
- </span>
- </Show>
- </div>
- </div>
- </TableCell>
-
- {/* Uptime */}
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span
- class={`text-xs whitespace-nowrap ${
- isPVEItem && (node?.uptime ?? 0) < 3600
- ? 'text-orange-500'
- : 'text-muted'
- }`}
- >
- <Show when={online && uptimeValue} fallback="-">
- <Show when={isMobile()} fallback={formatUptime(uptimeValue)}>
- {formatUptime(uptimeValue, true)}
- </Show>
- </Show>
- </span>
- </div>
- </TableCell>
-
- {/* CPU */}
- <TableCell
- class={tdClass}
- style={isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
- >
- <div class="h-5">
- <EnhancedCPUBar
- usage={cpuPercentValue}
- loadAverage={isPVEItem ? node!.loadAverage?.[0] : undefined}
- cores={
- isMobile() ? undefined : isPVEItem ? node!.cpuInfo?.cores : undefined
- }
- model={isPVEItem ? node!.cpuInfo?.model : undefined}
- resourceId={metricsKey}
- />
- </div>
- </TableCell>
-
- {/* Memory */}
- <TableCell
- class={tdClass}
- style={isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
- >
- <div class="h-5">
- <Show
- when={isPVEItem}
- fallback={
- <ResponsiveMetricCell
- value={memoryPercentValue}
- type="memory"
- resourceId={metricsKey}
- sublabel={
- pbs!.memoryTotal
- ? `${formatBytes(pbs!.memoryUsed)}/${formatBytes(pbs!.memoryTotal)}`
- : undefined
- }
- isRunning={online}
- showMobile={false}
- />
- }
- >
- <StackedMemoryBar
- used={node!.memory?.used || 0}
- total={node!.memory?.total || 0}
- balloon={node!.memory?.balloon || 0}
- swapUsed={node!.memory?.swapUsed || 0}
- swapTotal={node!.memory?.swapTotal || 0}
- resourceId={metricsKey}
- />
- </Show>
- </div>
- </TableCell>
-
- {/* Disk */}
- <TableCell
- class={tdClass}
- style={isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
- >
- <div class="h-5">
- <Show
- when={isPVEItem}
- fallback={
- <ResponsiveMetricCell
- value={diskPercentValue}
- type="disk"
- resourceId={metricsKey}
- sublabel={diskSublabel}
- isRunning={online}
- showMobile={false}
- />
- }
- >
- <StackedDiskBar
- aggregateDisk={{
- total: node!.disk?.total || 0,
- used: node!.disk?.used || 0,
- free: (node!.disk?.total || 0) - (node!.disk?.used || 0),
- usage: node!.disk?.total ? node!.disk.used / node!.disk.total : 0,
- }}
- />
- </Show>
- </div>
- </TableCell>
-
- {/* Temperature */}
- <Show when={hasAnyTemperatureData()}>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <Show
- when={
- online &&
- isPVEItem &&
- cpuTemperatureValue !== null &&
- (node!.temperature?.hasCPU ??
- node!.temperature?.hasGPU ??
- node!.temperature?.available) &&
- isTemperatureMonitoringEnabled(node!)
- }
- fallback={<span class="text-xs text-muted">-</span>}
- >
- {(() => {
- const value = cpuTemperatureValue as number;
- const temp = node!.temperature;
- const cpuMinValue =
- typeof temp?.cpuMin === 'number' && temp.cpuMin > 0
- ? temp.cpuMin
- : null;
- const cpuMaxValue =
- typeof temp?.cpuMaxRecord === 'number' && temp.cpuMaxRecord > 0
- ? temp.cpuMaxRecord
- : null;
- const hasMinMax = cpuMinValue !== null && cpuMaxValue !== null;
-
- const gpus = temp?.gpu ?? [];
- const hasGPU = gpus.length > 0;
-
- if (hasMinMax || hasGPU) {
- const min =
- typeof cpuMinValue === 'number'
- ? Math.round(cpuMinValue)
- : undefined;
- const max =
- typeof cpuMaxValue === 'number'
- ? Math.round(cpuMaxValue)
- : undefined;
-
- return (
- <div
- title={`Min: ${min !== undefined ? formatTemperature(min) : '-'}, Max: ${max !== undefined ? formatTemperature(max) : '-'}${hasGPU ? `\nGPU: ${gpus.map((g) => formatTemperature(g.edge ?? g.junction ?? g.mem)).join(', ')}` : ''}`}
- >
- <TemperatureGauge
- value={value}
- min={min}
- max={max}
- critical={temperatureThreshold()}
- warning={Math.max(0, temperatureThreshold() - 5)}
- />
- </div>
- );
- }
-
- return (
- <TemperatureGauge
- value={value}
- critical={temperatureThreshold()}
- warning={Math.max(0, temperatureThreshold() - 5)}
- />
- );
- })()}
- </Show>
- </div>
- </TableCell>
- </Show>
-
- {/* Dashboard tab: VMs and CTs */}
- <Show when={props.currentTab === 'dashboard'}>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span class={online ? 'text-xs text-base-content' : 'text-xs text-muted'}>
- {online ? (getCountValue(item, 'vmCount') ?? '-') : '-'}
- </span>
- </div>
- </TableCell>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span class={online ? 'text-xs text-base-content' : 'text-xs text-muted'}>
- {online ? (getCountValue(item, 'containerCount') ?? '-') : '-'}
- </span>
- </div>
- </TableCell>
- </Show>
-
- {/* Storage tab: Storage and Disks */}
- <Show when={props.currentTab === 'storage'}>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span class={online ? 'text-xs text-base-content' : 'text-xs text-muted'}>
- {online ? (getCountValue(item, 'storageCount') ?? '-') : '-'}
- </span>
- </div>
- </TableCell>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span class={online ? 'text-xs text-base-content' : 'text-xs text-muted'}>
- {online ? (getCountValue(item, 'diskCount') ?? '-') : '-'}
- </span>
- </div>
- </TableCell>
- </Show>
-
- {/* Recovery tab */}
- <Show when={props.currentTab === 'recovery'}>
- <TableCell class={tdClass}>
- <div class="flex justify-center">
- <span class={online ? 'text-xs text-base-content' : 'text-xs text-muted'}>
- {online ? (getCountValue(item, 'backupCount') ?? '-') : '-'}
- </span>
- </div>
- </TableCell>
- </Show>
-
- {/* Link Column (Moved to end) */}
- <TableCell class="px-0 py-1 align-middle text-center">
- <Show
- when={isPVEItem ? node!.guestURL || node!.host : pbs!.guestURL || pbs!.host}
- >
- <a
- href={
- isPVEItem
- ? node!.guestURL || node!.host || `https://${node!.name}:8006`
- : pbs!.guestURL || pbs!.host || `https://${pbs!.name}:8007`
- }
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- class="inline-flex justify-center items-center text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors"
- title={`Open ${displayName()} web interface`}
- >
- <svg
- class="w-3.5 h-3.5"
- fill="none"
- stroke="currentColor"
- viewBox="0 0 24 24"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
- />
- </svg>
- </a>
- </Show>
- </TableCell>
- </TableRow>
- <Show when={isExpanded() && isPVEItem}>
- <TableRow>
- <TableCell
- colspan={totalColumnCount()}
- class="bg-surface-alt px-4 py-4 border-b border-border-subtle shadow-inner"
- >
- <Suspense
- fallback={<div class="flex justify-center p-4">Loading stats...</div>}
- >
- <InfrastructureDetailsDrawer
- node={node!}
- agent={linkedAgentForDrawer()}
- />
- </Suspense>
- </TableCell>
- </TableRow>
- </Show>
- </>
- );
- }}
+ <TableBody class="divide-y divide-border">
+ <For each={table.sortedItems()}>
+ {(item) => <InfrastructureSummaryTableRow item={item} table={table} tableProps={props} />}
</For>
</TableBody>
</Table>
diff --git a/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx b/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx
new file mode 100644
index 0000000000..ed72c6dbf1
--- /dev/null
+++ b/frontend-modern/src/components/shared/InfrastructureSummaryTableRow.tsx
@@ -0,0 +1,505 @@
+import { Show, Suspense, createMemo, lazy } from 'solid-js';
+import type { Component } from 'solid-js';
+import type { Agent, Node, PBSInstance } from '@/types/api';
+import { formatBytes, formatUptime } from '@/utils/format';
+import { getAlertStyles } from '@/utils/alerts';
+import { getNodeDisplayName, hasAlternateDisplayName } from '@/utils/nodes';
+import { formatTemperature } from '@/utils/temperature';
+import { StatusDot } from '@/components/shared/StatusDot';
+import { ResponsiveMetricCell } from '@/components/shared/responsive';
+import { EnhancedCPUBar } from '@/components/Dashboard/EnhancedCPUBar';
+import { StackedMemoryBar } from '@/components/Dashboard/StackedMemoryBar';
+import { StackedDiskBar } from '@/components/Dashboard/StackedDiskBar';
+import { TemperatureGauge } from '@/components/shared/TemperatureGauge';
+import { getNodeStatusIndicator, getPBSStatusIndicator } from '@/utils/status';
+import { TableCell, TableRow } from '@/components/shared/Table';
+import {
+ getInfrastructureSummaryCountValue,
+ getInfrastructureSummaryCpuPercent,
+ getInfrastructureSummaryCpuTemperatureValue,
+ getInfrastructureSummaryDiskPercent,
+ getInfrastructureSummaryDiskSublabel,
+ getInfrastructureSummaryMemoryPercent,
+ getInfrastructureSummaryMetricsKey,
+ isInfrastructureSummaryItemOnline,
+ isPVE,
+ resolveInfrastructureSummaryLinkedAgent,
+ type InfrastructureSummaryTableProps,
+ type TableItem,
+} from './infrastructureSummaryTableModel';
+import type { InfrastructureSummaryTableState } from './useInfrastructureSummaryTableState';
+
+const InfrastructureDetailsDrawer = lazy(() =>
+ import('./InfrastructureDetailsDrawer').then((module) => ({
+ default: module.InfrastructureDetailsDrawer,
+ })),
+);
+
+const tdClass = 'px-2 py-1 align-middle';
+const metricColumnStyle = { 'min-width': '140px', 'max-width': '180px' } as const;
+
+interface InfrastructureSummaryTableRowProps {
+ item: TableItem;
+ table: InfrastructureSummaryTableState;
+ tableProps: InfrastructureSummaryTableProps;
+}
+
+export const InfrastructureSummaryTableRow: Component<InfrastructureSummaryTableRowProps> = (
+ props,
+) => {
+ const isPVEItem = isPVE(props.item);
+ const isPBSItem = !isPVEItem;
+ const node = () => (isPVEItem ? (props.item as Node) : null);
+ const pbs = () => (isPBSItem ? (props.item as PBSInstance) : null);
+ const online = createMemo(() => isInfrastructureSummaryItemOnline(props.item));
+ const nodeId = () => (isPVEItem ? node()!.id : pbs()!.name);
+ const resourceId = () => (isPVEItem ? node()!.id || node()!.name : pbs()!.id || pbs()!.name);
+ const isSelected = createMemo(() => props.tableProps.selectedNode === nodeId());
+ const isExpanded = createMemo(() => props.table.isExpandedNode(nodeId()));
+
+ const statusIndicator = createMemo(() =>
+ isPVEItem ? getNodeStatusIndicator(node() as Node) : getPBSStatusIndicator(pbs() as PBSInstance),
+ );
+ const cpuPercentValue = createMemo(() => getInfrastructureSummaryCpuPercent(props.item));
+ const memoryPercentValue = createMemo(() => getInfrastructureSummaryMemoryPercent(props.item));
+ const diskPercentValue = createMemo(() => getInfrastructureSummaryDiskPercent(props.item));
+ const diskSublabel = createMemo(() => getInfrastructureSummaryDiskSublabel(props.item));
+ const cpuTemperatureValue = createMemo(() => getInfrastructureSummaryCpuTemperatureValue(props.item));
+ const uptimeValue = createMemo(() => props.item.uptime ?? 0);
+ const displayName = () => (isPVEItem ? getNodeDisplayName(node() as Node) : pbs()!.name);
+ const showActualName = () => isPVEItem && hasAlternateDisplayName(node() as Node);
+ const linkedAgentForDrawer = (): Agent | undefined =>
+ isPVEItem && node()
+ ? resolveInfrastructureSummaryLinkedAgent(node() as Node, props.tableProps.agents)
+ : undefined;
+ const metricsKey = createMemo(() => getInfrastructureSummaryMetricsKey(props.item));
+ const alertStyles = createMemo(() =>
+ getAlertStyles(resourceId(), props.table.activeAlerts, props.table.alertsEnabled()),
+ );
+ const showAlertHighlight = createMemo(
+ () => alertStyles().hasUnacknowledgedAlert && online(),
+ );
+
+ const rowStyle = createMemo(() => {
+ const styles: Record<string, string> = {};
+ const shadows: string[] = [];
+
+ if (showAlertHighlight()) {
+ const color = alertStyles().severity === 'critical' ? '#ef4444' : '#eab308';
+ shadows.push(`inset 4px 0 0 0 ${color}`);
+ }
+
+ if (isSelected()) {
+ shadows.push('0 0 0 1px rgba(59, 130, 246, 0.5)');
+ shadows.push('0 2px 4px -1px rgba(0, 0, 0, 0.1)');
+ }
+
+ if (shadows.length > 0) {
+ styles['box-shadow'] = shadows.join(', ');
+ }
+
+ return styles;
+ });
+
+ const rowClass = createMemo(() => {
+ const baseHover =
+ 'cursor-pointer transition-all duration-200 relative hover:shadow-sm group';
+
+ if (isSelected()) {
+ return `${baseHover} z-10 bg-blue-50 dark:bg-blue-900`;
+ }
+
+ if (showAlertHighlight()) {
+ const alertBg =
+ alertStyles().severity === 'critical'
+ ? 'bg-red-50 dark:bg-red-950'
+ : 'bg-yellow-50 dark:bg-yellow-950';
+ return `${baseHover} ${alertBg}`;
+ }
+
+ let className = baseHover;
+ if (props.tableProps.selectedNode && props.tableProps.selectedNode !== nodeId()) {
+ className += ' opacity-50 hover:opacity-80';
+ }
+ if (!online()) {
+ className += ' opacity-60';
+ }
+ return className;
+ });
+
+ return (
+ <>
+ <TableRow
+ class={rowClass()}
+ style={{ ...rowStyle(), 'min-height': '36px' }}
+ onClick={() => props.tableProps.onNodeClick(nodeId(), isPVEItem ? 'pve' : 'pbs')}
+ >
+ <TableCell
+ class={`pr-2 py-1 align-middle overflow-hidden ${showAlertHighlight() ? 'pl-4' : 'pl-3'}`}
+ >
+ <div class="flex items-center gap-1.5 min-w-0">
+ <Show when={isPVEItem}>
+ <div
+ class={`cursor-pointer transition-transform duration-200 ${isExpanded() ? 'rotate-90' : ''}`}
+ onClick={(event) => props.table.toggleNodeExpand(nodeId(), event)}
+ >
+ <svg
+ class="w-3.5 h-3.5 hover:text-base-content"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M9 5l7 7-7 7"
+ />
+ </svg>
+ </div>
+ </Show>
+ <StatusDot
+ variant={statusIndicator().variant}
+ title={statusIndicator().label}
+ ariaLabel={statusIndicator().label}
+ size="xs"
+ />
+ <span
+ class="font-medium text-[11px] text-base-content whitespace-nowrap select-text"
+ title={displayName()}
+ >
+ {displayName()}
+ </span>
+ <Show when={showActualName()}>
+ <span class="text-[9px] text-muted whitespace-nowrap">({node()!.name})</span>
+ </Show>
+ <div class="hidden xl:flex items-center gap-1.5 ml-1 flex-shrink min-w-0 overflow-hidden">
+ <Show when={isPVEItem}>
+ <span class="text-[9px] px-1 py-0 rounded font-medium bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-400">
+ PVE
+ </span>
+ </Show>
+ <Show when={isPVEItem && node()!.pveVersion}>
+ <span class="text-[9px] text-muted whitespace-nowrap">
+ v{node()!.pveVersion.split('/')[1] || node()!.pveVersion}
+ </span>
+ </Show>
+ <Show when={isPVEItem && node()!.isClusterMember !== undefined}>
+ <span
+ class={`text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap ${
+ node()!.isClusterMember
+ ? 'bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-400'
+ : 'bg-surface-alt text-muted'
+ }`}
+ >
+ {node()!.isClusterMember ? node()!.clusterName : 'Standalone'}
+ </span>
+ </Show>
+ <Show when={isPVEItem && node()!.linkedAgentId}>
+ <span
+ class="text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-400"
+ title="Pulse agent installed for enhanced metrics"
+ >
+ +Agent
+ </span>
+ </Show>
+ <Show
+ when={
+ isPVEItem &&
+ online() &&
+ node()!.pendingUpdates !== undefined &&
+ node()!.pendingUpdates > 0
+ }
+ >
+ <span
+ class={`text-[9px] px-1 py-0 rounded font-medium whitespace-nowrap ${
+ (node()!.pendingUpdates ?? 0) >= 10
+ ? 'bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-400'
+ : 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-400'
+ }`}
+ title={`${node()!.pendingUpdates} pending apt update${node()!.pendingUpdates !== 1 ? 's' : ''}`}
+ >
+ {node()!.pendingUpdates} updates
+ </span>
+ </Show>
+ <Show when={isPBSItem}>
+ <span class="text-[9px] px-1 py-0 rounded font-medium bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-400">
+ PBS
+ </span>
+ </Show>
+ <Show when={isPBSItem && pbs()!.version}>
+ <span class="text-[9px] text-muted whitespace-nowrap">v{pbs()!.version}</span>
+ </Show>
+ </div>
+ </div>
+ </TableCell>
+
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span
+ class={`text-xs whitespace-nowrap ${
+ isPVEItem && uptimeValue() < 3600 ? 'text-orange-500' : 'text-muted'
+ }`}
+ >
+ <Show when={online() && uptimeValue()} fallback="-">
+ <Show when={props.table.isMobile()} fallback={formatUptime(uptimeValue())}>
+ {formatUptime(uptimeValue(), true)}
+ </Show>
+ </Show>
+ </span>
+ </div>
+ </TableCell>
+
+ <TableCell
+ class={tdClass}
+ style={props.table.isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
+ >
+ <div class="h-5">
+ <EnhancedCPUBar
+ usage={cpuPercentValue()}
+ loadAverage={isPVEItem ? node()!.loadAverage?.[0] : undefined}
+ cores={props.table.isMobile() ? undefined : isPVEItem ? node()!.cpuInfo?.cores : undefined}
+ model={isPVEItem ? node()!.cpuInfo?.model : undefined}
+ resourceId={metricsKey()}
+ />
+ </div>
+ </TableCell>
+
+ <TableCell
+ class={tdClass}
+ style={props.table.isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
+ >
+ <div class="h-5">
+ <Show
+ when={isPVEItem}
+ fallback={
+ <ResponsiveMetricCell
+ value={memoryPercentValue()}
+ type="memory"
+ resourceId={metricsKey()}
+ sublabel={
+ pbs()!.memoryTotal
+ ? `${formatBytes(pbs()!.memoryUsed)}/${formatBytes(pbs()!.memoryTotal)}`
+ : undefined
+ }
+ isRunning={online()}
+ showMobile={false}
+ />
+ }
+ >
+ <StackedMemoryBar
+ used={node()!.memory?.used || 0}
+ total={node()!.memory?.total || 0}
+ balloon={node()!.memory?.balloon || 0}
+ swapUsed={node()!.memory?.swapUsed || 0}
+ swapTotal={node()!.memory?.swapTotal || 0}
+ resourceId={metricsKey()}
+ />
+ </Show>
+ </div>
+ </TableCell>
+
+ <TableCell
+ class={tdClass}
+ style={props.table.isMobile() ? { 'min-width': '80px' } : metricColumnStyle}
+ >
+ <div class="h-5">
+ <Show
+ when={isPVEItem}
+ fallback={
+ <ResponsiveMetricCell
+ value={diskPercentValue()}
+ type="disk"
+ resourceId={metricsKey()}
+ sublabel={diskSublabel()}
+ isRunning={online()}
+ showMobile={false}
+ />
+ }
+ >
+ <StackedDiskBar
+ aggregateDisk={{
+ total: node()!.disk?.total || 0,
+ used: node()!.disk?.used || 0,
+ free: (node()!.disk?.total || 0) - (node()!.disk?.used || 0),
+ usage: node()!.disk?.total ? node()!.disk!.used / node()!.disk!.total : 0,
+ }}
+ />
+ </Show>
+ </div>
+ </TableCell>
+
+ <Show when={props.table.hasAnyTemperatureData()}>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <Show
+ when={
+ online() &&
+ isPVEItem &&
+ cpuTemperatureValue() !== null &&
+ (node()!.temperature?.hasCPU ??
+ node()!.temperature?.hasGPU ??
+ node()!.temperature?.available) &&
+ props.table.isTemperatureMonitoringEnabled(node()!)
+ }
+ fallback={<span class="text-xs text-muted">-</span>}
+ >
+ {(() => {
+ const value = cpuTemperatureValue() as number;
+ const temperature = node()!.temperature;
+ const cpuMinValue =
+ typeof temperature?.cpuMin === 'number' && temperature.cpuMin > 0
+ ? temperature.cpuMin
+ : null;
+ const cpuMaxValue =
+ typeof temperature?.cpuMaxRecord === 'number' && temperature.cpuMaxRecord > 0
+ ? temperature.cpuMaxRecord
+ : null;
+ const hasMinMax = cpuMinValue !== null && cpuMaxValue !== null;
+ const gpus = temperature?.gpu ?? [];
+ const hasGPU = gpus.length > 0;
+
+ if (hasMinMax || hasGPU) {
+ const min =
+ typeof cpuMinValue === 'number' ? Math.round(cpuMinValue) : undefined;
+ const max =
+ typeof cpuMaxValue === 'number' ? Math.round(cpuMaxValue) : undefined;
+
+ return (
+ <div
+ title={`Min: ${min !== undefined ? formatTemperature(min) : '-'}, Max: ${max !== undefined ? formatTemperature(max) : '-'}${hasGPU ? `\nGPU: ${gpus.map((gpu) => formatTemperature(gpu.edge ?? gpu.junction ?? gpu.mem)).join(', ')}` : ''}`}
+ >
+ <TemperatureGauge
+ value={value}
+ min={min}
+ max={max}
+ critical={props.table.temperatureThreshold()}
+ warning={Math.max(0, props.table.temperatureThreshold() - 5)}
+ />
+ </div>
+ );
+ }
+
+ return (
+ <TemperatureGauge
+ value={value}
+ critical={props.table.temperatureThreshold()}
+ warning={Math.max(0, props.table.temperatureThreshold() - 5)}
+ />
+ );
+ })()}
+ </Show>
+ </div>
+ </TableCell>
+ </Show>
+
+ <Show when={props.tableProps.currentTab === 'dashboard'}>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>
+ {online()
+ ? (getInfrastructureSummaryCountValue(props.item, 'vmCount', props.tableProps) ??
+ '-')
+ : '-'}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>
+ {online()
+ ? (getInfrastructureSummaryCountValue(
+ props.item,
+ 'containerCount',
+ props.tableProps,
+ ) ?? '-')
+ : '-'}
+ </span>
+ </div>
+ </TableCell>
+ </Show>
+
+ <Show when={props.tableProps.currentTab === 'storage'}>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>
+ {online()
+ ? (getInfrastructureSummaryCountValue(
+ props.item,
+ 'storageCount',
+ props.tableProps,
+ ) ?? '-')
+ : '-'}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>
+ {online()
+ ? (getInfrastructureSummaryCountValue(props.item, 'diskCount', props.tableProps) ??
+ '-')
+ : '-'}
+ </span>
+ </div>
+ </TableCell>
+ </Show>
+
+ <Show when={props.tableProps.currentTab === 'recovery'}>
+ <TableCell class={tdClass}>
+ <div class="flex justify-center">
+ <span class={online() ? 'text-xs text-base-content' : 'text-xs text-muted'}>
+ {online()
+ ? (getInfrastructureSummaryCountValue(
+ props.item,
+ 'backupCount',
+ props.tableProps,
+ ) ?? '-')
+ : '-'}
+ </span>
+ </div>
+ </TableCell>
+ </Show>
+
+ <TableCell class="px-0 py-1 align-middle text-center">
+ <Show when={isPVEItem ? node()!.guestURL || node()!.host : pbs()!.guestURL || pbs()!.host}>
+ <a
+ href={
+ isPVEItem
+ ? node()!.guestURL || node()!.host || `https://${node()!.name}:8006`
+ : pbs()!.guestURL || pbs()!.host || `https://${pbs()!.name}:8007`
+ }
+ target="_blank"
+ rel="noopener noreferrer"
+ onClick={(event) => event.stopPropagation()}
+ class="inline-flex justify-center items-center text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors"
+ title={`Open ${displayName()} web interface`}
+ >
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
+ />
+ </svg>
+ </a>
+ </Show>
+ </TableCell>
+ </TableRow>
+
+ <Show when={isExpanded() && isPVEItem}>
+ <TableRow>
+ <TableCell
+ colspan={props.table.totalColumnCount()}
+ class="bg-surface-alt px-4 py-4 border-b border-border-subtle shadow-inner"
+ >
+ <Suspense fallback={<div class="flex justify-center p-4">Loading stats...</div>}>
+ <InfrastructureDetailsDrawer node={node()!} agent={linkedAgentForDrawer()} />
+ </Suspense>
+ </TableCell>
+ </TableRow>
+ </Show>
+ </>
+ );
+};
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 18caecea7c..d592051473 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
import calloutCardSource from '@/components/shared/CalloutCard.tsx?raw';
import filterButtonGroupSource from '@/components/shared/FilterButtonGroup.tsx?raw';
+import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';
+import infrastructureSummaryTableRowSource from '@/components/shared/InfrastructureSummaryTableRow.tsx?raw';
+import infrastructureSummaryTableModelSource from '@/components/shared/infrastructureSummaryTableModel.ts?raw';
+import infrastructureSummaryTableStateSource from '@/components/shared/useInfrastructureSummaryTableState.ts?raw';
import monitoredSystemLimitWarningBannerSource from '@/components/shared/MonitoredSystemLimitWarningBanner.tsx?raw';
import selectionCardGroupSource from '@/components/shared/SelectionCardGroup.tsx?raw';
import tagBadgesSource from '@/components/shared/TagBadges.tsx?raw';
@@ -32,6 +36,7 @@ describe('shared primitive guardrails', () => {
expect(rawTableUsers).toEqual([
'./InfrastructureSummaryTable.tsx',
+ './InfrastructureSummaryTableRow.tsx',
'./PulseDataGrid.tsx',
]);
});
@@ -105,4 +110,33 @@ describe('shared primitive guardrails', () => {
"from '@/components/Dashboard/TagBadges'",
);
});
+
+ it('keeps infrastructure summary table on shell, runtime, and model owners', () => {
+ expect(infrastructureSummaryTableSource).toContain('useInfrastructureSummaryTableState');
+ expect(infrastructureSummaryTableSource).toContain('InfrastructureSummaryTableRow');
+ expect(infrastructureSummaryTableSource).not.toContain('useWebSocket');
+ expect(infrastructureSummaryTableSource).not.toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableSource).not.toContain('createSignal');
+ expect(infrastructureSummaryTableSource).not.toContain('getNormalizedIdentityLookupVariants');
+ expect(infrastructureSummaryTableSource).not.toContain('getAgentLikeIdentityAliases');
+
+ expect(infrastructureSummaryTableStateSource).toContain('useWebSocket');
+ expect(infrastructureSummaryTableStateSource).toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableStateSource).toContain('export function useInfrastructureSummaryTableState');
+ expect(infrastructureSummaryTableStateSource).toContain('createSignal');
+
+ expect(infrastructureSummaryTableModelSource).toContain('getNormalizedIdentityLookupVariants');
+ expect(infrastructureSummaryTableModelSource).toContain('getAgentLikeIdentityAliases');
+ expect(infrastructureSummaryTableModelSource).toContain(
+ 'export const resolveInfrastructureSummaryLinkedAgent',
+ );
+ expect(infrastructureSummaryTableModelSource).toContain(
+ 'export const sortInfrastructureSummaryItems',
+ );
+
+ expect(infrastructureSummaryTableRowSource).toContain('InfrastructureDetailsDrawer');
+ expect(infrastructureSummaryTableRowSource).toContain('getAlertStyles');
+ expect(infrastructureSummaryTableRowSource).not.toContain('useWebSocket');
+ expect(infrastructureSummaryTableRowSource).not.toContain('useAlertsActivation');
+ });
});
diff --git a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
index 0be9179e64..8e36938fd2 100644
--- a/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/InfrastructureSummaryTable.test.tsx
@@ -2,6 +2,10 @@ import { describe, expect, it, vi } from 'vitest';
import { fireEvent, render, waitFor } from '@solidjs/testing-library';
import { InfrastructureSummaryTable } from '@/components/shared/InfrastructureSummaryTable';
import type { Agent, Node } from '@/types/api';
+import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';
+import infrastructureSummaryTableRowSource from '@/components/shared/InfrastructureSummaryTableRow.tsx?raw';
+import infrastructureSummaryTableModelSource from '@/components/shared/infrastructureSummaryTableModel.ts?raw';
+import infrastructureSummaryTableStateSource from '@/components/shared/useInfrastructureSummaryTableState.ts?raw';
import resourceIdentitySource from '@/utils/resourceIdentity.ts?raw';
const enhancedCpuBarMock = vi.fn();
@@ -96,6 +100,21 @@ const makeAgent = (overrides: Partial<Agent> = {}): Agent => ({
});
describe('InfrastructureSummaryTable', () => {
+ it('keeps the shared table on shell, runtime, and model owners', () => {
+ expect(infrastructureSummaryTableSource).toContain('useInfrastructureSummaryTableState');
+ expect(infrastructureSummaryTableSource).toContain('InfrastructureSummaryTableRow');
+ expect(infrastructureSummaryTableSource).not.toContain('useWebSocket');
+ expect(infrastructureSummaryTableSource).not.toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableStateSource).toContain('useWebSocket');
+ expect(infrastructureSummaryTableStateSource).toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableModelSource).toContain(
+ 'resolveInfrastructureSummaryLinkedAgent',
+ );
+ expect(infrastructureSummaryTableModelSource).toContain('sortInfrastructureSummaryItems');
+ expect(infrastructureSummaryTableRowSource).toContain('InfrastructureDetailsDrawer');
+ expect(infrastructureSummaryTableRowSource).toContain('getAlertStyles');
+ });
+
it('uses the shared normalized identity lookup helper', () => {
expect(resourceIdentitySource).toContain('getNormalizedIdentityLookupVariants');
expect(resourceIdentitySource).not.toContain(
diff --git a/frontend-modern/src/components/shared/infrastructureSummaryTableModel.ts b/frontend-modern/src/components/shared/infrastructureSummaryTableModel.ts
new file mode 100644
index 0000000000..9920c4c492
--- /dev/null
+++ b/frontend-modern/src/components/shared/infrastructureSummaryTableModel.ts
@@ -0,0 +1,301 @@
+import type { Agent, Node, PBSInstance } from '@/types/api';
+import { formatBytes } from '@/utils/format';
+import { buildMetricKey } from '@/utils/metricsKeys';
+import { getNodeDisplayName } from '@/utils/nodes';
+import { getCpuTemperature } from '@/utils/temperature';
+import {
+ getAgentLikeIdentityAliases,
+ getNormalizedIdentityLookupVariants,
+} from '@/utils/resourceIdentity';
+import { asTrimmedString } from '@/utils/stringUtils';
+
+export interface InfrastructureSummaryTableProps {
+ nodes: Node[];
+ pbsInstances?: PBSInstance[];
+ vmCounts?: Record<string, number>;
+ containerCounts?: Record<string, number>;
+ storageCounts?: Record<string, number>;
+ diskCounts?: Record<string, number>;
+ agents?: Agent[];
+ backupCounts?: Record<string, number>;
+ currentTab: 'dashboard' | 'storage' | 'recovery';
+ selectedNode: string | null;
+ globalTemperatureMonitoringEnabled?: boolean;
+ onNodeClick: (nodeId: string, nodeType: 'pve' | 'pbs') => void;
+}
+
+export type TableItem = Node | PBSInstance;
+
+export type CountSortKey =
+ | 'vmCount'
+ | 'containerCount'
+ | 'storageCount'
+ | 'diskCount'
+ | 'backupCount';
+
+export type InfrastructureSummarySortKey =
+ | 'default'
+ | 'name'
+ | 'uptime'
+ | 'cpu'
+ | 'memory'
+ | 'disk'
+ | 'temperature'
+ | CountSortKey;
+
+const asRecord = (value: unknown): Record<string, unknown> | undefined =>
+ value && typeof value === 'object' ? (value as Record<string, unknown>) : undefined;
+
+const getAgentLinkedNodeId = (agent: Agent): string | undefined => {
+ const agentRecord = agent as unknown as Record<string, unknown>;
+ const platformData = asRecord(agentRecord.platformData);
+ const platformAgent = asRecord(platformData?.agent);
+
+ return (
+ asTrimmedString(agent.linkedNodeId) ||
+ asTrimmedString(platformData?.linkedNodeId) ||
+ asTrimmedString(platformAgent?.linkedNodeId)
+ );
+};
+
+export const isPVE = (item: TableItem): item is Node =>
+ (item as Node).pveVersion !== undefined || (item as Node & { type?: string }).type === 'agent';
+
+export const isTemperatureMonitoringEnabled = (node: Node, globalEnabled = true): boolean => {
+ if (
+ node.temperatureMonitoringEnabled !== undefined &&
+ node.temperatureMonitoringEnabled !== null
+ ) {
+ return node.temperatureMonitoringEnabled;
+ }
+ return globalEnabled;
+};
+
+export const isInfrastructureSummaryItemOnline = (item: TableItem) => {
+ if (isPVE(item)) {
+ return item.status === 'online' && (item.uptime || 0) > 0;
+ }
+ return item.status === 'healthy' || item.status === 'online';
+};
+
+export const getPbsTotals = (pbs: PBSInstance) =>
+ (pbs.datastores ?? []).reduce(
+ (acc, datastore) => {
+ acc.used += datastore.used || 0;
+ acc.total += datastore.total || 0;
+ return acc;
+ },
+ { used: 0, total: 0 },
+ );
+
+export const getInfrastructureSummaryCpuPercent = (item: TableItem) => {
+ if (isPVE(item)) {
+ return Math.round((item.cpu || 0) * 100);
+ }
+ return Math.round(item.cpu || 0);
+};
+
+export const getInfrastructureSummaryMemoryPercent = (item: TableItem) => {
+ if (isPVE(item)) {
+ return Math.round(item.memory?.usage || 0);
+ }
+ if (!item.memoryTotal) return 0;
+ return Math.round((item.memoryUsed / item.memoryTotal) * 100);
+};
+
+export const getInfrastructureSummaryDiskPercent = (item: TableItem) => {
+ if (isPVE(item)) {
+ if (!item.disk || item.disk.total === 0) return 0;
+ return Math.round((item.disk.used / item.disk.total) * 100);
+ }
+ const totals = getPbsTotals(item);
+ if (totals.total === 0) return 0;
+ return Math.round((totals.used / totals.total) * 100);
+};
+
+export const getInfrastructureSummaryDiskSublabel = (item: TableItem) => {
+ if (isPVE(item)) {
+ if (!item.disk) return undefined;
+ return `${formatBytes(item.disk.used)}/${formatBytes(item.disk.total)}`;
+ }
+ if (!item.datastores || item.datastores.length === 0) return undefined;
+ const totals = getPbsTotals(item);
+ return `${formatBytes(totals.used)}/${formatBytes(totals.total)}`;
+};
+
+export const getInfrastructureSummaryCpuTemperatureValue = (item: TableItem) => {
+ if (!isPVE(item)) return null;
+ const value = getCpuTemperature(item.temperature);
+ return value !== null ? Math.round(value) : null;
+};
+
+export const getInfrastructureSummaryCountValue = (
+ item: TableItem,
+ key: CountSortKey,
+ props: InfrastructureSummaryTableProps,
+): number | null => {
+ if (!isPVE(item)) {
+ if (key === 'backupCount') {
+ return props.backupCounts?.[item.name] ?? 0;
+ }
+ return null;
+ }
+
+ switch (key) {
+ case 'vmCount':
+ return props.vmCounts?.[item.id] ?? 0;
+ case 'containerCount':
+ return props.containerCounts?.[item.id] ?? 0;
+ case 'storageCount':
+ return props.storageCounts?.[item.id] ?? 0;
+ case 'diskCount':
+ return props.diskCounts?.[item.id] ?? 0;
+ case 'backupCount':
+ return props.backupCounts?.[item.id] ?? 0;
+ default:
+ return null;
+ }
+};
+
+const getInfrastructureSummarySortValue = (
+ item: TableItem,
+ key: InfrastructureSummarySortKey,
+ props: InfrastructureSummaryTableProps,
+): number | string | null => {
+ switch (key) {
+ case 'name':
+ return isPVE(item) ? getNodeDisplayName(item) : item.name;
+ case 'uptime':
+ return item.uptime ?? 0;
+ case 'cpu':
+ return getInfrastructureSummaryCpuPercent(item);
+ case 'memory':
+ return getInfrastructureSummaryMemoryPercent(item);
+ case 'disk':
+ return getInfrastructureSummaryDiskPercent(item);
+ case 'temperature':
+ return getInfrastructureSummaryCpuTemperatureValue(item);
+ case 'vmCount':
+ case 'containerCount':
+ case 'storageCount':
+ case 'diskCount':
+ case 'backupCount':
+ return getInfrastructureSummaryCountValue(item, key, props);
+ default:
+ return null;
+ }
+};
+
+const defaultInfrastructureSummaryComparison = (left: TableItem, right: TableItem) => {
+ const leftIsPVE = isPVE(left);
+ const rightIsPVE = isPVE(right);
+ if (leftIsPVE !== rightIsPVE) return leftIsPVE ? -1 : 1;
+
+ const leftOnline = isInfrastructureSummaryItemOnline(left);
+ const rightOnline = isInfrastructureSummaryItemOnline(right);
+ if (leftOnline !== rightOnline) return leftOnline ? -1 : 1;
+
+ const leftName = leftIsPVE ? getNodeDisplayName(left) : left.name;
+ const rightName = rightIsPVE ? getNodeDisplayName(right) : right.name;
+
+ return leftName.localeCompare(rightName);
+};
+
+const compareInfrastructureSummaryValues = (
+ left: number | string | null,
+ right: number | string | null,
+) => {
+ const leftEmpty =
+ left === null || left === undefined || (typeof left === 'number' && Number.isNaN(left));
+ const rightEmpty =
+ right === null || right === undefined || (typeof right === 'number' && Number.isNaN(right));
+
+ if (leftEmpty && rightEmpty) return 0;
+ if (leftEmpty) return 1;
+ if (rightEmpty) return -1;
+
+ if (typeof left === 'number' && typeof right === 'number') {
+ if (left === right) return 0;
+ return left < right ? -1 : 1;
+ }
+
+ const leftString = String(left).toLowerCase();
+ const rightString = String(right).toLowerCase();
+ if (leftString === rightString) return 0;
+ return leftString < rightString ? -1 : 1;
+};
+
+export const getInfrastructureSummaryDefaultSortDirection = (
+ key: Exclude<InfrastructureSummarySortKey, 'default'>,
+) => {
+ switch (key) {
+ case 'name':
+ return 'asc';
+ default:
+ return 'desc';
+ }
+};
+
+export const sortInfrastructureSummaryItems = (
+ props: InfrastructureSummaryTableProps,
+ sortKey: InfrastructureSummarySortKey,
+ sortDirection: 'asc' | 'desc',
+) => {
+ const items: TableItem[] = [];
+
+ if (props.nodes) items.push(...props.nodes);
+ if (props.pbsInstances) items.push(...props.pbsInstances);
+
+ return items.sort((left, right) => {
+ if (sortKey === 'default') {
+ return defaultInfrastructureSummaryComparison(left, right);
+ }
+
+ const valueLeft = getInfrastructureSummarySortValue(left, sortKey, props);
+ const valueRight = getInfrastructureSummarySortValue(right, sortKey, props);
+ const comparison = compareInfrastructureSummaryValues(valueLeft, valueRight);
+
+ if (comparison !== 0) {
+ return sortDirection === 'asc' ? comparison : -comparison;
+ }
+
+ return defaultInfrastructureSummaryComparison(left, right);
+ });
+};
+
+export const getInfrastructureSummaryMetricsKey = (item: TableItem) => {
+ if (isPVE(item) && item.linkedAgentId) {
+ return buildMetricKey('agent', item.linkedAgentId);
+ }
+
+ const resourceId = isPVE(item) ? item.id || item.name : item.id || item.name;
+ return buildMetricKey('node', resourceId);
+};
+
+export const resolveInfrastructureSummaryLinkedAgent = (
+ node: Node,
+ agents: Agent[] = [],
+): Agent | undefined => {
+ const linkedAgentId = node.linkedAgentId;
+ if (linkedAgentId) {
+ const byId = agents.find((agent) => getAgentLikeIdentityAliases(agent).includes(linkedAgentId));
+ if (byId) return byId;
+ }
+
+ const nodeName = (node.name || '').trim();
+ return agents.find((agent) => {
+ const linkedNodeId = getAgentLinkedNodeId(agent);
+ if (linkedNodeId === node.id) {
+ return true;
+ }
+
+ if (!nodeName) {
+ return false;
+ }
+
+ const aliases = getAgentLikeIdentityAliases(agent).flatMap((value) =>
+ getNormalizedIdentityLookupVariants(value),
+ );
+ return aliases.includes(nodeName.toLowerCase());
+ });
+};
diff --git a/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts b/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts
new file mode 100644
index 0000000000..215ed712d3
--- /dev/null
+++ b/frontend-modern/src/components/shared/useInfrastructureSummaryTableState.ts
@@ -0,0 +1,88 @@
+import { createMemo, createSignal } from 'solid-js';
+import { useWebSocket } from '@/App';
+import { useBreakpoint } from '@/hooks/useBreakpoint';
+import { useAlertsActivation } from '@/stores/alertsActivation';
+import {
+ getInfrastructureSummaryDefaultSortDirection,
+ isTemperatureMonitoringEnabled,
+ sortInfrastructureSummaryItems,
+ type InfrastructureSummarySortKey,
+ type InfrastructureSummaryTableProps,
+} from './infrastructureSummaryTableModel';
+
+export function useInfrastructureSummaryTableState(props: InfrastructureSummaryTableProps) {
+ const { activeAlerts } = useWebSocket();
+ const alertsActivation = useAlertsActivation();
+ const alertsEnabled = createMemo(() => alertsActivation.activationState() === 'active');
+ const { isMobile } = useBreakpoint();
+ const temperatureThreshold = createMemo(() => alertsActivation.getTemperatureThreshold());
+
+ const [sortKey, setSortKey] = createSignal<InfrastructureSummarySortKey>('default');
+ const [sortDirection, setSortDirection] = createSignal<'asc' | 'desc'>('asc');
+ const [expandedNodeId, setExpandedNodeId] = createSignal<string | null>(null);
+
+ const hasAnyTemperatureData = createMemo(
+ () =>
+ props.nodes?.some(
+ (node) =>
+ node.temperature?.available ||
+ isTemperatureMonitoringEnabled(node, props.globalTemperatureMonitoringEnabled ?? true),
+ ) || false,
+ );
+
+ const totalColumnCount = createMemo(() => {
+ let count = 6;
+ if (hasAnyTemperatureData()) count += 1;
+ if (props.currentTab === 'dashboard') count += 2;
+ else if (props.currentTab === 'storage') count += 2;
+ else if (props.currentTab === 'recovery') count += 1;
+ return count;
+ });
+
+ const sortedItems = createMemo(() =>
+ sortInfrastructureSummaryItems(props, sortKey(), sortDirection()),
+ );
+
+ const handleSort = (key: Exclude<InfrastructureSummarySortKey, 'default'>) => {
+ if (sortKey() === key) {
+ if (sortDirection() === 'asc') {
+ setSortDirection('desc');
+ } else {
+ setSortKey('default');
+ setSortDirection('asc');
+ }
+ return;
+ }
+
+ setSortKey(key);
+ setSortDirection(getInfrastructureSummaryDefaultSortDirection(key));
+ };
+
+ const renderSortIndicator = (key: InfrastructureSummarySortKey) => {
+ if (sortKey() !== key) return null;
+ return sortDirection() === 'asc' ? '▲' : '▼';
+ };
+
+ const toggleNodeExpand = (nodeId: string, event: MouseEvent) => {
+ event.stopPropagation();
+ setExpandedNodeId((previous) => (previous === nodeId ? null : nodeId));
+ };
+
+ return {
+ activeAlerts,
+ alertsEnabled,
+ handleSort,
+ hasAnyTemperatureData,
+ isExpandedNode: (nodeId: string) => expandedNodeId() === nodeId,
+ isMobile,
+ isTemperatureMonitoringEnabled: (node: Parameters<typeof isTemperatureMonitoringEnabled>[0]) =>
+ isTemperatureMonitoringEnabled(node, props.globalTemperatureMonitoringEnabled ?? true),
+ renderSortIndicator,
+ sortedItems,
+ temperatureThreshold,
+ toggleNodeExpand,
+ totalColumnCount,
+ };
+}
+
+export type InfrastructureSummaryTableState = ReturnType<typeof useInfrastructureSummaryTableState>;
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 9931c12bb3..fbf4e92146 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -9,6 +9,9 @@ import investigateAlertButtonSource from '@/components/Alerts/InvestigateAlertBu
import alertTargetTypesSource from '@/utils/alertTargetTypes.ts?raw';
import resourceBadgesSource from '@/components/Infrastructure/resourceBadges.ts?raw';
import infrastructureSummaryTableSource from '@/components/shared/InfrastructureSummaryTable.tsx?raw';
+import infrastructureSummaryTableRowSource from '@/components/shared/InfrastructureSummaryTableRow.tsx?raw';
+import sharedInfrastructureSummaryTableModelSource from '@/components/shared/infrastructureSummaryTableModel.ts?raw';
+import infrastructureSummaryTableStateSource from '@/components/shared/useInfrastructureSummaryTableState.ts?raw';
import resourceBadgePresentationSource from '@/utils/resourceBadgePresentation.ts?raw';
import workloadTypeBadgesSource from '@/components/shared/workloadTypeBadges.ts?raw';
import tagBadgesSource from '@/components/shared/TagBadges.tsx?raw';
@@ -2588,7 +2591,9 @@ describe('frontend resource type boundaries', () => {
expect(chatIdentifiersSource).toContain('normalizeChatMentionKeyPart');
expect(chatIdentifiersSource).toContain('normalizeChatToolName');
expect(infrastructureSummaryModelSource).toContain('getNormalizedIdentityLookupVariants');
- expect(infrastructureSummaryTableSource).toContain('getNormalizedIdentityLookupVariants');
+ expect(sharedInfrastructureSummaryTableModelSource).toContain(
+ 'getNormalizedIdentityLookupVariants',
+ );
expect(resourceIdentitySource).toContain('getNormalizedIdentityLookupVariants');
expect(stringUtilsSource).toContain('export const asTrimmedString');
expect(resourceIdentitySource).not.toContain(
@@ -2597,9 +2602,25 @@ describe('frontend resource type boundaries', () => {
expect(infrastructureSummaryModelSource).not.toContain(
'const asTrimmedString = (value: unknown): string | null => {',
);
- expect(infrastructureSummaryTableSource).not.toContain(
+ expect(sharedInfrastructureSummaryTableModelSource).not.toContain(
'const asTrimmedString = (value: unknown): string | undefined => {',
);
+ expect(infrastructureSummaryTableSource).toContain('useInfrastructureSummaryTableState');
+ expect(infrastructureSummaryTableSource).toContain('InfrastructureSummaryTableRow');
+ expect(infrastructureSummaryTableSource).not.toContain('useWebSocket');
+ expect(infrastructureSummaryTableSource).not.toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableSource).not.toContain('createSignal');
+ expect(infrastructureSummaryTableSource).not.toContain('getAgentLikeIdentityAliases');
+ expect(infrastructureSummaryTableStateSource).toContain('useWebSocket');
+ expect(infrastructureSummaryTableStateSource).toContain('useAlertsActivation');
+ expect(infrastructureSummaryTableStateSource).toContain(
+ 'export function useInfrastructureSummaryTableState',
+ );
+ expect(infrastructureSummaryTableRowSource).toContain('InfrastructureDetailsDrawer');
+ expect(infrastructureSummaryTableRowSource).toContain('getAlertStyles');
+ expect(sharedInfrastructureSummaryTableModelSource).toContain(
+ 'resolveInfrastructureSummaryLinkedAgent',
+ );
expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicyAISafeSummary(');
expect(useUnifiedResourcesSource).not.toContain('normalizeResourcePolicy(');
expect(useUnifiedResourcesSource).not.toContain('const resolvePolicySensitivity =');