From c528b938a03542995a36b1094707d3ca4afc2638 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Sat, 3 Jan 2026 16:04:10 +0100 Subject: [PATCH] Auto-commit local changes before build (2026-01-03 16:04:10) --- .last-branch | 2 +- .../backend/app/main/routes_reporting_api.py | 40 +++++++++++-------- .../src/backend/app/main/routes_reports.py | 4 +- .../src/templates/main/reports.html | 8 ++-- .../src/templates/main/reports_new.html | 16 +++++++- docs/changelog.md | 11 +++++ 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/.last-branch b/.last-branch index 0304ea5..b87b12d 100644 --- a/.last-branch +++ b/.last-branch @@ -1 +1 @@ -v20260103-10-reports-summary-columns-metadata +v20260103-11-reports-view-raw-columns-fix diff --git a/containers/backupchecks/src/backend/app/main/routes_reporting_api.py b/containers/backupchecks/src/backend/app/main/routes_reporting_api.py index db5714c..103f3e3 100644 --- a/containers/backupchecks/src/backend/app/main/routes_reporting_api.py +++ b/containers/backupchecks/src/backend/app/main/routes_reporting_api.py @@ -180,24 +180,10 @@ def api_reports_create(): return {"id": r.id} -@main_bp.route("/api/reports/columns", methods=["GET"]) -@login_required -def api_reports_columns(): - """Return column metadata used by the Reports UI. - The UI uses this endpoint for: - - grouped column selectors in the "New report" wizard - - translating column keys into human-readable labels - - sensible default columns per view - - Note: Column keys map to fields returned by: - - /api/reports//data?view=summary - - /api/reports//data?view=snapshot - """ - err = _require_reporting_role() - if err is not None: - return err +def build_report_columns_meta(): + """Build the column metadata payload for reporting UIs.""" # Keep the payload stable so report_config can safely store selected keys. return { "views": [ @@ -312,6 +298,28 @@ def api_reports_columns(): }, ], } + +@main_bp.route("/api/reports/columns", methods=["GET"]) +@login_required +def api_reports_columns(): + """Return column metadata used by the Reports UI. + + The UI uses this endpoint for: + - grouped column selectors in the "New report" wizard + - translating column keys into human-readable labels + - sensible default columns per view + + Note: Column keys map to fields returned by: + - /api/reports//data?view=summary + - /api/reports//data?view=snapshot + """ + err = _require_reporting_role() + if err is not None: + return err + + # Keep the payload stable so report_config can safely store selected keys. + return build_report_columns_meta() + @main_bp.route("/api/reports/", methods=["DELETE"]) diff --git a/containers/backupchecks/src/backend/app/main/routes_reports.py b/containers/backupchecks/src/backend/app/main/routes_reports.py index aa60d18..5b29dc6 100644 --- a/containers/backupchecks/src/backend/app/main/routes_reports.py +++ b/containers/backupchecks/src/backend/app/main/routes_reports.py @@ -1,5 +1,6 @@ from .routes_shared import * # noqa: F401,F403 from datetime import date, timedelta +from .routes_reporting_api import build_report_columns_meta def get_default_report_period(): """Return default report period (last 7 days).""" @@ -53,6 +54,7 @@ def reports(): return render_template( "main/reports.html", initial_reports=items, + columns_meta=build_report_columns_meta(), default_period_start=period_start.isoformat(), default_period_end=period_end.isoformat(), ) @@ -70,4 +72,4 @@ def reports_new(): ) customer_items = [{"id": int(c.id), "name": c.name or ""} for c in customers] - return render_template("main/reports_new.html", initial_customers=customer_items) + return render_template("main/reports_new.html", initial_customers=customer_items, columns_meta=build_report_columns_meta()) diff --git a/containers/backupchecks/src/templates/main/reports.html b/containers/backupchecks/src/templates/main/reports.html index 1a273d4..ddc0fc0 100644 --- a/containers/backupchecks/src/templates/main/reports.html +++ b/containers/backupchecks/src/templates/main/reports.html @@ -163,6 +163,7 @@ -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index 747fae2..f1f988c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -90,6 +90,17 @@ - Corrected the **Missed** column mapping to use `missed_count` for Summary views instead of snapshot-specific fields. - Ensured column metadata is consistent between backend and frontend to allow future graphical output. +--- + +## v20260103-11-reports-view-raw-columns-fix + +### Changed +- Fixed the **View raw** action in Reports by correcting a broken JavaScript function call that prevented raw data from loading. +- Extended the Reports backend to always include column metadata (`columns_meta`) in the response. +- Updated the Reports UI to use embedded column metadata as a fallback, ensuring column selection is available even when an API fetch fails. +- Improved column metadata loading logic to only fetch metadata when it is not already present in the report payload. + + ================================================================================================================================================ ## v0.1.15