diff --git a/orchestrator/package.json b/orchestrator/package.json index 01b7450..50f6289 100644 --- a/orchestrator/package.json +++ b/orchestrator/package.json @@ -13,6 +13,8 @@ "build:client": "vite build", "start": "node dist/server/index.js", "db:migrate": "tsx src/server/db/migrate.ts", + "db:clear": "tsx src/server/db/clear.ts", + "db:drop": "tsx src/server/db/clear.ts --drop", "pipeline:run": "tsx src/server/pipeline/run.ts" }, "dependencies": { @@ -40,4 +42,4 @@ "typescript": "^5.7.2", "vite": "^6.0.3" } -} +} \ No newline at end of file diff --git a/orchestrator/src/client/App.tsx b/orchestrator/src/client/App.tsx index d39096a..43bb021 100644 --- a/orchestrator/src/client/App.tsx +++ b/orchestrator/src/client/App.tsx @@ -135,11 +135,24 @@ export const App: React.FC = () => { } }; + // Clear database + const handleClearDatabase = async () => { + try { + const result = await api.clearDatabase(); + addToast(`Database cleared! Deleted ${result.jobsDeleted} jobs.`, 'success'); + loadJobs(); + } catch (error) { + const message = error instanceof Error ? error.message : 'Failed to clear database'; + addToast(message, 'error'); + } + }; + return ( <>
diff --git a/orchestrator/src/client/api/client.ts b/orchestrator/src/client/api/client.ts index 0d470e3..b166bc6 100644 --- a/orchestrator/src/client/api/client.ts +++ b/orchestrator/src/client/api/client.ts @@ -89,3 +89,18 @@ export async function runPipeline(config?: { body: JSON.stringify(config || {}), }); } + +// Database API +export async function clearDatabase(): Promise<{ + message: string; + jobsDeleted: number; + runsDeleted: number; +}> { + return fetchApi<{ + message: string; + jobsDeleted: number; + runsDeleted: number; + }>('/database', { + method: 'DELETE', + }); +} diff --git a/orchestrator/src/client/components/Header.tsx b/orchestrator/src/client/components/Header.tsx index 9890504..b45ec1a 100644 --- a/orchestrator/src/client/components/Header.tsx +++ b/orchestrator/src/client/components/Header.tsx @@ -3,11 +3,12 @@ */ import React from 'react'; -import { RocketIcon, PlayIcon, RefreshIcon } from './Icons'; +import { RocketIcon, PlayIcon, RefreshIcon, TrashIcon } from './Icons'; interface HeaderProps { onRunPipeline: () => void; onRefresh: () => void; + onClearDatabase: () => void; isPipelineRunning: boolean; isLoading: boolean; } @@ -15,9 +16,16 @@ interface HeaderProps { export const Header: React.FC = ({ onRunPipeline, onRefresh, + onClearDatabase, isPipelineRunning, isLoading, }) => { + const handleClearDatabase = () => { + if (window.confirm('Are you sure you want to clear all jobs from the database? This cannot be undone.')) { + onClearDatabase(); + } + }; + return (
@@ -30,6 +38,16 @@ export const Header: React.FC = ({
+ +