diff --git a/app/routers/ui.py b/app/routers/ui.py index 123271b..1f23768 100644 --- a/app/routers/ui.py +++ b/app/routers/ui.py @@ -265,13 +265,25 @@ def job_detail(job_id: int, request: Request, db: Session = Depends(get_db)): job = db.query(PrintJob).filter(PrintJob.id == job_id).first() if not job: raise HTTPException(status_code=404, detail="Job not found") - stl = db.query(StlCache).filter_by(filename=job.file_name).first() if job.file_name else None + + file_missing = False + stl = None + if job.file_name: + file_path = get_stl_dir() / job.file_name + if not file_path.exists(): + file_missing = True + else: + stl = db.query(StlCache).filter_by(filename=job.file_name).first() + if stl is None and not job.file_name.endswith(".gcode"): + stl = analyse(job.file_name, db) + estimation = estimate(stl.volume_ccm, job.job_material) if stl and stl.volume_ccm else None return templates.TemplateResponse("job_detail.html", { "request": request, "active": "jobs", "job": job, "stl": stl, + "file_missing": file_missing, "estimation": estimation, "printers": db.query(Printer).order_by(Printer.name).all(), "brackets": db.query(JobBracket).order_by(JobBracket.name).all(), diff --git a/app/templates/job_detail.html b/app/templates/job_detail.html index 776272a..21d93f3 100644 --- a/app/templates/job_detail.html +++ b/app/templates/job_detail.html @@ -103,7 +103,7 @@
{{ job.file_name }} not found on disk.
+ | Bounding box | @@ -136,7 +141,7 @@ {% elif job.file_name and job.file_name.endswith('.gcode') %}