From dca117ed791251ab0a274aa1c28ce67213bbee6a Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Mon, 16 Feb 2026 15:12:10 +0100 Subject: [PATCH] Add customer-to-jobs filtering navigation --- .../src/backend/app/main/routes_jobs.py | 29 +++++++++++++++++-- .../src/templates/main/customers.html | 6 +++- .../backupchecks/src/templates/main/jobs.html | 10 +++++++ docs/changelog-claude.md | 10 +++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/containers/backupchecks/src/backend/app/main/routes_jobs.py b/containers/backupchecks/src/backend/app/main/routes_jobs.py index ab4ee03..c07cce1 100644 --- a/containers/backupchecks/src/backend/app/main/routes_jobs.py +++ b/containers/backupchecks/src/backend/app/main/routes_jobs.py @@ -13,12 +13,33 @@ from .routes_shared import ( @login_required @roles_required("admin", "operator", "viewer") def jobs(): - # Join with customers for display - jobs = ( + selected_customer_id = None + selected_customer_name = "" + customer_id_raw = (request.args.get("customer_id") or "").strip() + if customer_id_raw: + try: + selected_customer_id = int(customer_id_raw) + except ValueError: + selected_customer_id = None + + base_query = ( Job.query .filter(Job.archived.is_(False)) .outerjoin(Customer, Customer.id == Job.customer_id) - .filter(db.or_(Customer.id.is_(None), Customer.active.is_(True))) + ) + + if selected_customer_id is not None: + base_query = base_query.filter(Job.customer_id == selected_customer_id) + selected_customer = Customer.query.filter(Customer.id == selected_customer_id).first() + if selected_customer is not None: + selected_customer_name = selected_customer.name or "" + else: + # Default listing hides jobs for inactive customers. + base_query = base_query.filter(db.or_(Customer.id.is_(None), Customer.active.is_(True))) + + # Join with customers for display + jobs = ( + base_query .add_columns( Job.id, Job.backup_software, @@ -54,6 +75,8 @@ def jobs(): "main/jobs.html", jobs=rows, can_manage_jobs=can_manage_jobs, + selected_customer_id=selected_customer_id, + selected_customer_name=selected_customer_name, ) diff --git a/containers/backupchecks/src/templates/main/customers.html b/containers/backupchecks/src/templates/main/customers.html index e2509ce..d418636 100644 --- a/containers/backupchecks/src/templates/main/customers.html +++ b/containers/backupchecks/src/templates/main/customers.html @@ -45,7 +45,11 @@ {% if customers %} {% for c in customers %} - {{ c.name }} + + + {{ c.name }} + + {% if c.active %} Active diff --git a/containers/backupchecks/src/templates/main/jobs.html b/containers/backupchecks/src/templates/main/jobs.html index 8240d12..3d98cf2 100644 --- a/containers/backupchecks/src/templates/main/jobs.html +++ b/containers/backupchecks/src/templates/main/jobs.html @@ -2,6 +2,16 @@ {% block content %}

Jobs

+{% if selected_customer_id %} + +{% endif %} +
diff --git a/docs/changelog-claude.md b/docs/changelog-claude.md index 656b7f4..a404e67 100644 --- a/docs/changelog-claude.md +++ b/docs/changelog-claude.md @@ -2,6 +2,16 @@ This file documents all changes made to this project via Claude Code. +## [2026-02-16] + +### Added +- Added customer-to-jobs navigation by making customer names clickable on the Customers page, linking to `/jobs?customer_id=` +- Added Jobs page customer filter context UI with an active filter banner and a "Clear filter" action + +### Changed +- Changed `/jobs` route to accept optional `customer_id` query parameter and return only jobs for that customer when provided +- Changed default Jobs listing behavior to keep existing inactive-customer filtering only when no `customer_id` filter is applied + ## [2026-02-13] ### Added