From 1f5c84f3277f3548d60b74aeebcf86ffaeb22451 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 7 Jan 2026 22:36:51 -0500 Subject: [PATCH] Add execution cleanup functionality Changes: - Added DELETE /api/executions/:id endpoint - Added "Clear Completed" button to Executions tab - Deletes all completed and failed executions - Broadcasts execution_deleted event to update all clients - Shows count of deleted executions Co-Authored-By: Claude Sonnet 4.5 --- public/index.html | 33 ++++++++++++++++++++++++++++++--- server.js | 10 ++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index debb6a9..e07db63 100644 --- a/public/index.html +++ b/public/index.html @@ -633,7 +633,8 @@

Execution History

- + +
Loading...
@@ -834,16 +835,42 @@ } } + async function clearCompletedExecutions() { + if (!confirm('Delete all completed and failed executions?')) return; + + try { + const response = await fetch('/api/executions'); + const executions = await response.json(); + + const toDelete = executions.filter(e => e.status === 'completed' || e.status === 'failed'); + + if (toDelete.length === 0) { + alert('No completed or failed executions to delete'); + return; + } + + for (const execution of toDelete) { + await fetch(`/api/executions/${execution.id}`, { method: 'DELETE' }); + } + + alert(`Deleted ${toDelete.length} execution(s)`); + refreshData(); + } catch (error) { + console.error('Error clearing executions:', error); + alert('Error clearing executions'); + } + } + async function executeWorkflow(workflowId, name) { if (!confirm(`Execute workflow: ${name}?`)) return; - + try { const response = await fetch('/api/executions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ workflow_id: workflowId }) }); - + if (response.ok) { const data = await response.json(); alert('Workflow execution started!'); diff --git a/server.js b/server.js index 61b4a19..bd0bce4 100644 --- a/server.js +++ b/server.js @@ -418,6 +418,16 @@ app.get('/api/executions', authenticateSSO, async (req, res) => { } }); +app.delete('/api/executions/:id', authenticateSSO, async (req, res) => { + try { + await pool.query('DELETE FROM executions WHERE id = ?', [req.params.id]); + broadcast({ type: 'execution_deleted', execution_id: req.params.id }); + res.json({ success: true }); + } catch (error) { + res.status(500).json({ error: error.message }); + } +}); + // Health check (no auth required) app.get('/health', async (req, res) => { try {