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 { Show, createMemo, createSignal, type Component } from 'solid-js';
import ExternalLinkIcon from 'lucide-solid/icons/external-link';
import type { HistoryTimeRange } from '@/api/charts';
import { getDrawerHeaderActionButtonClass } from '@/components/shared/buttonModel';
import { DrawerSubjectHeading } from '@/components/shared/DrawerSubjectHeading';
import { ObjectDrawerHeader } from '@/components/shared/ObjectDrawerHeader';
import { Subtabs } from '@/components/shared/Subtabs';
import { WebInterfaceLink } from '@/components/shared/WebInterfaceLink';
import { getSimpleStatusIndicator } from '@/utils/status';
import { GUEST_DRAWER_HISTORY_DEFAULT_RANGE } from '@/components/Workloads/guestDrawerModel';
import { ResourceOperatorStateSection } from '@/components/Infrastructure/ResourceOperatorStateSection';
import { WebInterfaceUrlField } from '@/components/shared/WebInterfaceUrlField';
import type { Resource } from '@/types/resource';
import { asTrimmedString } from '@/utils/stringUtils';
import { DockerHostActionHistory } from './DockerHostActionHistory';
import { DockerHostDrawerManagement, DockerHostDrawerOverview } from './DockerHostDrawerOverview';
import {
DOCKER_HOST_DRAWER_HISTORY_GROUPS,
getDockerHostDrawerCurrentMetrics,
getDockerHostDrawerHistoryTarget,
} from './dockerHostDrawerModel';
interface DockerHostDrawerProps {
host: Resource;
customUrl?: string;
onCustomUrlChange?: (url: string) => void;
onClose?: () => void;
}
type DockerHostDrawerTab = 'overview' | 'manage';
export const DockerHostDrawer: Component<DockerHostDrawerProps> = (props) => {
const [activeTab, setActiveTab] = createSignal<DockerHostDrawerTab>('overview');
const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>(
GUEST_DRAWER_HISTORY_DEFAULT_RANGE,
);
const headingId = () => `docker-host-drawer-heading-${props.host.id}`;
const displayName = createMemo(() => asTrimmedString(props.host.name) || props.host.id);
const historyTarget = createMemo(() => getDockerHostDrawerHistoryTarget(props.host));
const currentMetrics = createMemo(() => getDockerHostDrawerCurrentMetrics(props.host));
const headerIndicator = createMemo(() => getSimpleStatusIndicator(props.host.status));
const metadataId = createMemo(
() => asTrimmedString(props.host.docker?.hostSourceId) || asTrimmedString(props.host.id),
);
const customUrl = () => props.customUrl ?? props.host.customUrl ?? '';
return (
<section class="space-y-3" aria-labelledby={headingId()} data-testid="docker-host-drawer">
<Show
when={props.onClose}
fallback={
<DrawerSubjectHeading
headingId={headingId()}
title={displayName()}
statusVariant={headerIndicator().variant}
statusLabel={headerIndicator().label}
/>
}
>
{(onClose) => (
<ObjectDrawerHeader
collapseLabel={`Collapse ${displayName()} details`}
onCollapse={onClose()}
actions={
<Show when={customUrl().trim()}>
<WebInterfaceLink
url={customUrl()}
ariaLabel={`Open web interface for ${displayName()}`}
class={getDrawerHeaderActionButtonClass()}
>
<ExternalLinkIcon class="h-3.5 w-3.5" aria-hidden="true" />
<span>Open</span>
</WebInterfaceLink>
</Show>
}
>
<DrawerSubjectHeading
headingId={headingId()}
title={displayName()}
statusVariant={headerIndicator().variant}
statusLabel={headerIndicator().label}
/>
</ObjectDrawerHeader>
)}
</Show>
<Subtabs
class="mb-1"
ariaLabel="Docker host drawer sections"
value={activeTab()}
onChange={(value) => setActiveTab(value as DockerHostDrawerTab)}
tabs={[
{ value: 'overview', label: 'Overview' },
{ value: 'manage', label: 'Manage' },
]}
/>
{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.
overflow-anchor: none prevents browser scroll anchoring from jumping when display toggles. */}
<div class={`[overflow-anchor:none] ${activeTab() === 'overview' ? '' : 'hidden'}`}>
<DockerHostDrawerOverview
host={props.host}
historyTarget={historyTarget()}
historyRange={historyRange()}
onHistoryRangeChange={setHistoryRange}
historyGroups={DOCKER_HOST_DRAWER_HISTORY_GROUPS}
currentMetrics={currentMetrics()}
historyEnabled={activeTab() === 'overview'}
/>
</div>
<div class={`[overflow-anchor:none] ${activeTab() === 'manage' ? '' : 'hidden'}`}>
<Show when={activeTab() === 'manage'}>
{/* The guest drawer's Manage order: operator state first, then this
platform's own controls, the web interface URL and action history. */}
<div class="space-y-3" data-testid="docker-host-manage-tab">
<ResourceOperatorStateSection
resourceId={props.host.id}
resourceType="docker-host"
platformType={props.host.platformType || 'docker'}
capabilities={props.host.capabilities}
/>
<DockerHostDrawerManagement host={props.host} />
<WebInterfaceUrlField
metadataKind="docker-host"
metadataId={metadataId()}
targetLabel={displayName()}
customUrl={customUrl()}
onCustomUrlChange={props.onCustomUrlChange}
/>
<DockerHostActionHistory resourceId={props.host.id} />
</div>
</Show>
</div>
</section>
);
};
export default DockerHostDrawer;