diff --git a/public/index.html b/public/index.html index 9b5fe65..e75f9eb 100644 --- a/public/index.html +++ b/public/index.html @@ -1085,7 +1085,21 @@ html += formatLogEntry(log); }); } - + + // Add action buttons + html += '
'; + + // Re-run button (only for quick commands with command in logs) + const commandLog = execution.logs?.find(l => l.action === 'command_sent'); + if (commandLog && commandLog.command) { + html += ``; + } + + // Download logs button + html += ``; + + html += '
'; + document.getElementById('executionDetails').innerHTML = html; const modal = document.getElementById('viewExecutionModal'); modal.dataset.executionId = executionId; @@ -1169,6 +1183,52 @@ return `${days}d ago`; } + async function rerunCommand(command, workerId) { + if (!confirm(`Re-run command: ${command}?`)) return; + + closeModal('viewExecutionModal'); + switchTab('quickcommand'); + + // Set the worker and command + document.getElementById('quickWorkerSelect').value = workerId; + document.getElementById('quickCommand').value = command; + + // Scroll to the command field + document.getElementById('quickCommand').scrollIntoView({ behavior: 'smooth' }); + } + + async function downloadExecutionLogs(executionId) { + try { + const response = await fetch(`/api/executions/${executionId}`); + const execution = await response.json(); + + // Create downloadable JSON + const data = { + execution_id: executionId, + workflow_name: execution.workflow_name || '[Quick Command]', + status: execution.status, + started_by: execution.started_by, + started_at: execution.started_at, + completed_at: execution.completed_at, + logs: execution.logs + }; + + // Create blob and download + const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `execution-${executionId}-${new Date().toISOString().split('T')[0]}.json`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + } catch (error) { + console.error('Error downloading logs:', error); + alert('Error downloading execution logs'); + } + } + async function respondToPrompt(executionId, response) { try { const res = await fetch(`/api/executions/${executionId}/respond`, {