Fix ESC handler, form reset, and scheduler next-run countdown

- Fix ESC key handler to use .modal.show class selector instead of style.display check
- Reset create workflow form fields when opening the create modal
- Show relative countdown (e.g. "in 5m") alongside next run timestamp in scheduler list

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 11:26:48 -04:00
parent 95f6554cc2
commit a596c6075c

View File

@@ -1326,7 +1326,15 @@
scheduleDesc = `Cron: ${s.schedule_value}`;
}
const nextRun = safeDate(s.next_run)?.toLocaleString() ?? 'Not scheduled';
const nextRunDate = safeDate(s.next_run);
const nextRunIn = nextRunDate ? (() => {
const secs = Math.round((nextRunDate - Date.now()) / 1000);
if (secs <= 0) return 'now';
if (secs < 60) return `${secs}s`;
if (secs < 3600) return `${Math.round(secs/60)}m`;
return `${Math.round(secs/3600)}h`;
})() : null;
const nextRun = nextRunDate ? `${nextRunDate.toLocaleString()}${nextRunIn ? ` (in ${nextRunIn})` : ''}` : 'Not scheduled';
const lastRun = safeDate(s.last_run)?.toLocaleString() ?? 'Never';
return `
@@ -2635,6 +2643,10 @@
}
function showCreateWorkflow() {
document.getElementById('workflowName').value = '';
document.getElementById('workflowDescription').value = '';
document.getElementById('workflowDefinition').value = '';
document.getElementById('workflowWebhookUrl').value = '';
document.getElementById('createWorkflowModal').classList.add('show');
}
@@ -3038,10 +3050,8 @@
// Close any open modal on ESC key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
document.querySelectorAll('.modal').forEach(modal => {
if (modal.style.display && modal.style.display !== 'none') {
modal.style.display = 'none';
}
document.querySelectorAll('.modal.show').forEach(modal => {
modal.classList.remove('show');
});
}
});