Add start, stop, and finish job actions
- POST /jobs/{id}/start: modal picks from idle/offline printers,
sets job → printing, printer → printing, logs "Job started on {name}"
- POST /jobs/{id}/stop: job → queued, clears printer_id + started_at,
printer → idle, logs "Job stopped (was on {name})"
- POST /jobs/{id}/finish: job → done, sets finished_at + duration_minutes,
printer → idle, logs "Job finished on {name}"
- Job detail shows Start / Stop+Finish buttons based on current status
- All printers currently printing are excluded from the Start printer picker
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,29 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{# ── Job actions ── #}
|
||||
{% set s = job.status.value %}
|
||||
{% if s == 'queued' %}
|
||||
<div class="mb-4">
|
||||
<button class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#startModal">
|
||||
<i class="bi bi-play-fill me-1"></i>Start Job
|
||||
</button>
|
||||
</div>
|
||||
{% elif s == 'printing' %}
|
||||
<div class="d-flex gap-2 mb-4">
|
||||
<form method="POST" action="/jobs/{{ job.id }}/finish">
|
||||
<button type="submit" class="btn btn-success btn-sm">
|
||||
<i class="bi bi-check-lg me-1"></i>Finish
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" action="/jobs/{{ job.id }}/stop">
|
||||
<button type="submit" class="btn btn-outline-warning btn-sm">
|
||||
<i class="bi bi-stop-fill me-1"></i>Stop
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row g-3 mb-4">
|
||||
|
||||
{# ── Job info ── #}
|
||||
@@ -312,4 +335,41 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── Start Job Modal ── #}
|
||||
{% if job.status.value == 'queued' %}
|
||||
<div class="modal fade" id="startModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark border-secondary">
|
||||
<form method="POST" action="/jobs/{{ job.id }}/start">
|
||||
<div class="modal-header border-secondary">
|
||||
<h6 class="modal-title text-white">Start Job on Printer</h6>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{% if available_printers %}
|
||||
<label class="form-label text-secondary small">Select printer <span class="text-danger">*</span></label>
|
||||
<select name="printer_id" class="form-select bg-dark border-secondary text-white" required>
|
||||
<option value="">— select —</option>
|
||||
{% for p in available_printers %}
|
||||
<option value="{{ p.id }}">{{ p.name }}{% if p.location %} · {{ p.location }}{% endif %} ({{ p.status.value }})</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<p class="text-warning mb-0">
|
||||
<i class="bi bi-exclamation-triangle me-1"></i>All printers are currently busy.
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="modal-footer border-secondary">
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-success btn-sm" {% if not available_printers %}disabled{% endif %}>
|
||||
<i class="bi bi-play-fill me-1"></i>Start
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user