Add services status view with polling and control actions
CI / basic-check (push) Has been cancelled

This commit is contained in:
Perplexity Bot
2026-08-03 22:22:59 +00:00
parent be55c35c3a
commit 186aae1b5f
10 changed files with 204 additions and 25 deletions
+16 -3
View File
@@ -1,9 +1,8 @@
import type { NetObject } from '../types';
import type { NetObject, ServiceInfo } from '../types';
const API_BASE = '/api/v1';
const AGENT_BASE = 'http://127.0.0.1:8001';
export async function fetchObjects(): Promise<NetObject[]> {
// Mock data for now
return [
{ id: '1', name: 'Site HQ', slug: 'site-hq', type: 'site', status: 'active' },
{ id: '2', name: 'Rack A', slug: 'rack-a', type: 'rack', status: 'active' },
@@ -12,3 +11,17 @@ export async function fetchObjects(): Promise<NetObject[]> {
{ id: '5', name: 'Firewall Edge', slug: 'firewall-edge', type: 'firewall', status: 'active' },
];
}
export async function fetchServices(): Promise<ServiceInfo[]> {
const res = await fetch(`${AGENT_BASE}/services`);
if (!res.ok) throw new Error('Impossibile leggere lo stato dei servizi');
return res.json();
}
export async function serviceAction(name: string, action: 'start' | 'stop' | 'restart') {
const res = await fetch(`${AGENT_BASE}/services/${encodeURIComponent(name)}/${action}`, {
method: 'POST',
});
if (!res.ok) throw new Error(`Azione ${action} fallita su ${name}`);
return res.json();
}