import { useState } from 'react'; import { ErrorBoundary } from '../../components'; import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '../../components/ui/card'; import { Button } from '../../components/ui/button'; import { Badge } from '../../components/ui/badge'; import { HardDrive, BookOpen, ExternalLink, Download, Trash2, Loader2, CheckCircle, AlertCircle, FileArchive, } from 'lucide-react'; import { useInstanceContext } from '../../hooks/useInstanceContext'; import { usePxeAssets, useDownloadPxeAsset, useDeletePxeAsset, } from '../../services/api'; import type { PxeAssetType } from '../../services/api'; export function PxePage() { const { currentInstance } = useInstanceContext(); const { data, isLoading, error } = usePxeAssets(currentInstance); const downloadAsset = useDownloadPxeAsset(); const deleteAsset = useDeletePxeAsset(); const [selectedVersion, setSelectedVersion] = useState('v1.8.0'); const [downloadingType, setDownloadingType] = useState(null); const handleDownload = (type: PxeAssetType) => { if (!currentInstance) return; setDownloadingType(type); // Build URL based on asset type let url = ''; if (type === 'kernel') { url = `https://github.com/siderolabs/talos/releases/download/${selectedVersion}/kernel-amd64`; } else if (type === 'initramfs') { url = `https://github.com/siderolabs/talos/releases/download/${selectedVersion}/initramfs-amd64.xz`; } downloadAsset.mutate( { instanceName: currentInstance, request: { type, version: selectedVersion, url }, }, { onSettled: () => setDownloadingType(null), } ); }; const handleDelete = (type: PxeAssetType) => { if (!currentInstance) return; if (confirm(`Are you sure you want to delete the ${type} asset?`)) { deleteAsset.mutate({ instanceName: currentInstance, type }); } }; const getStatusBadge = (status?: string) => { // Default to 'missing' if status is undefined const statusValue = status || 'missing'; const variants: Record = { available: 'success', missing: 'secondary', downloading: 'default', error: 'destructive', }; const icons: Record = { available: , missing: , downloading: , error: , }; return ( {icons[statusValue]} {statusValue.charAt(0).toUpperCase() + statusValue.slice(1)} ); }; const getAssetIcon = (type: string) => { switch (type) { case 'kernel': return ; case 'initramfs': return ; case 'iso': return ; default: return ; } }; return (
{/* Educational Intro Section */}

What is PXE Boot?

PXE (Preboot Execution Environment) is like having a "network installer" that can set up computers without needing USB drives or DVDs. When you turn on a computer, instead of booting from its hard drive, it can boot from the network and automatically install an operating system or run diagnostics.

This is especially useful for setting up multiple computers in your cloud infrastructure. PXE can automatically install and configure the same operating system on many machines, making it easy to expand your personal cloud.

PXE Configuration Manage PXE boot assets and network boot configuration
{!currentInstance ? (

No Instance Selected

Please select or create an instance to manage PXE assets.

) : error ? (

Error Loading Assets

{(error as Error).message}

) : (
{/* Version Selection */}
{/* Assets List */}

Boot Assets

{isLoading ? (
) : (
{data?.assets.filter((asset) => asset.type !== 'iso').map((asset) => (
{getAssetIcon(asset.type)}
{asset.type}
{getStatusBadge(asset.status)}
{asset.version &&
Version: {asset.version}
} {asset.size &&
Size: {asset.size}
} {asset.path && (
{asset.path}
)} {asset.error && (
{asset.error}
)}
{asset.status !== 'available' && asset.status !== 'downloading' && ( )} {asset.status === 'available' && ( )}
))}
)}
{/* Download All Button */} {data?.assets && data.assets.some((a) => a.status !== 'available') && (
)}
)}
); }