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.

Promote machine facts in drawer rows

rcourtmanfec42de89f7b
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
index 2443d495fd..c2db3b0dc9 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
@@ -37,6 +37,7 @@ import {
import { formatConfidenceLabel } from '@/utils/confidencePresentation';
import { formatIdentifierLabel } from '@/utils/textPresentation';
import { shouldShowResourcePlatformId } from '@/utils/resourceIdentity';
+import { isPulseAgentPlatformResource } from '@/utils/agentResources';
import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';
import { formatInteger } from './resourceDetailMappers';
import { buildPbsJobHealthEvidenceModel } from './resourceDetailDrawerServiceModel';
@@ -84,6 +85,60 @@ const TrueNASDetailsDisclosure: Component<{
</SupportDisclosure>
);
+const machineHostDetailsTitle = (resource: Resource): string =>
+ isPulseAgentPlatformResource(resource) ? 'Machine' : 'Host';
+
+const machineHostDetailsNoun = (resource: Resource): string =>
+ isPulseAgentPlatformResource(resource) ? 'machine' : 'host';
+
+const HostDetailsDisclosure: Component<{
+ resource: Resource;
+ drawer: UseResourceDetailDrawerStateResult;
+ class?: string;
+ contentClass?: string;
+}> = (props) => {
+ const noun = () => machineHostDetailsNoun(props.resource);
+
+ return (
+ <SupportDisclosure
+ title={machineHostDetailsTitle(props.resource)}
+ summary={props.drawer.hostDetailSummary()}
+ expanded={props.drawer.showHostDetails()}
+ onToggle={() => props.drawer.setShowHostDetails((value) => !value)}
+ showLabel={`Show ${noun()}`}
+ hideLabel={`Hide ${noun()}`}
+ class={props.class}
+ contentClass={
+ props.contentClass ??
+ 'mt-3 flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[220px] [&>*]:max-w-full [&>*]:overflow-hidden'
+ }
+ dataTestId="resource-host-details-section"
+ >
+ <Show when={props.drawer.proxmoxNode()}>
+ {(node) => (
+ <>
+ <SystemInfoCard variant="node" node={node()} />
+ <HardwareCard variant="node" node={node()} />
+ <RootDiskCard node={node()} />
+ </>
+ )}
+ </Show>
+ <Show when={props.drawer.agentInfo()}>
+ {(agent) => (
+ <>
+ <SystemInfoCard variant="agent" agent={agent()} />
+ <HardwareCard variant="agent" agent={agent()} />
+ <NetworkInterfacesCard interfaces={agent().networkInterfaces} />
+ <DisksCard disks={agent().disks} />
+ <RaidCard arrays={props.drawer.agentMeta()?.raid} />
+ <TemperaturesCard rows={props.drawer.temperatureRows()} />
+ </>
+ )}
+ </Show>
+ </SupportDisclosure>
+ );
+};
+
const pbsEvidenceBadgeClass = (tone: string): string => {
switch (tone) {
case 'danger':
@@ -147,6 +202,8 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
drawer.actionAuditCount() > 0 ||
Boolean(drawer.actionAuditError()));
const shouldPromoteTrueNASDetails = () => compactTableRow() && drawer.hasTrueNASDetails();
+ const shouldPromoteHostDetails = () =>
+ compactTableRow() && isPulseAgentPlatformResource(resource) && drawer.hasHostDetails();
return (
<div class="space-y-3">
@@ -154,6 +211,10 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
<TrueNASDetailsDisclosure drawer={drawer} class="space-y-2" contentClass="space-y-2" />
</Show>
+ <Show when={shouldPromoteHostDetails()}>
+ <HostDetailsDisclosure resource={resource} drawer={drawer} />
+ </Show>
+
<Show
when={compactTableRow()}
fallback={
@@ -456,7 +517,7 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
drawer.hasServiceDetails() ||
drawer.hasVMwareDetails() ||
drawer.hasTrueNASDetails() ||
- drawer.hasHostDetails() ||
+ (drawer.hasHostDetails() && !shouldPromoteHostDetails()) ||
drawer.hasAccessContext() ||
drawer.hasInvestigationContext()
}
@@ -1188,40 +1249,8 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
</SupportDisclosure>
</Show>
- <Show when={drawer.hasHostDetails()}>
- <SupportDisclosure
- title="Host"
- summary={drawer.hostDetailSummary()}
- expanded={drawer.showHostDetails()}
- onToggle={() => drawer.setShowHostDetails((value) => !value)}
- showLabel="Show host"
- hideLabel="Hide host"
- class="h-full"
- contentClass="mt-3 flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[220px] [&>*]:max-w-full [&>*]:overflow-hidden"
- dataTestId="resource-host-details-section"
- >
- <Show when={drawer.proxmoxNode()}>
- {(node) => (
- <>
- <SystemInfoCard variant="node" node={node()} />
- <HardwareCard variant="node" node={node()} />
- <RootDiskCard node={node()} />
- </>
- )}
- </Show>
- <Show when={drawer.agentInfo()}>
- {(agent) => (
- <>
- <SystemInfoCard variant="agent" agent={agent()} />
- <HardwareCard variant="agent" agent={agent()} />
- <NetworkInterfacesCard interfaces={agent().networkInterfaces} />
- <DisksCard disks={agent().disks} />
- <RaidCard arrays={drawer.agentMeta()?.raid} />
- <TemperaturesCard rows={drawer.temperatureRows()} />
- </>
- )}
- </Show>
- </SupportDisclosure>
+ <Show when={drawer.hasHostDetails() && !shouldPromoteHostDetails()}>
+ <HostDetailsDisclosure resource={resource} drawer={drawer} class="h-full" />
</Show>
</div>
</Show>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
index 560810e51f..f3102a8fe8 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { Resource } from '@/types/resource';
import { ResourceDetailDrawer } from '../ResourceDetailDrawer';
@@ -89,4 +89,90 @@ describe('ResourceDetailDrawer machine metrics history', () => {
expect(screen.queryByRole('button', { name: 'History' })).not.toBeInTheDocument();
});
+
+ it('opens agent machine facts by default in table-row presentation', () => {
+ render(() => (
+ <ResourceDetailDrawer
+ presentation="table-row"
+ resource={resource({
+ id: 'agent-mac-mini',
+ displayName: 'Mac Mini',
+ agent: {
+ hostname: 'richard-mac-mini.local',
+ osName: 'macOS',
+ osVersion: '15.5',
+ kernelVersion: '24.5.0',
+ architecture: 'arm64',
+ cpuCount: 10,
+ memory: {
+ total: 24 * 1024 * 1024 * 1024,
+ used: 12 * 1024 * 1024 * 1024,
+ free: 12 * 1024 * 1024 * 1024,
+ usage: 0.5,
+ },
+ disks: [
+ {
+ mountpoint: '/',
+ total: 994 * 1024 * 1024 * 1024,
+ used: 512 * 1024 * 1024 * 1024,
+ free: 482 * 1024 * 1024 * 1024,
+ },
+ ],
+ networkInterfaces: [
+ {
+ name: 'en0',
+ mac: '00:11:22:33:44:55',
+ addresses: ['192.168.0.42'],
+ },
+ ],
+ agentVersion: '6.0.0',
+ uptimeSeconds: 3600,
+ },
+ })}
+ />
+ ));
+
+ const machineSection = screen.getByTestId('resource-host-details-section');
+ expect(within(machineSection).getByText('Machine')).toBeInTheDocument();
+ expect(
+ within(machineSection).getByRole('button', { name: 'Hide machine' }),
+ ).toBeInTheDocument();
+ expect(within(machineSection).queryByRole('button', { name: 'Show machine' })).toBeNull();
+ expect(within(machineSection).getByText('richard-mac-mini.local')).toBeInTheDocument();
+ expect(within(machineSection).getByText('Network')).toBeInTheDocument();
+ expect(within(machineSection).getByText('192.168.0.42')).toBeInTheDocument();
+ expect(within(machineSection).getByText('Disks')).toBeInTheDocument();
+ });
+
+ it('keeps provider-owned host facts collapsed in table-row presentation', () => {
+ render(() => (
+ <ResourceDetailDrawer
+ presentation="table-row"
+ resource={resource({
+ id: 'pve-node-1',
+ displayName: 'pve-node-1',
+ platformType: 'proxmox-pve',
+ sourceType: 'api',
+ sources: ['proxmox'],
+ platformData: {
+ sources: ['proxmox'],
+ proxmox: {
+ nodeName: 'pve-node-1',
+ pveVersion: '8.2.7',
+ kernelVersion: '6.8.12',
+ cpuInfo: {
+ cores: 8,
+ },
+ },
+ },
+ })}
+ />
+ ));
+
+ const hostSection = screen.getByTestId('resource-host-details-section');
+ expect(within(hostSection).getByText('Host')).toBeInTheDocument();
+ expect(within(hostSection).getByRole('button', { name: 'Show host' })).toBeInTheDocument();
+ expect(within(hostSection).queryByRole('button', { name: 'Hide host' })).toBeNull();
+ expect(within(hostSection).queryByText('Hardware')).toBeNull();
+ });
});
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
index 3593de74b6..404ad8c35e 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
@@ -3,6 +3,7 @@ import type { Resource } from '@/types/resource';
import type { HistoryTimeRange } from '@/api/charts';
import { GUEST_DRAWER_HISTORY_DEFAULT_RANGE } from '@/components/Workloads/guestDrawerModel';
import { createLocalStorageBooleanSignal, STORAGE_KEYS } from '@/utils/localStorage';
+import { isPulseAgentPlatformResource } from '@/utils/agentResources';
import { useResourceDetailDrawerDockerActionsState } from './useResourceDetailDrawerDockerActionsState';
import { useResourceDetailDrawerHistoryState } from './useResourceDetailDrawerHistoryState';
import { useResourceDetailDrawerDerivedState } from './useResourceDetailDrawerDerivedState';
@@ -30,7 +31,9 @@ export const useResourceDetailDrawerState = (options: UseResourceDetailDrawerSta
const [showAccessContext, setShowAccessContext] = createSignal(false);
const [showInvestigationContext, setShowInvestigationContext] = createSignal(false);
const [showDiscoveryContext, setShowDiscoveryContext] = createSignal(false);
- const [showHostDetails, setShowHostDetails] = createSignal(false);
+ const [showHostDetails, setShowHostDetails] = createSignal(
+ options.presentation === 'table-row' && isPulseAgentPlatformResource(resource),
+ );
const [showServiceDetails, setShowServiceDetails] = createSignal(false);
const [showVMwareDetails, setShowVMwareDetails] = createSignal(false);
const [showTrueNASDetails, setShowTrueNASDetails] = createSignal(