more admin dashboard polish, some code cleanup

This commit is contained in:
ari melody 2025-11-06 22:08:06 +00:00
parent 65f277b3f2
commit c547fca0d7
Signed by: ari
GPG key ID: CF99829C92678188
27 changed files with 187 additions and 270 deletions

View file

@ -4,4 +4,29 @@ document.addEventListener("readystatechange", () => {
document.querySelectorAll(".artists-group .artist").forEach(el => {
hijackClickEvent(el, el.querySelector("a.artist-name"))
});
const newArtistBtn = document.getElementById("create-artist");
if (newArtistBtn) newArtistBtn.addEventListener("click", event => {
event.preventDefault();
const id = prompt("Enter an ID for this artist:");
if (id == null || id == "") return;
fetch("/api/v1/artist", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({id})
}).then(res => {
res.text().then(text => {
if (res.ok) {
location = "/admin/artists/" + id;
} else {
alert(text);
console.error(text);
}
})
}).catch(err => {
alert("Failed to create artist. Check the console for details.");
console.error(err);
});
});
});