'use client' import { useState, useEffect } from 'react' import { CpuChipIcon, ServerIcon, CircleStackIcon, GlobeAltIcon, CheckCircleIcon, ExclamationTriangleIcon, ArrowPathIcon } from '@heroicons/react/24/outline' interface SystemInfo { os: string architecture: string cpu_cores: number memory_mb: number gpus: Array<{ name: string memory: string driver: string type: string }> network: { hostname: string interfaces: string[] public_ip?: string private_ips: string[] docker_bridge?: string } storage: { total_space_gb: number free_space_gb: number mount_path: string } docker: { available: boolean version?: string compose_available: boolean swarm_mode: boolean } } interface SystemDetectionProps { systemInfo: SystemInfo | null configData: any onComplete: (data: any) => void onBack?: () => void isCompleted: boolean } export default function SystemDetection({ systemInfo, configData, onComplete, onBack, isCompleted }: SystemDetectionProps) { const [loading, setLoading] = useState(!systemInfo) const [refreshing, setRefreshing] = useState(false) const [detectedInfo, setDetectedInfo] = useState(systemInfo) useEffect(() => { if (!detectedInfo) { refreshSystemInfo() } }, []) const refreshSystemInfo = async () => { setRefreshing(true) try { const response = await fetch('/api/setup/system') if (response.ok) { const result = await response.json() setDetectedInfo(result.system_info) } } catch (error) { console.error('Failed to detect system info:', error) } finally { setLoading(false) setRefreshing(false) } } const handleContinue = () => { if (detectedInfo) { onComplete({ system: detectedInfo, validated: true }) } } const getStatusColor = (condition: boolean) => { return condition ? 'text-eucalyptus-600' : 'text-red-600' } const getStatusIcon = (condition: boolean) => { return condition ? CheckCircleIcon : ExclamationTriangleIcon } if (loading) { return (

Detecting system configuration...

) } if (!detectedInfo) { return (

System Detection Failed

Unable to detect system configuration. Please try again.

) } return (
{/* System Overview */}

System Overview

Hostname
{detectedInfo.network.hostname}
Operating System
{detectedInfo.os} ({detectedInfo.architecture})
{/* Hardware Information */}
{/* CPU & Memory */}

CPU & Memory

CPU
{detectedInfo.cpu_cores} cores
Memory
{Math.round(detectedInfo.memory_mb / 1024)} GB total
{/* Storage */}

Storage

Disk Space
{detectedInfo.storage.total_space_gb} GB total, {' '} {detectedInfo.storage.free_space_gb} GB available
{/* GPU Information */} {detectedInfo.gpus && detectedInfo.gpus.length > 0 && (

GPU Configuration ({detectedInfo.gpus.length} GPU{detectedInfo.gpus.length !== 1 ? 's' : ''})

{detectedInfo.gpus.map((gpu, index) => (
{gpu.name}
{gpu.type.toUpperCase()} • {gpu.memory} • {gpu.driver}
))}
)} {/* Network Information */}

Network Configuration

Hostname
{detectedInfo.network.hostname}
{detectedInfo.network.private_ips && detectedInfo.network.private_ips.length > 0 && (
Private IP Addresses
{detectedInfo.network.private_ips.map((ip, index) => (
{ip} active
))}
)} {detectedInfo.network.public_ip && (
Public IP
{detectedInfo.network.public_ip}
)}
{/* Software Requirements */}

Software Requirements

{[ { name: 'Docker', installed: detectedInfo.docker.available, version: detectedInfo.docker.version, required: true }, { name: 'Docker Compose', installed: detectedInfo.docker.compose_available, version: undefined, required: false }, { name: 'Docker Swarm', installed: detectedInfo.docker.swarm_mode, version: undefined, required: false } ].map((software, index) => { const StatusIcon = getStatusIcon(software.installed) return (
{software.name}
{software.version && (
Version: {software.version}
)}
{software.required && ( Required )} {software.installed ? 'Installed' : 'Missing'}
) })}
{/* System Validation */}

System Validation

{[ { check: 'Minimum memory (2GB required)', passed: detectedInfo.memory_mb >= 2048, warning: detectedInfo.memory_mb < 4096 }, { check: 'Available disk space (10GB required)', passed: detectedInfo.storage.free_space_gb >= 10 }, { check: 'Docker installed and running', passed: detectedInfo.docker.available } ].map((validation, index) => { const StatusIcon = getStatusIcon(validation.passed) return (
{validation.check} {validation.warning && validation.passed && ( (Warning: Recommend 4GB+) )}
) })}
{/* Action Buttons */}
{onBack && ( )}
) }