import { useCallback } from 'react'; import { Search, Loader2, Network, HardDrive, Box, Database, Link, ArrowLeftRight, ArrowUpDown, Router, Wifi, Monitor, Container, FolderTree, Folder, Settings } from 'lucide-react'; import { useShallow } from 'zustand/react/shallow'; import { useTopologyStore, Orientation, StatusFilter } from '../store/topologyStore'; import { ViewMode, NodeType } from '../types'; import { getNodeColor } from '../utils/colors'; interface HeaderProps { onRefresh?: () => Promise; isLoading?: boolean; } const viewModes: { mode: ViewMode; label: string; icon: React.ReactNode }[] = [ { mode: 'full', label: 'Full', icon: }, { mode: 'network', label: 'Network', icon: }, { mode: 'host', label: 'Hosts', icon: }, { mode: 'service', label: 'Services', icon: }, { mode: 'filesystem', label: 'Files', icon: }, ]; const orientations: { value: Orientation; label: string; icon: React.ReactNode }[] = [ { value: 'LR', label: 'Left to Right', icon: }, { value: 'TB', label: 'Top to Bottom', icon: }, ]; const nodeTypeFilters: { type: NodeType; icon: React.ReactNode }[] = [ { type: 'gateway', icon: }, { type: 'vlan', icon: }, { type: 'wifi', icon: }, { type: 'host_physical', icon: }, { type: 'host_vm', icon: }, { type: 'host_container', icon: }, { type: 'service', icon: }, { type: 'volume', icon: }, { type: 'mount', icon: }, { type: 'path', icon: }, ]; export default function Header({ onRefresh, isLoading: externalLoading }: HeaderProps) { const { viewMode, setViewMode, orientation, setOrientation, searchQuery, setSearchQuery, typeFilters, toggleTypeFilter, statusFilter, setStatusFilter, toggleLeftPanel, toggleRightPanel, leftPanelOpen, rightPanelOpen, isLoading: storeLoading, pollInterval, setPollInterval } = useTopologyStore(useShallow((s) => ({ viewMode: s.viewMode, setViewMode: s.setViewMode, orientation: s.orientation, setOrientation: s.setOrientation, searchQuery: s.searchQuery, setSearchQuery: s.setSearchQuery, typeFilters: s.typeFilters, toggleTypeFilter: s.toggleTypeFilter, statusFilter: s.statusFilter, setStatusFilter: s.setStatusFilter, toggleLeftPanel: s.toggleLeftPanel, toggleRightPanel: s.toggleRightPanel, leftPanelOpen: s.leftPanelOpen, rightPanelOpen: s.rightPanelOpen, isLoading: s.isLoading, pollInterval: s.pollInterval, setPollInterval: s.setPollInterval, }))); const loading = externalLoading ?? storeLoading; const handleRefresh = useCallback(async () => { if (onRefresh) { await onRefresh(); } }, [onRefresh]); return (

Homelab Topology

{viewModes.map(({ mode, label, icon }) => ( ))}
{nodeTypeFilters.map(({ type, icon }) => { const isActive = typeFilters.includes(type); const color = getNodeColor(type); return ( ); })}
); }