aboutsummaryrefslogtreecommitdiff
path: root/web/client.html
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-05-31 18:14:25 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-05-31 18:14:25 +0200
commit0a8e25ea698333c73c50fc84e3334e1079606a10 (patch)
treecbb29a6c23de33214e67b951a75f1c554ba2fcef /web/client.html
parent1f89f1d22ced0bb107514efb7e861247c2941a70 (diff)
downloadWRMS-0a8e25ea698333c73c50fc84e3334e1079606a10.tar.gz
WRMS-0a8e25ea698333c73c50fc84e3334e1079606a10.zip
allow admins to skip or delete songs
Diffstat (limited to 'web/client.html')
-rw-r--r--web/client.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/web/client.html b/web/client.html
index 20aa7ad..91ce11d 100644
--- a/web/client.html
+++ b/web/client.html
@@ -147,6 +147,17 @@
listItem.appendChild(document.createTextNode(song.weight + ' ' + formatSong(song)));
listItem.appendChild(newSourceLabel(song));
+ {{if .IsAdmin}}
+ let delBtn = document.createElement("button");
+ delBtn.style.marginLeft = 10 + "px";
+ delBtn.appendChild(document.createTextNode("delete"));
+ delBtn.addEventListener("click", function() {
+ const params = new URLSearchParams();
+ params.append("song", song.uri)
+ new HttpClient().get("/delete?" + params.toString(), console.log);
+ });
+ listItem.appendChild(delBtn);
+ {{end}}
playlist.appendChild(listItem);
}
}
@@ -156,6 +167,14 @@
renderPlaylist();
}
+ function handleDelete(deleted) {
+ for (const deletedSong of deleted) {
+ const index = songs.findIndex(function(s) {return s.uri == deletedSong.uri});
+ if (index > -1) { songs.splice(index, 1); }
+ }
+ renderPlaylist();
+ }
+
function handleVotes(direction, votedSongs) {
for (const song of votedSongs) {
votes.set(song.uri, direction)
@@ -219,6 +238,9 @@
case "add":
handleAdd(cmd.songs)
break;
+ case "delete":
+ handleDelete(cmd.songs)
+ break;
case "update":
handleUpdate(cmd.songs)
break;
@@ -327,6 +349,10 @@
document.getElementById("ppbutton").addEventListener("click", function() {
new HttpClient().get("/playpause", console.log);
});
+
+ document.getElementById("nextbutton").addEventListener("click", function() {
+ new HttpClient().get("/next", console.log);
+ });
{{end}}
}
</script>
@@ -362,6 +388,7 @@
{{if .IsAdmin}}
<div id='controls'>
<button id="ppbutton">Play</button>
+ <button id="nextbutton">Next</button>
</div>
{{end}}