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
import { Component, For, Show, createMemo } from 'solid-js';
import {
buildSummaryDisclosureControlsId,
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
import { resolvePhysicalDiskMetricResourceId } from '@/features/storageBackups/storageMetricsIdentity';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/shared/Table';
import { formatBytes } from '@/utils/format';
import { getTemperatureTextClass } from '@/utils/temperature';
import {
PHYSICAL_DISK_CELL_DEVICE_CLASS,
PHYSICAL_DISK_CELL_DISK_CLASS,
PHYSICAL_DISK_CELL_HEALTH_CLASS,
PHYSICAL_DISK_CELL_HOST_CLASS,
PHYSICAL_DISK_CELL_LIFE_CLASS,
PHYSICAL_DISK_CELL_PARENT_CLASS,
PHYSICAL_DISK_CELL_ROLE_CLASS,
PHYSICAL_DISK_CELL_SIZE_CLASS,
PHYSICAL_DISK_CELL_TEMP_CLASS,
PHYSICAL_DISK_COL_DEVICE_CLASS,
PHYSICAL_DISK_COL_DISK_CLASS,
PHYSICAL_DISK_COL_HEALTH_CLASS,
PHYSICAL_DISK_COL_HOST_CLASS,
PHYSICAL_DISK_COL_LIFE_CLASS,
PHYSICAL_DISK_COL_PARENT_CLASS,
PHYSICAL_DISK_COL_ROLE_CLASS,
PHYSICAL_DISK_COL_SIZE_CLASS,
PHYSICAL_DISK_COL_TEMP_CLASS,
PHYSICAL_DISK_EMPTY_CARD_CLASS,
PHYSICAL_DISK_EMPTY_FALLBACK_CLASS,
PHYSICAL_DISK_EMPTY_FALLBACK_TEXT_CLASS,
PHYSICAL_DISK_EMPTY_MESSAGE_CLASS,
PHYSICAL_DISK_EMPTY_REQUIREMENTS_CLASS,
PHYSICAL_DISK_EMPTY_REQUIREMENTS_LIST_CLASS,
PHYSICAL_DISK_EMPTY_REQUIREMENTS_NOTE_CLASS,
PHYSICAL_DISK_EMPTY_REQUIREMENTS_TITLE_CLASS,
PHYSICAL_DISK_EMPTY_TITLE_CLASS,
PHYSICAL_DISK_HEADER_DEVICE_CLASS,
PHYSICAL_DISK_HEADER_DISK_CLASS,
PHYSICAL_DISK_HEADER_HEALTH_CLASS,
PHYSICAL_DISK_HEADER_HOST_CLASS,
PHYSICAL_DISK_HEADER_LIFE_CLASS,
PHYSICAL_DISK_HEADER_PARENT_CLASS,
PHYSICAL_DISK_HEADER_ROLE_CLASS,
PHYSICAL_DISK_HEADER_SIZE_CLASS,
PHYSICAL_DISK_HEADER_TEMP_CLASS,
PHYSICAL_DISK_HEALTH_LABEL_CLASS,
PHYSICAL_DISK_HEALTH_WRAP_CLASS,
PHYSICAL_DISK_DEVICE_TEXT_CLASS,
PHYSICAL_DISK_LIFE_CLASS,
PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS,
PHYSICAL_DISK_NAME_TEXT_CLASS,
PHYSICAL_DISK_NAME_WRAP_CLASS,
PHYSICAL_DISK_SIZE_VALUE_CLASS,
PHYSICAL_DISK_TEMPERATURE_CLASS,
PHYSICAL_DISK_TEMPERATURE_LAST_KNOWN_CLASS,
PHYSICAL_DISK_VALUE_TEXT_CLASS,
PHYSICAL_DISK_TABLE_BODY_CLASS,
PHYSICAL_DISK_TABLE_CLASS,
PHYSICAL_DISK_TABLE_HEADER_ROW_CLASS,
PHYSICAL_DISK_TABLE_ROW_CLASS,
PHYSICAL_DISK_TABLE_ROW_HOVER_CLASS,
PHYSICAL_DISK_TABLE_ROW_SELECTED_CLASS,
PHYSICAL_DISK_TABLE_ROW_STYLE,
getPhysicalDiskCellPaddingClass,
getPhysicalDiskColumnWidthStyle,
getPhysicalDiskEmptyStatePresentation,
getPhysicalDiskHealthCompactLabel,
getPhysicalDiskHealthStatus,
getPhysicalDiskTemperatureThresholds,
getPhysicalDiskHealthSummary,
getPhysicalDiskHostLabel,
getPhysicalDiskLifeLabel,
getPhysicalDiskLifeTextClass,
getPhysicalDiskParentLabel,
getPhysicalDiskRoleLabel,
getPhysicalDiskTableLayoutModeForContainer,
getPhysicalDiskTemperaturePresentation,
isPhysicalDiskColumnVisible,
type PhysicalDiskAlertResourceIdResolver,
type PhysicalDiskTableColumnId,
} from '@/features/storageBackups/diskPresentation';
import { useObservedElementWidth } from '@/hooks/useObservedElementWidth';
import { PlatformWindowedRows } from '@/features/platformPage/sharedPlatformPage';
import type { Alert } from '@/types/api';
import type { Resource } from '@/types/resource';
import type { StorageHealthFilter } from '@/features/storageBackups/models';
import { getStorageSourceOption } from '@/utils/storageSources';
import { DiskDrawer } from './DiskDrawer';
import { useDiskListModel } from './useDiskListModel';
interface DiskListProps {
disks: Resource[];
/** Alert override keys of the machine reporting each disk; absent means none. */
getDiskAlertResourceIds?: PhysicalDiskAlertResourceIdResolver;
/** A disk's own open alerts, for its drawer. */
getDiskAlerts?: (disk: Resource) => Alert[];
nodes: Resource[];
selectedNode: string | null;
sourceFilter?: string;
healthFilter?: StorageHealthFilter;
roleFilter?: string;
groupFilter?: string;
searchTerm: string;
selectedDiskId: string | null;
highlightedSummarySeriesId?: string | null;
onSelectedDiskChange: (diskId: string | null) => void;
onHoverChange?: (diskId: string | null) => void;
}
// The disk table's columns: the colgroup below declares one <col> for each.
const PHYSICAL_DISK_TABLE_COLUMN_COUNT = 9;
export const DiskList: Component<DiskListProps> = (props) => {
const tableWidth = useObservedElementWidth();
const layoutMode = createMemo(() =>
getPhysicalDiskTableLayoutModeForContainer(tableWidth.width() ?? 0),
);
const columnClass = (
baseClass: string,
columnId: PhysicalDiskTableColumnId,
visibleClass: 'table-column' | 'table-cell',
) => {
const visibility = isPhysicalDiskColumnVisible(layoutMode(), columnId)
? visibleClass
: 'hidden';
// Rendered cells and headers shed the shared primitives' desktop padding
// on the phone layouts; `<col>` elements carry no padding.
const padding =
visibleClass === 'table-cell' ? getPhysicalDiskCellPaddingClass(layoutMode()) : '';
return `${baseClass} ${padding} ${visibility}`.replace(/\s+/g, ' ').trim();
};
const columnStyle = (columnId: PhysicalDiskTableColumnId) =>
getPhysicalDiskColumnWidthStyle(layoutMode(), columnId);
const model = useDiskListModel({
disks: () => props.disks,
getDiskAlertResourceIds: (disk) => props.getDiskAlertResourceIds?.(disk) ?? [],
nodes: () => props.nodes,
selectedNode: () => props.selectedNode,
sourceFilter: () => props.sourceFilter ?? 'all',
healthFilter: () => props.healthFilter ?? 'all',
roleFilter: () => props.roleFilter ?? 'all',
groupFilter: () => props.groupFilter ?? 'all',
searchTerm: () => props.searchTerm,
selectedDiskId: () => props.selectedDiskId,
setSelectedDiskId: props.onSelectedDiskChange,
});
const emptyState = () =>
getPhysicalDiskEmptyStatePresentation({
selectedNodeName: model.selectedNodeName(),
searchTerm: props.searchTerm,
diskCount: (props.disks || []).length,
hasPVENodes: model.hasPVENodes(),
healthFilter: props.healthFilter ?? 'all',
sourceFilterLabel:
props.sourceFilter && props.sourceFilter !== 'all'
? getStorageSourceOption(props.sourceFilter).label
: null,
roleFilterLabel:
props.roleFilter && props.roleFilter !== 'all'
? (model.roleFilterOptions().find((option) => option.value === props.roleFilter)?.label ??
null)
: null,
groupFilterLabel:
props.groupFilter && props.groupFilter !== 'all'
? (model.groupFilterOptions().find((option) => option.value === props.groupFilter)
?.label ?? null)
: null,
});
return (
<div>
<Show when={model.filteredDisks().length === 0}>
<div class={`p-4 sm:p-6 ${PHYSICAL_DISK_EMPTY_CARD_CLASS}`}>
<div class="">
<p class={PHYSICAL_DISK_EMPTY_TITLE_CLASS}>{emptyState().title}</p>
<Show when={emptyState().nodeMessage}>
{(message) => <p class={PHYSICAL_DISK_EMPTY_MESSAGE_CLASS}>{message()}</p>}
</Show>
<Show when={emptyState().searchMessage}>
{(message) => <p class={PHYSICAL_DISK_EMPTY_MESSAGE_CLASS}>{message()}</p>}
</Show>
<For each={emptyState().filterMessages}>
{(message) => <p class={PHYSICAL_DISK_EMPTY_MESSAGE_CLASS}>{message}</p>}
</For>
</div>
<Show when={!props.searchTerm && (props.disks || []).length === 0}>
<Show
when={emptyState().showRequirements}
fallback={
<div class={PHYSICAL_DISK_EMPTY_FALLBACK_CLASS}>
<p class={PHYSICAL_DISK_EMPTY_FALLBACK_TEXT_CLASS}>
{emptyState().fallbackMessage}
</p>
</div>
}
>
<div class={PHYSICAL_DISK_EMPTY_REQUIREMENTS_CLASS}>
<p class={PHYSICAL_DISK_EMPTY_REQUIREMENTS_TITLE_CLASS}>
{emptyState().requirementsTitle}
</p>
<ol class={PHYSICAL_DISK_EMPTY_REQUIREMENTS_LIST_CLASS}>
<For each={emptyState().requirementsItems}>{(item) => <li>{item}</li>}</For>
</ol>
<p class={PHYSICAL_DISK_EMPTY_REQUIREMENTS_NOTE_CLASS}>
{emptyState().requirementsNote}
</p>
</div>
</Show>
</Show>
</div>
</Show>
<Show when={model.filteredDisks().length > 0}>
<Table
class={PHYSICAL_DISK_TABLE_CLASS}
wrapperRef={tableWidth.setElement}
data-storage-table="physical-disks"
data-storage-layout={layoutMode()}
>
<colgroup>
<col
class={columnClass(PHYSICAL_DISK_COL_DISK_CLASS, 'disk', 'table-column')}
style={columnStyle('disk')}
data-storage-column="disk"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_DEVICE_CLASS, 'device', 'table-column')}
style={columnStyle('device')}
data-storage-column="device"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_HOST_CLASS, 'host', 'table-column')}
style={columnStyle('host')}
data-storage-column="host"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_ROLE_CLASS, 'role', 'table-column')}
style={columnStyle('role')}
data-storage-column="role"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_PARENT_CLASS, 'parent', 'table-column')}
style={columnStyle('parent')}
data-storage-column="parent"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_HEALTH_CLASS, 'health', 'table-column')}
style={columnStyle('health')}
data-storage-column="health"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_LIFE_CLASS, 'life', 'table-column')}
style={columnStyle('life')}
data-storage-column="life"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_TEMP_CLASS, 'temp', 'table-column')}
style={columnStyle('temp')}
data-storage-column="temp"
/>
<col
class={columnClass(PHYSICAL_DISK_COL_SIZE_CLASS, 'size', 'table-column')}
style={columnStyle('size')}
data-storage-column="size"
/>
</colgroup>
<TableHeader>
<TableRow class={PHYSICAL_DISK_TABLE_HEADER_ROW_CLASS}>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_DISK_CLASS, 'disk', 'table-cell')}
data-storage-column="disk"
>
Disk
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_DEVICE_CLASS, 'device', 'table-cell')}
data-storage-column="device"
>
Device
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_HOST_CLASS, 'host', 'table-cell')}
data-storage-column="host"
>
Host
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_ROLE_CLASS, 'role', 'table-cell')}
data-storage-column="role"
>
Role
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_PARENT_CLASS, 'parent', 'table-cell')}
data-storage-column="parent"
aria-label="Belongs To"
title="Belongs To"
>
Belongs
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_HEALTH_CLASS, 'health', 'table-cell')}
data-storage-column="health"
>
Health
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_LIFE_CLASS, 'life', 'table-cell')}
data-storage-column="life"
aria-label="SSD life remaining"
title="SSD life remaining"
>
Life
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_TEMP_CLASS, 'temp', 'table-cell')}
data-storage-column="temp"
>
Temp
</TableHead>
<TableHead
class={columnClass(PHYSICAL_DISK_HEADER_SIZE_CLASS, 'size', 'table-cell')}
data-storage-column="size"
>
Size
</TableHead>
</TableRow>
</TableHeader>
<TableBody class={PHYSICAL_DISK_TABLE_BODY_CLASS}>
<PlatformWindowedRows items={model.filteredDisks} estimatedRowHeight={32}>
{(disk) => {
// Windowed rows retain their owner by resource ID across live
// snapshots. Derive the presentation reactively, not just when
// the row first mounts, so health and identity cannot go stale.
const data = createMemo(() => model.getDiskData(disk));
const status = createMemo(() => getPhysicalDiskHealthStatus(data()));
const hostLabel = createMemo(() => getPhysicalDiskHostLabel(data(), disk));
const healthSummary = createMemo(() => getPhysicalDiskHealthSummary(status()));
const temperature = createMemo(() =>
getPhysicalDiskTemperaturePresentation(data()),
);
const healthCompactLabel = createMemo(() =>
getPhysicalDiskHealthCompactLabel(status().label),
);
const healthLabelClass = () =>
`${PHYSICAL_DISK_HEALTH_LABEL_CLASS} ${status().tone}`;
const isSelected = () => model.selectedDisk()?.id === disk.id;
const summarySeriesId = createMemo(() => resolvePhysicalDiskMetricResourceId(disk));
const isSummaryHighlighted = () =>
props.highlightedSummarySeriesId === summarySeriesId();
const detailControlsId = createMemo(() =>
buildSummaryDisclosureControlsId(summarySeriesId()),
);
const interactiveRowHandlers = createSummaryInteractiveRowPreviewHandlers({
onPreview: () => props.onHoverChange?.(disk.id),
onPreviewClear: () => props.onHoverChange?.(null),
});
return (
<>
<TableRow
data-row-id={disk.id}
data-summary-series-id={summarySeriesId()}
data-summary-row-active={
isSummaryHighlighted() && !isSelected() ? 'true' : 'false'
}
class={`${PHYSICAL_DISK_TABLE_ROW_CLASS} ${
isSelected()
? PHYSICAL_DISK_TABLE_ROW_SELECTED_CLASS
: PHYSICAL_DISK_TABLE_ROW_HOVER_CLASS
}`.trim()}
style={PHYSICAL_DISK_TABLE_ROW_STYLE}
onClick={() => model.toggleSelectedDisk(disk)}
{...interactiveRowHandlers}
>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_DISK_CLASS, 'disk', 'table-cell')}
data-storage-column="disk"
>
<div class={PHYSICAL_DISK_NAME_WRAP_CLASS}>
<SummaryRowActionButton
kind="disclosure"
subjectLabel={data().model || 'disk'}
expanded={isSelected()}
controlsId={detailControlsId()}
hideWhenRowTappableOnMobile
onAction={() => model.toggleSelectedDisk(disk)}
onPreviewClear={() => props.onHoverChange?.(null)}
/>
<span
class={PHYSICAL_DISK_NAME_TEXT_CLASS}
title={data().devPath || data().model || disk.name || 'Unknown Disk'}
>
{data().model || 'Unknown Disk'}
</span>
</div>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_DEVICE_CLASS, 'device', 'table-cell')}
data-storage-column="device"
>
<Show
when={data().devPath}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span class={PHYSICAL_DISK_DEVICE_TEXT_CLASS} title={data().devPath}>
{data().devPath}
</span>
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_HOST_CLASS, 'host', 'table-cell')}
data-storage-column="host"
>
<Show
when={hostLabel()}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span class={PHYSICAL_DISK_VALUE_TEXT_CLASS} title={hostLabel()}>
{hostLabel()}
</span>
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_ROLE_CLASS, 'role', 'table-cell')}
data-storage-column="role"
>
<Show
when={getPhysicalDiskRoleLabel(data())}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span
class={PHYSICAL_DISK_VALUE_TEXT_CLASS}
title={getPhysicalDiskRoleLabel(data())}
>
{getPhysicalDiskRoleLabel(data())}
</span>
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_PARENT_CLASS, 'parent', 'table-cell')}
data-storage-column="parent"
>
<Show
when={getPhysicalDiskParentLabel(data())}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span
class={PHYSICAL_DISK_VALUE_TEXT_CLASS}
title={getPhysicalDiskParentLabel(data())}
>
{getPhysicalDiskParentLabel(data())}
</span>
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_HEALTH_CLASS, 'health', 'table-cell')}
data-storage-column="health"
>
<div class={PHYSICAL_DISK_HEALTH_WRAP_CLASS}>
{/* The row shows the verdict word only; the reason is the
cell's title here and is spelled out in the disk drawer.
The phone projection of the table container shows the
shorter word; the tone stays on each span so the rendered
label is the styled element in either projection. */}
<Show
when={healthCompactLabel() !== status().label}
fallback={
<span class={healthLabelClass()} title={healthSummary() || undefined}>
{status().label}
</span>
}
>
<span
class={`${healthLabelClass()} platform-table-label-compact`}
title={healthSummary() || undefined}
>
{healthCompactLabel()}
</span>
<span
class={`${healthLabelClass()} platform-table-label-full`}
title={healthSummary() || undefined}
>
{status().label}
</span>
</Show>
</div>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_LIFE_CLASS, 'life', 'table-cell')}
data-storage-column="life"
>
<Show
when={getPhysicalDiskLifeLabel(data())}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
<span
class={`${PHYSICAL_DISK_LIFE_CLASS} ${getPhysicalDiskLifeTextClass(data())}`}
>
{getPhysicalDiskLifeLabel(data())}
</span>
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_TEMP_CLASS, 'temp', 'table-cell')}
data-storage-column="temp"
>
<Show
when={temperature()}
fallback={<span class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}>—</span>}
>
{(reading) => (
<span
class={`${PHYSICAL_DISK_TEMPERATURE_CLASS} ${
reading().current
? getTemperatureTextClass(
data().temperature,
getPhysicalDiskTemperatureThresholds(data()),
'diskTemperature',
)
: PHYSICAL_DISK_TEMPERATURE_LAST_KNOWN_CLASS
}`}
title={reading().title}
data-temperature-reading={
reading().current ? 'current' : 'last-known'
}
>
{reading().label}
<Show when={!reading().current}>
<span class="sr-only">, last known</span>
</Show>
</span>
)}
</Show>
</TableCell>
<TableCell
class={columnClass(PHYSICAL_DISK_CELL_SIZE_CLASS, 'size', 'table-cell')}
data-storage-column="size"
>
<Show
when={data().size > 0}
fallback={
<span
class={PHYSICAL_DISK_MUTED_PLACEHOLDER_CLASS}
title="Disk size not reported by SMART/agent"
>
—
</span>
}
>
<span class={PHYSICAL_DISK_SIZE_VALUE_CLASS}>
{formatBytes(data().size)}
</span>
</Show>
</TableCell>
</TableRow>
<Show when={isSelected()}>
<InlineDetailTableRow
cellId={detailControlsId()}
colspan={PHYSICAL_DISK_TABLE_COLUMN_COUNT}
data-inline-detail-for={summarySeriesId()}
>
<DiskDrawer
disk={disk}
alertResourceIds={props.getDiskAlertResourceIds?.(disk)}
alerts={props.getDiskAlerts?.(disk)}
onClose={() => model.toggleSelectedDisk(disk)}
/>
</InlineDetailTableRow>
</Show>
</>
);
}}
</PlatformWindowedRows>
</TableBody>
</Table>
</Show>
</div>
);
};