import { useEffect, useState } from 'react' import { apiRequest } from '../api/client' import { Play, Square, RotateCw, Loader2 } from 'lucide-react' interface Service { id: string name: string unit: string status: string } export function ServicesPage() { const [services, setServices] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState('') const [actionId, setActionId] = useState(null) const load = () => { setLoading(true) apiRequest<{ services: Service[] }>('/service/list') .then((data) => setServices(data.services || [])) .catch((err) => setError(err.message)) .finally(() => setLoading(false)) } useEffect(() => { load() }, []) const handleStart = (id: string) => { setActionId(id) apiRequest<{ status: boolean }>(`/service/${id}/start`, { method: 'POST' }) .then(load) .catch((err) => setError(err.message)) .finally(() => setActionId(null)) } const handleStop = (id: string) => { setActionId(id) apiRequest<{ status: boolean }>(`/service/${id}/stop`, { method: 'POST' }) .then(load) .catch((err) => setError(err.message)) .finally(() => setActionId(null)) } const handleRestart = (id: string) => { setActionId(id) apiRequest<{ status: boolean }>(`/service/${id}/restart`, { method: 'POST' }) .then(load) .catch((err) => setError(err.message)) .finally(() => setActionId(null)) } const isActive = (status: string) => status === 'active' || status === 'activating' if (loading) return
Loading...
return (

Services

{error && (
{error}
)}
Control system services via systemctl. Requires panel to run with sufficient privileges.
{services.map((s) => ( ))}
Service Unit Status Actions
{s.name} {s.unit} {s.status} {isActive(s.status) ? ( <> ) : ( )}
) }