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 a66460be19
Signed by: ari
GPG key ID: CF99829C92678188
23 changed files with 163 additions and 231 deletions

24
admin/static/tracks.js Normal file
View file

@ -0,0 +1,24 @@
const newTrackBtn = document.getElementById("create-track");
if (newTrackBtn) newTrackBtn.addEventListener("click", event => {
event.preventDefault();
const title = prompt("Enter an title for this track:");
if (title == null || title == "") return;
fetch("/api/v1/track", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({title})
}).then(res => {
res.text().then(text => {
if (res.ok) {
location = "/admin/tracks/" + text;
} else {
alert(text);
console.error(text);
}
})
}).catch(err => {
alert("Failed to create track. Check the console for details.");
console.error(err);
});
});