Add job brackets for grouping multi-part or repeated jobs
- JobBracket model: name, customer, notes
- Migration 0006: job_brackets table + bracket_id FK on print_jobs
- /brackets: list with per-bracket progress bar
- /brackets/{id}: detail with jobs table + Add Job(s) modal (quantity field
creates N identical jobs in one shot, each with its own UUID and log entry)
- /jobs Add Job modal: optional bracket selector
- Sidebar: Brackets nav item added
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
<li><a href="/" class="nav-link {% if active == 'dashboard' %}active{% endif %}"><i class="bi bi-speedometer2 me-2"></i>Dashboard</a></li>
|
||||
<li><a href="/printers" class="nav-link {% if active == 'printers' %}active{% endif %}"><i class="bi bi-printer me-2"></i>Printers</a></li>
|
||||
<li><a href="/jobs" class="nav-link {% if active == 'jobs' %}active{% endif %}"><i class="bi bi-list-task me-2"></i>Jobs</a></li>
|
||||
<li><a href="/brackets" class="nav-link {% if active == 'brackets' %}active{% endif %}"><i class="bi bi-collection me-2"></i>Brackets</a></li>
|
||||
<li><a href="/filaments" class="nav-link {% if active == 'filaments' %}active{% endif %}"><i class="bi bi-record-circle me-2"></i>Filaments</a></li>
|
||||
<li><a href="/todos" class="nav-link {% if active == 'todos' %}active{% endif %}"><i class="bi bi-check2-square me-2"></i>To-Do</a></li>
|
||||
<li><a href="/pricing" class="nav-link {% if active == 'pricing' %}active{% endif %}"><i class="bi bi-currency-euro me-2"></i>Pricing</a></li>
|
||||
|
||||
162
app/templates/bracket_detail.html
Normal file
162
app/templates/bracket_detail.html
Normal file
@@ -0,0 +1,162 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ bracket.name }} — POPS{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set total = bracket.jobs | length %}
|
||||
{% set done = bracket.jobs | selectattr('status.value', 'equalto', 'done') | list | length %}
|
||||
{% set printing = bracket.jobs | selectattr('status.value', 'equalto', 'printing') | list | length %}
|
||||
{% set pct = (done / total * 100) | int if total else 0 %}
|
||||
|
||||
<div class="d-flex align-items-center gap-3 mb-4">
|
||||
<a href="/brackets" class="text-secondary text-decoration-none"><i class="bi bi-arrow-left"></i></a>
|
||||
<div class="flex-grow-1">
|
||||
<h5 class="text-white mb-0">{{ bracket.name }}</h5>
|
||||
{% if bracket.customer %}<small class="text-secondary">{{ bracket.customer }}</small>{% endif %}
|
||||
</div>
|
||||
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#addJobsModal">
|
||||
<i class="bi bi-plus-lg me-1"></i>Add Job(s)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{# ── Progress ── #}
|
||||
{% if total %}
|
||||
<div class="card mb-4 p-3">
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<span class="text-secondary small">{{ done }} done · {{ printing }} printing · {{ total - done - printing }} queued</span>
|
||||
<span class="text-secondary small">{{ pct }}%</span>
|
||||
</div>
|
||||
<div class="progress" style="height:8px">
|
||||
<div class="progress-bar bg-success" style="width:{{ pct }}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# ── Jobs table ── #}
|
||||
<div class="card">
|
||||
{% if bracket.jobs %}
|
||||
<table class="table table-dark table-hover mb-0 align-middle" style="font-size:.875rem">
|
||||
<thead>
|
||||
<tr class="text-secondary small">
|
||||
<th class="fw-normal">UUID</th>
|
||||
<th class="fw-normal">File</th>
|
||||
<th class="fw-normal">Material</th>
|
||||
<th class="fw-normal">Printer</th>
|
||||
<th class="fw-normal">Status</th>
|
||||
<th class="fw-normal text-end">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for j in bracket.jobs %}
|
||||
<tr>
|
||||
<td class="font-monospace text-secondary" style="font-size:.75rem">
|
||||
{{ j.job_uuid[:8] if j.job_uuid else '—' }}
|
||||
</td>
|
||||
<td class="text-white">{{ j.file_name or j.name }}</td>
|
||||
<td class="text-secondary">
|
||||
{% if j.filament %}{{ j.filament.material.value }}{% if j.filament.color %} · {{ j.filament.color }}{% endif %}{% else %}—{% endif %}
|
||||
</td>
|
||||
<td class="text-secondary">{{ j.printer.name if j.printer else '—' }}</td>
|
||||
<td>
|
||||
{% set s = j.status.value %}
|
||||
{% if s == 'printing' %}<span class="badge bg-primary">printing</span>
|
||||
{% elif s == 'done' %}<span class="badge bg-success">done</span>
|
||||
{% elif s == 'failed' %}<span class="badge bg-danger">failed</span>
|
||||
{% elif s == 'cancelled' %}<span class="badge bg-warning text-dark">cancelled</span>
|
||||
{% else %}<span class="badge bg-secondary">queued</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-secondary text-end">{{ j.created_at.strftime('%d.%m %H:%M') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="card-body text-secondary">No jobs in this bracket yet.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{# ── Add Jobs Modal ── #}
|
||||
<div class="modal fade" id="addJobsModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content bg-dark border-secondary">
|
||||
<form method="POST" action="/brackets/{{ bracket.id }}/jobs" enctype="multipart/form-data">
|
||||
<div class="modal-header border-secondary">
|
||||
<h6 class="modal-title text-white">Add Job(s) to Bracket</h6>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body d-flex flex-column gap-3">
|
||||
|
||||
{# STL file #}
|
||||
<div>
|
||||
<label class="form-label text-secondary small">STL / File</label>
|
||||
<ul class="nav nav-pills mb-2" role="tablist">
|
||||
<li class="nav-item">
|
||||
<button class="nav-link active py-1 px-3" style="font-size:.8rem"
|
||||
data-bs-toggle="pill" data-bs-target="#bUploadPane" type="button">
|
||||
<i class="bi bi-upload me-1"></i>Upload
|
||||
</button>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<button class="nav-link py-1 px-3" style="font-size:.8rem"
|
||||
data-bs-toggle="pill" data-bs-target="#bLibraryPane" type="button">
|
||||
<i class="bi bi-folder2-open me-1"></i>Library
|
||||
<span class="badge bg-secondary ms-1">{{ stl_files | length }}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade show active" id="bUploadPane">
|
||||
<input type="file" name="stl_file"
|
||||
class="form-control bg-dark border-secondary text-white"
|
||||
accept=".stl,.3mf,.gcode">
|
||||
</div>
|
||||
<div class="tab-pane fade" id="bLibraryPane">
|
||||
{% if stl_files %}
|
||||
<select name="stl_select" class="form-select bg-dark border-secondary text-white">
|
||||
<option value="">— select file —</option>
|
||||
{% for f in stl_files %}<option value="{{ f }}">{{ f }}</option>{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<p class="text-secondary small mb-0">No files in library yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary small">Material & Color</label>
|
||||
<select name="filament_id" class="form-select bg-dark border-secondary text-white">
|
||||
<option value="">— none —</option>
|
||||
{% for f in filaments %}
|
||||
<option value="{{ f.id }}">{{ f.material.value }}{% if f.color %} · {{ f.color }}{% endif %}{% if f.brand %} ({{ f.brand }}){% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary small">
|
||||
Quantity
|
||||
<span class="text-secondary fw-normal">(copies to create)</span>
|
||||
</label>
|
||||
<input type="number" name="quantity"
|
||||
class="form-control bg-dark border-secondary text-white"
|
||||
value="1" min="1" max="500">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Notes</label>
|
||||
<textarea name="notes" class="form-control bg-dark border-secondary text-white"
|
||||
rows="2" placeholder="Optional notes (applied to all copies)"></textarea>
|
||||
</div>
|
||||
|
||||
</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-primary btn-sm">Add Jobs</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
87
app/templates/brackets.html
Normal file
87
app/templates/brackets.html
Normal file
@@ -0,0 +1,87 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Brackets — POPS{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex align-items-center justify-content-between mb-4">
|
||||
<h5 class="text-white mb-0">Job Brackets</h5>
|
||||
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#addBracketModal">
|
||||
<i class="bi bi-plus-lg me-1"></i>New Bracket
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
{% if brackets %}
|
||||
<table class="table table-dark table-hover mb-0 align-middle">
|
||||
<thead>
|
||||
<tr class="text-secondary small">
|
||||
<th class="fw-normal">Name</th>
|
||||
<th class="fw-normal">Customer</th>
|
||||
<th class="fw-normal">Progress</th>
|
||||
<th class="fw-normal text-end">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for b in brackets %}
|
||||
{% set total = b.jobs | length %}
|
||||
{% set done = b.jobs | selectattr('status.value', 'equalto', 'done') | list | length %}
|
||||
{% set pct = (done / total * 100) | int if total else 0 %}
|
||||
<tr>
|
||||
<td><a href="/brackets/{{ b.id }}" class="text-white text-decoration-none fw-medium">{{ b.name }}</a></td>
|
||||
<td class="text-secondary">{{ b.customer or '—' }}</td>
|
||||
<td style="min-width:200px">
|
||||
{% if total %}
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="progress flex-grow-1" style="height:6px">
|
||||
<div class="progress-bar bg-success" style="width:{{ pct }}%"></div>
|
||||
</div>
|
||||
<span class="text-secondary small">{{ done }}/{{ total }}</span>
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="text-secondary small">no jobs</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-secondary small text-end">{{ b.created_at.strftime('%d.%m.%Y') }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="card-body text-secondary">No brackets yet.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{# ── Create Bracket Modal ── #}
|
||||
<div class="modal fade" id="addBracketModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark border-secondary">
|
||||
<form method="POST" action="/brackets">
|
||||
<div class="modal-header border-secondary">
|
||||
<h6 class="modal-title text-white">New Job Bracket</h6>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body d-flex flex-column gap-3">
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Name <span class="text-danger">*</span></label>
|
||||
<input type="text" name="name" class="form-control bg-dark border-secondary text-white"
|
||||
placeholder="e.g. Chair set, 30× phone stand" required autofocus>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Customer</label>
|
||||
<input type="text" name="customer" class="form-control bg-dark border-secondary text-white"
|
||||
placeholder="Customer name or reference">
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Notes</label>
|
||||
<textarea name="notes" class="form-control bg-dark border-secondary text-white"
|
||||
rows="2" placeholder="Optional notes"></textarea>
|
||||
</div>
|
||||
</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-primary btn-sm">Create</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -152,6 +152,16 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Bracket <span class="text-secondary fw-normal">(optional)</span></label>
|
||||
<select name="bracket_id" class="form-select bg-dark border-secondary text-white">
|
||||
<option value="">— none —</option>
|
||||
{% for b in brackets %}
|
||||
<option value="{{ b.id }}">{{ b.name }}{% if b.customer %} · {{ b.customer }}{% endif %}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="form-label text-secondary small">Notes</label>
|
||||
<textarea name="notes" class="form-control bg-dark border-secondary text-white"
|
||||
|
||||
Reference in New Issue
Block a user