.. _frontend-components: ========== Components ========== This page documents the reusable React components in ``frontend/src/components/``. ---- Layout Components ================= :Location: ``src/components/layout/`` Components that define the overall page structure. Layout.tsx ---------- Main layout wrapper that provides the header, sidebar, and content area. .. code-block:: text import { Layout } from '@/components/layout/Layout' // Used in App.tsx as the root route element }> } /> {/* Child routes render in the Outlet */} Structure: .. code-block:: text ┌─────────────────────────────────────────────────┐ │ Header │ ├──────────┬──────────────────────────────────────┤ │ │ │ │ Sidebar │ Content │ │ │ (Outlet) │ │ │ │ └──────────┴──────────────────────────────────────┘ Header.tsx ---------- Top navigation bar with logo, title, and global actions. .. code-block:: text
FUSION
{/* Theme toggle, user menu, etc. */}
Sidebar.tsx ----------- Navigation sidebar with links to all pages. .. code-block:: text const navItems = [ { path: '/', label: 'Runs', icon: PlayIcon }, { path: '/topology', label: 'Topology', icon: NetworkIcon }, { path: '/config', label: 'Config', icon: FileIcon }, { path: '/codebase', label: 'Codebase', icon: CodeIcon }, { path: '/settings', label: 'Settings', icon: SettingsIcon }, ] ---- Run Components ============== :Location: ``src/components/runs/`` Components for displaying and managing simulation runs. RunCard.tsx ----------- Card component displaying a single run in the list view. .. code-block:: text interface RunCardProps { run: Run onClick?: () => void } function RunCard({ run, onClick }: RunCardProps) { return (
{run.name || run.id}
Created: {formatDate(run.created_at)}
) } RunStatusBadge.tsx ------------------ Status indicator badge with appropriate colors. .. code-block:: text interface RunStatusBadgeProps { status: RunStatus } const statusColors = { PENDING: 'bg-yellow-100 text-yellow-800', RUNNING: 'bg-blue-100 text-blue-800', COMPLETED: 'bg-green-100 text-green-800', FAILED: 'bg-red-100 text-red-800', CANCELLED: 'bg-gray-100 text-gray-800', } function RunStatusBadge({ status }: RunStatusBadgeProps) { return ( {status} ) } ProgressChart.tsx ----------------- Visual progress indicator for running simulations. .. code-block:: text interface ProgressChartProps { progress: RunProgress | null } function ProgressChart({ progress }: ProgressChartProps) { if (!progress) return null const percent = progress.percent_complete ?? 0 return (
Erlang {progress.current_erlang} {percent.toFixed(1)}%
) } ---- Topology Components =================== :Location: ``src/components/topology/`` Components for network visualization. NetworkGraph.tsx ---------------- Interactive network graph using D3.js force-directed layout. .. code-block:: text interface NetworkGraphProps { topology: TopologyResponse onNodeClick?: (nodeId: number) => void selectedNode?: number | null } function NetworkGraph({ topology, onNodeClick, selectedNode }: NetworkGraphProps) { const svgRef = useRef(null) useEffect(() => { // D3 force simulation setup const simulation = d3.forceSimulation(topology.nodes) .force('link', d3.forceLink(topology.links)) .force('charge', d3.forceManyBody()) .force('center', d3.forceCenter(width / 2, height / 2)) // Draw nodes and links... }, [topology]) return } Features: - Force-directed layout with draggable nodes - Click to select nodes - Zoom and pan controls - Link highlighting for selected node - Optional utilization coloring UtilizationLegend.tsx --------------------- Color legend for link utilization visualization. .. code-block:: text function UtilizationLegend() { return (
Utilization:
) } ---- Artifact Components =================== :Location: ``src/components/artifacts/`` Components for browsing simulation output files. ArtifactBrowser.tsx ------------------- File browser for simulation artifacts with folder navigation. .. code-block:: text interface ArtifactBrowserProps { runId: string } function ArtifactBrowser({ runId }: ArtifactBrowserProps) { const [currentPath, setCurrentPath] = useState('') const { data: artifacts } = useQuery({ queryKey: ['artifacts', runId, currentPath], queryFn: () => artifactsApi.list(runId, currentPath), }) return (
setCurrentPath(`${currentPath}/${name}`)} onFileClick={(item) => window.open(item.downloadUrl)} />
) } ---- UI Components ============= :Location: ``src/components/ui/`` Generic reusable UI components (buttons, inputs, cards, etc.). These typically follow the shadcn/ui pattern - unstyled, composable components with Tailwind classes. Common Components ----------------- - **Button** - Primary, secondary, outline variants - **Input** - Text input with label and error state - **Select** - Dropdown selection - **Card** - Container with border and shadow - **Badge** - Small status indicators - **Tabs** - Tab navigation component - **Dialog** - Modal dialog - **Toast** - Notification messages Example Usage ------------- .. code-block:: text import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Card, CardHeader, CardContent } from '@/components/ui/card' function MyComponent() { return (

Form Title

) }