Add Background Jobs dashboard for admin users

New admin page at /admin/jobs showing:
- PyPI cache job status (pending, in-progress, completed, failed)
- Failed task list with error details
- Retry individual packages or retry all failed
- Auto-refresh every 5 seconds (toggleable)
- Placeholder for future NPM cache jobs

Accessible from admin dropdown menu as "Background Jobs".
This commit is contained in:
Mondo Diaz
2026-02-02 11:26:55 -06:00
parent e0562195df
commit a39b6f098f
6 changed files with 632 additions and 0 deletions

View File

@@ -746,3 +746,43 @@ export async function testUpstreamSource(id: string): Promise<UpstreamSourceTest
});
return handleResponse<UpstreamSourceTestResult>(response);
}
// =============================================================================
// PyPI Cache Jobs API
// =============================================================================
import {
PyPICacheStatus,
PyPICacheTask,
PyPICacheRetryResponse,
} from './types';
export async function getPyPICacheStatus(): Promise<PyPICacheStatus> {
const response = await fetch('/pypi/cache/status', {
credentials: 'include',
});
return handleResponse<PyPICacheStatus>(response);
}
export async function getPyPICacheFailedTasks(limit: number = 50): Promise<PyPICacheTask[]> {
const response = await fetch(`/pypi/cache/failed?limit=${limit}`, {
credentials: 'include',
});
return handleResponse<PyPICacheTask[]>(response);
}
export async function retryPyPICacheTask(packageName: string): Promise<PyPICacheRetryResponse> {
const response = await fetch(`/pypi/cache/retry/${encodeURIComponent(packageName)}`, {
method: 'POST',
credentials: 'include',
});
return handleResponse<PyPICacheRetryResponse>(response);
}
export async function retryAllPyPICacheTasks(): Promise<PyPICacheRetryResponse> {
const response = await fetch('/pypi/cache/retry-all', {
method: 'POST',
credentials: 'include',
});
return handleResponse<PyPICacheRetryResponse>(response);
}