From 0a8e25ea698333c73c50fc84e3334e1079606a10 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 31 May 2023 18:14:25 +0200 Subject: allow admins to skip or delete songs --- web/client.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'web') 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}} } @@ -362,6 +388,7 @@ {{if .IsAdmin}}
+
{{end}} -- cgit v1.2.3