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.

Add unified connections table primitive

rcourtman1d66d62c3e75
diff --git a/frontend-modern/src/components/Settings/ConnectionsTable.tsx b/frontend-modern/src/components/Settings/ConnectionsTable.tsx
new file mode 100644
index 0000000000..350af6dcfd
--- /dev/null
+++ b/frontend-modern/src/components/Settings/ConnectionsTable.tsx
@@ -0,0 +1,111 @@
+import { Component, For, Show, type Accessor } from 'solid-js';
+import { Card } from '@/components/shared/Card';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import { formatRelativeTime } from '@/utils/format';
+import type { ConnectionRow, ConnectionStatus } from './connectionsTableModel';
+
+interface ConnectionsTableProps {
+ rows: Accessor<readonly ConnectionRow[]>;
+ onAddSystem?: () => void;
+}
+
+const STATUS_DOT_CLASS: Record<ConnectionStatus, string> = {
+ reporting: 'bg-emerald-500',
+ pending: 'bg-amber-400',
+ offline: 'bg-slate-400',
+ error: 'bg-rose-500',
+ unknown: 'bg-slate-300',
+};
+
+export const ConnectionsTable: Component<ConnectionsTableProps> = (props) => {
+ return (
+ <Card padding="none" tone="card" class="rounded-md">
+ <div class="flex items-center justify-between gap-3 border-b border-border px-4 py-3">
+ <div>
+ <h3 class="text-base font-semibold text-base-content">Connections</h3>
+ <p class="text-xs text-muted">
+ Every system Pulse is configured to monitor, regardless of how it reports.
+ </p>
+ </div>
+ <Show when={props.onAddSystem}>
+ <button
+ type="button"
+ onClick={props.onAddSystem}
+ class="inline-flex items-center gap-1.5 rounded-md bg-blue-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-blue-700"
+ >
+ + Add a system
+ </button>
+ </Show>
+ </div>
+ <Show
+ when={props.rows().length > 0}
+ fallback={
+ <div class="px-4 py-10 text-center text-sm text-muted">
+ No systems connected yet. Use
+ <span class="mx-1 font-medium text-base-content">+ Add a system</span>
+ to connect your first one.
+ </div>
+ }
+ >
+ <div class="overflow-auto">
+ <Table class="min-w-[max-content] w-full divide-y divide-border text-sm">
+ <TableHeader class="bg-surface-alt">
+ <TableRow>
+ <TableHead class="py-2 pl-4 pr-3 text-left text-xs font-semibold uppercase tracking-wide text-muted">
+ Name
+ </TableHead>
+ <TableHead class="px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted">
+ Kind
+ </TableHead>
+ <TableHead class="px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted">
+ Method
+ </TableHead>
+ <TableHead class="px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted">
+ Status
+ </TableHead>
+ <TableHead class="px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted">
+ Last reported
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class="divide-y divide-border bg-surface">
+ <For each={props.rows()}>
+ {(r) => (
+ <TableRow class="even:bg-surface-alt">
+ <TableCell class="py-2.5 pl-4 pr-3">
+ <div class="font-medium text-base-content">{r.name}</div>
+ <Show when={r.host && r.host !== r.name}>
+ <div class="text-xs text-muted">{r.host}</div>
+ </Show>
+ </TableCell>
+ <TableCell class="px-3 py-2.5 text-base-content">{r.kindLabel}</TableCell>
+ <TableCell class="px-3 py-2.5 text-base-content">{r.methodLabel}</TableCell>
+ <TableCell class="px-3 py-2.5">
+ <span class="inline-flex items-center gap-2">
+ <span
+ aria-hidden="true"
+ class={`inline-block h-2 w-2 rounded-full ${STATUS_DOT_CLASS[r.status]}`}
+ />
+ <span class="text-base-content">{r.statusLabel}</span>
+ </span>
+ </TableCell>
+ <TableCell class="px-3 py-2.5 text-muted">
+ {formatRelativeTime(r.lastReportedMs, { emptyText: '—' })}
+ </TableCell>
+ </TableRow>
+ )}
+ </For>
+ </TableBody>
+ </Table>
+ </div>
+ </Show>
+ </Card>
+ );
+};
diff --git a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
new file mode 100644
index 0000000000..7eabca4a3b
--- /dev/null
+++ b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
@@ -0,0 +1,67 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { ConnectionsTable } from '../ConnectionsTable';
+import type { ConnectionRow } from '../connectionsTableModel';
+
+const row = (overrides: Partial<ConnectionRow> = {}): ConnectionRow => ({
+ id: 'pve:pve-1',
+ kind: 'pve',
+ kindLabel: 'Proxmox VE',
+ method: 'api',
+ methodLabel: 'API',
+ name: 'production-pve',
+ host: '10.0.0.1',
+ status: 'reporting',
+ statusLabel: 'Reporting',
+ lastReportedMs: Date.now() - 5_000,
+ ...overrides,
+});
+
+describe('ConnectionsTable', () => {
+ afterEach(() => cleanup());
+
+ it('renders an empty-state hint when no rows exist', () => {
+ render(() => (
+ <ConnectionsTable rows={() => []} />
+ ) as any);
+ expect(screen.getByText(/No systems connected yet/i)).toBeInTheDocument();
+ expect(screen.queryByRole('table')).toBeNull();
+ });
+
+ it('renders one row per connection with kind, method, and status labels', () => {
+ render(() => (
+ <ConnectionsTable
+ rows={() => [
+ row(),
+ row({
+ id: 'agent:tower',
+ kind: 'agent',
+ kindLabel: 'Agent host',
+ method: 'agent',
+ methodLabel: 'Agent',
+ name: 'tower',
+ host: undefined,
+ }),
+ ]}
+ />
+ ) as any);
+
+ expect(screen.getByRole('table')).toBeInTheDocument();
+ expect(screen.getByText('production-pve')).toBeInTheDocument();
+ expect(screen.getByText('tower')).toBeInTheDocument();
+ expect(screen.getAllByText('Reporting')).toHaveLength(2);
+ expect(screen.getByText('Proxmox VE')).toBeInTheDocument();
+ expect(screen.getByText('Agent host')).toBeInTheDocument();
+ });
+
+ it('surfaces the add-system action only when an onAddSystem handler is provided', () => {
+ const onAddSystem = vi.fn();
+ render(() => (
+ <ConnectionsTable rows={() => []} onAddSystem={onAddSystem} />
+ ) as any);
+
+ const button = screen.getByRole('button', { name: /Add a system/i });
+ fireEvent.click(button);
+ expect(onAddSystem).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/frontend-modern/src/components/Settings/__tests__/connectionsTableModel.test.ts b/frontend-modern/src/components/Settings/__tests__/connectionsTableModel.test.ts
new file mode 100644
index 0000000000..34218bb4bb
--- /dev/null
+++ b/frontend-modern/src/components/Settings/__tests__/connectionsTableModel.test.ts
@@ -0,0 +1,137 @@
+import { describe, expect, it } from 'vitest';
+import type { NodeConfigWithStatus } from '@/types/nodes';
+import type { Resource } from '@/types/resource';
+import type { TrueNASConnection } from '@/api/truenas';
+import type { VMwareConnection } from '@/api/vmware';
+import {
+ agentConnectionRow,
+ buildConnectionRows,
+ pbsConnectionRow,
+ pmgConnectionRow,
+ pveConnectionRow,
+ truenasConnectionRow,
+ vmwareConnectionRow,
+} from '../connectionsTableModel';
+
+const pveNode = (overrides: Partial<NodeConfigWithStatus> = {}): NodeConfigWithStatus =>
+ ({
+ id: 'pve-1',
+ name: 'pve-1',
+ host: '10.0.0.1',
+ user: 'root',
+ type: 'pve',
+ verifySSL: true,
+ monitorVMs: true,
+ monitorContainers: true,
+ monitorStorage: true,
+ monitorBackups: true,
+ monitorPhysicalDisks: false,
+ status: 'connected',
+ ...overrides,
+ }) as NodeConfigWithStatus;
+
+const truenas = (overrides: Partial<TrueNASConnection> = {}): TrueNASConnection =>
+ ({
+ id: 'tn-1',
+ name: 'Tower NAS',
+ host: '10.0.0.20',
+ useHttps: true,
+ insecureSkipVerify: false,
+ enabled: true,
+ ...overrides,
+ }) as TrueNASConnection;
+
+const vmware = (overrides: Partial<VMwareConnection> = {}): VMwareConnection =>
+ ({
+ id: 'vm-1',
+ name: 'vCenter',
+ host: '10.0.0.30',
+ insecureSkipVerify: false,
+ enabled: true,
+ ...overrides,
+ }) as VMwareConnection;
+
+const agentResource = (overrides: Partial<Resource> = {}): Resource =>
+ ({
+ id: 'agent-1',
+ type: 'agent',
+ name: 'tower',
+ displayName: 'tower',
+ platformId: 'agent-tower',
+ platformType: 'agent',
+ sourceType: 'agent',
+ status: 'online',
+ lastSeen: 1700000000000,
+ ...overrides,
+ }) as Resource;
+
+describe('connectionsTableModel', () => {
+ it('maps PVE / PBS / PMG node status into unified reporting states', () => {
+ expect(pveConnectionRow(pveNode()).status).toBe('reporting');
+ expect(pveConnectionRow(pveNode({ status: 'pending' })).status).toBe('pending');
+ expect(pveConnectionRow(pveNode({ status: 'disconnected' })).status).toBe('offline');
+ expect(pveConnectionRow(pveNode({ status: 'error' })).status).toBe('error');
+ expect(pbsConnectionRow(pveNode({ type: 'pbs', status: 'offline' })).kind).toBe('pbs');
+ expect(pmgConnectionRow(pveNode({ type: 'pmg', status: 'connected' })).kind).toBe('pmg');
+ });
+
+ it('prefers the display name over the internal name', () => {
+ const row = pveConnectionRow(pveNode({ displayName: 'Production cluster', name: 'pve-1' }));
+ expect(row.name).toBe('Production cluster');
+ });
+
+ it('treats a disabled TrueNAS or VMware connection as offline regardless of poll state', () => {
+ const tnRow = truenasConnectionRow(truenas({ enabled: false, poll: { lastSuccessAt: '2026-01-01T00:00:00Z' } }));
+ const vmRow = vmwareConnectionRow(vmware({ enabled: false, poll: { lastSuccessAt: '2026-01-01T00:00:00Z' } }));
+ expect(tnRow.status).toBe('offline');
+ expect(vmRow.status).toBe('offline');
+ });
+
+ it('reports pending when a connection has no poll success and no failures', () => {
+ expect(truenasConnectionRow(truenas()).status).toBe('pending');
+ expect(vmwareConnectionRow(vmware()).status).toBe('pending');
+ });
+
+ it('reports reporting with a lastReportedMs once a poll has succeeded', () => {
+ const row = truenasConnectionRow(
+ truenas({ poll: { lastSuccessAt: '2026-01-01T00:00:00Z', consecutiveFailures: 0 } }),
+ );
+ expect(row.status).toBe('reporting');
+ expect(row.lastReportedMs).toBe(Date.parse('2026-01-01T00:00:00Z'));
+ });
+
+ it('reports error when consecutive failures exceed the tolerance', () => {
+ expect(
+ truenasConnectionRow(
+ truenas({ poll: { lastSuccessAt: '2026-01-01T00:00:00Z', consecutiveFailures: 5 } }),
+ ).status,
+ ).toBe('error');
+ expect(
+ vmwareConnectionRow(vmware({ poll: { consecutiveFailures: 1 } })).status,
+ ).toBe('error');
+ });
+
+ it('maps agent resource status into unified reporting states and carries lastSeen', () => {
+ expect(agentConnectionRow(agentResource()).status).toBe('reporting');
+ expect(agentConnectionRow(agentResource()).lastReportedMs).toBe(1700000000000);
+ expect(agentConnectionRow(agentResource({ status: 'offline' })).status).toBe('offline');
+ expect(agentConnectionRow(agentResource({ status: 'degraded' })).status).toBe('error');
+ expect(agentConnectionRow(agentResource({ status: 'unknown' })).status).toBe('unknown');
+ });
+
+ it('merges every source into a single alpha-sorted row set with stable composite ids', () => {
+ const rows = buildConnectionRows({
+ pveNodes: [pveNode({ id: 'a', name: 'zeus' })],
+ pbsNodes: [pveNode({ id: 'b', type: 'pbs', name: 'backup' })],
+ pmgNodes: [],
+ truenasConnections: [truenas({ id: 'c', name: 'mira' })],
+ vmwareConnections: [vmware({ id: 'd', name: 'apex' })],
+ agentResources: [agentResource({ id: 'e', name: 'tower', displayName: 'tower' })],
+ });
+
+ expect(rows.map((r) => r.name)).toEqual(['apex', 'backup', 'mira', 'tower', 'zeus']);
+ expect(new Set(rows.map((r) => r.id)).size).toBe(rows.length);
+ expect(rows.find((r) => r.name === 'tower')?.method).toBe('agent');
+ expect(rows.find((r) => r.name === 'apex')?.method).toBe('api');
+ });
+});
diff --git a/frontend-modern/src/components/Settings/connectionsTableModel.ts b/frontend-modern/src/components/Settings/connectionsTableModel.ts
new file mode 100644
index 0000000000..f15270f2e4
--- /dev/null
+++ b/frontend-modern/src/components/Settings/connectionsTableModel.ts
@@ -0,0 +1,173 @@
+import type { Resource } from '@/types/resource';
+import type { NodeConfigWithStatus } from '@/types/nodes';
+import type { TrueNASConnection } from '@/api/truenas';
+import type { VMwareConnection } from '@/api/vmware';
+
+export type ConnectionKind = 'pve' | 'pbs' | 'pmg' | 'truenas' | 'vmware' | 'agent';
+export type ConnectionMethod = 'api' | 'agent';
+export type ConnectionStatus = 'reporting' | 'pending' | 'offline' | 'error' | 'unknown';
+
+export interface ConnectionRow {
+ id: string;
+ kind: ConnectionKind;
+ kindLabel: string;
+ method: ConnectionMethod;
+ methodLabel: string;
+ name: string;
+ host?: string;
+ status: ConnectionStatus;
+ statusLabel: string;
+ lastReportedMs?: number;
+}
+
+export const CONNECTION_KIND_LABELS: Record<ConnectionKind, string> = {
+ pve: 'Proxmox VE',
+ pbs: 'PBS',
+ pmg: 'PMG',
+ truenas: 'TrueNAS',
+ vmware: 'VMware',
+ agent: 'Agent host',
+};
+
+export const CONNECTION_METHOD_LABELS: Record<ConnectionMethod, string> = {
+ api: 'API',
+ agent: 'Agent',
+};
+
+export const CONNECTION_STATUS_LABELS: Record<ConnectionStatus, string> = {
+ reporting: 'Reporting',
+ pending: 'Pending',
+ offline: 'Offline',
+ error: 'Error',
+ unknown: 'Unknown',
+};
+
+function row(
+ kind: ConnectionKind,
+ id: string,
+ name: string,
+ method: ConnectionMethod,
+ status: ConnectionStatus,
+ host?: string,
+ lastReportedMs?: number,
+): ConnectionRow {
+ return {
+ id: `${kind}:${id}`,
+ kind,
+ kindLabel: CONNECTION_KIND_LABELS[kind],
+ method,
+ methodLabel: CONNECTION_METHOD_LABELS[method],
+ name,
+ host,
+ status,
+ statusLabel: CONNECTION_STATUS_LABELS[status],
+ lastReportedMs,
+ };
+}
+
+function mapNodeStatus(status: NodeConfigWithStatus['status']): ConnectionStatus {
+ switch (status) {
+ case 'connected':
+ return 'reporting';
+ case 'pending':
+ return 'pending';
+ case 'disconnected':
+ case 'offline':
+ return 'offline';
+ case 'error':
+ return 'error';
+ default:
+ return 'unknown';
+ }
+}
+
+export function pveConnectionRow(node: NodeConfigWithStatus): ConnectionRow {
+ return row('pve', node.id, node.displayName || node.name, 'api', mapNodeStatus(node.status), node.host);
+}
+
+export function pbsConnectionRow(node: NodeConfigWithStatus): ConnectionRow {
+ return row('pbs', node.id, node.displayName || node.name, 'api', mapNodeStatus(node.status), node.host);
+}
+
+export function pmgConnectionRow(node: NodeConfigWithStatus): ConnectionRow {
+ return row('pmg', node.id, node.displayName || node.name, 'api', mapNodeStatus(node.status), node.host);
+}
+
+function pollBackedStatus(
+ enabled: boolean,
+ lastSuccessAt: string | undefined,
+ consecutiveFailures: number | undefined,
+): { status: ConnectionStatus; lastReportedMs?: number } {
+ if (!enabled) return { status: 'offline' };
+ const lastReportedMs = lastSuccessAt ? Date.parse(lastSuccessAt) || undefined : undefined;
+ const fails = consecutiveFailures ?? 0;
+ if (fails > 2) return { status: 'error', lastReportedMs };
+ if (fails > 0 && !lastReportedMs) return { status: 'error' };
+ if (lastReportedMs) return { status: 'reporting', lastReportedMs };
+ return { status: 'pending' };
+}
+
+export function truenasConnectionRow(conn: TrueNASConnection): ConnectionRow {
+ const { status, lastReportedMs } = pollBackedStatus(
+ conn.enabled,
+ conn.poll?.lastSuccessAt,
+ conn.poll?.consecutiveFailures,
+ );
+ return row('truenas', conn.id, conn.name || conn.host, 'api', status, conn.host, lastReportedMs);
+}
+
+export function vmwareConnectionRow(conn: VMwareConnection): ConnectionRow {
+ const { status, lastReportedMs } = pollBackedStatus(
+ conn.enabled,
+ conn.poll?.lastSuccessAt,
+ conn.poll?.consecutiveFailures,
+ );
+ return row('vmware', conn.id, conn.name || conn.host, 'api', status, conn.host, lastReportedMs);
+}
+
+function mapResourceStatus(status: Resource['status']): ConnectionStatus {
+ switch (status) {
+ case 'online':
+ case 'running':
+ return 'reporting';
+ case 'offline':
+ case 'stopped':
+ return 'offline';
+ case 'degraded':
+ return 'error';
+ default:
+ return 'unknown';
+ }
+}
+
+export function agentConnectionRow(resource: Resource): ConnectionRow {
+ return row(
+ 'agent',
+ resource.id,
+ resource.displayName || resource.name,
+ 'agent',
+ mapResourceStatus(resource.status),
+ undefined,
+ resource.lastSeen || undefined,
+ );
+}
+
+export interface ConnectionsTableSources {
+ pveNodes: readonly NodeConfigWithStatus[];
+ pbsNodes: readonly NodeConfigWithStatus[];
+ pmgNodes: readonly NodeConfigWithStatus[];
+ truenasConnections: readonly TrueNASConnection[];
+ vmwareConnections: readonly VMwareConnection[];
+ agentResources: readonly Resource[];
+}
+
+export function buildConnectionRows(sources: ConnectionsTableSources): ConnectionRow[] {
+ return [
+ ...sources.pveNodes.map(pveConnectionRow),
+ ...sources.pbsNodes.map(pbsConnectionRow),
+ ...sources.pmgNodes.map(pmgConnectionRow),
+ ...sources.truenasConnections.map(truenasConnectionRow),
+ ...sources.vmwareConnections.map(vmwareConnectionRow),
+ ...sources.agentResources.map(agentConnectionRow),
+ ].sort((a, b) => a.name.localeCompare(b.name));
+}