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
24
admin/static/tracks.js
Normal file
24
admin/static/tracks.js
Normal 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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue