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',
};
}
}

View file

@ -0,0 +1,43 @@
// Task service for fetching task status
import type { User } from 'oidc-client-ts';
import type { TaskStatusResponse } from '@/types';
import { apiRequest } from './apiClient';
import { API_ENDPOINTS } from '@/constants';
export interface CancelTaskResponse {
success: boolean;
message: string;
}
/**
* Fetch all active tasks for the current user
*/
export async function fetchTasksForUser(user: User): Promise<string[]> {
return apiRequest<string[]>(user, API_ENDPOINTS.TASKS_FOR_USER);
}
/**
* Fetch the status of a specific task
*/
export async function fetchTaskStatus(
user: User,
taskId: string
): Promise<TaskStatusResponse> {
return apiRequest<TaskStatusResponse>(user, API_ENDPOINTS.TASK_STATUS, {
params: { task_id: taskId },
});
}
/**
* Cancel a running task
*/
export async function cancelTask(
user: User,
taskId: string
): Promise<CancelTaskResponse> {
return apiRequest<CancelTaskResponse>(user, API_ENDPOINTS.CANCEL_TASK, {
method: 'POST',
params: { task_id: taskId },
});
}