import { useState } from 'react'; import { Link } from 'react-router'; 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, Loader2, CheckCircle, AlertCircle, FileArchive, ArrowLeft, CloudLightning, } from 'lucide-react'; import { useAssetList, useDownloadAsset, useAssetStatus } from '../../services/api/hooks/useAssets'; import type { AssetType } from '../../services/api/types/asset'; export function AssetsPxePage() { const { data, isLoading, error } = useAssetList(); const downloadAsset = useDownloadAsset(); const [selectedVersion, setSelectedVersion] = useState('v1.8.0'); // Select the first schematic by default if available const schematic = data?.schematics?.[0] || null; const schematicId = schematic?.schematic_id || null; const { data: statusData } = useAssetStatus(schematicId); // Get PXE assets (kernel and initramfs) const pxeAssets = schematic?.assets.filter((asset) => asset.type !== 'iso') || []; const handleDownload = async (assetType: AssetType) => { if (!schematicId) return; try { await downloadAsset.mutateAsync({ schematicId, request: { version: selectedVersion, assets: [assetType] }, }); } catch (err) { console.error('Download failed:', err); } }; const handleDownloadAll = async () => { if (!schematicId) return; try { await downloadAsset.mutateAsync({ schematicId, request: { version: selectedVersion, assets: ['kernel', 'initramfs'] }, }); } catch (err) { console.error('Download failed:', err); } }; const getStatusBadge = (downloaded: boolean, downloading?: boolean) => { if (downloading) { return ( Downloading ); } if (downloaded) { return ( Available ); } return ( Missing ); }; const getAssetIcon = (type: string) => { switch (type) { case 'kernel': return ; case 'initramfs': return ; default: return ; } }; const getDownloadProgress = (assetType: AssetType) => { if (!statusData?.progress?.[assetType]) return null; const progress = statusData.progress[assetType]; if (progress?.status === 'downloading' && progress.bytes_downloaded && progress.total_bytes) { const percentage = (progress.bytes_downloaded / progress.total_bytes) * 100; return (
Downloading... {percentage.toFixed(1)}%
); } return null; }; const isAssetDownloading = (assetType: AssetType) => { return statusData?.progress?.[assetType]?.status === 'downloading'; }; return (
{/* Header */}
Wild Cloud / PXE Management
{/* Main Content */}
{/* 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
{error ? (

Error Loading Assets

{(error as Error).message}

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

Boot Assets

{isLoading ? (
) : (
{pxeAssets.map((asset) => (
{getAssetIcon(asset.type)}
{asset.type}
{getStatusBadge(asset.downloaded, isAssetDownloading(asset.type as AssetType))}
{schematic?.version &&
Version: {schematic.version}
} {asset.size &&
Size: {(asset.size / 1024 / 1024).toFixed(2)} MB
} {asset.path && (
{asset.path}
)}
{getDownloadProgress(asset.type as AssetType)}
{!asset.downloaded && !isAssetDownloading(asset.type as AssetType) && ( )}
))}
)}
{/* Download All Button */} {pxeAssets.length > 0 && pxeAssets.some((a) => !a.downloaded) && (
)}
)}
); }