Add services status view with polling and control actions
CI / basic-check (push) Has been cancelled
CI / basic-check (push) Has been cancelled
This commit is contained in:
+16
-3
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user