224a53975d
- Introduced isolated coverage tests for ProxyHosts with various scenarios including rendering, bulk apply, and link behavior. - Enhanced existing ProxyHosts coverage tests to include additional assertions and error handling. - Added tests for Uptime component to verify rendering and monitoring toggling functionality. - Created utility functions for setting labels and help texts related to proxy host settings. - Implemented bulk settings application logic with progress tracking and error handling. - Added toast utility tests to ensure callback functionality and ID incrementing. - Improved type safety in test files by using appropriate TypeScript types.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import client from './client';
|
|
|
|
export interface UptimeMonitor {
|
|
id: string;
|
|
upstream_host?: string;
|
|
proxy_host_id?: number;
|
|
remote_server_id?: number;
|
|
name: string;
|
|
type: string;
|
|
url: string;
|
|
interval: number;
|
|
enabled: boolean;
|
|
status: string;
|
|
last_check?: string | null;
|
|
latency: number;
|
|
max_retries: number;
|
|
}
|
|
|
|
export interface UptimeHeartbeat {
|
|
id: number;
|
|
monitor_id: string;
|
|
status: string;
|
|
latency: number;
|
|
message: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export const getMonitors = async () => {
|
|
const response = await client.get<UptimeMonitor[]>('/uptime/monitors');
|
|
return response.data;
|
|
};
|
|
|
|
export const getMonitorHistory = async (id: string, limit: number = 50) => {
|
|
const response = await client.get<UptimeHeartbeat[]>(`/uptime/monitors/${id}/history?limit=${limit}`);
|
|
return response.data;
|
|
};
|
|
|
|
export const updateMonitor = async (id: string, data: Partial<UptimeMonitor>) => {
|
|
const response = await client.put<UptimeMonitor>(`/uptime/monitors/${id}`, data);
|
|
return response.data;
|
|
};
|
|
|
|
export const deleteMonitor = async (id: string) => {
|
|
const response = await client.delete<void>(`/uptime/monitors/${id}`);
|
|
return response.data;
|
|
};
|
|
|
|
export async function syncMonitors(body?: { interval?: number; max_retries?: number }) {
|
|
const res = await client.post('/uptime/sync', body || {});
|
|
return res.data;
|
|
}
|