'use client'; import { Play, Square, RotateCw, Activity } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { ProcessInfo, ProcessStateCode, getProcessStateClass, formatUptime, canStartProcess, canStopProcess } from '@/lib/supervisor/types'; import { useStartProcess, useStopProcess, useRestartProcess } from '@/lib/hooks/useSupervisor'; import { cn } from '@/lib/utils/cn'; interface ProcessCardProps { process: ProcessInfo; } export function ProcessCard({ process }: ProcessCardProps) { const startMutation = useStartProcess(); const stopMutation = useStopProcess(); const restartMutation = useRestartProcess(); const fullName = `${process.group}:${process.name}`; const isLoading = startMutation.isPending || stopMutation.isPending || restartMutation.isPending; const uptime = process.state === 20 ? formatUptime(process.start, process.now) : 'Not running'; const handleStart = () => startMutation.mutate({ name: fullName }); const handleStop = () => stopMutation.mutate({ name: fullName }); const handleRestart = () => restartMutation.mutate(fullName); return (
{process.name}

{process.group}

{process.statename}
{/* Metrics */}
PID: {process.pid || 'N/A'}
Uptime: {uptime}
{process.exitstatus !== 0 && (
Exit Status: {process.exitstatus}
)}
{/* Error Description */} {process.spawnerr && (
{process.spawnerr}
)} {/* Actions */}
{/* Description */} {process.description && process.description !== 'pid ' + process.pid && (

{process.description}

)}
); }