feat: add background backup execution endpoint and job detail UI template
This commit is contained in:
parent
1e972738d4
commit
500d1407cc
17
gui_app.py
17
gui_app.py
@ -898,6 +898,23 @@ def cancel_schedule(jobid):
|
||||
return redirect(url_for('job_detail', jobid=jobid))
|
||||
|
||||
|
||||
@app.route('/job/<jobid>/run', methods=['POST'])
|
||||
@login_required
|
||||
def run_job_now(jobid):
|
||||
info = jobs.get(jobid)
|
||||
if not info:
|
||||
abort(404)
|
||||
if info.get('status') in ('running', 'queued'):
|
||||
flash('Backup is already running or queued.', 'warning')
|
||||
return redirect(url_for('job_detail', jobid=jobid))
|
||||
|
||||
# Start backup execution in a background thread
|
||||
t = threading.Thread(target=run_job_thread, args=(jobid,), daemon=True)
|
||||
t.start()
|
||||
flash('Backup triggered successfully and is running in the background.', 'success')
|
||||
return redirect(url_for('job_detail', jobid=jobid))
|
||||
|
||||
|
||||
# ── Template filter ───────────────────────────────────────────────────────────
|
||||
@app.template_filter('startswith')
|
||||
def startswith_filter(value, prefix):
|
||||
|
||||
@ -142,7 +142,15 @@
|
||||
</div>
|
||||
<div class="topbar-subtitle">Job ID: <span class="mono">{{ job.id }}</span></div>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<div class="topbar-actions" style="display: flex; gap: 8px; align-items: center;">
|
||||
{% if job.status != 'running' and job.status != 'queued' %}
|
||||
<form method="post" action="/job/{{ job.id }}/run" style="margin: 0;">
|
||||
<button class="btn btn-primary btn-sm" type="submit">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 4px;"><polygon points="5 3 19 12 5 21 5 3"/></svg>
|
||||
Run Now
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<a href="/jobs" class="btn btn-ghost btn-sm">
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 6px;"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
|
||||
All Jobs
|
||||
|
||||
@ -167,10 +167,16 @@
|
||||
{{ job.started_fmt }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="job-actions">
|
||||
<div class="job-actions" style="display: flex; gap: 8px;">
|
||||
<a href="/job/{{ job.id }}" class="btn btn-ghost btn-sm">View</a>
|
||||
{% if job.status != 'running' and job.status != 'queued' %}
|
||||
<form method="post" action="/job/{{ job.id }}/run" style="margin: 0;">
|
||||
<button class="btn btn-primary btn-sm" type="submit">Run Now</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if job.schedule_id %}
|
||||
<form method="post" action="/job/{{ job.id }}/cancel-schedule"
|
||||
style="margin: 0;"
|
||||
onsubmit="return confirm('Cancel this schedule?')">
|
||||
<button class="btn btn-danger btn-sm" type="submit">Cancel Schedule</button>
|
||||
</form>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user