diff --git a/app/routers/ui.py b/app/routers/ui.py index 5dd8f68..1dc1f05 100644 --- a/app/routers/ui.py +++ b/app/routers/ui.py @@ -308,58 +308,9 @@ def create_bracket( return RedirectResponse(url="/brackets", status_code=HTTP_303_SEE_OTHER) -@router.get("/brackets/{bracket_id}", response_class=HTMLResponse) -def bracket_detail(bracket_id: int, request: Request, db: Session = Depends(get_db)): - from fastapi import HTTPException - bracket = db.query(JobBracket).filter(JobBracket.id == bracket_id).first() - if not bracket: - raise HTTPException(status_code=404, detail="Bracket not found") - return templates.TemplateResponse("bracket_detail.html", { - "request": request, - "active": "brackets", - "bracket": bracket, - "stl_files": (stl_files := list_stl_files()), - "stl_cache": get_cache_map(stl_files, db), - "materials": available_materials() or MATERIALS, - "colors": available_colors() or COLORS, - }) - - -@router.post("/brackets/{bracket_id}/jobs") -async def add_jobs_to_bracket( - bracket_id: int, - quantity: int = Form(1), - job_material: str = Form(""), - job_color: str = Form(""), - notes: str = Form(""), - stl_file: UploadFile = File(None), - stl_select: str = Form(""), - db: Session = Depends(get_db), -): - filename = None - if stl_file and stl_file.filename: - filename = stl_file.filename - (get_stl_dir() / filename).write_bytes(await stl_file.read()) - analyse(filename, db) - elif stl_select: - filename = stl_select - - for _ in range(max(1, min(quantity, 500))): - job = PrintJob( - job_uuid=str(_uuid.uuid4()), - name=Path(filename).stem if filename else "Unnamed", - file_name=filename, - bracket_id=bracket_id, - job_material=job_material or None, - job_color=job_color or None, - notes=notes.strip() or None, - ) - db.add(job) - db.flush() - db.add(JobLog(job_id=job.id, message="Job created")) - - db.commit() - return RedirectResponse(url=f"/brackets/{bracket_id}", status_code=HTTP_303_SEE_OTHER) +@router.get("/brackets/{bracket_id}") +def bracket_detail_redirect(bracket_id: int): + return RedirectResponse(url=f"/jobs?bracket_id={bracket_id}", status_code=HTTP_303_SEE_OTHER) # ── To-Do ────────────────────────────────────────────────────────────────────── diff --git a/app/templates/bracket_detail.html b/app/templates/bracket_detail.html deleted file mode 100644 index f566294..0000000 --- a/app/templates/bracket_detail.html +++ /dev/null @@ -1,170 +0,0 @@ -{% 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 %} - -
- -
-
{{ bracket.name }}
- {% if bracket.customer %}{{ bracket.customer }}{% endif %} -
- -
- -{# ── Progress ── #} -{% if total %} -
-
- {{ done }} done · {{ printing }} printing · {{ total - done - printing }} queued - {{ pct }}% -
-
-
-
-
-{% endif %} - -{# ── Jobs table ── #} -
- {% if bracket.jobs %} - - - - - - - - - - - - - {% for j in bracket.jobs %} - - - - - - - - - {% endfor %} - -
UUIDFileMaterialPrinterStatusCreated
- {{ j.job_uuid[:8] if j.job_uuid else '—' }} - {{ j.file_name or j.name }} - {% if j.job_material %}{{ j.job_material }}{% if j.job_color %} · {{ j.job_color }}{% endif %}{% else %}—{% endif %} - {{ j.printer.name if j.printer else '—' }} - {% set s = j.status.value %} - {% if s == 'printing' %}printing - {% elif s == 'done' %}done - {% elif s == 'failed' %}failed - {% elif s == 'cancelled' %}cancelled - {% else %}queued - {% endif %} - {{ j.created_at.strftime('%d.%m %H:%M') }}
- {% else %} -
No jobs in this bracket yet.
- {% endif %} -
- -{# ── Add Jobs Modal ── #} - -{% endblock %} diff --git a/app/templates/brackets.html b/app/templates/brackets.html index 83f81b6..e45dfbf 100644 --- a/app/templates/brackets.html +++ b/app/templates/brackets.html @@ -26,7 +26,7 @@ {% set done = b.jobs | selectattr('status.value', 'equalto', 'done') | list | length %} {% set pct = (done / total * 100) | int if total else 0 %} - {{ b.name }} + {{ b.name }} {{ b.customer or '—' }} {% if total %} diff --git a/app/templates/job_detail.html b/app/templates/job_detail.html index dc9a495..39f0e8c 100644 --- a/app/templates/job_detail.html +++ b/app/templates/job_detail.html @@ -41,7 +41,7 @@ Printer {{ job.printer.name if job.printer else '—' }} Bracket - {% if job.bracket %}{{ job.bracket.name }}{% else %}—{% endif %} + {% if job.bracket %}{{ job.bracket.name }}{% else %}—{% endif %} Created {{ job.created_at.strftime('%d.%m.%Y %H:%M') }} {% if job.started_at %}