2024-08-31 00:30:30 +00:00
|
|
|
const newReleaseBtn = document.getElementById("create-release");
|
2024-09-03 07:07:45 +00:00
|
|
|
const newArtistBtn = document.getElementById("create-artist");
|
2024-09-01 03:43:32 +00:00
|
|
|
const newTrackBtn = document.getElementById("create-track");
|
2024-08-31 00:30:30 +00:00
|
|
|
|
|
|
|
newReleaseBtn.addEventListener("click", event => {
|
|
|
|
event.preventDefault();
|
|
|
|
const id = prompt("Enter an ID for this release:");
|
|
|
|
if (id == null || id == "") return;
|
|
|
|
|
|
|
|
fetch("/api/v1/music", {
|
|
|
|
method: "POST",
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
body: JSON.stringify({id})
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ok) location = "/admin/release/" + id;
|
|
|
|
else {
|
|
|
|
res.text().then(err => {
|
|
|
|
alert("Request failed: " + err);
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
alert("Failed to create release. Check the console for details.");
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
});
|
2024-09-01 03:43:32 +00:00
|
|
|
|
2024-09-03 07:07:45 +00:00
|
|
|
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/artist/" + id;
|
|
|
|
} else {
|
|
|
|
alert("Request failed: " + text);
|
|
|
|
console.error(text);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
|
|
|
alert("Failed to create artist. Check the console for details.");
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-09-01 03:43:32 +00:00
|
|
|
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/track/" + text;
|
|
|
|
} else {
|
|
|
|
alert("Request failed: " + text);
|
|
|
|
console.error(text);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}).catch(err => {
|
2024-09-03 07:07:45 +00:00
|
|
|
alert("Failed to create track. Check the console for details.");
|
2024-09-01 03:43:32 +00:00
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
});
|