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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Surface vSphere health signals
rcourtmanffd2a7efede6
diff --git a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.tsindex 4cb5eba157..956d454da8 100644--- a/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts+++ b/frontend-modern/src/features/platformPage/__tests__/platformOverviewLayout.guardrails.test.ts@@ -24,6 +24,7 @@ import truenasStorageTopologyTableSource from '@/features/truenas/TrueNASStorageimport truenasSystemsTableSource from '@/features/truenas/TrueNASSystemsTable.tsx?raw';import truenasVirtualMachinesTableSource from '@/features/truenas/TrueNASVirtualMachinesTable.tsx?raw';import vmwarePageSurfaceSource from '@/features/vmware/VmwarePageSurface.tsx?raw';+import vsphereAlertsTableSource from '@/features/vmware/VsphereAlertsTable.tsx?raw';import vsphereDatastoresTableSource from '@/features/vmware/VsphereDatastoresTable.tsx?raw';import vsphereHostsTableSource from '@/features/vmware/VsphereHostsTable.tsx?raw';import vsphereVirtualMachinesTableSource from '@/features/vmware/VsphereVirtualMachinesTable.tsx?raw';@@ -42,6 +43,7 @@ const platformTableSources = [truenasStorageTopologyTableSource,truenasSystemsTableSource,truenasVirtualMachinesTableSource,+ vsphereAlertsTableSource,vsphereDatastoresTableSource,vsphereHostsTableSource,vsphereVirtualMachinesTableSource,@@ -194,6 +196,7 @@ describe('platform overview layout guardrails', () => {expect(truenasStorageTopologyTableSource).toContain('md:min-w-[960px]');expect(truenasVirtualMachinesTableSource).toContain('md:min-w-[960px]');expect(vmwarePageSurfaceSource).toContain('<VsphereHostsTable');+ expect(vmwarePageSurfaceSource).toContain('<VsphereAlertsTable');expect(vmwarePageSurfaceSource).toContain('<VsphereVirtualMachinesTable');expect(vmwarePageSurfaceSource).not.toContain('<WorkloadsSurface');expect(vmwarePageSurfaceSource).toContain('<VsphereDatastoresTable');diff --git a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx b/frontend-modern/src/features/vmware/VmwarePageSurface.tsxindex 74a96107b4..b4a689646f 100644--- a/frontend-modern/src/features/vmware/VmwarePageSurface.tsx+++ b/frontend-modern/src/features/vmware/VmwarePageSurface.tsx@@ -15,6 +15,7 @@ import {type VmwarePageModel,type VmwarePageTabId,} from './vmwarePageModel';+import { VsphereAlertsTable } from './VsphereAlertsTable';import { VsphereDatastoresTable } from './VsphereDatastoresTable';import { VsphereVirtualMachinesTable } from './VsphereVirtualMachinesTable';@@ -110,6 +111,14 @@ function VmwareOverview(props: VmwareOverviewProps) {emptyDescription="Hosts appear here once the vCenter connection enumerates them."showToolbar={false}/>+ <Show when={props.model().incidents.length > 0}>+ <VsphereAlertsTable+ incidents={props.model().incidents}+ emptyIcon={vmwareIcon()}+ emptyTitle="No active vSphere health signals"+ emptyDescription="vSphere triggered alarms and overall health signals appear here when vCenter reports them."+ />+ </Show><VsphereVirtualMachinesTablevms={props.model().vms}scope={props.model().resources}diff --git a/frontend-modern/src/features/vmware/VsphereAlertsTable.tsx b/frontend-modern/src/features/vmware/VsphereAlertsTable.tsxnew file mode 100644index 0000000000..673bc2a1b2--- /dev/null+++ b/frontend-modern/src/features/vmware/VsphereAlertsTable.tsx@@ -0,0 +1,383 @@+import { For, Show, type Component, type JSX } from 'solid-js';+import XIcon from 'lucide-solid/icons/x';+import { StatusDot } from '@/components/shared/StatusDot';+import { TableCard } from '@/components/shared/TableCard';+import { TableCardHeader } from '@/components/shared/TableCardHeader';+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+} from '@/components/shared/Table';+import {+ PLATFORM_TABLE_BODY_CLASS,+ PLATFORM_TABLE_CARD_CLASS,+ PLATFORM_TABLE_HEADER_ROW_CLASS,+ PlatformTableEmptyState,+ PlatformTableToolbar,+ createPlatformTableFilterState,+ getPlatformTableCellClassForKind,+ getPlatformTableHeadClassForKind,+ type PlatformTableFilterOption,+} from '@/features/platformPage/sharedPlatformPage';+import {+ createPlatformResourceDetailState,+ getPlatformResourceDetailRowClass,+} from '@/features/platformPage/PlatformResourceDetailTableRow';+import type { ResourceType } from '@/types/resource';+import type { StatusIndicatorVariant } from '@/utils/status';+import { getAlertFilteredEmptyState } from '@/utils/alertOverviewPresentation';+import {+ filterVmwareIncidents,+ type VmwareIncidentRow,+ type VmwareIncidentSeverityFilter,+} from './vmwarePageModel';++const VSPHERE_INCIDENT_STATUS_OPTIONS: PlatformTableFilterOption<VmwareIncidentSeverityFilter>[] = [+ { value: 'all', label: 'All' },+ { value: 'critical', label: 'Critical', tone: 'danger' },+ { value: 'warning', label: 'Warning', tone: 'warning' },+ { value: 'info', label: 'Info', tone: 'success' },+];++const severityVariant = (severity: VmwareIncidentRow['severityBucket']): StatusIndicatorVariant => {+ switch (severity) {+ case 'critical':+ return 'danger';+ case 'warning':+ return 'warning';+ case 'info':+ return 'muted';+ }+};++const severityTextClass = (severity: VmwareIncidentRow['severityBucket']): string => {+ switch (severity) {+ case 'critical':+ return 'text-red-700 dark:text-red-300';+ case 'warning':+ return 'text-amber-700 dark:text-amber-300';+ case 'info':+ return 'text-muted';+ }+};++const severityLabel = (severity: string): string => {+ const normalized = severity.trim();+ if (!normalized) return 'Info';+ return normalized.charAt(0).toUpperCase() + normalized.slice(1).toLowerCase();+};++const formatResourceType = (type: ResourceType): string => {+ switch (type) {+ case 'agent':+ return 'Host';+ case 'vm':+ return 'VM';+ case 'storage':+ return 'Datastore';+ default:+ return type;+ }+};++const formatEntityType = (value: string): string => {+ const normalized = value.trim().toLowerCase();+ if (normalized === 'host') return 'Host';+ if (normalized === 'vm') return 'VM';+ if (normalized === 'datastore') return 'Datastore';+ return normalized ? normalized.charAt(0).toUpperCase() + normalized.slice(1) : '-';+};++const formatCode = (code: string): string => {+ const normalized = code.trim().replace(/^vmware_/, '');+ if (!normalized) return '-';+ return normalized+ .split(/[\s_-]+/)+ .filter(Boolean)+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())+ .join(' ');+};++const formatStartedAt = (value: string | undefined): string => {+ if (!value) return '-';+ const parsed = new Date(value);+ if (Number.isNaN(parsed.getTime())) return '-';+ if (parsed.getUTCFullYear() < 2000) return '-';+ return parsed.toLocaleString(undefined, {+ month: 'short',+ day: 'numeric',+ hour: '2-digit',+ minute: '2-digit',+ });+};++const detailDateTime = (value?: string): string => {+ if (!value) return '-';+ const parsed = new Date(value);+ if (Number.isNaN(parsed.getTime())) return value;+ if (parsed.getUTCFullYear() < 2000) return '-';+ return parsed.toLocaleString(undefined, {+ month: 'short',+ day: 'numeric',+ year: 'numeric',+ hour: '2-digit',+ minute: '2-digit',+ });+};++const DetailField: Component<{ label: string; value: string | undefined }> = (props) => (+ <div class="min-w-0">+ <dt class="text-[10px] font-semibold uppercase tracking-wide text-muted">{props.label}</dt>+ <dd class="mt-1 truncate text-xs text-base-content" title={props.value || '-'}>+ {props.value || '-'}+ </dd>+ </div>+);++const AlertDetail: Component<{ incident: VmwareIncidentRow; onClose: () => void }> = (props) => {+ const meta = () => props.incident.resource.vmware;+ return (+ <div data-testid="vsphere-alert-detail" class="space-y-3">+ <div class="flex min-w-0 items-start justify-between gap-3">+ <div class="min-w-0">+ <div class="text-sm font-semibold text-base-content">vSphere health detail</div>+ <div class="mt-0.5 truncate text-xs text-muted" title={props.incident.summary}>+ {severityLabel(props.incident.severity)} · {formatCode(props.incident.code)}+ </div>+ </div>+ <button+ type="button"+ class="inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted hover:bg-surface-hover hover:text-base-content"+ aria-label="Close"+ onClick={props.onClose}+ >+ <XIcon class="h-4 w-4" />+ </button>+ </div>++ <dl class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">+ <DetailField label="Summary" value={props.incident.summary} />+ <DetailField label="Signal" value={props.incident.label} />+ <DetailField label="Severity" value={severityLabel(props.incident.severity)} />+ <DetailField label="Entity" value={formatEntityType(props.incident.entityType)} />+ <DetailField label="Managed object" value={props.incident.managedObjectId} />+ <DetailField label="Resource" value={props.incident.resourceName} />+ <DetailField label="vCenter" value={meta()?.connectionName || meta()?.vcenterHost} />+ <DetailField label="Datacenter" value={meta()?.datacenterName} />+ <DetailField label="Cluster" value={meta()?.clusterName || meta()?.computeResourceName} />+ <DetailField label="Started" value={detailDateTime(props.incident.startedAt)} />+ <DetailField label="Source" value={props.incident.source} />+ <DetailField label="Action" value={props.incident.action} />+ </dl>+ </div>+ );+};++export const VsphereAlertsTable: Component<{+ incidents: VmwareIncidentRow[];+ emptyIcon: JSX.Element;+ emptyTitle: string;+ emptyDescription: string;+ showToolbar?: boolean;+}> = (props) => {+ const tableState = createPlatformTableFilterState({+ resources: () => props.incidents,+ initialStatus: 'all' as VmwareIncidentSeverityFilter,+ filter: filterVmwareIncidents,+ });+ const drawer = createPlatformResourceDetailState({ idPrefix: 'vsphere-alert-drawer' });+ const filteredEmptyState = () => getAlertFilteredEmptyState('vSphere health signals', 'severity');++ return (+ <Show+ when={props.incidents.length > 0}+ fallback={+ <PlatformTableEmptyState+ icon={props.emptyIcon}+ title={props.emptyTitle}+ description={props.emptyDescription}+ />+ }+ >+ <div class="space-y-3">+ <Show when={props.showToolbar !== false}>+ <PlatformTableToolbar+ search={tableState.search}+ onSearchChange={tableState.setSearch}+ searchPlaceholder="Search vSphere health"+ status={tableState.status()}+ onStatusChange={tableState.setStatus}+ statusOptions={VSPHERE_INCIDENT_STATUS_OPTIONS}+ visible={tableState.visible()}+ total={tableState.total()}+ rowNoun="signals"+ />+ </Show>++ <Show+ when={tableState.filtered().length > 0}+ fallback={+ <PlatformTableEmptyState+ icon={props.emptyIcon}+ title={filteredEmptyState().title}+ description={filteredEmptyState().description}+ />+ }+ >+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>+ <TableCardHeader title="Health Signals" />+ <Table class="min-w-full table-fixed text-xs md:min-w-[1040px]">+ <TableHeader>+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[20%]`}>+ Resource+ </TableHead>+ <TableHead class={`${getPlatformTableHeadClassForKind('badge')} md:w-[10%]`}>+ Severity+ </TableHead>+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[34%]`}>+ Signal+ </TableHead>+ <TableHead+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[14%]`}+ >+ vCenter+ </TableHead>+ <TableHead+ class={`${getPlatformTableHeadClassForKind('text')} hidden lg:table-cell md:w-[12%]`}+ >+ Entity+ </TableHead>+ <TableHead+ class={`${getPlatformTableHeadClassForKind('text')} hidden xl:table-cell md:w-[10%]`}+ >+ Started+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>+ <For each={tableState.filtered()}>+ {(incident) => {+ const meta = () => incident.resource.vmware;+ const detailRowId = () => drawer.detailRowId(incident);+ const isExpanded = () => drawer.isExpanded(incident);+ return (+ <>+ <TableRow+ class={`${getPlatformResourceDetailRowClass(isExpanded())} text-[11px] sm:text-xs`}+ aria-controls={isExpanded() ? detailRowId() : undefined}+ aria-expanded={isExpanded() ? 'true' : 'false'}+ data-vsphere-alert-row={incident.id}+ onClick={() => drawer.toggle(incident)}+ onKeyDown={drawer.handleActivationKey(incident)}+ tabIndex={0}+ >+ <TableCell class={getPlatformTableCellClassForKind('name')}>+ <div class="flex min-w-0 items-center gap-2">+ <StatusDot+ size="sm"+ variant={severityVariant(incident.severityBucket)}+ title={severityLabel(incident.severity)}+ />+ <div class="min-w-0">+ <div+ class="truncate font-medium text-base-content"+ title={incident.resourceName}+ >+ {incident.resourceName}+ </div>+ <div class="truncate text-[10px] text-muted">+ {formatResourceType(incident.resourceType)}+ <Show when={incident.resource.parentName}>+ {' '}+ on {incident.resource.parentName}+ </Show>+ </div>+ </div>+ </div>+ </TableCell>+ <TableCell class={getPlatformTableCellClassForKind('badge')}>+ <span+ class={`text-[11px] font-semibold ${severityTextClass(+ incident.severityBucket,+ )}`}+ >+ {severityLabel(incident.severity)}+ </span>+ </TableCell>+ <TableCell class={getPlatformTableCellClassForKind('text')}>+ <span class="block truncate text-base-content" title={incident.summary}>+ {incident.summary}+ </span>+ <span class="block truncate text-[10px] text-muted">+ {incident.label}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} hidden md:table-cell`}+ >+ <span+ class="block truncate text-base-content"+ title={meta()?.connectionName || meta()?.vcenterHost}+ >+ {meta()?.connectionName || meta()?.vcenterHost || '-'}+ </span>+ <span class="block truncate text-[10px] text-muted">+ {meta()?.datacenterName || meta()?.clusterName || '-'}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content lg:table-cell`}+ >+ <span class="block truncate" title={incident.managedObjectId}>+ {formatEntityType(incident.entityType)}+ </span>+ <span class="block truncate text-[10px] text-muted">+ {incident.managedObjectId}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content xl:table-cell`}+ >+ {formatStartedAt(incident.startedAt)}+ </TableCell>+ </TableRow>+ <Show when={isExpanded()}>+ <TableRow+ data-inline-detail-for={incident.id}+ data-vsphere-alert-detail-row={incident.id}+ >+ <TableCell+ id={detailRowId()}+ colspan={6}+ class="border-b border-border bg-surface-alt p-0"+ >+ <div+ class="px-2 py-3 sm:px-4 sm:py-4"+ onClick={(event) => event.stopPropagation()}+ >+ <AlertDetail+ incident={incident}+ onClose={() => drawer.close(incident)}+ />+ </div>+ </TableCell>+ </TableRow>+ </Show>+ </>+ );+ }}+ </For>+ </TableBody>+ </Table>+ </TableCard>+ </Show>+ </div>+ </Show>+ );+};++export default VsphereAlertsTable;diff --git a/frontend-modern/src/features/vmware/__tests__/VsphereAlertsTable.test.tsx b/frontend-modern/src/features/vmware/__tests__/VsphereAlertsTable.test.tsxnew file mode 100644index 0000000000..5cdcdd7aa9--- /dev/null+++ b/frontend-modern/src/features/vmware/__tests__/VsphereAlertsTable.test.tsx@@ -0,0 +1,95 @@+import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';+import { afterEach, describe, expect, it } from 'vitest';++import { VsphereAlertsTable } from '@/features/vmware/VsphereAlertsTable';+import { buildVmwareIncidentRows } from '@/features/vmware/vmwarePageModel';+import type { Resource } from '@/types/resource';++const makeHost = (overrides: Partial<Resource> = {}): Resource =>+ ({+ id: 'host-alarm',+ type: 'agent',+ name: 'esxi-01.lab.local',+ displayName: 'esxi-01.lab.local',+ status: 'degraded',+ platformType: 'vmware-vsphere',+ platformScopes: ['vmware-vsphere'],+ sourceType: 'api',+ vmware: {+ entityType: 'host',+ managedObjectId: 'host-101',+ connectionName: 'lab-vcenter',+ vcenterHost: 'vcsa.lab.local',+ datacenterName: 'Primary DC',+ clusterName: 'Production Cluster',+ },+ incidents: [+ {+ provider: 'vmware',+ nativeId: 'alarm-401',+ code: 'vmware_alarm_state',+ severity: 'critical',+ source: 'vmware',+ summary: 'Host host-101 has VMware alarm Host connection and power state (red)',+ startedAt: '2026-05-21T14:30:00Z',+ },+ ],+ ...overrides,+ }) as Resource;++afterEach(() => {+ cleanup();+});++describe('VsphereAlertsTable', () => {+ it('renders native vSphere health signal rows with inline details', async () => {+ const host = makeHost();+ const incidents = buildVmwareIncidentRows([host]);++ render(() => (+ <VsphereAlertsTable+ incidents={incidents}+ emptyIcon={<span />}+ emptyTitle="No signals"+ emptyDescription="No signals"+ showToolbar={false}+ />+ ));++ const table = screen.getByRole('table');+ expect(within(table).getByText('Resource')).toBeInTheDocument();+ expect(within(table).getByText('Severity')).toBeInTheDocument();+ expect(within(table).getByText('Signal')).toBeInTheDocument();+ expect(within(table).getByText('vCenter')).toBeInTheDocument();+ expect(within(table).getByText('Entity')).toBeInTheDocument();+ expect(screen.getByText('esxi-01.lab.local')).toBeInTheDocument();+ expect(screen.getByText('Critical')).toBeInTheDocument();+ expect(+ screen.getByText('Host host-101 has VMware alarm Host connection and power state (red)'),+ ).toBeInTheDocument();+ expect(screen.getByText('lab-vcenter')).toBeInTheDocument();+ expect(screen.getByText('host-101')).toBeInTheDocument();++ const row = screen+ .getByText('Host host-101 has VMware alarm Host connection and power state (red)')+ .closest('tr');+ expect(row).toHaveAttribute('aria-expanded', 'false');++ await fireEvent.click(row!);++ expect(row).toHaveAttribute('aria-expanded', 'true');+ const detail = within(screen.getByTestId('vsphere-alert-detail'));+ expect(detail.getByText('vSphere health detail')).toBeInTheDocument();+ expect(detail.getByText('Managed object')).toBeInTheDocument();+ expect(detail.getByText('host-101')).toBeInTheDocument();+ expect(detail.getByText('Datacenter')).toBeInTheDocument();+ expect(detail.getByText('Primary DC')).toBeInTheDocument();+ expect(detail.getByText('Action')).toBeInTheDocument();+ expect(detail.getByText('Investigate in vCenter')).toBeInTheDocument();++ await fireEvent.click(detail.getByRole('button', { name: 'Close' }));++ expect(screen.queryByTestId('vsphere-alert-detail')).not.toBeInTheDocument();+ expect(row).toHaveAttribute('aria-expanded', 'false');+ });+});diff --git a/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts b/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.tsindex 4cad1cdd98..b96549e2f4 100644--- a/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts+++ b/frontend-modern/src/features/vmware/__tests__/vmwarePageModel.test.ts@@ -4,8 +4,10 @@ import {VMWARE_TAB_SPECS,buildVmwarePageModel,filterVmwareDatastores,+ filterVmwareIncidents,filterVmwareVirtualMachines,mapVmwareDatastoreStatus,+ mapVmwareIncidentSeverity,mapVmwareVirtualMachineStatus,} from '../vmwarePageModel';@@ -172,4 +174,70 @@ describe('vmwarePageModel', () => {),).toEqual(['vm-powered-off']);});++ it('builds and filters vSphere health signals from resource incidents', () => {+ const hostAlarm = makeResource({+ id: 'host-alarm',+ type: 'agent',+ name: 'esxi-01.lab.local',+ displayName: 'esxi-01.lab.local',+ status: 'degraded',+ vmware: {+ entityType: 'host',+ managedObjectId: 'host-101',+ connectionName: 'lab-vcenter',+ vcenterHost: 'vcsa.lab.local',+ datacenterName: 'Primary DC',+ clusterName: 'Production Cluster',+ },+ incidents: [+ {+ provider: 'vmware',+ nativeId: 'alarm-401',+ code: 'vmware_alarm_state',+ severity: 'critical',+ source: 'vmware',+ summary: 'Host host-101 has VMware alarm Host connection and power state (red)',+ startedAt: '2026-05-21T14:30:00Z',+ },+ ],+ });+ const datastoreHealth = makeResource({+ id: 'datastore-health',+ type: 'storage',+ name: 'edge-cold-iscsi',+ status: 'degraded',+ incidentSeverity: 'yellow',+ incidentCode: 'vmware_health_state',+ incidentSummary: 'Datastore datastore-304 has VMware overall status yellow',+ storage: { topology: 'datastore', platform: 'vmware-vsphere' },+ vmware: {+ entityType: 'datastore',+ managedObjectId: 'datastore-304',+ activeAlarmSummary: 'Datastore usage on disk',+ },+ });++ const rows = buildVmwarePageModel([datastoreHealth, hostAlarm]).incidents;++ expect(mapVmwareIncidentSeverity('red')).toBe('critical');+ expect(mapVmwareIncidentSeverity('yellow')).toBe('warning');+ expect(rows.map((row) => row.id)).toEqual([+ 'host-alarm:incident:alarm-401:0',+ 'datastore-health:incident:rollup',+ ]);+ expect(rows[0]).toMatchObject({+ resourceName: 'esxi-01.lab.local',+ entityType: 'host',+ managedObjectId: 'host-101',+ severityBucket: 'critical',+ label: 'vSphere Alarm',+ });+ expect(+ filterVmwareIncidents(rows, 'datastore-304', 'warning').map((row) => row.resourceId),+ ).toEqual(['datastore-health']);+ expect(+ filterVmwareIncidents(rows, 'production', 'critical').map((row) => row.resourceId),+ ).toEqual(['host-alarm']);+ });});diff --git a/frontend-modern/src/features/vmware/vmwarePageModel.ts b/frontend-modern/src/features/vmware/vmwarePageModel.tsindex e2d4d30d9a..3a67a6bc93 100644--- a/frontend-modern/src/features/vmware/vmwarePageModel.ts+++ b/frontend-modern/src/features/vmware/vmwarePageModel.ts@@ -1,5 +1,5 @@import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';-import type { Resource, ResourceType } from '@/types/resource';+import type { Resource, ResourceIncident, ResourceType } from '@/types/resource';export type VmwarePageTabId = 'overview' | 'storage';export type VmwareDatastoreStatusFilter =@@ -16,6 +16,7 @@ export type VmwareVirtualMachineStatusFilter =| 'powered-off'| 'suspended'| 'unknown';+export type VmwareIncidentSeverityFilter = 'all' | 'critical' | 'warning' | 'info';export type VmwareTabSpec = {id: VmwarePageTabId;@@ -42,6 +43,27 @@ export type VmwarePageModel = {hosts: Resource[];vms: Resource[];datastores: Resource[];+ incidents: VmwareIncidentRow[];+};++export type VmwareIncidentRow = {+ id: string;+ resource: Resource;+ resourceId: string;+ resourceName: string;+ resourceType: ResourceType;+ entityType: string;+ managedObjectId: string;+ severity: string;+ severityBucket: Exclude<VmwareIncidentSeverityFilter, 'all'>;+ code: string;+ source: string;+ summary: string;+ label: string;+ category: string;+ startedAt?: string;+ action: string;+ priority: number;};export function buildVmwarePageModel(resources: Resource[]): VmwarePageModel {@@ -59,18 +81,22 @@ export function buildVmwarePageModel(resources: Resource[]): VmwarePageModel {(resource.storage?.topology === 'datastore' || resource.vmware?.entityType === 'datastore'),).sort(compareVmwareDatastores);+ const incidents = buildVmwareIncidentRows(vmwareResources);return {resources: vmwareResources,hosts,vms,datastores,+ incidents,};}const normalize = (value: unknown): string =>typeof value === 'string' ? value.trim().toLowerCase() : '';+const trimString = (value: unknown): string => (typeof value === 'string' ? value.trim() : '');+const normalizeToken = (value: unknown): string => normalize(value).replace(/[\s_-]/g, '');const vmwareDatastoreDisplayName = (resource: Resource): string =>@@ -79,6 +105,13 @@ const vmwareDatastoreDisplayName = (resource: Resource): string =>const vmwareVirtualMachineDisplayName = (resource: Resource): string =>resource.displayName?.trim() || resource.name?.trim() || resource.id;+const vmwareResourceDisplayName = (resource: Resource): string =>+ trimString(resource.displayName) ||+ trimString(resource.name) ||+ trimString(resource.vmware?.runtimeHostName) ||+ trimString(resource.vmware?.managedObjectId) ||+ resource.id;+const vmwareDatastoreStatusRank = (resource: Resource): number => {switch (mapVmwareDatastoreStatus(resource)) {case 'inaccessible':@@ -130,6 +163,28 @@ const compareVmwareVirtualMachines = (left: Resource, right: Resource): number =);};+const incidentSeverityRank = (severity: string): number => {+ switch (mapVmwareIncidentSeverity(severity)) {+ case 'critical':+ return 3;+ case 'warning':+ return 2;+ case 'info':+ return 1;+ }+};++export function mapVmwareIncidentSeverity(+ severity: string | undefined,+): Exclude<VmwareIncidentSeverityFilter, 'all'> {+ const normalized = normalize(severity);+ if (['critical', 'crit', 'fatal', 'error', 'failed', 'failure', 'red'].includes(normalized)) {+ return 'critical';+ }+ if (['warning', 'warn', 'alert', 'degraded', 'yellow'].includes(normalized)) return 'warning';+ return 'info';+}+export function mapVmwareVirtualMachineStatus(resource: Resource,): Exclude<VmwareVirtualMachineStatusFilter, 'all'> {@@ -187,6 +242,115 @@ export function mapVmwareDatastoreStatus(return 'unknown';}+const titleize = (value: string): string =>+ value+ .split(/[\s_-]+/)+ .filter(Boolean)+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())+ .join(' ');++const hasIncidentSignal = (incident: ResourceIncident): boolean =>+ Boolean(trimString(incident.code) || trimString(incident.summary));++const hasIncidentRollup = (resource: Resource): boolean =>+ (resource.incidentCount ?? 0) > 0 ||+ Boolean(+ trimString(resource.incidentCode) ||+ trimString(resource.incidentSummary) ||+ trimString(resource.incidentLabel),+ );++const vmwareIncidentLabel = (resource: Resource, incident: ResourceIncident): string => {+ const label = trimString(resource.incidentLabel);+ if (label) return label;+ const code = trimString(incident.code);+ if (code === 'vmware_alarm_state') return 'vSphere Alarm';+ if (code === 'vmware_health_state') return 'vSphere Health';+ return code ? titleize(code.replace(/^vmware_/, '')) : 'vSphere Health';+};++const buildIncidentRow = (+ resource: Resource,+ incident: ResourceIncident,+ index: number,+): VmwareIncidentRow => {+ const severity = trimString(incident.severity) || trimString(resource.incidentSeverity) || 'info';+ const code = trimString(incident.code) || trimString(resource.incidentCode) || 'vmware_alert';+ const summary =+ trimString(incident.summary) ||+ trimString(resource.incidentSummary) ||+ vmwareIncidentLabel(resource, incident);+ const nativeId = trimString(incident.nativeId);+ const rowKey = nativeId || code || String(index);++ return {+ id: `${resource.id}:incident:${rowKey}:${index}`,+ resource,+ resourceId: resource.id,+ resourceName: vmwareResourceDisplayName(resource),+ resourceType: resource.type,+ entityType: trimString(resource.vmware?.entityType) || resource.type,+ managedObjectId: trimString(resource.vmware?.managedObjectId) || resource.id,+ severity,+ severityBucket: mapVmwareIncidentSeverity(severity),+ code,+ source: trimString(incident.source) || trimString(incident.provider) || 'vmware',+ summary,+ label: vmwareIncidentLabel(resource, incident),+ category: trimString(resource.incidentCategory) || 'vcenter-health',+ startedAt: incident.startedAt,+ action: trimString(resource.incidentAction) || 'Investigate in vCenter',+ priority: resource.incidentPriority ?? incidentSeverityRank(severity) * 1000,+ };+};++const buildRollupIncidentRow = (resource: Resource): VmwareIncidentRow => {+ const severity = trimString(resource.incidentSeverity) || 'info';+ const code = trimString(resource.incidentCode) || 'vmware_alert';+ const count = resource.incidentCount ?? 0;+ const summary =+ trimString(resource.incidentSummary) ||+ trimString(resource.incidentLabel) ||+ `${count || 1} active vSphere alert${count === 1 ? '' : 's'}`;+ const incident: ResourceIncident = {+ code,+ severity,+ summary,+ source: 'vmware',+ };++ return {+ ...buildIncidentRow(resource, incident, 0),+ id: `${resource.id}:incident:rollup`,+ };+};++export function buildVmwareIncidentRows(resources: Resource[]): VmwareIncidentRow[] {+ const rows: VmwareIncidentRow[] = [];+ for (const resource of resources) {+ const incidents = (resource.incidents ?? []).filter(hasIncidentSignal);+ if (incidents.length > 0) {+ incidents.forEach((incident, index) =>+ rows.push(buildIncidentRow(resource, incident, index)),+ );+ continue;+ }+ if (hasIncidentRollup(resource)) {+ rows.push(buildRollupIncidentRow(resource));+ }+ }++ return rows.sort((a, b) => {+ const severityDelta = incidentSeverityRank(b.severity) - incidentSeverityRank(a.severity);+ if (severityDelta !== 0) return severityDelta;+ const priorityDelta = b.priority - a.priority;+ if (priorityDelta !== 0) return priorityDelta;+ const entityDelta = a.entityType.localeCompare(b.entityType);+ if (entityDelta !== 0) return entityDelta;+ return a.resourceName.localeCompare(b.resourceName);+ });+}+const vmwareDatastoreSearchHaystack = (resource: Resource): string =>[resource.id,@@ -272,3 +436,42 @@ export function filterVmwareVirtualMachines(return vmwareVirtualMachineSearchHaystack(vm).includes(needle);});}++const incidentSearchHaystack = (row: VmwareIncidentRow): string =>+ [+ row.resourceId,+ row.resourceName,+ row.resourceType,+ row.entityType,+ row.managedObjectId,+ row.severity,+ row.code,+ row.source,+ row.summary,+ row.label,+ row.category,+ row.action,+ row.resource.vmware?.connectionName,+ row.resource.vmware?.vcenterHost,+ row.resource.vmware?.datacenterName,+ row.resource.vmware?.clusterName,+ row.resource.vmware?.runtimeHostName,+ row.resource.vmware?.activeAlarmSummary,+ ...(row.resource.tags ?? []),+ ]+ .filter((value): value is string => typeof value === 'string' && value.trim().length > 0)+ .join(' ')+ .toLowerCase();++export function filterVmwareIncidents(+ incidents: VmwareIncidentRow[],+ search: string,+ severity: VmwareIncidentSeverityFilter,+): VmwareIncidentRow[] {+ const needle = normalize(search);+ return incidents.filter((incident) => {+ if (severity !== 'all' && incident.severityBucket !== severity) return false;+ if (!needle) return true;+ return incidentSearchHaystack(incident).includes(needle);+ });+}