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 { For, Show, createMemo, type Component } from 'solid-js';
import AlertTriangle from 'lucide-solid/icons/alert-triangle';
import Cloud from 'lucide-solid/icons/cloud';
import EyeOff from 'lucide-solid/icons/eye-off';
import Info from 'lucide-solid/icons/info';
import Lock from 'lucide-solid/icons/lock';
import RefreshCw from 'lucide-solid/icons/refresh-cw';
import ShieldCheck from 'lucide-solid/icons/shield-check';
import { useResourceStats } from '@/hooks/useResourceStats';
import { Button, ButtonLink } from '@/components/shared/Button';
import SettingsPanel from '@/components/shared/SettingsPanel';
import {
SettingsLoadingSkeleton,
SettingsSkeletonBlock,
SettingsSkeletonCard,
} from '@/components/shared/SettingsLoadingSkeleton';
import { settingsTabPath } from './settingsNavigationModel';
import {
buildDataHandlingPanelModel,
type DataHandlingPostureItem,
} from './dataHandlingPanelModel';
const meterClassByTone: Record<DataHandlingPostureItem['tone'], string> = {
neutral: 'bg-slate-400',
info: 'bg-sky-500 dark:bg-sky-400',
success: 'bg-emerald-500 dark:bg-emerald-400',
warning: 'bg-amber-500 dark:bg-amber-400',
danger: 'bg-rose-500 dark:bg-rose-400',
};
const badgeClassByTone: Record<DataHandlingPostureItem['tone'], string> = {
neutral: 'border border-border bg-surface text-muted',
info: 'bg-sky-100 text-sky-700 dark:bg-sky-900/25 dark:text-sky-200',
success: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/25 dark:text-emerald-200',
warning: 'bg-amber-100 text-amber-700 dark:bg-amber-900/25 dark:text-amber-200',
danger: 'bg-rose-100 text-rose-700 dark:bg-rose-900/25 dark:text-rose-200',
};
const formatCount = (value: number): string => new Intl.NumberFormat().format(value);
const policyScopeItems = [
{
label: 'Resource classification',
description:
'Groups monitored resources by sensitivity so restricted infrastructure is not treated like routine inventory.',
},
{
label: 'AI context boundary',
description:
'Shows which resource details can be summarized externally, should prefer local handling, or must stay local.',
},
{
label: 'Identifier redaction',
description:
'Counts hostnames, IP addresses, platform IDs, aliases, and paths marked for removal from guarded views.',
},
] as const;
const errorMessageFor = (error: unknown): string => {
if (error instanceof Error && error.message.trim()) {
return error.message;
}
return 'Unable to load resource policy posture.';
};
const PolicyScopeSummary: Component = () => (
<section class="rounded-md border border-sky-200 bg-sky-50 px-4 py-4 dark:border-sky-900/25 dark:bg-sky-950/40">
<div class="flex items-start gap-3">
<Info class="mt-0.5 h-4 w-4 shrink-0 text-sky-700 dark:text-sky-300" aria-hidden="true" />
<div class="min-w-0">
<h3 class="text-sm font-semibold text-base-content">Read-only resource privacy posture</h3>
<p class="mt-1 text-sm text-muted">
Pulse derives this from the unified resource registry. It does not configure retention,
backups, credentials, or billing data.
</p>
</div>
</div>
<div class="mt-4 grid gap-3 lg:grid-cols-3">
<For each={policyScopeItems}>
{(item) => (
<div class="rounded-md border border-border bg-surface px-3 py-3">
<p class="text-xs font-semibold uppercase tracking-wide text-base-content">
{item.label}
</p>
<p class="mt-1 text-sm text-muted">{item.description}</p>
</div>
)}
</For>
</div>
</section>
);
const EmptyPolicyPostureState: Component = () => (
<section class="rounded-md border border-border bg-surface-alt px-4 py-5">
<div class="flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between">
<div class="max-w-3xl">
<p class="text-sm font-semibold text-base-content">No monitored resources to classify</p>
<p class="mt-2 text-sm text-muted">
Pulse has not received canonical resource data for this scope yet. Once infrastructure
discovery has resources, this page will show which resource details stay local, which can
be summarized, and which identifiers are redacted.
</p>
<p class="mt-2 text-sm text-muted">
This is expected on a fresh instance, before discovery finishes, or when the selected
organization does not have visible monitored resources.
</p>
</div>
<ButtonLink
href={settingsTabPath('infrastructure-systems')}
variant="secondary"
size="mdCompact"
class="w-fit"
>
Open Infrastructure
</ButtonLink>
</div>
</section>
);
const PostureMeter: Component<{ item: DataHandlingPostureItem }> = (props) => (
<div class="rounded-md border border-border bg-surface-alt px-4 py-3">
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<p class="text-sm font-semibold text-base-content">{props.item.label}</p>
<p class="mt-1 text-xs text-muted">{props.item.description}</p>
</div>
<span
class={`shrink-0 rounded-sm px-2 py-0.5 text-xs font-semibold ${badgeClassByTone[props.item.tone]}`}
>
{formatCount(props.item.count)}
</span>
</div>
<div
class="mt-3 h-2 overflow-hidden rounded-sm bg-surface-hover"
aria-label={`${props.item.label} ${props.item.percentage}%`}
>
<div
class={`h-full rounded-sm ${meterClassByTone[props.item.tone]}`}
style={{ width: `${props.item.percentage}%` }}
/>
</div>
</div>
);
export const DataHandlingPanel: Component = () => {
const resources = useResourceStats();
const model = createMemo(() => buildDataHandlingPanelModel(resources.policyPosture()));
const errorMessage = createMemo(() => {
const error = resources.error();
return error ? errorMessageFor(error) : '';
});
return (
<SettingsPanel
title="Resource Data Policy"
description="Review the current privacy boundary for monitored resource data."
bodyClass="space-y-5"
action={
<Button
type="button"
variant="outline"
size="sm"
class="min-h-11 sm:min-h-0"
isLoading={resources.loading()}
onClick={() => {
void resources.refetch();
}}
>
<RefreshCw class="mr-2 h-4 w-4" aria-hidden="true" />
Refresh
</Button>
}
>
<Show when={errorMessage()}>
{(message) => (
<div
role="alert"
aria-live="polite"
class="rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-900/25 dark:text-amber-100"
>
<div class="flex items-start gap-3">
<AlertTriangle class="mt-0.5 h-4 w-4 shrink-0" aria-hidden="true" />
<p>{message()}</p>
</div>
</div>
)}
</Show>
<Show
when={!resources.loading() || resources.policyPosture()}
fallback={
<SettingsLoadingSkeleton label="Loading resource data policy">
<div class="grid gap-3 md:grid-cols-3">
<For each={[1, 2, 3]}>
{() => (
<SettingsSkeletonCard class="min-h-28 bg-surface-alt p-4 space-y-0">
<SettingsSkeletonBlock class="h-4 w-24" />
<SettingsSkeletonBlock class="mt-4 h-8 w-16" />
<SettingsSkeletonBlock class="mt-3 h-3 w-32" />
</SettingsSkeletonCard>
)}
</For>
</div>
</SettingsLoadingSkeleton>
}
>
<PolicyScopeSummary />
<Show when={model().hasResources} fallback={<EmptyPolicyPostureState />}>
<div class="grid gap-3 md:grid-cols-3">
<div class="rounded-md border border-border bg-surface-alt p-4">
<div class="flex items-center gap-2 text-sm font-semibold text-base-content">
<ShieldCheck class="h-4 w-4 text-emerald-600 dark:text-emerald-300" />
Governed Resources
</div>
<p class="mt-3 text-3xl font-semibold text-base-content">
{formatCount(model().totalResources)}
</p>
<p class="mt-1 text-xs text-muted">Resources carrying policy metadata.</p>
</div>
<div class="rounded-md border border-border bg-surface-alt p-4">
<div class="flex items-center gap-2 text-sm font-semibold text-base-content">
<Lock class="h-4 w-4 text-teal-600 dark:text-teal-300" />
Local-Only
</div>
<p class="mt-3 text-3xl font-semibold text-base-content">
{formatCount(model().localOnlyResources)}
</p>
<p class="mt-1 text-xs text-muted">Resources kept inside this Pulse instance.</p>
</div>
<div class="rounded-md border border-border bg-surface-alt p-4">
<div class="flex items-center gap-2 text-sm font-semibold text-base-content">
<EyeOff class="h-4 w-4 text-muted" />
Redaction Hints
</div>
<p class="mt-3 text-3xl font-semibold text-base-content">
{formatCount(model().redactionHintCount)}
</p>
<p class="mt-1 text-xs text-muted">Field-level protections applied by policy.</p>
</div>
</div>
<div class="grid gap-4 xl:grid-cols-2">
<section class="space-y-3">
<div>
<h3 class="text-sm font-semibold text-base-content">Sensitivity</h3>
<p class="mt-1 text-xs text-muted">
Classification applied to monitored resources.
</p>
</div>
<div class="space-y-2">
<For each={model().sensitivityItems}>{(item) => <PostureMeter item={item} />}</For>
</div>
</section>
<section class="space-y-3">
<div class="flex items-start gap-2">
<Cloud class="mt-0.5 h-4 w-4 text-sky-600 dark:text-sky-300" />
<div>
<h3 class="text-sm font-semibold text-base-content">Handling Boundary</h3>
<p class="mt-1 text-xs text-muted">
Routing policy for summaries and local-only resource data.
</p>
</div>
</div>
<div class="space-y-2">
<For each={model().routingItems}>{(item) => <PostureMeter item={item} />}</For>
</div>
</section>
</div>
<section class="rounded-md border border-border bg-surface-alt px-4 py-4">
<div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
<div>
<h3 class="text-sm font-semibold text-base-content">Redaction Coverage</h3>
<p class="mt-1 text-xs text-muted">
Fields removed when a resource requires a guarded display.
</p>
</div>
<Show when={!model().hasRedactions}>
<span class="w-fit rounded-sm bg-surface px-2 py-1 text-xs font-medium text-muted">
No active redaction hints
</span>
</Show>
</div>
<Show when={model().hasRedactions}>
<div class="mt-4 flex flex-wrap gap-2">
<For each={model().redactionItems}>
{(item) => (
<span
class={`inline-flex items-center gap-1.5 rounded-sm px-2.5 py-1 text-xs font-medium ${badgeClassByTone[item.tone]}`}
title={item.description}
>
{item.label}
<span class="font-semibold">{formatCount(item.count)}</span>
</span>
)}
</For>
</div>
</Show>
</section>
</Show>
</Show>
</SettingsPanel>
);
};
export default DataHandlingPanel;