Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

fix(frontend): preserve drawer chart range across live updates

rcourtman40a85175be27
diff --git a/frontend-modern/src/components/Dashboard/GuestDrawer.tsx b/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
index 3e82bccebc..a593194f0b 100644
--- a/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
@@ -7,488 +7,585 @@ import { ResourceType, HistoryTimeRange } from '@/api/charts';
import { hasFeature } from '@/stores/license';
import { DiscoveryTab } from '../Discovery/DiscoveryTab';
import type { ResourceType as DiscoveryResourceType } from '@/types/discovery';
+import { useDrawerHistoryRange } from '@/hooks/useDrawerHistoryRange';
type Guest = VM | Container;
interface GuestDrawerProps {
- guest: Guest;
- metricsKey: string;
- onClose: () => void;
- customUrl?: string;
- onCustomUrlChange?: (guestId: string, url: string) => void;
+ guest: Guest;
+ metricsKey: string;
+ onClose: () => void;
+ customUrl?: string;
+ onCustomUrlChange?: (guestId: string, url: string) => void;
}
export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
- const guestId = () => {
- if (props.guest.id) return props.guest.id;
- return `${props.guest.instance}:${props.guest.node}:${props.guest.vmid}`;
- };
-
- const isVM = (guest: Guest): guest is VM => {
- return guest.type === 'qemu';
- };
-
- const hasOsInfo = () => {
- // Both VMs and containers can have OS info
- return (props.guest.osName?.length ?? 0) > 0 || (props.guest.osVersion?.length ?? 0) > 0;
- };
-
- const osName = () => {
- return props.guest.osName || '';
- };
-
- const osVersion = () => {
- return props.guest.osVersion || '';
- };
-
- const hasAgentInfo = () => {
- return !!props.guest.agentVersion;
- };
-
- const agentVersion = () => {
- return props.guest.agentVersion || '';
- };
-
- const ipAddresses = () => {
- return props.guest.ipAddresses || [];
- };
-
- const memoryExtraLines = () => {
- if (!props.guest.memory) return undefined;
- const lines: string[] = [];
- const total = props.guest.memory.total ?? 0;
- if (
- props.guest.memory.balloon &&
- props.guest.memory.balloon > 0 &&
- props.guest.memory.balloon !== total
- ) {
- lines.push(`Balloon: ${formatBytes(props.guest.memory.balloon)}`);
- }
- if (props.guest.memory.swapTotal && props.guest.memory.swapTotal > 0) {
- const swapUsed = props.guest.memory.swapUsed ?? 0;
- lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(props.guest.memory.swapTotal)}`);
- }
- return lines.length > 0 ? lines : undefined;
- };
-
- const hasFilesystemDetails = () => {
- if (!props.guest.disks) return false;
- return props.guest.disks.length > 0;
- };
-
- const networkInterfaces = () => {
- // Both VMs and containers can have network interfaces
- return props.guest.networkInterfaces || [];
- };
-
- const hasNetworkInterfaces = () => {
- return networkInterfaces().length > 0;
- };
-
- const fallbackGuestId = () => {
- return props.guest.id || `${props.guest.instance}:${props.guest.node}:${props.guest.vmid}`;
- };
-
- const metricsResource = (): { type: ResourceType; id: string } => {
- const key = props.metricsKey || '';
- const separatorIndex = key.indexOf(':');
- const fallbackType: ResourceType = isVM(props.guest) ? 'vm' : 'container';
-
- if (separatorIndex === -1) {
- return { type: fallbackType, id: fallbackGuestId() };
- }
-
- const kind = key.slice(0, separatorIndex);
- const id = key.slice(separatorIndex + 1) || fallbackGuestId();
- const type: ResourceType = kind === 'vm' || kind === 'container' ? kind : fallbackType;
-
- return { type, id };
- };
-
- const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
-
- // All tabs are always rendered (hidden via CSS) to avoid any DOM
- // mount/unmount during tab switches. Mounting new components inside
- // a <For>-rendered table row causes SolidJS to recreate the row,
- // which detaches the element and resets the scroll container.
- const switchTab = (tab: 'overview' | 'discovery') => {
- setActiveTab(tab);
- };
-
- const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>('1h');
- const isHistoryLocked = () => !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
-
- // Get discovery resource type for the guest
- const discoveryResourceType = (): DiscoveryResourceType => {
- return isVM(props.guest) ? 'vm' : 'lxc';
- };
- return (
- <div class="space-y-3">
- {/* Tabs */}
- <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
- <button
- onClick={() => switchTab('overview')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'overview'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
- >
- Overview
- {activeTab() === 'overview' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
- <button
- onClick={() => switchTab('discovery')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'discovery'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
+ const guestId = () => {
+ if (props.guest.id) return props.guest.id;
+ return `${props.guest.instance}:${props.guest.node}:${props.guest.vmid}`;
+ };
+
+ const isVM = (guest: Guest): guest is VM => {
+ return guest.type === 'qemu';
+ };
+
+ const hasOsInfo = () => {
+ // Both VMs and containers can have OS info
+ return (props.guest.osName?.length ?? 0) > 0 || (props.guest.osVersion?.length ?? 0) > 0;
+ };
+
+ const osName = () => {
+ return props.guest.osName || '';
+ };
+
+ const osVersion = () => {
+ return props.guest.osVersion || '';
+ };
+
+ const hasAgentInfo = () => {
+ return !!props.guest.agentVersion;
+ };
+
+ const agentVersion = () => {
+ return props.guest.agentVersion || '';
+ };
+
+ const ipAddresses = () => {
+ return props.guest.ipAddresses || [];
+ };
+
+ const memoryExtraLines = () => {
+ if (!props.guest.memory) return undefined;
+ const lines: string[] = [];
+ const total = props.guest.memory.total ?? 0;
+ if (
+ props.guest.memory.balloon &&
+ props.guest.memory.balloon > 0 &&
+ props.guest.memory.balloon !== total
+ ) {
+ lines.push(`Balloon: ${formatBytes(props.guest.memory.balloon)}`);
+ }
+ if (props.guest.memory.swapTotal && props.guest.memory.swapTotal > 0) {
+ const swapUsed = props.guest.memory.swapUsed ?? 0;
+ lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(props.guest.memory.swapTotal)}`);
+ }
+ return lines.length > 0 ? lines : undefined;
+ };
+
+ const hasFilesystemDetails = () => {
+ if (!props.guest.disks) return false;
+ return props.guest.disks.length > 0;
+ };
+
+ const networkInterfaces = () => {
+ // Both VMs and containers can have network interfaces
+ return props.guest.networkInterfaces || [];
+ };
+
+ const hasNetworkInterfaces = () => {
+ return networkInterfaces().length > 0;
+ };
+
+ const fallbackGuestId = () => {
+ return props.guest.id || `${props.guest.instance}:${props.guest.node}:${props.guest.vmid}`;
+ };
+
+ const metricsResource = (): { type: ResourceType; id: string } => {
+ const key = props.metricsKey || '';
+ const separatorIndex = key.indexOf(':');
+ const fallbackType: ResourceType = isVM(props.guest) ? 'vm' : 'container';
+
+ if (separatorIndex === -1) {
+ return { type: fallbackType, id: fallbackGuestId() };
+ }
+
+ const kind = key.slice(0, separatorIndex);
+ const id = key.slice(separatorIndex + 1) || fallbackGuestId();
+ const type: ResourceType = kind === 'vm' || kind === 'container' ? kind : fallbackType;
+
+ return { type, id };
+ };
+
+ const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
+
+ // All tabs are always rendered (hidden via CSS) to avoid any DOM
+ // mount/unmount during tab switches. Mounting new components inside
+ // a <For>-rendered table row causes SolidJS to recreate the row,
+ // which detaches the element and resets the scroll container.
+ const switchTab = (tab: 'overview' | 'discovery') => {
+ setActiveTab(tab);
+ };
+
+ const [historyRange, setHistoryRange] = useDrawerHistoryRange(
+ `guest:${metricsResource().type}:${metricsResource().id}`,
+ );
+ const isHistoryLocked = () =>
+ !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
+
+ // Get discovery resource type for the guest
+ const discoveryResourceType = (): DiscoveryResourceType => {
+ return isVM(props.guest) ? 'vm' : 'lxc';
+ };
+ return (
+ <div class="space-y-3">
+ {/* Tabs */}
+ <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
+ <button
+ onClick={() => switchTab('overview')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'overview'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Overview
+ {activeTab() === 'overview' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ <button
+ onClick={() => switchTab('discovery')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'discovery'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Discovery
+ {activeTab() === 'discovery' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ </div>
+
+ {/* 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={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ {/* Flex layout - items grow to fill space, max ~4 per row */}
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
+ {/* System Info - always show */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ System
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <Show when={props.guest.cpus}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">CPUs</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.guest.cpus}
+ </span>
+ </div>
+ </Show>
+ <Show when={props.guest.uptime > 0}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Uptime</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {formatUptime(props.guest.uptime)}
+ </span>
+ </div>
+ </Show>
+ <Show when={props.guest.node}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Node</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.guest.node}
+ </span>
+ </div>
+ </Show>
+ <Show when={hasAgentInfo()}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Agent</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 truncate ml-2"
+ title={
+ isVM(props.guest) ? `QEMU guest agent ${agentVersion()}` : agentVersion()
+ }
+ >
+ {isVM(props.guest) ? `QEMU ${agentVersion()}` : agentVersion()}
+ </span>
+ </div>
+ </Show>
+ </div>
+ </div>
+
+ {/* Guest Info - OS and IPs */}
+ <Show when={hasOsInfo() || ipAddresses().length > 0}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Guest Info
+ </div>
+ <div class="space-y-2">
+ <Show when={hasOsInfo()}>
+ <div
+ class="text-[11px] text-gray-600 dark:text-gray-300 truncate"
+ title={`${osName()} ${osVersion()}`.trim()}
+ >
+ <Show when={osName().length > 0}>
+ <span class="font-medium">{osName()}</span>
+ </Show>
+ <Show when={osName().length > 0 && osVersion().length > 0}>
+ <span class="text-gray-400 dark:text-gray-500 mx-1">•</span>
+ </Show>
+ <Show when={osVersion().length > 0}>
+ <span>{osVersion()}</span>
+ </Show>
+ </div>
+ </Show>
+ <Show when={ipAddresses().length > 0}>
+ <div class="flex flex-wrap gap-1">
+ <For each={ipAddresses()}>
+ {(ip) => (
+ <span
+ class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate"
+ title={ip}
+ >
+ {ip}
+ </span>
+ )}
+ </For>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </Show>
+
+ {/* Memory Details */}
+ <Show when={memoryExtraLines() && memoryExtraLines()!.length > 0}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Memory
+ </div>
+ <div class="space-y-1 text-[11px] text-gray-600 dark:text-gray-300">
+ <For each={memoryExtraLines()!}>{(line) => <div>{line}</div>}</For>
+ </div>
+ </div>
+ </Show>
+
+ {/* Backup Info */}
+ <Show when={props.guest.lastBackup}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Backup
+ </div>
+ <div class="space-y-1 text-[11px]">
+ {(() => {
+ const backupDate = new Date(props.guest.lastBackup);
+ const now = new Date();
+ const daysSince = Math.floor(
+ (now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24),
+ );
+ const isOld = daysSince > 7;
+ const isCritical = daysSince > 30;
+ return (
+ <>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Last Backup</span>
+ <span
+ class={`font-medium ${isCritical ? 'text-red-600 dark:text-red-400' : isOld ? 'text-amber-600 dark:text-amber-400' : 'text-green-600 dark:text-green-400'}`}
+ >
+ {daysSince === 0
+ ? 'Today'
+ : daysSince === 1
+ ? 'Yesterday'
+ : `${daysSince}d ago`}
+ </span>
+ </div>
+ <div class="text-[10px] text-gray-400 dark:text-gray-500">
+ {backupDate.toLocaleDateString()}
+ </div>
+ </>
+ );
+ })()}
+ </div>
+ </div>
+ </Show>
+
+ {/* Tags */}
+ <Show
+ when={
+ props.guest.tags &&
+ (Array.isArray(props.guest.tags)
+ ? props.guest.tags.length > 0
+ : props.guest.tags.length > 0)
+ }
+ >
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Tags
+ </div>
+ <div class="flex flex-wrap gap-1">
+ <For
+ each={
+ Array.isArray(props.guest.tags)
+ ? props.guest.tags
+ : props.guest.tags?.split(',') || []
+ }
>
- Discovery
- {activeTab() === 'discovery' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
+ {(tag) => (
+ <span class="inline-block rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-700 dark:bg-gray-700 dark:text-gray-200">
+ {tag.trim()}
+ </span>
+ )}
+ </For>
+ </div>
</div>
-
- {/* 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={activeTab() === 'overview' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- {/* Flex layout - items grow to fill space, max ~4 per row */}
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
- {/* System Info - always show */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">System</div>
- <div class="space-y-1.5 text-[11px]">
- <Show when={props.guest.cpus}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">CPUs</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.guest.cpus}</span>
- </div>
- </Show>
- <Show when={props.guest.uptime > 0}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Uptime</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{formatUptime(props.guest.uptime)}</span>
- </div>
- </Show>
- <Show when={props.guest.node}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Node</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.guest.node}</span>
- </div>
- </Show>
- <Show when={hasAgentInfo()}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Agent</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 truncate ml-2" title={isVM(props.guest) ? `QEMU guest agent ${agentVersion()}` : agentVersion()}>
- {isVM(props.guest) ? `QEMU ${agentVersion()}` : agentVersion()}
- </span>
- </div>
- </Show>
- </div>
+ </Show>
+
+ {/* Filesystems */}
+ <Show when={hasFilesystemDetails() && props.guest.disks && props.guest.disks.length > 0}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Filesystems
+ </div>
+ <div class="text-[11px] text-gray-600 dark:text-gray-300">
+ <DiskList
+ disks={props.guest.disks || []}
+ diskStatusReason={isVM(props.guest) ? props.guest.diskStatusReason : undefined}
+ />
+ </div>
+ </div>
+ </Show>
+
+ {/* Network Interfaces */}
+ <Show when={hasNetworkInterfaces()}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Network
+ </div>
+ <div class="space-y-2">
+ <For each={networkInterfaces().slice(0, 4)}>
+ {(iface) => {
+ const addresses = iface.addresses ?? [];
+ const hasTraffic = (iface.rxBytes ?? 0) > 0 || (iface.txBytes ?? 0) > 0;
+ return (
+ <div class="rounded border border-dashed border-gray-200 p-2 dark:border-gray-700 overflow-hidden">
+ <div class="flex items-center gap-2 text-[11px] font-medium text-gray-700 dark:text-gray-200 min-w-0">
+ <span class="truncate min-w-0">{iface.name || 'interface'}</span>
+ <Show when={iface.mac}>
+ <span
+ class="text-[9px] text-gray-400 dark:text-gray-500 font-normal truncate shrink-0 max-w-[100px]"
+ title={iface.mac}
+ >
+ {iface.mac}
+ </span>
+ </Show>
</div>
-
- {/* Guest Info - OS and IPs */}
- <Show when={hasOsInfo() || ipAddresses().length > 0}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Guest Info</div>
- <div class="space-y-2">
- <Show when={hasOsInfo()}>
- <div class="text-[11px] text-gray-600 dark:text-gray-300 truncate" title={`${osName()} ${osVersion()}`.trim()}>
- <Show when={osName().length > 0}>
- <span class="font-medium">{osName()}</span>
- </Show>
- <Show when={osName().length > 0 && osVersion().length > 0}>
- <span class="text-gray-400 dark:text-gray-500 mx-1">•</span>
- </Show>
- <Show when={osVersion().length > 0}>
- <span>{osVersion()}</span>
- </Show>
- </div>
- </Show>
- <Show when={ipAddresses().length > 0}>
- <div class="flex flex-wrap gap-1">
- <For each={ipAddresses()}>
- {(ip) => (
- <span class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate" title={ip}>
- {ip}
- </span>
- )}
- </For>
- </div>
- </Show>
- </div>
- </div>
+ <Show when={addresses.length > 0}>
+ <div class="flex flex-wrap gap-1 mt-1">
+ <For each={addresses}>
+ {(ip) => (
+ <span
+ class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate"
+ title={ip}
+ >
+ {ip}
+ </span>
+ )}
+ </For>
+ </div>
</Show>
-
- {/* Memory Details */}
- <Show when={memoryExtraLines() && memoryExtraLines()!.length > 0}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Memory</div>
- <div class="space-y-1 text-[11px] text-gray-600 dark:text-gray-300">
- <For each={memoryExtraLines()!}>{(line) => <div>{line}</div>}</For>
- </div>
- </div>
- </Show>
-
- {/* Backup Info */}
- <Show when={props.guest.lastBackup}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Backup</div>
- <div class="space-y-1 text-[11px]">
- {(() => {
- const backupDate = new Date(props.guest.lastBackup);
- const now = new Date();
- const daysSince = Math.floor((now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24));
- const isOld = daysSince > 7;
- const isCritical = daysSince > 30;
- return (
- <>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Last Backup</span>
- <span class={`font-medium ${isCritical ? 'text-red-600 dark:text-red-400' : isOld ? 'text-amber-600 dark:text-amber-400' : 'text-green-600 dark:text-green-400'}`}>
- {daysSince === 0 ? 'Today' : daysSince === 1 ? 'Yesterday' : `${daysSince}d ago`}
- </span>
- </div>
- <div class="text-[10px] text-gray-400 dark:text-gray-500">
- {backupDate.toLocaleDateString()}
- </div>
- </>
- );
- })()}
- </div>
- </div>
- </Show>
-
- {/* Tags */}
- <Show when={props.guest.tags && (Array.isArray(props.guest.tags) ? props.guest.tags.length > 0 : props.guest.tags.length > 0)}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Tags</div>
- <div class="flex flex-wrap gap-1">
- <For each={Array.isArray(props.guest.tags) ? props.guest.tags : (props.guest.tags?.split(',') || [])}>
- {(tag) => (
- <span class="inline-block rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-700 dark:bg-gray-700 dark:text-gray-200">
- {tag.trim()}
- </span>
- )}
- </For>
- </div>
- </div>
- </Show>
-
- {/* Filesystems */}
- <Show when={hasFilesystemDetails() && props.guest.disks && props.guest.disks.length > 0}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Filesystems</div>
- <div class="text-[11px] text-gray-600 dark:text-gray-300">
- <DiskList
- disks={props.guest.disks || []}
- diskStatusReason={isVM(props.guest) ? props.guest.diskStatusReason : undefined}
- />
- </div>
- </div>
+ <Show when={hasTraffic}>
+ <div class="flex gap-3 mt-1 text-[10px] text-gray-500 dark:text-gray-400">
+ <span>RX {formatBytes(iface.rxBytes ?? 0)}</span>
+ <span>TX {formatBytes(iface.txBytes ?? 0)}</span>
+ </div>
</Show>
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ </div>
+ </Show>
+ </div>
- {/* Network Interfaces */}
- <Show when={hasNetworkInterfaces()}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Network</div>
- <div class="space-y-2">
- <For each={networkInterfaces().slice(0, 4)}>
- {(iface) => {
- const addresses = iface.addresses ?? [];
- const hasTraffic = (iface.rxBytes ?? 0) > 0 || (iface.txBytes ?? 0) > 0;
- return (
- <div class="rounded border border-dashed border-gray-200 p-2 dark:border-gray-700 overflow-hidden">
- <div class="flex items-center gap-2 text-[11px] font-medium text-gray-700 dark:text-gray-200 min-w-0">
- <span class="truncate min-w-0">{iface.name || 'interface'}</span>
- <Show when={iface.mac}>
- <span class="text-[9px] text-gray-400 dark:text-gray-500 font-normal truncate shrink-0 max-w-[100px]" title={iface.mac}>{iface.mac}</span>
- </Show>
- </div>
- <Show when={addresses.length > 0}>
- <div class="flex flex-wrap gap-1 mt-1">
- <For each={addresses}>
- {(ip) => (
- <span class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate" title={ip}>
- {ip}
- </span>
- )}
- </For>
- </div>
- </Show>
- <Show when={hasTraffic}>
- <div class="flex gap-3 mt-1 text-[10px] text-gray-500 dark:text-gray-400">
- <span>RX {formatBytes(iface.rxBytes ?? 0)}</span>
- <span>TX {formatBytes(iface.txBytes ?? 0)}</span>
- </div>
- </Show>
- </div>
- );
- }}
- </For>
- </div>
- </div>
- </Show>
- </div>
-
- {/* Performance History */}
- <div class="mt-3 space-y-3">
- {/* Shared range selector */}
- <div class="flex items-center gap-2">
- <svg class="w-3.5 h-3.5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
- <circle cx="12" cy="12" r="10" />
- <path stroke-linecap="round" d="M12 6v6l4 2" />
- </svg>
- <select
- value={historyRange()}
- onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
- class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
- style={{ "background-image": "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")", "background-repeat": "no-repeat", "background-position": "right 6px center" }}
- >
- <option value="1h">Last 1 hour</option>
- <option value="6h">Last 6 hours</option>
- <option value="12h">Last 12 hours</option>
- <option value="24h">Last 24 hours</option>
- <option value="7d">Last 7 days</option>
- <option value="30d">Last 30 days</option>
- <option value="90d">Last 90 days</option>
- </select>
- </div>
+ {/* Performance History */}
+ <div class="mt-3 space-y-3">
+ {/* Shared range selector */}
+ <div class="flex items-center gap-2">
+ <svg
+ class="w-3.5 h-3.5 text-gray-400"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ stroke-width="2"
+ >
+ <circle cx="12" cy="12" r="10" />
+ <path stroke-linecap="round" d="M12 6v6l4 2" />
+ </svg>
+ <select
+ value={historyRange()}
+ onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
+ class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
+ style={{
+ 'background-image':
+ "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")",
+ 'background-repeat': 'no-repeat',
+ 'background-position': 'right 6px center',
+ }}
+ >
+ <option value="1h">Last 1 hour</option>
+ <option value="6h">Last 6 hours</option>
+ <option value="12h">Last 12 hours</option>
+ <option value="24h">Last 24 hours</option>
+ <option value="7d">Last 7 days</option>
+ <option value="30d">Last 30 days</option>
+ <option value="90d">Last 90 days</option>
+ </select>
+ </div>
+
+ <div class="relative">
+ <div class="space-y-3">
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource().type}
+ resourceId={metricsResource().id}
+ metric="cpu"
+ height={120}
+ color="#8b5cf6"
+ label="CPU"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource().type}
+ resourceId={metricsResource().id}
+ metric="memory"
+ height={120}
+ color="#f59e0b"
+ label="Memory"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource().type}
+ resourceId={metricsResource().id}
+ metric="disk"
+ height={120}
+ color="#10b981"
+ label="Disk"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ </div>
+
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[250px]">
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource().type}
+ resourceId={metricsResource().id}
+ metric="netin"
+ height={120}
+ color="#3b82f6"
+ label="Net In"
+ unit="B/s"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource().type}
+ resourceId={metricsResource().id}
+ metric="netout"
+ height={120}
+ color="#6366f1"
+ label="Net Out"
+ unit="B/s"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ </div>
+ </div>
- <div class="relative">
- <div class="space-y-3">
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource().type}
- resourceId={metricsResource().id}
- metric="cpu"
- height={120}
- color="#8b5cf6"
- label="CPU"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource().type}
- resourceId={metricsResource().id}
- metric="memory"
- height={120}
- color="#f59e0b"
- label="Memory"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource().type}
- resourceId={metricsResource().id}
- metric="disk"
- height={120}
- color="#10b981"
- label="Disk"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- </div>
-
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[250px]">
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource().type}
- resourceId={metricsResource().id}
- metric="netin"
- height={120}
- color="#3b82f6"
- label="Net In"
- unit="B/s"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource().type}
- resourceId={metricsResource().id}
- metric="netout"
- height={120}
- color="#6366f1"
- label="Net Out"
- unit="B/s"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- </div>
- </div>
-
- {/* Single shared Pro lock overlay */}
- <Show when={isHistoryLocked()}>
- <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
- <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
- <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
- </svg>
- </div>
- <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">{historyRange() === '30d' ? '30' : '90'}-Day History</h3>
- <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
- Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of historical data retention.
- </p>
- <a
- href="https://pulserelay.pro/pricing"
- target="_blank"
- class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
- >
- Unlock Pro Features
- </a>
- </div>
- </Show>
- </div>
- </div>
+ {/* Single shared Pro lock overlay */}
+ <Show when={isHistoryLocked()}>
+ <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
+ <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="white"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
+ <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
+ </svg>
</div>
+ <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">
+ {historyRange() === '30d' ? '30' : '90'}-Day History
+ </h3>
+ <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
+ Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of
+ historical data retention.
+ </p>
+ <a
+ href="https://pulserelay.pro/pricing"
+ target="_blank"
+ class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
+ >
+ Unlock Pro Features
+ </a>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </div>
- {/* Always rendered, hidden via CSS. Wrapped in a local Suspense
+ {/* Always rendered, hidden via CSS. Wrapped in a local Suspense
so DiscoveryTab's createResource loading state doesn't bubble
up to the app-level Suspense and replace the entire page. */}
- <div class={activeTab() === 'discovery' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- <Suspense fallback={
- <div class="flex items-center justify-center py-8">
- <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">Loading discovery...</span>
- </div>
- }>
- <DiscoveryTab
- resourceType={discoveryResourceType()}
- hostId={props.guest.node}
- resourceId={String(props.guest.vmid)}
- hostname={props.guest.name}
- guestId={guestId()}
- customUrl={props.customUrl}
- onCustomUrlChange={(url) => props.onCustomUrlChange?.(guestId(), url)}
- />
- </Suspense>
- </div>
- </div>
- );
+ <div
+ class={activeTab() === 'discovery' ? '' : 'hidden'}
+ style={{ 'overflow-anchor': 'none' }}
+ >
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
+ <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">
+ Loading discovery...
+ </span>
+ </div>
+ }
+ >
+ <DiscoveryTab
+ resourceType={discoveryResourceType()}
+ hostId={props.guest.node}
+ resourceId={String(props.guest.vmid)}
+ hostname={props.guest.name}
+ guestId={guestId()}
+ customUrl={props.customUrl}
+ onCustomUrlChange={(url) => props.onCustomUrlChange?.(guestId(), url)}
+ />
+ </Suspense>
+ </div>
+ </div>
+ );
};
diff --git a/frontend-modern/src/components/Hosts/HostDrawer.tsx b/frontend-modern/src/components/Hosts/HostDrawer.tsx
index cc3dfbc285..c3d3975cda 100644
--- a/frontend-modern/src/components/Hosts/HostDrawer.tsx
+++ b/frontend-modern/src/components/Hosts/HostDrawer.tsx
@@ -6,447 +6,551 @@ import { ResourceType, HistoryTimeRange } from '@/api/charts';
import { hasFeature } from '@/stores/license';
import { DiscoveryTab } from '../Discovery/DiscoveryTab';
import { StackedDiskBar } from '@/components/Dashboard/StackedDiskBar';
+import { useDrawerHistoryRange } from '@/hooks/useDrawerHistoryRange';
interface HostDrawerProps {
- host: Host;
- onClose: () => void;
- customUrl?: string;
- onCustomUrlChange?: (hostId: string, url: string) => void;
+ host: Host;
+ onClose: () => void;
+ customUrl?: string;
+ onCustomUrlChange?: (hostId: string, url: string) => void;
}
export const HostDrawer: Component<HostDrawerProps> = (props) => {
- const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
- const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>('1h');
- const [editingUrl, setEditingUrl] = createSignal(false);
- const [urlInput, setUrlInput] = createSignal('');
+ const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
+ const [historyRange, setHistoryRange] = useDrawerHistoryRange(`host:${props.host.id}`);
+ const [editingUrl, setEditingUrl] = createSignal(false);
+ const [urlInput, setUrlInput] = createSignal('');
- // For unified host agents, the backend stores metrics with resourceType 'host'
- const metricsResource = { type: 'host' as ResourceType, id: props.host.id };
+ // For unified host agents, the backend stores metrics with resourceType 'host'
+ const metricsResource = { type: 'host' as ResourceType, id: props.host.id };
- const switchTab = (tab: 'overview' | 'discovery') => {
- setActiveTab(tab);
- };
+ const switchTab = (tab: 'overview' | 'discovery') => {
+ setActiveTab(tab);
+ };
- const isHistoryLocked = () => !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
+ const isHistoryLocked = () =>
+ !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
- const diskStats = () => {
- if (!props.host.disks || props.host.disks.length === 0) return { percent: 0, used: 0, total: 0 };
- const totalUsed = props.host.disks.reduce((sum, d) => sum + (d.used ?? 0), 0);
- const totalSize = props.host.disks.reduce((sum, d) => sum + (d.total ?? 0), 0);
- return {
- percent: totalSize > 0 ? (totalUsed / totalSize) * 100 : 0,
- used: totalUsed,
- total: totalSize
- };
+ const diskStats = () => {
+ if (!props.host.disks || props.host.disks.length === 0)
+ return { percent: 0, used: 0, total: 0 };
+ const totalUsed = props.host.disks.reduce((sum, d) => sum + (d.used ?? 0), 0);
+ const totalSize = props.host.disks.reduce((sum, d) => sum + (d.total ?? 0), 0);
+ return {
+ percent: totalSize > 0 ? (totalUsed / totalSize) * 100 : 0,
+ used: totalUsed,
+ total: totalSize,
};
+ };
+
+ return (
+ <div class="space-y-3">
+ {/* Tabs */}
+ <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
+ <button
+ onClick={() => switchTab('overview')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'overview'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Overview
+ {activeTab() === 'overview' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ <button
+ onClick={() => switchTab('discovery')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'discovery'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Discovery
+ {activeTab() === 'discovery' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ </div>
- return (
- <div class="space-y-3">
- {/* Tabs */}
- <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
- <button
- onClick={() => switchTab('overview')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'overview'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
+ {/* Overview Tab */}
+ <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
+ {/* System Info */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ System
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">Hostname</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 select-all truncate"
+ title={props.host.hostname}
>
- Overview
- {activeTab() === 'overview' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
- <button
- onClick={() => switchTab('discovery')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'discovery'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
+ {props.host.hostname}
+ </span>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Platform</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200 capitalize">
+ {props.host.platform || 'Unknown'}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">OS</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 truncate"
+ title={`${props.host.osName} ${props.host.osVersion}`}
>
- Discovery
- {activeTab() === 'discovery' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
- </div>
-
- {/* Overview Tab */}
- <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
- {/* System Info */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">System</div>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">Hostname</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 select-all truncate" title={props.host.hostname}>{props.host.hostname}</span>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Platform</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 capitalize">{props.host.platform || 'Unknown'}</span>
- </div>
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">OS</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 truncate" title={`${props.host.osName} ${props.host.osVersion}`}>{props.host.osName} {props.host.osVersion}</span>
- </div>
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">Kernel</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 truncate" title={props.host.kernelVersion}>{props.host.kernelVersion}</span>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Architecture</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.host.architecture}</span>
- </div>
- <Show when={props.host.uptimeSeconds}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Uptime</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{formatUptime(props.host.uptimeSeconds!)}</span>
- </div>
- </Show>
- {/* Web Interface URL */}
- <div class="pt-1.5 mt-1.5 border-t border-gray-100 dark:border-gray-700/50">
- <Show when={editingUrl()} fallback={
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">URL</span>
- <Show when={props.customUrl} fallback={
- <button
- onClick={() => { setUrlInput(''); setEditingUrl(true); }}
- class="text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 font-medium cursor-pointer"
- >
- + Add
- </button>
- }>
- <div class="flex items-center gap-1.5 min-w-0">
- <a
- href={props.customUrl}
- target="_blank"
- rel="noopener noreferrer"
- class="text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 font-medium truncate max-w-[150px]"
- title={props.customUrl}
- onClick={(e) => e.stopPropagation()}
- >
- {props.customUrl!.replace(/^https?:\/\//, '')}
- </a>
- <button
- onClick={() => { setUrlInput(props.customUrl || ''); setEditingUrl(true); }}
- class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 shrink-0"
- title="Edit URL"
- >
- <svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
- </svg>
- </button>
- </div>
- </Show>
- </div>
- }>
- <div class="space-y-1.5">
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">URL</span>
- </div>
- <input
- type="url"
- value={urlInput()}
- onInput={(e) => setUrlInput(e.currentTarget.value)}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- const val = urlInput().trim();
- if (val) props.onCustomUrlChange?.(props.host.id, val);
- setEditingUrl(false);
- } else if (e.key === 'Escape') {
- setEditingUrl(false);
- }
- }}
- placeholder="https://192.168.1.100:8006"
- class="w-full px-2 py-1 text-[11px] rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
- autofocus
- />
- <div class="flex items-center gap-1.5">
- <button
- onClick={() => {
- const val = urlInput().trim();
- if (val) props.onCustomUrlChange?.(props.host.id, val);
- setEditingUrl(false);
- }}
- class="px-2 py-0.5 text-[10px] font-medium rounded bg-blue-500 hover:bg-blue-600 text-white"
- >
- Save
- </button>
- <Show when={props.customUrl}>
- <button
- onClick={() => {
- props.onCustomUrlChange?.(props.host.id, '');
- setEditingUrl(false);
- }}
- class="px-2 py-0.5 text-[10px] font-medium rounded text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20"
- >
- Remove
- </button>
- </Show>
- <button
- onClick={() => setEditingUrl(false)}
- class="px-2 py-0.5 text-[10px] font-medium rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"
- >
- Cancel
- </button>
- </div>
- </div>
- </Show>
- </div>
+ {props.host.osName} {props.host.osVersion}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">Kernel</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 truncate"
+ title={props.host.kernelVersion}
+ >
+ {props.host.kernelVersion}
+ </span>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Architecture</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.host.architecture}
+ </span>
+ </div>
+ <Show when={props.host.uptimeSeconds}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Uptime</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {formatUptime(props.host.uptimeSeconds!)}
+ </span>
+ </div>
+ </Show>
+ {/* Web Interface URL */}
+ <div class="pt-1.5 mt-1.5 border-t border-gray-100 dark:border-gray-700/50">
+ <Show
+ when={editingUrl()}
+ fallback={
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">URL</span>
+ <Show
+ when={props.customUrl}
+ fallback={
+ <button
+ onClick={() => {
+ setUrlInput('');
+ setEditingUrl(true);
+ }}
+ class="text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 font-medium cursor-pointer"
+ >
+ + Add
+ </button>
+ }
+ >
+ <div class="flex items-center gap-1.5 min-w-0">
+ <a
+ href={props.customUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300 font-medium truncate max-w-[150px]"
+ title={props.customUrl}
+ onClick={(e) => e.stopPropagation()}
+ >
+ {props.customUrl!.replace(/^https?:\/\//, '')}
+ </a>
+ <button
+ onClick={() => {
+ setUrlInput(props.customUrl || '');
+ setEditingUrl(true);
+ }}
+ class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 shrink-0"
+ title="Edit URL"
+ >
+ <svg
+ class="w-3 h-3"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ stroke-width="2"
+ >
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
+ </svg>
+ </button>
</div>
+ </Show>
</div>
-
- {/* Hardware Info */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Hardware</div>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">CPU</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.host.cpuCount} Cores</span>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Memory</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">
- {formatBytes(props.host.memory?.total || 0)}
- </span>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Agent</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.host.agentVersion}</span>
- </div>
- </div>
+ }
+ >
+ <div class="space-y-1.5">
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">URL</span>
</div>
+ <input
+ type="url"
+ value={urlInput()}
+ onInput={(e) => setUrlInput(e.currentTarget.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ const val = urlInput().trim();
+ if (val) props.onCustomUrlChange?.(props.host.id, val);
+ setEditingUrl(false);
+ } else if (e.key === 'Escape') {
+ setEditingUrl(false);
+ }
+ }}
+ placeholder="https://192.168.1.100:8006"
+ class="w-full px-2 py-1 text-[11px] rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:ring-1 focus:ring-blue-500 focus:border-blue-500"
+ autofocus
+ />
+ <div class="flex items-center gap-1.5">
+ <button
+ onClick={() => {
+ const val = urlInput().trim();
+ if (val) props.onCustomUrlChange?.(props.host.id, val);
+ setEditingUrl(false);
+ }}
+ class="px-2 py-0.5 text-[10px] font-medium rounded bg-blue-500 hover:bg-blue-600 text-white"
+ >
+ Save
+ </button>
+ <Show when={props.customUrl}>
+ <button
+ onClick={() => {
+ props.onCustomUrlChange?.(props.host.id, '');
+ setEditingUrl(false);
+ }}
+ class="px-2 py-0.5 text-[10px] font-medium rounded text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20"
+ >
+ Remove
+ </button>
+ </Show>
+ <button
+ onClick={() => setEditingUrl(false)}
+ class="px-2 py-0.5 text-[10px] font-medium rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"
+ >
+ Cancel
+ </button>
+ </div>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </div>
- {/* Network Interfaces */}
- <Show when={props.host.networkInterfaces && props.host.networkInterfaces.length > 0}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Network</div>
- <div class="max-h-[140px] overflow-y-auto custom-scrollbar space-y-2">
- <For each={props.host.networkInterfaces}>
- {(iface) => (
- <div class="rounded border border-dashed border-gray-200 p-2 dark:border-gray-700 overflow-hidden">
- <div class="flex items-center gap-2 text-[11px] font-medium text-gray-700 dark:text-gray-200 min-w-0">
- <span class="truncate min-w-0">{iface.name}</span>
- <Show when={iface.mac}>
- <span class="text-[9px] text-gray-400 dark:text-gray-500 font-normal truncate shrink-0 max-w-[100px]" title={iface.mac}>{iface.mac}</span>
- </Show>
- </div>
- <Show when={iface.addresses && iface.addresses.length > 0}>
- <div class="flex flex-wrap gap-1 mt-1">
- <For each={iface.addresses}>
- {(ip) => (
- <span class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate" title={ip}>
- {ip}
- </span>
- )}
- </For>
- </div>
- </Show>
- </div>
- )}
- </For>
- </div>
- </div>
- </Show>
-
- {/* Disk Usage */}
- <Show when={props.host.disks && props.host.disks.length > 0}>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Disks</div>
- <div class="max-h-[140px] overflow-y-auto custom-scrollbar space-y-2">
- {/* Summary bar */}
- <div class="mb-3">
- <div class="flex justify-between text-[10px] mb-1">
- <span class="text-gray-500 dark:text-gray-400">Total Usage</span>
- <span class="text-gray-700 dark:text-gray-200">
- {formatBytes(diskStats().used)} / {formatBytes(diskStats().total)}
- </span>
- </div>
- <StackedDiskBar
- disks={props.host.disks}
- mode="mini"
- aggregateDisk={{
- total: diskStats().total,
- used: diskStats().used,
- free: diskStats().total - diskStats().used,
- usage: diskStats().percent / 100
- }}
- />
- </div>
+ {/* Hardware Info */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Hardware
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">CPU</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.host.cpuCount} Cores
+ </span>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Memory</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {formatBytes(props.host.memory?.total || 0)}
+ </span>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Agent</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.host.agentVersion}
+ </span>
+ </div>
+ </div>
+ </div>
- <For each={props.host.disks}>
- {(disk) => (
- <div class="text-[10px]">
- <div class="flex justify-between mb-0.5">
- <span class="text-gray-600 dark:text-gray-300 truncate max-w-[120px]" title={disk.mountpoint}>{disk.mountpoint}</span>
- <span class="text-gray-500 dark:text-gray-400">{formatBytes(disk.used)} / {formatBytes(disk.total)}</span>
- </div>
- <div class="h-1.5 w-full rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden">
- <div
- class="h-full rounded-full transition-all duration-500 bg-blue-500"
- style={{ width: `${Math.min(100, Math.max(0, (disk.used / disk.total) * 100))}%` }}
- />
- </div>
- </div>
- )}
- </For>
- </div>
+ {/* Network Interfaces */}
+ <Show when={props.host.networkInterfaces && props.host.networkInterfaces.length > 0}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Network
+ </div>
+ <div class="max-h-[140px] overflow-y-auto custom-scrollbar space-y-2">
+ <For each={props.host.networkInterfaces}>
+ {(iface) => (
+ <div class="rounded border border-dashed border-gray-200 p-2 dark:border-gray-700 overflow-hidden">
+ <div class="flex items-center gap-2 text-[11px] font-medium text-gray-700 dark:text-gray-200 min-w-0">
+ <span class="truncate min-w-0">{iface.name}</span>
+ <Show when={iface.mac}>
+ <span
+ class="text-[9px] text-gray-400 dark:text-gray-500 font-normal truncate shrink-0 max-w-[100px]"
+ title={iface.mac}
+ >
+ {iface.mac}
+ </span>
+ </Show>
+ </div>
+ <Show when={iface.addresses && iface.addresses.length > 0}>
+ <div class="flex flex-wrap gap-1 mt-1">
+ <For each={iface.addresses}>
+ {(ip) => (
+ <span
+ class="inline-block rounded bg-blue-100 px-1.5 py-0.5 text-[10px] text-blue-700 dark:bg-blue-900/40 dark:text-blue-200 max-w-full truncate"
+ title={ip}
+ >
+ {ip}
+ </span>
+ )}
+ </For>
</div>
- </Show>
+ </Show>
+ </div>
+ )}
+ </For>
+ </div>
+ </div>
+ </Show>
+
+ {/* Disk Usage */}
+ <Show when={props.host.disks && props.host.disks.length > 0}>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Disks
+ </div>
+ <div class="max-h-[140px] overflow-y-auto custom-scrollbar space-y-2">
+ {/* Summary bar */}
+ <div class="mb-3">
+ <div class="flex justify-between text-[10px] mb-1">
+ <span class="text-gray-500 dark:text-gray-400">Total Usage</span>
+ <span class="text-gray-700 dark:text-gray-200">
+ {formatBytes(diskStats().used)} / {formatBytes(diskStats().total)}
+ </span>
+ </div>
+ <StackedDiskBar
+ disks={props.host.disks}
+ mode="mini"
+ aggregateDisk={{
+ total: diskStats().total,
+ used: diskStats().used,
+ free: diskStats().total - diskStats().used,
+ usage: diskStats().percent / 100,
+ }}
+ />
</div>
- {/* Performance Charts */}
- <div class="mt-3 space-y-3">
- <div class="flex items-center gap-2">
- <svg class="w-3.5 h-3.5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
- <circle cx="12" cy="12" r="10" />
- <path stroke-linecap="round" d="M12 6v6l4 2" />
- </svg>
- <select
- value={historyRange()}
- onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
- class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
- style={{ "background-image": "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")", "background-repeat": "no-repeat", "background-position": "right 6px center" }}
+ <For each={props.host.disks}>
+ {(disk) => (
+ <div class="text-[10px]">
+ <div class="flex justify-between mb-0.5">
+ <span
+ class="text-gray-600 dark:text-gray-300 truncate max-w-[120px]"
+ title={disk.mountpoint}
>
- <option value="1h">Last 1 hour</option>
- <option value="6h">Last 6 hours</option>
- <option value="12h">Last 12 hours</option>
- <option value="24h">Last 24 hours</option>
- <option value="7d">Last 7 days</option>
- <option value="30d">Last 30 days</option>
- <option value="90d">Last 90 days</option>
- </select>
+ {disk.mountpoint}
+ </span>
+ <span class="text-gray-500 dark:text-gray-400">
+ {formatBytes(disk.used)} / {formatBytes(disk.total)}
+ </span>
+ </div>
+ <div class="h-1.5 w-full rounded-full bg-gray-200 dark:bg-gray-700 overflow-hidden">
+ <div
+ class="h-full rounded-full transition-all duration-500 bg-blue-500"
+ style={{
+ width: `${Math.min(100, Math.max(0, (disk.used / disk.total) * 100))}%`,
+ }}
+ />
+ </div>
</div>
+ )}
+ </For>
+ </div>
+ </div>
+ </Show>
+ </div>
- <div class="relative">
- <div class="space-y-3">
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="cpu"
- height={120}
- color="#8b5cf6"
- label="CPU"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="memory"
- height={120}
- color="#f59e0b"
- label="Memory"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="disk"
- height={120}
- color="#10b981"
- label="Disk"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- </div>
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[250px]">
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="netin"
- height={120}
- color="#3b82f6"
- label="Net In"
- unit="B/s"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="netout"
- height={120}
- color="#6366f1"
- label="Net Out"
- unit="B/s"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- </div>
- </div>
- {/* Lock Overlay */}
- <Show when={isHistoryLocked()}>
- <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
- <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
- <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
- </svg>
- </div>
- <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">{historyRange() === '30d' ? '30' : '90'}-Day History</h3>
- <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
- Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of historical data retention.
- </p>
- <a
- href="https://pulserelay.pro/pricing"
- target="_blank"
- class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
- >
- Unlock Pro Features
- </a>
- </div>
- </Show>
- </div>
+ {/* Performance Charts */}
+ <div class="mt-3 space-y-3">
+ <div class="flex items-center gap-2">
+ <svg
+ class="w-3.5 h-3.5 text-gray-400"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ stroke-width="2"
+ >
+ <circle cx="12" cy="12" r="10" />
+ <path stroke-linecap="round" d="M12 6v6l4 2" />
+ </svg>
+ <select
+ value={historyRange()}
+ onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
+ class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
+ style={{
+ 'background-image':
+ "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")",
+ 'background-repeat': 'no-repeat',
+ 'background-position': 'right 6px center',
+ }}
+ >
+ <option value="1h">Last 1 hour</option>
+ <option value="6h">Last 6 hours</option>
+ <option value="12h">Last 12 hours</option>
+ <option value="24h">Last 24 hours</option>
+ <option value="7d">Last 7 days</option>
+ <option value="30d">Last 30 days</option>
+ <option value="90d">Last 90 days</option>
+ </select>
+ </div>
+
+ <div class="relative">
+ <div class="space-y-3">
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="cpu"
+ height={120}
+ color="#8b5cf6"
+ label="CPU"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="memory"
+ height={120}
+ color="#f59e0b"
+ label="Memory"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
</div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="disk"
+ height={120}
+ color="#10b981"
+ label="Disk"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ </div>
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(50%-0.375rem)] [&>*]:min-w-[250px]">
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="netin"
+ height={120}
+ color="#3b82f6"
+ label="Net In"
+ unit="B/s"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="netout"
+ height={120}
+ color="#6366f1"
+ label="Net Out"
+ unit="B/s"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ </div>
</div>
+ {/* Lock Overlay */}
+ <Show when={isHistoryLocked()}>
+ <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
+ <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="white"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
+ <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
+ </svg>
+ </div>
+ <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">
+ {historyRange() === '30d' ? '30' : '90'}-Day History
+ </h3>
+ <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
+ Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of
+ historical data retention.
+ </p>
+ <a
+ href="https://pulserelay.pro/pricing"
+ target="_blank"
+ class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
+ >
+ Unlock Pro Features
+ </a>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </div>
- {/* Discovery Tab */}
- <div class={activeTab() === 'discovery' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- <Suspense fallback={
- <div class="flex items-center justify-center py-8">
- <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">Loading discovery...</span>
- </div>
- }>
- <DiscoveryTab
- resourceType="host"
- hostId={props.host.id}
- resourceId={props.host.id} /* For hosts, typically same as hostId */
- hostname={props.host.hostname}
- guestId={props.host.id}
- customUrl={props.customUrl}
- onCustomUrlChange={(url) => props.onCustomUrlChange?.(props.host.id, url)}
- commandsEnabled={props.host.commandsEnabled}
- />
- </Suspense>
+ {/* Discovery Tab */}
+ <div
+ class={activeTab() === 'discovery' ? '' : 'hidden'}
+ style={{ 'overflow-anchor': 'none' }}
+ >
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
+ <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">
+ Loading discovery...
+ </span>
</div>
- </div>
- );
+ }
+ >
+ <DiscoveryTab
+ resourceType="host"
+ hostId={props.host.id}
+ resourceId={props.host.id} /* For hosts, typically same as hostId */
+ hostname={props.host.hostname}
+ guestId={props.host.id}
+ customUrl={props.customUrl}
+ onCustomUrlChange={(url) => props.onCustomUrlChange?.(props.host.id, url)}
+ commandsEnabled={props.host.commandsEnabled}
+ />
+ </Suspense>
+ </div>
+ </div>
+ );
};
diff --git a/frontend-modern/src/components/shared/NodeDrawer.tsx b/frontend-modern/src/components/shared/NodeDrawer.tsx
index afcbbfe3eb..f91d4840ed 100644
--- a/frontend-modern/src/components/shared/NodeDrawer.tsx
+++ b/frontend-modern/src/components/shared/NodeDrawer.tsx
@@ -7,281 +7,347 @@ import { hasFeature } from '@/stores/license';
import { DiscoveryTab } from '../Discovery/DiscoveryTab';
import { StackedDiskBar } from '@/components/Dashboard/StackedDiskBar';
import { HostMetadataAPI } from '@/api/hostMetadata';
+import { useDrawerHistoryRange } from '@/hooks/useDrawerHistoryRange';
interface NodeDrawerProps {
- node: Node;
- customUrl?: string; // Nodes don't typically have custom URL in current architecture but we can keep it
- onCustomUrlChange?: (hostId: string, url: string) => void;
+ node: Node;
+ customUrl?: string; // Nodes don't typically have custom URL in current architecture but we can keep it
+ onCustomUrlChange?: (hostId: string, url: string) => void;
}
export const NodeDrawer: Component<NodeDrawerProps> = (props) => {
- const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
- const [historyRange, setHistoryRange] = createSignal<HistoryTimeRange>('1h');
+ const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
+ const [historyRange, setHistoryRange] = useDrawerHistoryRange(
+ `node:${props.node.id || props.node.name}`,
+ );
- // For nodes, we treat them as 'host' for charts if consistent, or 'node' if charts API expects it.
- // Charts API (api/charts.ts) shows ResourceType includes 'node' and 'host'.
- // Typically 'node' is used for PVE nodes.
- const metricsResource = { type: 'node' as ResourceType, id: props.node.id || props.node.name };
+ // For nodes, we treat them as 'host' for charts if consistent, or 'node' if charts API expects it.
+ // Charts API (api/charts.ts) shows ResourceType includes 'node' and 'host'.
+ // Typically 'node' is used for PVE nodes.
+ const metricsResource = { type: 'node' as ResourceType, id: props.node.id || props.node.name };
- // Fetch custom URL from metadata
- const [fetchedCustomUrl, setFetchedCustomUrl] = createSignal<string | undefined>(props.customUrl);
+ // Fetch custom URL from metadata
+ const [fetchedCustomUrl, setFetchedCustomUrl] = createSignal<string | undefined>(props.customUrl);
- // Fetch metadata on mount
- createEffect(() => {
- const hostId = props.node.id || props.node.name;
- HostMetadataAPI.getMetadata(hostId).then(meta => {
- if (meta && meta.customUrl) {
- setFetchedCustomUrl(meta.customUrl);
- }
- }).catch(e => console.error("Failed to load node metadata", e));
- });
-
- const handleCustomUrlChange = (url: string) => {
- setFetchedCustomUrl(url);
- if (props.onCustomUrlChange) {
- props.onCustomUrlChange(props.node.id || props.node.name, url);
+ // Fetch metadata on mount
+ createEffect(() => {
+ const hostId = props.node.id || props.node.name;
+ HostMetadataAPI.getMetadata(hostId)
+ .then((meta) => {
+ if (meta && meta.customUrl) {
+ setFetchedCustomUrl(meta.customUrl);
}
- };
+ })
+ .catch((e) => console.error('Failed to load node metadata', e));
+ });
- const switchTab = (tab: 'overview' | 'discovery') => {
- setActiveTab(tab);
- };
+ const handleCustomUrlChange = (url: string) => {
+ setFetchedCustomUrl(url);
+ if (props.onCustomUrlChange) {
+ props.onCustomUrlChange(props.node.id || props.node.name, url);
+ }
+ };
- const isHistoryLocked = () => !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
+ const switchTab = (tab: 'overview' | 'discovery') => {
+ setActiveTab(tab);
+ };
- const diskStats = () => {
- if (!props.node.disk) return { percent: 0, used: 0, total: 0 };
- const total = props.node.disk.total || 0;
- const used = props.node.disk.used || 0;
- return {
- percent: total > 0 ? (used / total) * 100 : 0,
- used: used,
- total: total
- };
+ const isHistoryLocked = () =>
+ !hasFeature('long_term_metrics') && (historyRange() === '30d' || historyRange() === '90d');
+
+ const diskStats = () => {
+ if (!props.node.disk) return { percent: 0, used: 0, total: 0 };
+ const total = props.node.disk.total || 0;
+ const used = props.node.disk.used || 0;
+ return {
+ percent: total > 0 ? (used / total) * 100 : 0,
+ used: used,
+ total: total,
};
+ };
+
+ return (
+ <div class="space-y-3">
+ {/* Tabs */}
+ <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
+ <button
+ onClick={() => switchTab('overview')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'overview'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Overview
+ {activeTab() === 'overview' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ <button
+ onClick={() => switchTab('discovery')}
+ class={`pb-2 text-sm font-medium transition-colors relative ${
+ activeTab() === 'discovery'
+ ? 'text-blue-600 dark:text-blue-400'
+ : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
+ }`}
+ >
+ Discovery
+ {activeTab() === 'discovery' && (
+ <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
+ )}
+ </button>
+ </div>
- return (
- <div class="space-y-3">
- {/* Tabs */}
- <div class="flex items-center gap-6 border-b border-gray-200 dark:border-gray-700 px-1 mb-1">
- <button
- onClick={() => switchTab('overview')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'overview'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
+ {/* Overview Tab */}
+ <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
+ {/* System Info */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ System
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">Node</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 select-all truncate"
+ title={props.node.name}
>
- Overview
- {activeTab() === 'overview' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
- <button
- onClick={() => switchTab('discovery')}
- class={`pb-2 text-sm font-medium transition-colors relative ${activeTab() === 'discovery'
- ? 'text-blue-600 dark:text-blue-400'
- : 'text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200'
- }`}
+ {props.node.name}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">Version</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 truncate"
+ title={props.node.pveVersion}
>
- Discovery
- {activeTab() === 'discovery' && (
- <div class="absolute bottom-0 left-0 right-0 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-t-full" />
- )}
- </button>
+ {props.node.pveVersion}
+ </span>
+ </div>
+ <div class="flex items-center justify-between gap-2 min-w-0">
+ <span class="text-gray-500 dark:text-gray-400 shrink-0">Kernel</span>
+ <span
+ class="font-medium text-gray-700 dark:text-gray-200 truncate"
+ title={props.node.kernelVersion}
+ >
+ {props.node.kernelVersion}
+ </span>
+ </div>
+ <Show when={props.node.uptime}>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Uptime</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {formatUptime(props.node.uptime!)}
+ </span>
+ </div>
+ </Show>
</div>
+ </div>
- {/* Overview Tab */}
- <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(25%-0.75rem)] [&>*]:min-w-[200px] [&>*]:max-w-full [&>*]:overflow-hidden">
- {/* System Info */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">System</div>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">Node</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 select-all truncate" title={props.node.name}>{props.node.name}</span>
- </div>
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">Version</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 truncate" title={props.node.pveVersion}>{props.node.pveVersion}</span>
- </div>
- <div class="flex items-center justify-between gap-2 min-w-0">
- <span class="text-gray-500 dark:text-gray-400 shrink-0">Kernel</span>
- <span class="font-medium text-gray-700 dark:text-gray-200 truncate" title={props.node.kernelVersion}>{props.node.kernelVersion}</span>
- </div>
- <Show when={props.node.uptime}>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Uptime</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{formatUptime(props.node.uptime!)}</span>
- </div>
- </Show>
- </div>
- </div>
-
- {/* Hardware Info */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Hardware</div>
- <div class="space-y-1.5 text-[11px]">
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">CPU Model</span>
- <div class="font-medium text-gray-700 dark:text-gray-200 text-right truncate max-w-[150px]" title={props.node.cpuInfo?.model || 'Unknown'}>
- {props.node.cpuInfo?.model || 'Unknown'}
- </div>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Cores</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">{props.node.cpuInfo?.cores || 0}</span>
- </div>
- <div class="flex items-center justify-between">
- <span class="text-gray-500 dark:text-gray-400">Memory</span>
- <span class="font-medium text-gray-700 dark:text-gray-200">
- {formatBytes(props.node.memory?.total || 0)}
- </span>
- </div>
- </div>
- </div>
-
- {/* Disk Usage */}
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">Root Disk</div>
- <div class="mb-3">
- <div class="flex justify-between text-[10px] mb-1">
- <span class="text-gray-500 dark:text-gray-400">Usage</span>
- <span class="text-gray-700 dark:text-gray-200">
- {formatBytes(diskStats().used)} / {formatBytes(diskStats().total)}
- </span>
- </div>
- <StackedDiskBar
- aggregateDisk={{
- total: diskStats().total,
- used: diskStats().used,
- free: diskStats().total - diskStats().used,
- usage: diskStats().percent / 100
- }}
- />
- </div>
- </div>
+ {/* Hardware Info */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Hardware
+ </div>
+ <div class="space-y-1.5 text-[11px]">
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">CPU Model</span>
+ <div
+ class="font-medium text-gray-700 dark:text-gray-200 text-right truncate max-w-[150px]"
+ title={props.node.cpuInfo?.model || 'Unknown'}
+ >
+ {props.node.cpuInfo?.model || 'Unknown'}
</div>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Cores</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {props.node.cpuInfo?.cores || 0}
+ </span>
+ </div>
+ <div class="flex items-center justify-between">
+ <span class="text-gray-500 dark:text-gray-400">Memory</span>
+ <span class="font-medium text-gray-700 dark:text-gray-200">
+ {formatBytes(props.node.memory?.total || 0)}
+ </span>
+ </div>
+ </div>
+ </div>
+
+ {/* Disk Usage */}
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-gray-700 dark:text-gray-200 mb-2">
+ Root Disk
+ </div>
+ <div class="mb-3">
+ <div class="flex justify-between text-[10px] mb-1">
+ <span class="text-gray-500 dark:text-gray-400">Usage</span>
+ <span class="text-gray-700 dark:text-gray-200">
+ {formatBytes(diskStats().used)} / {formatBytes(diskStats().total)}
+ </span>
+ </div>
+ <StackedDiskBar
+ aggregateDisk={{
+ total: diskStats().total,
+ used: diskStats().used,
+ free: diskStats().total - diskStats().used,
+ usage: diskStats().percent / 100,
+ }}
+ />
+ </div>
+ </div>
+ </div>
- {/* Performance Charts */}
- <div class="mt-3 space-y-3">
- <div class="flex items-center gap-2">
- <svg class="w-3.5 h-3.5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
- <circle cx="12" cy="12" r="10" />
- <path stroke-linecap="round" d="M12 6v6l4 2" />
- </svg>
- <select
- value={historyRange()}
- onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
- class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
- style={{ "background-image": "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")", "background-repeat": "no-repeat", "background-position": "right 6px center" }}
- >
- <option value="1h">Last 1 hour</option>
- <option value="6h">Last 6 hours</option>
- <option value="12h">Last 12 hours</option>
- <option value="24h">Last 24 hours</option>
- <option value="7d">Last 7 days</option>
- <option value="30d">Last 30 days</option>
- <option value="90d">Last 90 days</option>
- </select>
- </div>
+ {/* Performance Charts */}
+ <div class="mt-3 space-y-3">
+ <div class="flex items-center gap-2">
+ <svg
+ class="w-3.5 h-3.5 text-gray-400"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ stroke-width="2"
+ >
+ <circle cx="12" cy="12" r="10" />
+ <path stroke-linecap="round" d="M12 6v6l4 2" />
+ </svg>
+ <select
+ value={historyRange()}
+ onChange={(e) => setHistoryRange(e.currentTarget.value as HistoryTimeRange)}
+ class="text-[11px] font-medium pl-2 pr-6 py-1 rounded-md border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 cursor-pointer focus:ring-1 focus:ring-blue-500 focus:border-blue-500 appearance-none"
+ style={{
+ 'background-image':
+ "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")",
+ 'background-repeat': 'no-repeat',
+ 'background-position': 'right 6px center',
+ }}
+ >
+ <option value="1h">Last 1 hour</option>
+ <option value="6h">Last 6 hours</option>
+ <option value="12h">Last 12 hours</option>
+ <option value="24h">Last 24 hours</option>
+ <option value="7d">Last 7 days</option>
+ <option value="30d">Last 30 days</option>
+ <option value="90d">Last 90 days</option>
+ </select>
+ </div>
- <div class="relative">
- <div class="space-y-3">
- <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="cpu"
- height={120}
- color="#8b5cf6"
- label="CPU"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="memory"
- height={120}
- color="#f59e0b"
- label="Memory"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
- <HistoryChart
- resourceType={metricsResource.type}
- resourceId={metricsResource.id}
- metric="disk"
- height={120}
- color="#10b981"
- label="Disk"
- unit="%"
- range={historyRange()}
- hideSelector={true}
- compact={true}
- hideLock={true}
- />
- </div>
- </div>
- </div>
- {/* Lock Overlay */}
- <Show when={isHistoryLocked()}>
- <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
- <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
- <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
- </svg>
- </div>
- <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">{historyRange() === '30d' ? '30' : '90'}-Day History</h3>
- <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
- Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of historical data retention.
- </p>
- <a
- href="https://pulserelay.pro/pricing"
- target="_blank"
- class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
- >
- Unlock Pro Features
- </a>
- </div>
- </Show>
- </div>
+ <div class="relative">
+ <div class="space-y-3">
+ <div class="flex flex-wrap gap-3 [&>*]:flex-1 [&>*]:basis-[calc(33.333%-0.5rem)] [&>*]:min-w-[250px]">
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="cpu"
+ height={120}
+ color="#8b5cf6"
+ label="CPU"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="memory"
+ height={120}
+ color="#f59e0b"
+ label="Memory"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
</div>
+ <div class="rounded border border-gray-200 bg-white/70 p-3 shadow-sm dark:border-gray-600/70 dark:bg-gray-900/30">
+ <HistoryChart
+ resourceType={metricsResource.type}
+ resourceId={metricsResource.id}
+ metric="disk"
+ height={120}
+ color="#10b981"
+ label="Disk"
+ unit="%"
+ range={historyRange()}
+ hideSelector={true}
+ compact={true}
+ hideLock={true}
+ />
+ </div>
+ </div>
</div>
+ {/* Lock Overlay */}
+ <Show when={isHistoryLocked()}>
+ <div class="absolute inset-0 z-10 flex flex-col items-center justify-center backdrop-blur-sm bg-white/60 dark:bg-gray-900/60 rounded-lg">
+ <div class="bg-indigo-500 rounded-full p-3 shadow-lg mb-3">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="white"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
+ <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
+ </svg>
+ </div>
+ <h3 class="text-lg font-bold text-gray-900 dark:text-white mb-1">
+ {historyRange() === '30d' ? '30' : '90'}-Day History
+ </h3>
+ <p class="text-sm text-gray-600 dark:text-gray-300 text-center max-w-[260px] mb-4">
+ Upgrade to Pulse Pro to unlock {historyRange() === '30d' ? '30' : '90'} days of
+ historical data retention.
+ </p>
+ <a
+ href="https://pulserelay.pro/pricing"
+ target="_blank"
+ class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-medium rounded-md shadow-sm transition-colors"
+ >
+ Unlock Pro Features
+ </a>
+ </div>
+ </Show>
+ </div>
+ </div>
+ </div>
- {/* Discovery Tab */}
- <div class={activeTab() === 'discovery' ? '' : 'hidden'} style={{ "overflow-anchor": "none" }}>
- <Suspense fallback={
- <div class="flex items-center justify-center py-8">
- <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">Loading discovery...</span>
- </div>
- }>
- <DiscoveryTab
- resourceType="host" /* Assuming 'host' type works for PVE nodes discovery, or if backend treats them same */
- hostId={props.node.id || props.node.name}
- resourceId={props.node.id || props.node.name}
- hostname={props.node.name}
- guestId={props.node.id || props.node.name}
- customUrl={fetchedCustomUrl()}
- onCustomUrlChange={handleCustomUrlChange}
- />
- </Suspense>
+ {/* Discovery Tab */}
+ <div
+ class={activeTab() === 'discovery' ? '' : 'hidden'}
+ style={{ 'overflow-anchor': 'none' }}
+ >
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
+ <span class="ml-2 text-sm text-gray-500 dark:text-gray-400">
+ Loading discovery...
+ </span>
</div>
- </div>
- );
+ }
+ >
+ <DiscoveryTab
+ resourceType="host" /* Assuming 'host' type works for PVE nodes discovery, or if backend treats them same */
+ hostId={props.node.id || props.node.name}
+ resourceId={props.node.id || props.node.name}
+ hostname={props.node.name}
+ guestId={props.node.id || props.node.name}
+ customUrl={fetchedCustomUrl()}
+ onCustomUrlChange={handleCustomUrlChange}
+ />
+ </Suspense>
+ </div>
+ </div>
+ );
};
-
diff --git a/frontend-modern/src/hooks/__tests__/useDrawerHistoryRange.test.tsx b/frontend-modern/src/hooks/__tests__/useDrawerHistoryRange.test.tsx
new file mode 100644
index 0000000000..65d3efc671
--- /dev/null
+++ b/frontend-modern/src/hooks/__tests__/useDrawerHistoryRange.test.tsx
@@ -0,0 +1,59 @@
+import { fireEvent, render } from '@solidjs/testing-library';
+import { createEffect, type Component } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+import type { HistoryTimeRange } from '@/api/charts';
+import { useDrawerHistoryRange } from '../useDrawerHistoryRange';
+
+const TestHarness: Component<{ resourceKey: string }> = (props) => {
+ const [historyRange, setHistoryRange] = useDrawerHistoryRange(props.resourceKey);
+
+ createEffect(() => {
+ historyRange();
+ });
+
+ return (
+ <select
+ aria-label="History range"
+ value={historyRange()}
+ onChange={(event) => setHistoryRange(event.currentTarget.value as HistoryTimeRange)}
+ >
+ <option value="1h">Last 1 hour</option>
+ <option value="6h">Last 6 hours</option>
+ <option value="12h">Last 12 hours</option>
+ <option value="24h">Last 24 hours</option>
+ <option value="7d">Last 7 days</option>
+ <option value="30d">Last 30 days</option>
+ <option value="90d">Last 90 days</option>
+ </select>
+ );
+};
+
+describe('useDrawerHistoryRange', () => {
+ beforeEach(() => {
+ window.localStorage.clear();
+ });
+
+ afterEach(() => {
+ window.localStorage.clear();
+ });
+
+ it('preserves the selected range across remounts for the same resource', async () => {
+ const first = render(() => <TestHarness resourceKey="vm:cluster-a:100" />);
+ const select = first.getByLabelText('History range') as HTMLSelectElement;
+
+ await fireEvent.change(select, { target: { value: '7d' } });
+ expect(select.value).toBe('7d');
+
+ first.unmount();
+
+ const second = render(() => <TestHarness resourceKey="vm:cluster-a:100" />);
+ expect((second.getByLabelText('History range') as HTMLSelectElement).value).toBe('7d');
+ });
+
+ it('falls back to 1h when storage contains an invalid range', () => {
+ window.localStorage.setItem('pulse.drawerHistoryRange.host:host-1', 'bogus');
+
+ const view = render(() => <TestHarness resourceKey="host:host-1" />);
+ expect((view.getByLabelText('History range') as HTMLSelectElement).value).toBe('1h');
+ });
+});
diff --git a/frontend-modern/src/hooks/useDrawerHistoryRange.ts b/frontend-modern/src/hooks/useDrawerHistoryRange.ts
new file mode 100644
index 0000000000..f271357e33
--- /dev/null
+++ b/frontend-modern/src/hooks/useDrawerHistoryRange.ts
@@ -0,0 +1,29 @@
+import type { HistoryTimeRange } from '@/api/charts';
+import { usePersistentSignal } from './usePersistentSignal';
+
+const DRAWER_HISTORY_RANGE_PREFIX = 'pulse.drawerHistoryRange';
+
+const allowedHistoryRanges = new Set<HistoryTimeRange>([
+ '1h',
+ '6h',
+ '12h',
+ '24h',
+ '7d',
+ '30d',
+ '90d',
+]);
+
+function normaliseHistoryRange(value: string): HistoryTimeRange {
+ return allowedHistoryRanges.has(value as HistoryTimeRange) ? (value as HistoryTimeRange) : '1h';
+}
+
+export function useDrawerHistoryRange(resourceKey: string) {
+ return usePersistentSignal<HistoryTimeRange>(
+ `${DRAWER_HISTORY_RANGE_PREFIX}.${resourceKey}`,
+ '1h',
+ {
+ deserialize: normaliseHistoryRange,
+ serialize: (value) => value,
+ },
+ );
+}