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) Successful in 5m47s

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
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-28 20:48:30 +01:00
1 parent 6c246b145f
commit 23717afec9
14 files changed
+273 -74

No files matched your search

+36
View File
@@ -2,6 +2,7 @@ package api_test
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
@@ -278,6 +279,41 @@ func TestRegionLocations(t *testing.T) {
t.Errorf("platform location seen by org B = %v, %v", lat, lon)
}
t.Run("public list", func(t *testing.T) {
req, _ := http.NewRequest(http.MethodGet, a.base+"/api/v1/public/regions", nil)
req.Header.Set("Origin", "https://www.example.org")
// The browser's transport trusts the test server; no cookie jar, so no session.
resp, err := (&http.Client{Transport: a.hc.Transport}).Do(req)
if err != nil {
t.Fatal(err)
}
defer func() { _ = resp.Body.Close() }()
var body struct {
Regions []map[string]any `json:"regions"`
}
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil || resp.StatusCode != http.StatusOK {
t.Fatalf("GET public regions = %d %v", resp.StatusCode, err)
}
if got := resp.Header.Get("Access-Control-Allow-Origin"); got != "*" {
t.Errorf("CORS header = %q, want *", got)
}
var found map[string]any
for _, r := range body.Regions {
if r["name"] == "Office plain" || r["key"] == "berlin" {
t.Errorf("public list shows an org region: %v", r)
}
if _, leaked := r["id"]; leaked {
t.Errorf("public list exposes region ids: %v", r)
}
if r["latitude"] == 50.1109 {
found = r
}
}
if _, isBool := found["online"].(bool); found == nil || found["longitude"] != 8.6821 || !isBool {
t.Errorf("platform region in public list = %v, want its location and online state", found)
}
})
_, _, html := a.page("/monitors/new")
if !strings.Contains(html, `data-region-map="select"`) || !strings.Contains(html, `data-lat="50.1109"`) || !strings.Contains(html, `data-lat="-33.8688"`) {
t.Errorf("monitor form lacks the region map or markers")