feat(regions): show checker regions on a map #169

Merged
Sebi merged 3 commits from feat/region-map into main 2026-11-28 19:50:36 +00:00
Owner

Summary

Shows checker regions on a map so users see where the platform checkers (and their own) stand when picking regions for a monitor. The map uses the self-hosted ZB-Server Maps (https://maps.zb-server.de, MapLibre GL, light and dark style).

  • Locations: migration 00058 adds optional latitude/longitude to regions (both or neither, range checked). POST …/regions accepts them. PATCH /api/v1/org/regions/:id (own regions) and PATCH /api/v1/admin/regions/:id (platform regions only) set them, and nulls remove them. Both are audited and documented in the OpenAPI spec.
  • Regions page / admin panel: a map of all located regions plus a "Location" column. "Set" opens a small form per manageable region, and a click on the map (or typing) fills the coordinates. The create form takes coordinates the same way.
  • Monitor form: a map above the region checkboxes when any region has a location. Clicking a marker ticks or unticks the region; the checkbox stays the source of truth. Filled = selected, grey = no live checker.
  • Public region list: GET /api/v1/public/regions answers without authentication and with CORS *, for the front page: {"regions":[{"key","name","latitude","longitude","online"}]}. It lists platform regions only (never org regions or ids), and each instance caches the answer for 30 s (Cache-Control: public, max-age=60).
  • Mobile: on touch screens one finger scrolls the page and two move the map (cooperative gestures, translated hints). Pins are larger, a tap leaves no sticky highlight, and the regions table hides key and owner on phones.
  • MapLibre (about 800 KB) loads only on pages with a map. If the map server is unreachable the map stays hidden and the list works as before.

Test plan

  • TestRegionLocations: create with location, PATCH set and remove, validation, another org or a platform region → 404, non-admin → 403, admin may only change platform regions, markers rendered in the monitor form and on the regions page
  • TestScripts/regionmap.html (headless Chromium, MapLibre stub): markers, fit, marker ↔ checkbox, map click fills the right form, remove sends nulls
  • TestRegionLocations/public_list: anonymous, CORS, platform regions only, no ids
  • Mobile at 360/390/768 px with touch: tapping pins and checkboxes stays in sync, no horizontal scroll, two-finger hint shown
  • TestScripts/regionmap_offline.html: the map stays hidden when MapLibre cannot load
  • Dev stack on :8080 with real tiles: set a location via the admin map, select regions via markers, light and dark, 375 px without horizontal scroll
  • go test ./..., golangci-lint 0 issues

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

## Summary Shows checker regions on a map so users see where the platform checkers (and their own) stand when picking regions for a monitor. The map uses the self-hosted ZB-Server Maps (`https://maps.zb-server.de`, MapLibre GL, light and dark style). - **Locations:** migration `00058` adds optional `latitude`/`longitude` to `regions` (both or neither, range checked). `POST …/regions` accepts them. `PATCH /api/v1/org/regions/:id` (own regions) and `PATCH /api/v1/admin/regions/:id` (platform regions only) set them, and nulls remove them. Both are audited and documented in the OpenAPI spec. - **Regions page / admin panel:** a map of all located regions plus a "Location" column. "Set" opens a small form per manageable region, and a click on the map (or typing) fills the coordinates. The create form takes coordinates the same way. - **Monitor form:** a map above the region checkboxes when any region has a location. Clicking a marker ticks or unticks the region; the checkbox stays the source of truth. Filled = selected, grey = no live checker. - **Public region list:** `GET /api/v1/public/regions` answers without authentication and with CORS `*`, for the front page: `{"regions":[{"key","name","latitude","longitude","online"}]}`. It lists platform regions only (never org regions or ids), and each instance caches the answer for 30 s (`Cache-Control: public, max-age=60`). - **Mobile:** on touch screens one finger scrolls the page and two move the map (cooperative gestures, translated hints). Pins are larger, a tap leaves no sticky highlight, and the regions table hides key and owner on phones. - MapLibre (about 800 KB) loads only on pages with a map. If the map server is unreachable the map stays hidden and the list works as before. ## Test plan - [x] `TestRegionLocations`: create with location, PATCH set and remove, validation, another org or a platform region → 404, non-admin → 403, admin may only change platform regions, markers rendered in the monitor form and on the regions page - [x] `TestScripts/regionmap.html` (headless Chromium, MapLibre stub): markers, fit, marker ↔ checkbox, map click fills the right form, remove sends nulls - [x] `TestRegionLocations/public_list`: anonymous, CORS, platform regions only, no ids - [x] Mobile at 360/390/768 px with touch: tapping pins and checkboxes stays in sync, no horizontal scroll, two-finger hint shown - [x] `TestScripts/regionmap_offline.html`: the map stays hidden when MapLibre cannot load - [x] Dev stack on :8080 with real tiles: set a location via the admin map, select regions via markers, light and dark, 375 px without horizontal scroll - [x] `go test ./...`, golangci-lint 0 issues 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 1 commit 2026-11-28 19:18:01 +00:00
feat(regions): show checker regions on a map
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m48s
ci / test (pull_request) Successful in 12m42s
ci / build (pull_request) Canceled after 30s
ci / image (pull_request) Canceled after 0s
3562f8224e
Regions get an optional location. Platform admins set it for platform
regions and org admins for their own, by clicking the map on the regions
page or entering the coordinates; PATCH /org/regions/:id and
/admin/regions/:id set or remove it.

The monitor form shows the located regions on a map from the
self-hosted ZB-Server Maps: a click on a marker ticks or unticks the
region, and the checkbox list stays the source of truth. MapLibre loads
only on pages with a map, and the map stays hidden if the map server
cannot be reached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 1 commit 2026-11-28 19:31:26 +00:00
feat(regions): label the map pins and link them to the region list
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m17s
ci / test (pull_request) Successful in 12m34s
ci / build (pull_request) Canceled after 4m21s
ci / image (pull_request) Canceled after 0s
6c246b145f
Pins carry the region's name, turn dark when the region is selected and
show a green dot while a checker of the region is live. Hovering a pin
highlights its row in the list and the other way round, and a region
ticked in the list pans into view. Scrolling the page no longer zooms
the map, and the attribution stays compact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 1 commit 2026-11-28 19:48:45 +00:00
feat(regions): public region list and touch-friendly maps
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m21s
ci / test (pull_request) Successful in 13m31s
ci / build (pull_request) Successful in 18m20s
ci / image (pull_request) In progress
23717afec9
GET /api/v1/public/regions lists the platform regions with their
location and whether a checker is online, without authentication and to
any origin, for the website's front page. Each instance answers from
memory for 30 seconds; organizations' own regions are never listed.

On touch screens one finger scrolls the page and two move the map, the
pins are larger, and a tap no longer leaves rows highlighted. The
gesture hints are translated, and the regions table drops the key and
owner columns on phones so the location fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 918c71f283 into main 2026-11-28 19:50:36 +00:00
Sebi deleted branch feat/region-map 2026-11-28 19:50:40 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#169