mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-29 03:27:27 +00:00
build: subpackages implementation (#164)
* migrate to hatch * reorder tests * generic fixtures * straight forward conftest * fix docs generation * fix tox environments * reformat tomls * cleanup pyproject * some play with renaming * move root conftest into pytest plugins * fix setup script * move fixtures to __init__.py * remove duplicate fixtures * disable pylint warning * simplify configuration fixture * remove empty conftest * remove crap from local pyprojects
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<script>
|
||||
const alertPlaceholder = document.getElementById("alert-placeholder");
|
||||
|
||||
function createAlert(title, message, clz, action, id) {
|
||||
id ??= md5(title + message); // MD5 id from the content
|
||||
if (alertPlaceholder.querySelector(`#alert-${id}`)) {
|
||||
return; // check if there are duplicates
|
||||
}
|
||||
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.id = `alert-${id}`;
|
||||
wrapper.classList.add("toast", clz);
|
||||
wrapper.role = "alert";
|
||||
wrapper.ariaLive = "assertive";
|
||||
wrapper.ariaAtomic = "true";
|
||||
wrapper.style.width = "500px"; // 500px is default modal size
|
||||
|
||||
const header = document.createElement("div");
|
||||
header.classList.add("toast-header");
|
||||
header.innerHTML = `<strong class="me-auto">${safe(title)}</strong> <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="close"></button>`;
|
||||
wrapper.appendChild(header);
|
||||
|
||||
const body = document.createElement("div");
|
||||
body.classList.add("toast-body", "text-bg-light");
|
||||
body.innerText = message;
|
||||
wrapper.appendChild(body);
|
||||
|
||||
alertPlaceholder.appendChild(wrapper);
|
||||
const toast = new bootstrap.Toast(wrapper);
|
||||
wrapper.addEventListener("hidden.bs.toast", _ => {
|
||||
wrapper.remove(); // bootstrap doesn't remove elements
|
||||
(action || reload)();
|
||||
});
|
||||
toast.show();
|
||||
}
|
||||
|
||||
function showFailure(title, description, error) {
|
||||
let details;
|
||||
try {
|
||||
details = JSON.parse(error.text).error; // execution handler json error response
|
||||
} catch (_) {
|
||||
details = error.text ?? error.message ?? error;
|
||||
}
|
||||
createAlert(title, description(details), "text-bg-danger");
|
||||
}
|
||||
|
||||
function showSuccess(title, description, action) {
|
||||
createAlert(title, description, "text-bg-success", action);
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user