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, Show, createMemo } from 'solid-js';
import type { StorageRecord } from '@/features/storageBackups/models';
import { getStoragePoolProtectionTextClass } from '@/features/storageBackups/rowPresentation';
import {
buildStoragePoolRowModel,
STORAGE_POOL_ROW_GROWTH_CELL_CLASS,
STORAGE_POOL_ROW_GROWTH_TEXT_CLASS,
STORAGE_POOL_ROW_CLASS,
STORAGE_POOL_ROW_EXPANDED_CLASS,
STORAGE_POOL_ROW_HEIGHT_CLASS,
STORAGE_POOL_ROW_PLACEHOLDER_CLASS,
STORAGE_POOL_ROW_HOST_CELL_CLASS,
STORAGE_POOL_ROW_ISSUE_CELL_CLASS,
STORAGE_POOL_ROW_ISSUE_TEXT_CLASS,
STORAGE_POOL_ROW_NAME_CELL_CLASS,
STORAGE_POOL_ROW_NAME_TEXT_CLASS,
STORAGE_POOL_ROW_PROTECTION_CELL_CLASS,
STORAGE_POOL_ROW_PROTECTION_TEXT_CLASS,
STORAGE_POOL_ROW_TEXT_TRUNCATE_CLASS,
STORAGE_POOL_ROW_TYPE_CELL_CLASS,
STORAGE_POOL_ROW_USAGE_FALLBACK_CLASS,
STORAGE_POOL_ROW_USAGE_BAR_WRAP_CLASS,
STORAGE_POOL_ROW_USAGE_CELL_CLASS,
STORAGE_POOL_ROW_USAGE_WRAP_CLASS,
} from '@/features/storageBackups/storagePoolRowPresentation';
import type { StorageCapacityDeltaPresentation } from '@/features/storageBackups/storageCapacityDeltaPresentation';
import type { PhysicalDiskAlertResourceIdResolver } from '@/features/storageBackups/diskPresentation';
import type { Resource } from '@/types/resource';
import {
getStoragePoolCellPaddingClass,
getStoragePoolTableColumns,
isStoragePoolColumnVisible,
type StoragePoolTableColumnId,
type StoragePoolTableLayoutMode,
} from '@/features/storageBackups/storagePagePresentation';
import { getPlatformTableCellClassForKind } from '@/features/platformPage/sharedPlatformPage';
import { EnhancedStorageBar } from './EnhancedStorageBar';
import { StoragePoolDrawer } from './StoragePoolDrawer';
import {
buildSummaryDisclosureControlsId,
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';
import { createRowTextSelectionGuard } from '@/components/shared/Table';
import type { Alert } from '@/types/api';
interface StoragePoolRowProps {
layoutMode: StoragePoolTableLayoutMode;
record: StorageRecord;
growthDelta?: StorageCapacityDeltaPresentation | null;
summarySeriesId: string;
expanded: boolean;
summaryHighlighted?: boolean;
onToggleExpand: () => void;
onHoverChange?: (recordId: string | null) => void;
rowClass: string;
alertHeadline?: string | null;
alertHeadlineCompact?: string | null;
alertHeadlineClass?: string;
physicalDisks: Resource[];
getDiskAlertResourceIds?: PhysicalDiskAlertResourceIdResolver;
/** The pool's open alerts, for its drawer; the same set its row is tinted by. */
alerts?: Alert[];
alertDataAttrs: {
'data-row-id': string;
'data-alert-state': string;
'data-alert-severity': string;
'data-resource-highlighted': string;
};
}
export const StoragePoolRow: Component<StoragePoolRowProps> = (props) => {
const columnClass = (baseClass: string, columnId: StoragePoolTableColumnId) =>
`${baseClass} ${getStoragePoolCellPaddingClass(props.layoutMode)} ${
isStoragePoolColumnVisible(props.layoutMode, columnId) ? 'table-cell' : 'hidden'
}`
.replace(/\s+/g, ' ')
.trim();
const row = createMemo(() => buildStoragePoolRowModel(props.record, props.growthDelta ?? null));
const detailControlsId = createMemo(() =>
buildSummaryDisclosureControlsId(props.summarySeriesId),
);
const selectionGuard = createRowTextSelectionGuard();
const interactiveRowHandlers = createSummaryInteractiveRowPreviewHandlers({
onPreview: () => props.onHoverChange?.(props.summarySeriesId),
onPreviewClear: () => props.onHoverChange?.(null),
});
return (
<>
<tr
class={`${STORAGE_POOL_ROW_CLASS} ${STORAGE_POOL_ROW_HEIGHT_CLASS} ${props.rowClass} ${props.expanded ? STORAGE_POOL_ROW_EXPANDED_CLASS : ''}`.trim()}
on:mousedown={selectionGuard.onMouseDown}
onClick={(event) => {
if (!selectionGuard.isSelectionClick(event)) props.onToggleExpand();
}}
{...interactiveRowHandlers}
data-summary-series-id={props.summarySeriesId}
data-summary-row-active={props.summaryHighlighted && !props.expanded ? 'true' : 'false'}
{...props.alertDataAttrs}
>
<td
class={columnClass(
`${STORAGE_POOL_ROW_NAME_CELL_CLASS} ${getPlatformTableCellClassForKind('name')}`,
'name',
)}
data-storage-column="name"
>
<div class="flex min-w-0 items-center gap-1.5">
<SummaryRowActionButton
kind="disclosure"
subjectLabel={props.record.name}
expanded={props.expanded}
controlsId={detailControlsId()}
hideWhenRowTappableOnMobile
onAction={props.onToggleExpand}
onPreviewClear={() => props.onHoverChange?.(null)}
/>
<span class={STORAGE_POOL_ROW_NAME_TEXT_CLASS} title={props.record.name}>
{props.record.name}
</span>
</div>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_ISSUE_CELL_CLASS} ${getPlatformTableCellClassForKind('text')}`,
'state',
)}
data-storage-column="state"
>
<Show
when={props.alertHeadline}
fallback={
<Show
when={row().stateLabel !== '—'}
fallback={<span class={STORAGE_POOL_ROW_PLACEHOLDER_CLASS}>—</span>}
>
<span
class={`${STORAGE_POOL_ROW_ISSUE_TEXT_CLASS} ${row().stateToneClass}`}
title={row().stateTitle || row().stateLabel}
>
{row().stateLabel}
</span>
</Show>
}
>
{(headline) => (
<span
class={`${STORAGE_POOL_ROW_ISSUE_TEXT_CLASS} ${props.alertHeadlineClass ?? ''}`}
title={`${headline()} · ${row().stateTitle || row().stateLabel}`}
data-storage-alert-headline
>
{props.layoutMode === 'narrow' || props.layoutMode === 'compact'
? (props.alertHeadlineCompact ?? headline())
: headline()}
</span>
)}
</Show>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_TYPE_CELL_CLASS} ${getPlatformTableCellClassForKind('text')}`,
'type',
)}
data-storage-column="type"
>
<span class={STORAGE_POOL_ROW_TEXT_TRUNCATE_CLASS} title={row().topologyLabel}>
{row().topologyLabel}
</span>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_HOST_CELL_CLASS} ${getPlatformTableCellClassForKind('text')}`,
'host',
)}
data-storage-column="host"
>
<span class={STORAGE_POOL_ROW_TEXT_TRUNCATE_CLASS} title={row().hostLabel}>
{row().hostLabel}
</span>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_PROTECTION_CELL_CLASS} ${getPlatformTableCellClassForKind('badge')}`,
'protection',
)}
data-storage-column="protection"
>
<Show
when={row().compactProtection !== '—'}
fallback={<span class={STORAGE_POOL_ROW_PLACEHOLDER_CLASS}>—</span>}
>
<span
class={`${STORAGE_POOL_ROW_PROTECTION_TEXT_CLASS} ${getStoragePoolProtectionTextClass(props.record)}`}
title={row().compactProtectionTitle || row().compactProtection}
>
{row().compactProtection}
</span>
</Show>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_USAGE_CELL_CLASS} ${getPlatformTableCellClassForKind('metric-bar')}`,
'usage',
)}
data-storage-column="usage"
>
<Show
when={row().totalBytes > 0}
fallback={<span class={STORAGE_POOL_ROW_USAGE_FALLBACK_CLASS}>n/a</span>}
>
<div class={STORAGE_POOL_ROW_USAGE_WRAP_CLASS}>
<div class={STORAGE_POOL_ROW_USAGE_BAR_WRAP_CLASS}>
<EnhancedStorageBar
used={row().usedBytes}
total={Math.max(row().totalBytes, 0)}
free={Math.max(row().freeBytes, 0)}
zfsPool={row().zfsPool || undefined}
/>
</div>
</div>
</Show>
</td>
<td
class={columnClass(
`${STORAGE_POOL_ROW_GROWTH_CELL_CLASS} ${getPlatformTableCellClassForKind('numeric-value')}`,
'growth',
)}
data-storage-column="growth"
>
<span
class={`${STORAGE_POOL_ROW_GROWTH_TEXT_CLASS} ${row().capacityDeltaToneClass}`}
title={row().capacityDeltaTitle}
>
{row().capacityDeltaLabel}
</span>
</td>
</tr>
<Show when={props.expanded}>
<InlineDetailTableRow
cellId={detailControlsId()}
colspan={getStoragePoolTableColumns('').length}
data-inline-detail-for={props.summarySeriesId}
>
<StoragePoolDrawer
record={props.record}
physicalDisks={props.physicalDisks}
getDiskAlertResourceIds={props.getDiskAlertResourceIds}
alerts={props.alerts}
onClose={props.onToggleExpand}
/>
</InlineDetailTableRow>
</Show>
</>
);
};