Add per-company backup reports (printable page and CSV)

/report.html shows one company's backups over the last 7, 30 or 90
days, chosen in the page and kept in the URL so reports can be
bookmarked or linked. Reached from Reports in the top bar, or a
company's name in a job's detail.

- Summary (jobs, runs, success rate, warnings, failures, overdue now);
  per job: run counts, success rate (successful / finished runs), last
  result and last successful backup; a day-by-day strip; every warning
  and failure with its message
- Print / Save as PDF: a print stylesheet prints light whatever the
  screen theme, hides the controls, keeps rows and strips whole across
  pages, and keeps the coloured cells and badges
- Days before a job was first known show as "Not monitored yet"
  rather than as missed backups, so a 90-day report for a newly added
  client doesn't look like 60 days of failures
- CSV of every run (full messages, times in the browser's time zone,
  UTF-8 BOM for Excel, formula-like values defused with a leading ')

Backend: GET /api/v1/tenants, /api/v1/reports/tenant and
/api/v1/reports/tenant.csv; periods capped at retention. tzdata added
for systems without time zone data. Frontend status and day-strip
helpers moved out of app.js into status.js / history.js for reuse.

Tested: 9 new backend tests; in the browser against the API with 30
days of demo history (summary, issues, strips, 7/30/90 switching,
CSV download with BOM, print styles applied on screen), mock mode and
phone width.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-08 14:56:54 -06:00
co-authored by Claude Opus 5.5
parent abb684ff0d
commit 2297187f88
15 changed files with 925 additions and 75 deletions
+21
View File
@@ -67,10 +67,31 @@ curl -X POST https://backups.example.com/api/v1/ingest \
| `GET /api/v1/jobs/{id}` | One job, plus the last finished run's duration, size, message and details |
| `GET /api/v1/jobs/{id}/runs?days=30` | Run history (no messages), newest first |
| `GET /api/v1/runs/{id}` | One run including message and details |
| `GET /api/v1/tenants` | Companies with jobs, for choosing a report |
| `GET /api/v1/reports/tenant?tenant=…&days=30` | One company's jobs and every run in the period (messages for warnings/failures only) |
| `GET /api/v1/reports/tenant.csv?tenant=…&days=30&tz=America/Edmonton` | The same as CSV, with full messages and times in `tz` |
| `GET /api/v1/health` | `{"status": "ok"}` |
The OpenAPI schema is at `/api/v1/openapi.json`.
## Reports
**Reports** in the dashboard's top bar (or a company's name in a job's detail) opens a backup report
for one company over the last 7, 30 or 90 days. The address carries the choice, e.g.
`/report.html?tenant=Alpha%20Construction&days=30`, so a report can be bookmarked or linked.
- **On the page:** a summary (jobs, runs, success rate, warnings, failures, overdue now); per job,
its run counts, success rate, last result and last successful backup; a day-by-day strip; and
every warning and failure with its message. **Print / Save as PDF** prints it light and without
the page controls, whatever the screen's theme.
- **CSV:** every run in the period, with full messages and times in the browser's time zone. It
opens directly in Excel. Values that a spreadsheet would treat as formulas are prefixed with `'`.
- **Success rate** is successful runs ÷ finished runs; runs still in progress don't count against it.
- **Days before a job was monitored** (before its earliest known run) show as *Not monitored
yet*, not as missed backups.
- Periods are limited by retention (`BACKUP_DASH_RETENTION_DAYS`, 90 by default). Anyone who can
sign in can view reports.
## Authentication
- **Dashboard users:** Microsoft 365 sign-in. nginx checks every request with