diff --git a/app/routers/ui.py b/app/routers/ui.py index 1c886a6..80f2550 100644 --- a/app/routers/ui.py +++ b/app/routers/ui.py @@ -163,6 +163,21 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str ) jobs = query.order_by(status_order, PrintJob.priority.desc(), PrintJob.created_at.asc()).all() + stl_files = list_stl_files() + stl_cache = get_cache_map(stl_files, db) + + bracket_gross_total = None + if active_bracket: + total = 0.0 + has_any = False + for j in active_bracket.jobs: + cached = stl_cache.get(j.file_name) + if cached and cached.volume_ccm: + total += estimate(cached.volume_ccm, j.job_material)["gross_price"] + has_any = True + if has_any: + bracket_gross_total = round(total, 2) + return templates.TemplateResponse("jobs.html", { "request": request, "active": "jobs", @@ -172,10 +187,11 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str "show_all": bool(show_all), "hidden_count": hidden_count, "active_bracket": active_bracket, + "bracket_gross_total": bracket_gross_total, "printers": db.query(Printer).order_by(Printer.name).all(), "brackets": db.query(JobBracket).order_by(JobBracket.name).all(), - "stl_files": (stl_files := list_stl_files()), - "stl_cache": get_cache_map(stl_files, db), + "stl_files": stl_files, + "stl_cache": stl_cache, "materials": available_materials() or MATERIALS, "colors": available_colors() or COLORS, "spool_map": spool_counts(), diff --git a/app/templates/jobs.html b/app/templates/jobs.html index 7148700..c850614 100644 --- a/app/templates/jobs.html +++ b/app/templates/jobs.html @@ -26,6 +26,11 @@ {{ active_bracket.name }} + {% if bracket_gross_total is not none %} + + {{ "%.2f"|format(bracket_gross_total) }} gross total + + {% endif %} × clear filter {% elif q %}