ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m59s
ci / test (pull_request) Successful in 12m44s
ci / build (pull_request) Successful in 18m14s
ci / image (pull_request) Canceled after 1m1s
With thousands of monitors on a status page the editor was tens of megabytes, as every row carried the options of all groups, and importing the monitor groups updated each monitor in its own statement. - The monitors of the editor are shown 50 at a time. All rows stay in the form, as saving replaces the page's monitors. - Rows carry their own group only and get the other options from the row template once shown or focused. - The filter matches a monitor's name and group path only, no longer the names of the groups in its select. - The import creates the groups one nesting level at a time and files all monitors in one statement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
73 lines
4.3 KiB
HTML
73 lines
4.3 KiB
HTML
<!doctype html><html><body data-msg-network="net">
|
|
<form data-api="/org/statuspages/p1/monitors" data-method="put" data-rows="monitors" data-next="#saved" id="sp">
|
|
<p><button type="button" id="all" data-check-all="on" data-check-target="[data-field=include]">all</button></p>
|
|
<input type="search" id="filter" data-filter-rows="#rows">
|
|
<template data-row-fields><span data-row-extra></span><select data-field="group_id" data-nullable><option value="">none</option><option value="g1">G1</option><option value="g2">G2</option></select></template>
|
|
<ul id="rows" data-page-size="2"></ul>
|
|
<nav data-row-pager="#rows">
|
|
<button type="button" id="prev" data-row-page="prev">prev</button>
|
|
<span id="status" data-row-page-status data-template="{from}-{to}/{total}"></span>
|
|
<button type="button" id="next" data-row-page="next">next</button>
|
|
</nav>
|
|
<button type="submit">save</button>
|
|
</form>
|
|
<pre id="out"></pre>
|
|
<script>
|
|
const sent = [];
|
|
window.axios = { create: () => ({ interceptors: { request: { use() {} } }, request: async (cfg) => { sent.push(cfg.data); return { data: {} }; }, post: async () => ({ data: {} }) }) };
|
|
const list = document.getElementById("rows");
|
|
for (const [id, name, on] of [["m1", "alpha", true], ["m2", "beta", false], ["m3", "gamma", false], ["m4", "alpine", false], ["m5", "delta", true]]) {
|
|
list.insertAdjacentHTML("beforeend", `<li data-row><input type="checkbox" data-field="include"${on ? " checked" : ""}><span data-filter-text>${name}</span><input type="hidden" data-field="monitor_id" value="${id}">${on ? '<span data-row-extra></span><select data-field="group_id" data-nullable data-lazy-options><option value="">none</option><option value="g2" selected>G2</option></select>' : ""}</li>`);
|
|
}
|
|
</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));
|
|
};
|
|
const visible = () => [...list.children].filter((r) => !r.hidden).map((r) => r.querySelector("[data-filter-text]").textContent);
|
|
const status = () => document.getElementById("status").textContent;
|
|
const submit = async () => {
|
|
sent.length = 0;
|
|
document.getElementById("sp").dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
|
|
await new Promise((r) => setTimeout(r, 50));
|
|
return sent[0] ? (typeof sent[0] === "string" ? JSON.parse(sent[0]) : sent[0]).monitors.map((m) => m.monitor_id) : null;
|
|
};
|
|
const sel = (id) => document.querySelector(`[value="${id}"]`).closest("[data-row]").querySelector("select");
|
|
check("shown row gets all options", [...sel("m1").options].map((o) => o.value), ["", "g1", "g2"]);
|
|
check("shown row keeps its group", sel("m1").value, "g2");
|
|
check("hidden row stays lean", sel("m5").options.length, 2);
|
|
check("first page", visible(), ["alpha", "beta"]);
|
|
check("first status", status(), "1-2/5");
|
|
check("prev disabled", document.getElementById("prev").disabled, true);
|
|
document.getElementById("next").click();
|
|
document.getElementById("next").click();
|
|
check("last page", visible(), ["delta"]);
|
|
check("last status", status(), "5-5/5");
|
|
check("next disabled", document.getElementById("next").disabled, true);
|
|
check("row shown later gets all options", sel("m5").options.length, 3);
|
|
check("rows of all pages sent", await submit(), ["m1", "m5"]);
|
|
const filter = document.getElementById("filter");
|
|
filter.value = "g1";
|
|
filter.dispatchEvent(new Event("input", { bubbles: true }));
|
|
check("group options are not searched", visible(), []);
|
|
filter.value = "alp";
|
|
filter.dispatchEvent(new Event("input", { bubbles: true }));
|
|
check("filtered", visible(), ["alpha", "alpine"]);
|
|
check("filtered status", status(), "1-2/2");
|
|
check("pager hidden for one page", document.querySelector("[data-row-pager]").hidden, true);
|
|
filter.value = "a";
|
|
filter.dispatchEvent(new Event("input", { bubbles: true }));
|
|
check("filter restarts at first page", visible(), ["alpha", "beta"]);
|
|
filter.value = "alp";
|
|
filter.dispatchEvent(new Event("input", { bubbles: true }));
|
|
document.getElementById("all").click();
|
|
check("check all ticks filtered rows only", await submit(), ["m1", "m4", "m5"]);
|
|
document.getElementById("out").textContent = out.join("\n");
|
|
})();
|
|
</script>
|
|
</body></html>
|