Run manual diagnostic attachments in the background
This commit is contained in:
1 parent
d845a5e4b6
commit
89ac4d5bcd
40 files changed
+1560
-58
No files matched your search
@@ -718,3 +718,5 @@ table.compact td, table.compact th { padding-top: 6px; padding-bottom: 6px; }
|
||||
.settings-tls-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.settings-tls-row .btn { grid-column: 1 / -1; justify-self: end; }
|
||||
}
|
||||
|
||||
.trace-output { margin: 6px 0 0; padding: 8px 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; font-family: var(--font-mono); font-size: 12px; background: var(--surface-2, rgba(127,127,127,.12)); border-radius: 6px; }
|
||||
@@ -0,0 +1,61 @@
|
||||
(() => {
|
||||
const form = document.getElementById("diagnostics-attach");
|
||||
const submit = document.getElementById("diagnostics-submit");
|
||||
const connection = document.getElementById("diagnostics-connection");
|
||||
const operation = () => document.getElementById("diagnostics-operation");
|
||||
const statusLink = connection.querySelector("a");
|
||||
let sending = false;
|
||||
|
||||
function updateSubmit() {
|
||||
const current = operation();
|
||||
if (current) {
|
||||
submit.disabled = sending || current.dataset.pending === "true";
|
||||
}
|
||||
}
|
||||
|
||||
document.body.addEventListener("htmx:configRequest", (event) => {
|
||||
const { triggeringEvent, parameters } = event.detail;
|
||||
if (triggeringEvent?.type === "diagnostics-changed") {
|
||||
parameters.operation = triggeringEvent.detail.operation;
|
||||
}
|
||||
});
|
||||
document.body.addEventListener("htmx:beforeRequest", (event) => {
|
||||
if (event.detail.elt === form) {
|
||||
if (sending || operation()?.dataset.pending === "true") {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
sending = true;
|
||||
connection.hidden = true;
|
||||
}
|
||||
});
|
||||
|
||||
document.body.addEventListener("htmx:afterSettle", (event) => {
|
||||
if (event.detail.elt.id === "diagnostics-operation") {
|
||||
updateSubmit();
|
||||
connection.hidden = true;
|
||||
}
|
||||
});
|
||||
document.body.addEventListener("htmx:afterRequest", (event) => {
|
||||
if (event.detail.requestConfig.elt === form) {
|
||||
sending = false;
|
||||
updateSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
for (const name of ["htmx:sendError", "htmx:timeout", "htmx:responseError"]) {
|
||||
document.body.addEventListener(name, (event) => {
|
||||
const source = event.detail.requestConfig?.elt;
|
||||
if (source === form) {
|
||||
connection.firstElementChild.textContent = "Запуск пока не подтверждён. Можно повторить отправку.";
|
||||
statusLink.href = "/diagnostics?operation=" + encodeURIComponent(document.getElementById("diagnostics-key").value);
|
||||
statusLink.hidden = false;
|
||||
connection.hidden = false;
|
||||
} else if (source?.id === "diagnostics-operation") {
|
||||
connection.firstElementChild.textContent = "Связь со страницей статуса прервалась. Продолжаем проверять…";
|
||||
statusLink.hidden = true;
|
||||
connection.hidden = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user