more admin dashboard polish, some code cleanup
This commit is contained in:
parent
65f277b3f2
commit
a66460be19
23 changed files with 163 additions and 231 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue