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
72 lines
2.2 KiB
Templ
72 lines
2.2 KiB
Templ
package web
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
|
)
|
|
|
|
// MapServer serves the map tiles, styles and the MapLibre library the
|
|
// region maps load.
|
|
const MapServer = "https://maps.zb-server.de"
|
|
|
|
// coord formats a coordinate for an attribute or input, empty for none.
|
|
func coord(f *float64) string {
|
|
if f == nil {
|
|
return ""
|
|
}
|
|
return strconv.FormatFloat(*f, 'f', -1, 64)
|
|
}
|
|
|
|
// HasLocation reports whether r has a place on the map.
|
|
func (r RegionOption) HasLocation() bool { return r.Lat != nil && r.Lon != nil }
|
|
|
|
// HasLocation reports whether r has a place on the map.
|
|
func (r Region) HasLocation() bool { return r.Lat != nil && r.Lon != nil }
|
|
|
|
// regionMap is a map of the regions marked with data-lat and data-lon
|
|
// inside the element items selects. In "select" mode a click on a marker
|
|
// toggles the region's checkbox; in "edit" mode a click on the map fills
|
|
// the active [data-location-form]. The script shows it once the map loads.
|
|
templ regionMap(mode, items string) {
|
|
<div
|
|
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-60 w-full overflow-hidden border border-rule sm:h-72"
|
|
></div>
|
|
}
|
|
|
|
// locationFields are the coordinate inputs of a region; empty ones remove
|
|
// the location.
|
|
templ locationFields(lat, lon *float64) {
|
|
<div class="flex flex-wrap gap-3">
|
|
for _, f := range []struct {
|
|
label, name, value, min, max string
|
|
}{
|
|
{i18n.T(ctx, "regions.latitude"), "latitude", coord(lat), "-90", "90"},
|
|
{i18n.T(ctx, "regions.longitude"), "longitude", coord(lon), "-180", "180"},
|
|
} {
|
|
<label class="mb-4 block">
|
|
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ f.label }</span>
|
|
<input
|
|
type="number"
|
|
step="any"
|
|
name={ f.name }
|
|
data-number
|
|
data-nullable
|
|
data-location-field={ f.name }
|
|
value={ f.value }
|
|
min={ f.min }
|
|
max={ f.max }
|
|
class="w-36 border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"
|
|
/>
|
|
</label>
|
|
}
|
|
</div>
|
|
}
|