From 04fb84c44a75bdc4fdae6cb14b269835e3173afb Mon Sep 17 00:00:00 2001 From: Rizqi Date: Mon, 22 Jun 2026 02:43:44 +0700 Subject: [PATCH] feat: add backup jobs dashboard and job deletion functionality --- gui_app.py | 33 +++++++++++++++++++++++++++++++++ templates/job_detail.html | 8 ++++++++ templates/jobs.html | 12 +++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gui_app.py b/gui_app.py index 5ea841e..9f5b848 100644 --- a/gui_app.py +++ b/gui_app.py @@ -1023,6 +1023,39 @@ def run_job_now(jobid): return redirect(url_for('job_detail', jobid=jobid)) +@app.route('/job//delete', methods=['POST']) +@login_required +def delete_job(jobid): + info = jobs.get(jobid) + if not info: + abort(404) + + # Cancel schedule first if it exists + sched_id = info.get('schedule_id') + if sched_id and scheduler: + try: + scheduler.remove_job(sched_id) + except Exception: + pass + + # Remove from jobs dict + with jobs_db_lock: + jobs.pop(jobid, None) + save_jobs_db() + + # Remove the job directory containing the log file + import shutil + job_dir = JOBS_DIR / jobid + if job_dir.exists(): + try: + shutil.rmtree(job_dir) + except Exception as e: + print(f"ERROR: Failed to delete job directory {job_dir}: {e}", file=sys.stderr) + + flash('Job and its schedule deleted successfully.', 'success') + return redirect(url_for('list_jobs')) + + # ── Template filter ─────────────────────────────────────────────────────────── @app.template_filter('startswith') def startswith_filter(value, prefix): diff --git a/templates/job_detail.html b/templates/job_detail.html index aa3ffde..33ad168 100644 --- a/templates/job_detail.html +++ b/templates/job_detail.html @@ -150,6 +150,14 @@ Run Now +
+ +
{% endif %} diff --git a/templates/jobs.html b/templates/jobs.html index 781a025..f874a9c 100644 --- a/templates/jobs.html +++ b/templates/jobs.html @@ -178,7 +178,17 @@
- + +
+ {% endif %} + {% if job.status != 'running' and job.status != 'queued' %} +
+
{% endif %}