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 / build (pull_request) Waiting for needed jobs
ci / image (pull_request) Waiting for needed jobs
ci / lint (pull_request) In progress
ci / test (pull_request) In progress

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

+3
View File
@@ -22,6 +22,9 @@ func paged(o obj) obj {
// show them.
var endpoints = []endpoint{
// Account
{method: "GET", path: "/api/v1/public/regions", tag: "Public", summary: "Platform regions with their locations", public: true,
description: "For websites showing where the platform checks from: no authentication, any origin (CORS), cached for up to a minute. Lists platform regions only; `latitude`/`longitude` are absent for regions without a location, and `online` is set while a checker of the region is connected.",
resp: obj{"regions": []publicRegion{}}},
{method: "POST", path: "/api/v1/auth/signup", tag: "Account", summary: "Create an account", public: true,
description: "Depending on the installation, sign-up is open, limited to the first user, or closed. Where addresses are confirmed, answers `{\"status\": \"verification_sent\"}` and mails a link; the account signs in after confirming. Otherwise starts a session, and `org_name`/`org_slug`, if given, create a first organization. One account per mailbox (+suffixes and Gmail dots count as the same address); a client address may create only a few accounts a day (`429 signup_limit`).",
req: signupRequest{}, resp: sessionStarted},
+82
View File
@@ -0,0 +1,82 @@
package api
import (
"encoding/json"
"net/http"
"sync"
"time"
"github.com/gin-gonic/gin"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/tenant"
)
// publicRegionsTTL is how long an instance serves the platform regions
// from memory, so the endpoint costs the database next to nothing however
// often a front page asks.
const publicRegionsTTL = 30 * time.Second
// publicRegion is a platform region as anyone may see it. Organizations'
// own regions are never listed.
type publicRegion struct {
Key string `json:"key"`
Name string `json:"name"`
// Latitude and longitude are absent for regions without a location.
Latitude *float64 `json:"latitude,omitempty"`
Longitude *float64 `json:"longitude,omitempty"`
// Online is set while at least one checker of the region is connected.
Online bool `json:"online"`
}
type publicRegionsCache struct {
mu sync.Mutex
body []byte
expires time.Time
}
// listPublicRegions answers without authentication and to any origin, for
// a website showing where the platform checks from.
func (s *Server) listPublicRegions(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Cache-Control", "public, max-age=60")
body, err := s.publicRegionsBody(c)
if err != nil {
internalError(c, err)
return
}
c.Data(http.StatusOK, "application/json; charset=utf-8", body)
}
func (s *Server) publicRegionsBody(c *gin.Context) ([]byte, error) {
cache := &s.publicRegions
cache.mu.Lock()
defer cache.mu.Unlock()
if cache.body != nil && time.Now().Before(cache.expires) {
return cache.body, nil
}
ctx := c.Request.Context()
var rows []store.Region
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
var err error
rows, err = q.ListPlatformRegions(ctx)
return err
})
if err != nil {
return nil, err
}
out := make([]publicRegion, len(rows))
for i, r := range rows {
n, err := s.sched.Instances(ctx, r.ID.String())
if err != nil {
return nil, err
}
out[i] = publicRegion{Key: r.Key, Name: r.Name, Latitude: r.Latitude, Longitude: r.Longitude, Online: n > 0}
}
body, err := json.Marshal(gin.H{"regions": out})
if err != nil {
return nil, err
}
cache.body, cache.expires = body, time.Now().Add(publicRegionsTTL)
return body, nil
}
+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")
+5
View File
@@ -67,6 +67,9 @@ type Server struct {
// snapshots lets status page servers asking for the same page at once
// share one build of it.
snapshots singleflight.Group
// publicRegions caches the answer of the public region list.
publicRegions publicRegionsCache
}
// Deps are the external resources a Server needs.
@@ -127,6 +130,8 @@ func (s *Server) Mount(r gin.IRouter) {
g := r.Group("/", s.sessions.Load(), s.localize(), auth.CSRF(), s.audit(), s.accountGate())
r.GET("/api/openapi.json", s.openAPIJSON)
// Public data for websites: no session, no CSRF.
r.GET("/api/v1/public/regions", s.listPublicRegions)
r.GET("/install.sh", s.installScript)
g.GET("/api/docs", s.apiDocsPage)
+3
View File
@@ -1371,6 +1371,9 @@
"regions.location_pick_hint": "Ein Klick auf die Karte setzt die Koordinaten einer neuen Region oder der Region, deren Standort du gerade setzt.",
"regions.location_set": "Setzen",
"regions.longitude": "Längengrad",
"regions.map_ctrl_key": "Strg",
"regions.map_scroll_hint": "{{.Key}} + Scrollen zoomt die Karte.",
"regions.map_touch_hint": "Mit zwei Fingern verschiebst du die Karte.",
"regions.own": "diese Organisation",
"regions.owner": "Besitzer",
"regions.platform": "Plattform",
+3
View File
@@ -1371,6 +1371,9 @@
"regions.location_pick_hint": "Click the map to fill in the coordinates of a new region, or of the region whose location you are setting.",
"regions.location_set": "Set",
"regions.longitude": "Longitude",
"regions.map_ctrl_key": "Ctrl",
"regions.map_scroll_hint": "Use {{.Key}} + scroll to zoom the map.",
"regions.map_touch_hint": "Use two fingers to move the map.",
"regions.own": "this organization",
"regions.owner": "Owner",
"regions.platform": "platform",
+6
View File
@@ -158,6 +158,12 @@
transform: scale(1.1);
box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}
@media (pointer: coarse) {
.region-pin {
padding: 6px 11px 6px 8px;
font-size: 12px;
}
}
.region-pin:focus-visible { outline: 2px solid var(--color-maintenance); outline-offset: 2px; }
.region-pick {
width: 14px;
+21 -4
View File
@@ -648,8 +648,24 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
let map;
try {
// Scrolling the page must not zoom the map; the buttons, a double
// click and pinching do.
map = new gl.Map({ container: box, style: mapStyle(server), center: [10.45, 51.17], zoom: 3, scrollZoom: false, attributionControl: { compact: true } });
// click and pinching do. On touch screens one finger scrolls the page
// and two move the map.
const touch = window.matchMedia?.("(pointer: coarse)").matches ?? false;
map = new gl.Map({
container: box,
style: mapStyle(server),
center: [10.45, 51.17],
zoom: 3,
// With cooperative gestures, scrolling zooms only with Ctrl or ⌘.
scrollZoom: touch,
cooperativeGestures: touch,
locale: {
"CooperativeGesturesHandler.MobileHelpText": box.dataset.touchHint,
"CooperativeGesturesHandler.WindowsHelpText": box.dataset.scrollHint.replace("{key}", box.dataset.ctrlKey),
"CooperativeGesturesHandler.MacHelpText": box.dataset.scrollHint.replace("{key}", "⌘"),
},
attributionControl: { compact: true },
});
} catch {
box.hidden = true;
return;
@@ -696,9 +712,10 @@ for (const el of document.querySelectorAll("input[data-tz-default]")) {
holder.classList.toggle("is-hover", on);
row.classList.toggle("is-hover", on);
};
// Mouse only: a tap would leave the highlight behind.
for (const el of [pin, row]) {
el.addEventListener("mouseenter", () => hover(true));
el.addEventListener("mouseleave", () => hover(false));
el.addEventListener("pointerenter", (ev) => ev.pointerType === "mouse" && hover(true));
el.addEventListener("pointerleave", () => hover(false));
}
if (selecting) {
// The checkbox stays the source of truth; its change event keeps
+4 -1
View File
@@ -33,8 +33,11 @@ templ regionMap(mode, items string) {
data-region-map={ mode }
data-region-items={ items }
data-map-server={ MapServer }
data-touch-hint={ i18n.T(ctx, "regions.map_touch_hint") }
data-scroll-hint={ i18n.T(ctx, "regions.map_scroll_hint", "Key", "{key}") }
data-ctrl-key={ i18n.T(ctx, "regions.map_ctrl_key") }
hidden
class="region-map mb-3 h-72 w-full overflow-hidden border border-rule"
class="region-map mb-3 h-60 w-full overflow-hidden border border-rule sm:h-72"
></div>
}
+92 -53
View File
@@ -93,7 +93,46 @@ func regionMap(mode, items string) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" hidden class=\"region-map mb-3 h-72 w-full overflow-hidden border border-rule\"></div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" data-touch-hint=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "regions.map_touch_hint")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 36, Col: 57}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" data-scroll-hint=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "regions.map_scroll_hint", "Key", "{key}")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 37, Col: 75}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\" data-ctrl-key=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "regions.map_ctrl_key")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 38, Col: 53}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\" hidden class=\"region-map mb-3 h-60 w-full overflow-hidden border border-rule sm:h-72\"></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -120,7 +159,7 @@ func locationFields(lat, lon *float64) templ.Component {
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<div class=\"flex flex-wrap gap-3\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"flex flex-wrap gap-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -130,90 +169,90 @@ func locationFields(lat, lon *float64) templ.Component {
{i18n.T(ctx, "regions.latitude"), "latitude", coord(lat), "-90", "90"},
{i18n.T(ctx, "regions.longitude"), "longitude", coord(lon), "-180", "180"},
} {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(f.label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 52, Col: 94}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</span> <input type=\"number\" step=\"any\" name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.name).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 56, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\" data-number data-nullable data-location-field=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.name).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 59, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "\" value=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<label class=\"mb-4 block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.value).Resolve(ctx)
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(f.label)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 60, Col: 20}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 55, Col: 94}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\" min=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</span> <input type=\"number\" step=\"any\" name=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var10 string
templ_7745c5c3_Var10, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.min).Resolve(ctx)
templ_7745c5c3_Var10, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.name).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 61, Col: 16}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 59, Col: 18}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" max=\"")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" data-number data-nullable data-location-field=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.max).Resolve(ctx)
templ_7745c5c3_Var11, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.name).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 62, Col: 16}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 62, Col: 33}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\" class=\"w-36 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink\"></label>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\" value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.value).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 63, Col: 20}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\" min=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.min).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 64, Col: 16}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\" max=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templruntime.NewAttributeExpression(f.max).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regionmap.templ`, Line: 65, Col: 16}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\" class=\"w-36 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink\"></label>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+4 -4
View File
@@ -79,8 +79,8 @@ templ regionsBody(v RegionsView) {
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
<tr>
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "sso.field.name") }</th>
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.key") }</th>
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.owner") }</th>
<th class="hidden py-2 pr-4 font-medium sm:table-cell">{ i18n.T(ctx, "regions.key") }</th>
<th class="hidden py-2 pr-4 font-medium sm:table-cell">{ i18n.T(ctx, "regions.owner") }</th>
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.instances") }</th>
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "regions.location") }</th>
<th class="py-2"></th>
@@ -97,8 +97,8 @@ templ regionsBody(v RegionsView) {
data-live={ strconv.FormatInt(r.Instances, 10) }
>
<td class="py-2.5 pr-4">{ r.Name }</td>
<td class="py-2.5 pr-4 font-mono text-xs">{ r.Key }</td>
<td class="py-2.5 pr-4">
<td class="hidden py-2.5 pr-4 font-mono text-xs sm:table-cell">{ r.Key }</td>
<td class="hidden py-2.5 pr-4 sm:table-cell">
if r.Platform {
<span class="text-muted">{ i18n.T(ctx, "regions.platform") }</span>
} else {
+7 -7
View File
@@ -137,27 +137,27 @@ func regionsBody(v RegionsView) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</th><th class=\"py-2 pr-4 font-medium\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</th><th class=\"hidden py-2 pr-4 font-medium sm:table-cell\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.key"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 82, Col: 68}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 82, Col: 89}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</th><th class=\"py-2 pr-4 font-medium\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</th><th class=\"hidden py-2 pr-4 font-medium sm:table-cell\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.owner"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 83, Col: 70}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 83, Col: 91}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
@@ -269,20 +269,20 @@ func regionsBody(v RegionsView) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</td><td class=\"py-2.5 pr-4 font-mono text-xs\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</td><td class=\"hidden py-2.5 pr-4 font-mono text-xs sm:table-cell\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(r.Key)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 100, Col: 56}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 100, Col: 77}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</td><td class=\"py-2.5 pr-4\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</td><td class=\"hidden py-2.5 pr-4 sm:table-cell\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+6 -4
View File
@@ -1,13 +1,13 @@
<!doctype html><html><body data-msg-network="net">
<form id="monitor">
<div id="select-map" data-region-map="select" data-region-items="#monitor-regions" data-map-server="stub" hidden style="width:300px;height:200px"></div>
<div id="select-map" data-region-map="select" data-region-items="#monitor-regions" data-map-server="stub" data-touch-hint="t" data-scroll-hint="{key} s" data-ctrl-key="Ctrl" hidden style="width:300px;height:200px"></div>
<div id="monitor-regions">
<label><input type="checkbox" name="regions" value="r1" data-multi checked data-lat="50.11" data-lon="8.68" data-name="Frankfurt" data-live="2"></label>
<label><input type="checkbox" name="regions" value="r2" data-multi data-lat="40.71" data-lon="-74.0" data-name="New York" data-live="0"></label>
<label><input type="checkbox" name="regions" value="r3" data-multi data-name="Office" data-live="1"></label>
</div>
</form>
<div id="edit-map" data-region-map="edit" data-region-items="#region-list" data-map-server="stub" hidden style="width:300px;height:200px"></div>
<div id="edit-map" data-region-map="edit" data-region-items="#region-list" data-map-server="stub" data-touch-hint="t" data-scroll-hint="{key} s" data-ctrl-key="Ctrl" hidden style="width:300px;height:200px"></div>
<table><tbody id="region-list">
<tr data-lat="50.11" data-lon="8.68" data-name="Frankfurt" data-live="2"><td><button type="button" id="toggle" data-location-toggle="location-r1">set</button></td></tr>
<tr id="location-r1" hidden><td><form data-api="/org/regions/r1" data-method="patch" data-next="#saved" data-location-form id="row-form">
@@ -71,9 +71,11 @@ window.maplibregl = {
check("marker click ticks checkbox", box("r2").checked, true);
check("marker follows", markers()[1].classList.contains("is-checked"), true);
check("row follows", box("r2").closest("label").classList.contains("is-checked"), true);
markers()[0].dispatchEvent(new Event("mouseenter"));
markers()[0].dispatchEvent(new PointerEvent("pointerenter", { pointerType: "touch" }));
check("a tap leaves no highlight", box("r1").closest("label").classList.contains("is-hover"), false);
markers()[0].dispatchEvent(new PointerEvent("pointerenter", { pointerType: "mouse" }));
check("hovering a marker lights its row", box("r1").closest("label").classList.contains("is-hover"), true);
box("r2").closest("label").dispatchEvent(new Event("mouseenter"));
box("r2").closest("label").dispatchEvent(new PointerEvent("pointerenter", { pointerType: "mouse" }));
check("hovering a row lights its marker", markers()[1].parentElement.classList.contains("is-hover"), true);
box("r1").click();
check("checkbox untick clears marker", markers()[0].classList.contains("is-checked"), false);
+1 -1
View File
@@ -1,5 +1,5 @@
<!doctype html><html><body data-msg-network="net">
<div id="map" data-region-map="select" data-region-items="#items" data-map-server="./missing" hidden></div>
<div id="map" data-region-map="select" data-region-items="#items" data-map-server="./missing" data-touch-hint="t" data-scroll-hint="{key} s" data-ctrl-key="Ctrl" hidden></div>
<div id="items"><input type="checkbox" data-lat="1" data-lon="2" data-name="x" data-live="1"></div>
<pre id="out"></pre>
<script>