import { useEffect, useState } from 'react' import { RefreshCw, AlertCircle, CheckCircle, MinusCircle } from 'lucide-react' import { api } from '../api/client' interface Service { name: string; status: 'running' | 'stopped' | 'failed' | 'unknown'; enabled: boolean } const statusIcon = { running: , stopped: , failed: , unknown: , } export default function Services() { const [services, setServices] = useState([]) const [loading, setLoading] = useState(false) const [acting, setActing] = useState(null) const fetch = async () => { setLoading(true) try { const r = await api.get('/nixserver/services'); setServices(r.data.data) } finally { setLoading(false) } } useEffect(() => { fetch() }, []) const act = async (name: string, action: string) => { setActing(name + action) try { await api.post(`/nixserver/services/${name}`, { action }); fetch() } catch (e: unknown) { alert((e as { response?: { data?: { error?: string } } })?.response?.data?.error ?? 'Failed') } finally { setActing(null) } } return (

Services

Manage system services

{['Service', 'Status', 'Startup', 'Actions'].map(h => ( ))} {services.map(s => ( ))} {!loading && services.length === 0 && ( )}
{h}
{s.name} {statusIcon[s.status]} {s.status} {s.enabled ? 'enabled' : 'disabled'}
{s.status !== 'running' && ( )} {s.status === 'running' && ( )}
No services found
) }