diff --git a/containers/libreportal/frontend/js/components/tasks/tasks-manager.js b/containers/libreportal/frontend/js/components/tasks/tasks-manager.js index 395b824..4252c10 100755 --- a/containers/libreportal/frontend/js/components/tasks/tasks-manager.js +++ b/containers/libreportal/frontend/js/components/tasks/tasks-manager.js @@ -2318,38 +2318,116 @@ class TasksManager { } async clearAllTasks() { - // Use the confirmation dialog system if available, otherwise fallback to confirm + const result = await this._showClearAllModal(this.tasks); + if (!result || !result.confirmed) return false; + await this.performClearAll({ cancelRunning: result.cancelRunning }); + return true; + } + + // Confirmation modal for clearAllTasks. Same openEoModal shape as + // _showDeleteTaskModal so visual identity matches every other destructive + // confirmation (Uninstall, Delete Task, …). Adds a "Cancel running tasks + // too" toggle (off by default) — when off, running/queued tasks are + // skipped; when on, they're cancelled first then deleted. + // Resolves {confirmed, cancelRunning}. Cancel/backdrop/close → confirmed=false. + _showClearAllModal(tasks) { return new Promise((resolve) => { - if (window.showConfirmation) { - window.showConfirmation( - 'Clear All Tasks', - 'Are you sure you want to clear all tasks? This will delete all task history and cannot be undone.', - () => { - this.performClearAll(); - resolve(true); + const escHtml = (s) => String(s == null ? '' : s) + .replace(/&/g, '&').replace(//g, '>'); + + const isActive = (t) => t && (t.status === 'running' || t.status === 'queued' || t.status === 'pending'); + const total = (tasks || []).length; + const runningCount = (tasks || []).filter(isActive).length; + const terminalCount = total - runningCount; + + const bodyHtml = ` +
This cannot be undone
+All selected tasks and their logs will be permanently removed.
+