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
107 lines
6.3 KiB
HTML
107 lines
6.3 KiB
HTML
<!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" 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" 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">
|
|
<input name="latitude" data-number data-nullable data-location-field="latitude" value="50.11">
|
|
<input name="longitude" data-number data-nullable data-location-field="longitude" value="8.68">
|
|
<button type="submit">save</button><button type="button" id="clear" data-location-clear>clear</button>
|
|
</form></td></tr>
|
|
</tbody></table>
|
|
<form data-api="/org/regions" id="create"><div data-location-form data-location-default>
|
|
<input name="latitude" data-number data-nullable data-location-field="latitude">
|
|
<input name="longitude" data-number data-nullable data-location-field="longitude">
|
|
</div></form>
|
|
<pre id="out"></pre>
|
|
<script>
|
|
const sent = [];
|
|
window.axios = { create: () => ({ interceptors: { request: { use() {} } }, request: async (cfg) => { sent.push(cfg); return { data: {} }; } }) };
|
|
const maps = [];
|
|
window.maplibregl = {
|
|
Map: class {
|
|
constructor(opts) { this.container = opts.container; this.handlers = {}; this.style = opts.style; maps.push(this); }
|
|
on(ev, fn) { (this.handlers[ev] ??= []).push(fn); }
|
|
fire(ev, arg) { for (const fn of this.handlers[ev] ?? []) fn(arg); }
|
|
addControl() {}
|
|
resize() {}
|
|
fitBounds(b) { this.bounds = b.points; }
|
|
jumpTo(o) { this.center = o.center; }
|
|
setStyle(s) { this.style = s; }
|
|
},
|
|
Marker: class {
|
|
constructor(o) { this.el = o.element; }
|
|
setLngLat(p) { this.at = p; this.el.dataset.at = p.join(","); return this; }
|
|
getLngLat() { return this.at; }
|
|
addTo(map) { map.container.append(this.el); return this; }
|
|
},
|
|
NavigationControl: class {},
|
|
LngLatBounds: class {
|
|
constructor(a) { this.points = [a]; }
|
|
extend(p) { this.points.push(p); return this; }
|
|
},
|
|
};
|
|
</script>
|
|
<script src="../assets/app.js"></script>
|
|
<script>
|
|
(async () => {
|
|
const out = [];
|
|
const check = (name, got, want) => {
|
|
const g = JSON.stringify(got), w = JSON.stringify(want);
|
|
out.push((g === w ? "PASS " : "FAIL ") + name + (g === w ? "" : " got=" + g + " want=" + w));
|
|
};
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
const sel = document.getElementById("select-map");
|
|
const markers = () => [...sel.querySelectorAll(".region-pin")];
|
|
const box = (v) => document.querySelector(`[value="${v}"]`);
|
|
check("select map shown", sel.hidden, false);
|
|
check("light style", maps[0].style, "stub/style-light.json");
|
|
check("markers for located regions", markers().map((m) => m.title), ["Frankfurt", "New York"]);
|
|
check("fits all markers", maps[0].bounds, [[8.68, 50.11], [-74, 40.71]]);
|
|
check("checked marker filled", markers().map((m) => m.classList.contains("is-checked")), [true, false]);
|
|
check("idle region marked", markers()[1].dataset.live, "0");
|
|
markers()[1].click();
|
|
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 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 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);
|
|
|
|
const edit = maps[1];
|
|
const click = (lat, lng) => edit.fire("click", { lngLat: { lat, lng, wrap() { return { lat, lng: lng > 180 ? lng - 360 : lng }; } } });
|
|
click(48.137154, 11.576124);
|
|
const create = document.getElementById("create");
|
|
check("map click fills create form", [create.elements.latitude.value, create.elements.longitude.value], ["48.1372", "11.5761"]);
|
|
check("pick marker shown", document.querySelector("#edit-map .region-pick")?.dataset.at, "11.576124,48.137154");
|
|
document.querySelector("#edit-map .region-pin").click();
|
|
check("marker click opens its row", document.getElementById("location-r1").hidden, false);
|
|
click(52.52, 373.4);
|
|
const row = document.getElementById("row-form");
|
|
check("map click fills open row", [row.elements.latitude.value, row.elements.longitude.value], ["52.52", "13.4"]);
|
|
check("create form untouched", create.elements.latitude.value, "48.1372");
|
|
document.getElementById("clear").click();
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
check("clear sends nulls", sent.at(-1) && [sent.at(-1).method, sent.at(-1).url, sent.at(-1).data], ["patch", "/org/regions/r1", { latitude: null, longitude: null }]);
|
|
document.getElementById("toggle").click();
|
|
check("toggle closes row", document.getElementById("location-r1").hidden, true);
|
|
click(1, 2);
|
|
check("closed row falls back to create form", create.elements.latitude.value, "1");
|
|
|
|
document.getElementById("out").textContent = out.join("\n");
|
|
})();
|
|
</script>
|
|
</body></html>
|