Files
Sebastian UnterschützandClaude Opus 5.5 e4ce619fbe
ci / image (pull_request) Successful in 4m25s
ci / build (pull_request) Successful in 8m15s
ci / test (pull_request) Successful in 8m51s
ci / lint (pull_request) Successful in 12m8s
feat: per-organization limits set by platform admins
Admins set default limits for monitors (all types), status pages and
regions per monitor, whether an organization's own checker regions count
towards the region limit, and how many organizations an account may own,
and override them per organization or account. Defaults are not copied:
changing one applies at once to everyone without an override. 0 means
unlimited; self-hosted defaults are unlimited, the cloud allows three
organizations per account.

Creations count under a per-organization advisory lock, so concurrent
requests cannot overshoot. A lowered limit keeps everything that exists:
monitors already beyond the region limit stay editable but may not grow.
Organizations see their usage in their settings and GET /org/limits;
the admin panel lists organizations with owner, usage and limits next
to their suspend and delete actions. Empty numeric form fields marked
data-nullable are sent as null.

Refs #111

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
2026-11-22 21:06:45 +01:00

154 lines
7.9 KiB
HTML

<!doctype html><html><body data-msg-network="net">
<form data-api="/org/monitors" data-next="#saved" id="f">
<select name="type" data-type-select><option value="http">http</option><option value="json" selected>json</option><option value="heartbeat">heartbeat</option></select>
<input name="name" value="Queue">
<div data-hide-for="heartbeat"><input name="target" value="https://x" required></div>
<fieldset data-type="json">
<select name="config.method"><option value="POST" selected>POST</option></select>
<textarea name="config.headers" data-headers>Authorization: Bearer a:b
X-Empty:
: nothing</textarea>
<input name="config.assertions.0.path" value="status"><input name="config.assertions.0.op" value="==">
<input name="config.assertions.1.path" value="queue.depth"><input name="config.assertions.1.op" value="<">
</fieldset>
<fieldset data-type="http" disabled hidden><select name="config.method"><option value="HEAD" selected>HEAD</option></select></fieldset>
<fieldset data-hide-for="heartbeat"><input type="checkbox" name="regions" value="r1" data-multi checked></fieldset>
<input type="hidden" name="alert_group_ids" data-multi>
<input type="checkbox" name="alert_group_ids" value="default" data-multi checked>
<input type="checkbox" name="alert_group_ids" value="ops" data-multi>
<input type="hidden" name="channel_ids" data-multi>
<button type="submit">save</button>
</form>
<form data-api="/org/agents/a1" data-method="patch" data-autosave id="auto">
<input type="checkbox" name="allow_private" checked>
</form>
<form data-api="/org/alert-groups/g1" data-method="put" id="qh">
<input name="name" value="Ops">
<input type="hidden" name="channel_ids" data-multi>
<div data-quiet-hours>
<input type="hidden" name="quiet_hours" data-multi>
<div data-quiet-list></div>
<template data-quiet-template>
<div data-quiet-row>
<input type="time" name="quiet_hours.__INDEX__.start" value="22:00">
<input type="time" name="quiet_hours.__INDEX__.end" value="07:00">
<input name="quiet_hours.__INDEX__.time_zone" value="" data-tz-default>
<input type="hidden" name="quiet_hours.__INDEX__.weekdays" data-multi>
<input type="checkbox" name="quiet_hours.__INDEX__.weekdays" value="1" data-multi>
<input type="checkbox" name="quiet_hours.__INDEX__.weekdays" value="5" data-multi>
<button type="button" data-quiet-remove>remove</button>
</div>
</template>
<button type="button" data-quiet-add>add</button>
</div>
<button type="submit">save</button>
</form>
<form data-api="/org/statuspages/p1/monitors" data-method="put" data-rows="monitors" id="sp">
<div data-row>
<input type="checkbox" data-field="include" checked>
<input type="hidden" data-field="monitor_id" value="m1">
<select data-field="group_id" data-nullable><option value="" selected>none</option><option value="g1">G1</option></select>
<input data-field="label" value="Web">
</div>
<div data-row>
<input type="checkbox" data-field="include" checked>
<input type="hidden" data-field="monitor_id" value="m2">
<select data-field="group_id" data-nullable><option value="">none</option><option value="g1" selected>G1</option></select>
<input data-field="label" value="">
</div>
<button type="submit">save</button>
</form>
<form data-api="/admin/orgs/o1/limits" data-method="put" id="limits">
<input name="monitors" data-number data-nullable value="">
<input name="status_pages" data-number data-nullable value="0">
<input name="regions_per_monitor" data-number value="">
</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: {} }) }) };
</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 form = document.getElementById("f");
const submit = async () => {
form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
await new Promise((r) => setTimeout(r, 20));
return sent.at(-1);
};
let body = await submit();
check("fields of a disabled fieldset are skipped", body.config.method, "POST");
check("numbered names build arrays", body.config.assertions, [{ path: "status", op: "==" }, { path: "queue.depth", op: "<" }]);
check("header lines become an object", body.config.headers, { Authorization: "Bearer a:b", "X-Empty": "" });
check("regions sent", body.regions, ["r1"]);
check("default alert group selected", body.alert_group_ids, ["default"]);
check("empty channel list stays an array", body.channel_ids, []);
form.querySelector('[name="alert_group_ids"][value="default"]').checked = false;
body = await submit();
check("cleared alert groups sent explicitly", body.alert_group_ids, []);
form.querySelector('[name="alert_group_ids"][value="ops"]').checked = true;
body = await submit();
check("custom alert group selected", body.alert_group_ids, ["ops"]);
const sel = form.querySelector("[data-type-select]");
sel.value = "heartbeat";
sel.dispatchEvent(new Event("change", { bubbles: true }));
check("target hidden for heartbeats", form.querySelector('[data-hide-for]').hidden, true);
check("target not required for heartbeats", form.querySelector('[name="target"]').required, false);
body = await submit();
check("regions of a hidden fieldset are not sent", body.regions, []);
sel.value = "json";
sel.dispatchEvent(new Event("change", { bubbles: true }));
check("target required again", form.querySelector('[name="target"]').required, true);
const box = document.querySelector("#auto input");
box.checked = false;
box.dispatchEvent(new Event("change", { bubbles: true }));
await new Promise((r) => setTimeout(r, 20));
check("autosave forms are sent on change", sent.at(-1), { allow_private: false });
const qhForm = document.getElementById("qh");
const submitQH = async () => {
qhForm.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
await new Promise((r) => setTimeout(r, 20));
return sent.at(-1);
};
check("empty quiet_hours sent as array", (await submitQH()).quiet_hours, []);
qhForm.querySelector("[data-quiet-add]").click();
qhForm.querySelector("[data-quiet-add]").click();
const rows = qhForm.querySelectorAll("[data-quiet-row]");
rows[0].querySelector('[name$=".time_zone"]').value = "UTC";
rows[1].querySelector('[name$=".start"]').value = "00:00";
rows[1].querySelector('[name$=".end"]').value = "00:00";
rows[1].querySelector('[name$=".time_zone"]').value = "Europe/Berlin";
rows[1].querySelector('[value="5"]').checked = true;
rows[0].querySelector("[data-quiet-remove]").click();
check("removing first quiet_hours row re-indexes densely", (await submitQH()).quiet_hours, [
{ start: "00:00", end: "00:00", time_zone: "Europe/Berlin", weekdays: ["5"] },
]);
qhForm.querySelector("[data-quiet-remove]").click();
check("removing all quiet_hours rows sends empty array", (await submitQH()).quiet_hours, []);
const spForm = document.getElementById("sp");
spForm.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
await new Promise((r) => setTimeout(r, 20));
check("data-rows respects data-nullable on group_id", sent.at(-1), {
monitors: [
{ monitor_id: "m1", group_id: null, label: "Web" },
{ monitor_id: "m2", group_id: "g1", label: "" },
],
});
const limits = document.getElementById("limits");
limits.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
await new Promise((r) => setTimeout(r, 20));
check("empty nullable numbers are null, others numbers", sent.at(-1), { monitors: null, status_pages: 0, regions_per_monitor: 0 });
document.getElementById("out").textContent = out.join("\n");
})();
</script></body></html>