Add configurable scheduling, UI health/task indicators, and auto-load map with default filters

This commit is contained in:
Viktor Barzin 2026-02-01 17:28:37 +00:00
parent 1c8c3e4657
commit c7ac448f15
18 changed files with 2287 additions and 656 deletions

View file

@ -0,0 +1,74 @@
// Health check service for backend connectivity
export type HealthStatus = 'checking' | 'healthy' | 'unhealthy';
export interface HealthCheckResult {
status: HealthStatus;
latencyMs?: number;
error?: string;
}
/**
* Check backend health by calling the /api/status endpoint
*/
export async function checkBackendHealth(): Promise<HealthCheckResult> {
const startTime = performance.now();
try {
const response = await fetch('/api/status', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
// Short timeout for health checks
signal: AbortSignal.timeout(5000),
});
const latencyMs = Math.round(performance.now() - startTime);
if (!response.ok) {
return {
status: 'unhealthy',
latencyMs,
error: `HTTP ${response.status}`,
};
}
const data = await response.json();
if (data.status === 'OK') {
return {
status: 'healthy',
latencyMs,
};
}
return {
status: 'unhealthy',
latencyMs,
error: 'Unexpected response',
};
} catch (error) {
const latencyMs = Math.round(performance.now() - startTime);
if (error instanceof Error) {
if (error.name === 'TimeoutError' || error.name === 'AbortError') {
return {
status: 'unhealthy',
latencyMs,
error: 'Request timeout',
};
}
return {
status: 'unhealthy',
latencyMs,
error: error.message,
};
}
return {
status: 'unhealthy',
latencyMs,
error: 'Connection failed',
};
}
}