feat(console): sort the monitor list and put monitors in an order of one's own
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m49s
ci / test (pull_request) Successful in 14m39s
ci / build (pull_request) Canceled after 14m22s
ci / image (pull_request) Canceled after 0s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m49s
ci / test (pull_request) Successful in 14m39s
ci / build (pull_request) Canceled after 14m22s
ci / image (pull_request) Canceled after 0s
The monitor list gets a sort switcher: the organization's own order, by default, or by name, status (problems first), uptime (worst first) or latency (slowest first). The choice is remembered in a cookie; paging follows it. "Arrange monitors" shows the whole tree with each group's monitors to drag, or move with up and down, into the order wanted; every change is saved at once through PUT /api/v1/org/monitors/order, which needs write access to every monitor given and is audited. Monitors without a position follow the positioned ones, by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
ca852c8299
commit
b0d4bcc002
16 files changed
+3389
-2653
No files matched your search
@@ -178,6 +178,43 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Saves the order of a list of monitors being arranged.
|
||||
const saveOrder = async (list) => {
|
||||
const ids = [...list.querySelectorAll(":scope > [data-sort-id]")].map((li) => li.dataset.sortId);
|
||||
try {
|
||||
await api.put(list.dataset.sortable, { monitor_ids: ids });
|
||||
} catch (err) {
|
||||
alert(message(err));
|
||||
location.reload();
|
||||
}
|
||||
};
|
||||
let dragged = null;
|
||||
document.addEventListener("dragstart", (ev) => {
|
||||
const item = ev.target.closest?.("[data-sortable] > [data-sort-id]");
|
||||
if (!item) return;
|
||||
dragged = item;
|
||||
ev.dataTransfer.effectAllowed = "move";
|
||||
item.style.opacity = "0.5";
|
||||
});
|
||||
document.addEventListener("dragover", (ev) => {
|
||||
const over = ev.target.closest?.("[data-sortable] > [data-sort-id]");
|
||||
if (!dragged || !over || over === dragged || over.parentElement !== dragged.parentElement) return;
|
||||
ev.preventDefault();
|
||||
const box = over.getBoundingClientRect();
|
||||
if (ev.clientY < box.top + box.height / 2) over.before(dragged);
|
||||
else over.after(dragged);
|
||||
});
|
||||
document.addEventListener("drop", (ev) => {
|
||||
if (dragged) ev.preventDefault();
|
||||
});
|
||||
document.addEventListener("dragend", async () => {
|
||||
if (!dragged) return;
|
||||
const list = dragged.parentElement;
|
||||
dragged.style.opacity = "";
|
||||
dragged = null;
|
||||
await saveOrder(list);
|
||||
});
|
||||
|
||||
document.addEventListener("click", async (ev) => {
|
||||
const navToggle = ev.target.closest("[data-nav-toggle]");
|
||||
if (navToggle) {
|
||||
@@ -186,6 +223,18 @@
|
||||
navToggle.setAttribute("aria-expanded", String(open));
|
||||
return;
|
||||
}
|
||||
// Moves a monitor up or down while arranging the monitor list.
|
||||
const move = ev.target.closest("[data-sort-move]");
|
||||
if (move) {
|
||||
const item = move.closest("[data-sort-id]");
|
||||
const other = move.dataset.sortMove === "up" ? item.previousElementSibling : item.nextElementSibling;
|
||||
if (!other) return;
|
||||
if (move.dataset.sortMove === "up") other.before(item);
|
||||
else other.after(item);
|
||||
move.focus();
|
||||
await saveOrder(item.closest("[data-sortable]"));
|
||||
return;
|
||||
}
|
||||
// Ticks or clears every checkbox named by data-check-all in its form.
|
||||
const checkAll = ev.target.closest("[data-check-all]");
|
||||
if (checkAll) {
|
||||
|
||||
Reference in new issue
Block a user