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.

Show Machines row identity context

rcourtman7a9b4062fbeb
diff --git a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
index 8cf65f4019..40c543a062 100644
--- a/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
+++ b/frontend-modern/src/features/standalone/AgentsMachinesTable.tsx
@@ -746,6 +746,33 @@ const titleCase = (value: string): string =>
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
.join(' ');
+const normalizedIdentityToken = (value: string | undefined): string =>
+ (value ?? '').trim().toLowerCase();
+
+const appendUniqueMachineSubtitlePart = (parts: string[], value: string | undefined) => {
+ const normalized = normalizedIdentityToken(value);
+ if (!normalized || parts.some((part) => normalizedIdentityToken(part) === normalized)) return;
+ parts.push(value?.trim() ?? '');
+};
+
+const machineIdentitySubtitleFor = (
+ name: string,
+ hostname: string | undefined,
+ primaryIp: string,
+ includePrimaryIp: boolean,
+): string => {
+ const parts: string[] = [];
+
+ if (normalizedIdentityToken(hostname) !== normalizedIdentityToken(name)) {
+ appendUniqueMachineSubtitlePart(parts, hostname);
+ }
+ if (includePrimaryIp) {
+ appendUniqueMachineSubtitlePart(parts, primaryIp);
+ }
+
+ return parts.slice(0, 2).join(' | ');
+};
+
const systemLabelFor = (machine: Resource): string => {
if (isAgentlessMachine(machine)) {
const protocol = (asTrimmedString(availabilityFor(machine)?.protocol) ?? '').toUpperCase();
@@ -1004,6 +1031,13 @@ export const AgentsMachinesTable: Component<{
const diskIOTotal = () => getAgentMachineDiskIOTotal(machine);
const diskIODetails = () => getAgentMachineDiskIODetails(machine);
const primaryIp = () => getAgentMachinePrimaryIp(machine);
+ const machineSubtitle = () =>
+ machineIdentitySubtitleFor(
+ name(),
+ hostname(),
+ primaryIp(),
+ !columnVisibility.isColumnVisible('ip'),
+ );
const ipValues = () => getAgentMachineIpValues(machine);
const raidArrays = () => getAgentMachineRaidArrayDetails(machine);
const raidSummary = () => getAgentMachineRaidSummary(machine);
@@ -1039,12 +1073,26 @@ export const AgentsMachinesTable: Component<{
{name()}
</span>
</div>
- <span
- class="mt-0.5 block truncate pl-5 text-[9px] text-muted sm:text-[10px] md:hidden"
- title={hostname() || systemLabel()}
+ <Show
+ when={machineSubtitle()}
+ fallback={
+ <span
+ class="mt-0.5 block truncate pl-5 text-[9px] text-muted sm:text-[10px] md:hidden"
+ title={systemLabel()}
+ >
+ {systemLabel()}
+ </span>
+ }
>
- {hostname() || systemLabel()}
- </span>
+ {(subtitle) => (
+ <span
+ class="mt-0.5 block truncate pl-5 text-[9px] text-muted sm:text-[10px]"
+ title={subtitle()}
+ >
+ {subtitle()}
+ </span>
+ )}
+ </Show>
</TableCell>
<Show when={columnVisibility.isColumnVisible('system')}>
<TableCell
diff --git a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
index 758f68ced7..4422ea66c9 100644
--- a/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
+++ b/frontend-modern/src/features/standalone/__tests__/AgentsMachinesTable.test.tsx
@@ -141,15 +141,36 @@ describe('AgentsMachinesTable', () => {
expect(screen.getByText('1.00 KB/s')).toBeInTheDocument();
expect(screen.getByText('8.00 KB/s')).toBeInTheDocument();
- expect(screen.queryByText('192.168.0.10')).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Sort by IP' })).not.toBeInTheDocument();
+ expect(screen.getByText('192.168.0.10')).toBeInTheDocument();
await fireEvent.click(screen.getByTitle('Choose which columns to display'));
await fireEvent.click(screen.getByLabelText('IP'));
await fireEvent.click(screen.getByLabelText('RAID'));
- expect(screen.getByText('192.168.0.10')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Sort by IP' })).toBeInTheDocument();
+ expect(screen.getAllByText('192.168.0.10').length).toBeGreaterThan(0);
expect(screen.getByText('1 clean')).toBeInTheDocument();
});
+ it('shows hostname and primary IP in the machine identity subtitle', () => {
+ render(() => (
+ <AgentsMachinesTable
+ resources={[
+ resource({
+ id: 'mac-mini',
+ name: 'Mac Mini',
+ identity: { hostname: 'richard-mac-mini.local', ips: ['192.168.0.98'] },
+ }),
+ ]}
+ emptyIcon={emptyIcon}
+ emptyTitle="No machines"
+ emptyDescription="Install Pulse Agent."
+ />
+ ));
+
+ expect(screen.getByText('richard-mac-mini.local | 192.168.0.98')).toBeInTheDocument();
+ });
+
it('shows structured agent network interface details from the Net I/O value', async () => {
const { container } = render(() => (
<AgentsMachinesTable
@@ -187,7 +208,7 @@ describe('AgentsMachinesTable', () => {
expect(await screen.findByText('Network Interfaces')).toBeInTheDocument();
expect(screen.getByText('en0')).toBeInTheDocument();
expect(screen.getByText('10:20:30:40:50:60')).toBeInTheDocument();
- expect(screen.getByText('192.168.0.20')).toBeInTheDocument();
+ expect(screen.getAllByText('192.168.0.20').length).toBeGreaterThan(0);
expect(screen.getByText('fe80::1')).toBeInTheDocument();
expect(screen.getByText('RX')).toBeInTheDocument();
expect(screen.getByText('TX')).toBeInTheDocument();