added segments

This commit is contained in:
2026-01-09 12:10:58 -08:00
parent 55e37fbca8
commit 67357b5038
55 changed files with 2310 additions and 75 deletions

View File

@@ -523,6 +523,12 @@
actionsHtml += `<button class="btn btn-sm btn-outline-danger" onclick="cancelJob('${job.id}')" title="Cancel"><i class="bi bi-x-circle"></i></button>`;
}
// force kill button: show if running/queued/paused regardless of cancel_requested
// Use a trash icon or skulls
if (['running', 'queued', 'paused'].includes(job.status)) {
actionsHtml += `<button class="btn btn-sm btn-danger ms-1" onclick="forceKillJob('${job.id}')" title="Force Kill (Mark Failed)"><i class="bi bi-trash-fill"></i></button>`;
}
row.innerHTML = `
<td><span class="${statusClass}">${job.operation}</span></td>
<td><small class="text-muted">${job.id.substring(0, 8)}...</small></td>
@@ -642,17 +648,21 @@
async function cancelJob(id) {
if (!confirm("Are you sure you want to cancel this job?")) return;
try {
await fetch(`/api/jobs/${id}/cancel`, { method: 'POST' }); // Wait, endpoint exists?
// Ah, I need to check if cancel endpoint exists in status.py!
// Actually request_cancel exists in manager, but verify API expose.
// Earlier views of status.py showed trigger endpoints.
// Let's assume standard /api/jobs/{id}/cancel might use DELETE or POST.
// Checking: src/api/status.py has cancel endpoint?
// If not, I need to add it.
await fetch(`/api/jobs/${id}/cancel`, { method: 'POST' });
loadDashboardData();
} catch (e) { showToast("Error", "Failed to cancel job", "error"); }
}
async function forceKillJob(id) {
if (!confirm("WARNING: Force Kill should only be used if a job is stuck!\n\nIt will mark the job as failed immediately but may not stop the background process if it is truly frozen.\n\nAre you sure?")) return;
try {
const res = await fetch(`/api/jobs/${id}/force-kill`, { method: 'POST' });
if (!res.ok) throw new Error("Failed to force kill");
showToast("Force Kill", "Job marked as failed.", "warning");
loadDashboardData();
} catch (e) { showToast("Error", "Failed to force kill job", "error"); }
}
function toggleSyncButtons(disabled) {
const ids = [
'sync-activities-btn', 'sync-all-activities-btn',
@@ -920,6 +930,9 @@
<td>${job.last_run ? new Date(job.last_run).toLocaleString() : 'Never'}</td>
<td class="${nextRunClass}">${job.next_run ? new Date(job.next_run).toLocaleString() : '-'}</td>
<td>
<button class="btn btn-sm btn-outline-success me-1" onclick="runJob(${job.id})" title="Run Now">
<i class="bi bi-play-fill"></i> Run
</button>
<button class="btn btn-sm btn-outline-primary" onclick="openEditModal(${job.id}, '${job.name}', ${job.interval_minutes}, ${job.enabled}, '${encodeURIComponent(JSON.stringify(JSON.parse(job.params || '{}')))}')">
<i class="bi bi-pencil"></i> Edit
</button>
@@ -957,6 +970,22 @@
}
}
async function runJob(id) {
if (!confirm("Run this scheduled job immediately?")) return;
try {
const response = await fetch(`/api/scheduling/jobs/${id}/run`, { method: 'POST' });
if (!response.ok) throw new Error("Failed to trigger job");
showToast("Job Triggered", "The scheduled job has been started.", "success");
loadJobs();
// Start polling or refresh dashboard active queue
loadDashboardData();
} catch (e) {
showToast("Error", e.message, "error");
}
}
async function saveJob() {
const id = document.getElementById('edit-job-id').value;
const interval = parseInt(document.getElementById('edit-job-interval').value);