Checkbox für Playliste hinzugefügt

This commit is contained in:
Erik Thiele
2026-05-10 13:49:05 +02:00
parent 296e59e709
commit a1b48e35d6
8 changed files with 152 additions and 61 deletions

View File

@@ -64,6 +64,7 @@
.playlist-row {
display: grid;
grid-template-columns:
28px /* Enabled */
1fr /* Name */
90px /* Typ */
80px /* Größe */
@@ -198,6 +199,11 @@
<li class="list-group-item playlist-row"
data-file="{{ file.name }}">
<input class="form-check-input playlist-enabled"
type="checkbox"
{% if file.enabled %}checked{% endif %}
title="Element aktivieren">
<span class="playlist-name"
{% if file.type == "image" %}
data-bs-toggle="tooltip"
@@ -248,7 +254,7 @@
<button class="btn btn-primary"
onclick="savePlaylist('priority')">
Priority-Reihenfolge speichern
Priority-Playlist speichern
</button>
</div>
@@ -354,6 +360,11 @@
<li class="list-group-item playlist-row"
data-file="{{ file.name }}">
<input class="form-check-input playlist-enabled"
type="checkbox"
{% if file.enabled %}checked{% endif %}
title="Element aktivieren">
<span class="playlist-name"
{% if file.type == "image" %}
data-bs-toggle="tooltip"
@@ -400,7 +411,7 @@
<button class="btn btn-primary"
onclick="savePlaylist('{{ screen }}')">
Reihenfolge speichern
Playlist speichern
</button>
</div>
@@ -448,12 +459,22 @@ document.addEventListener("DOMContentLoaded", function () {
const items = document.querySelectorAll(
"#playlist-" + screen + " li"
);
const playlist = [];
const enabled = {};
items.forEach((item) => {
const checkbox = item.querySelector(".playlist-enabled");
const fileName = item.dataset.file;
enabled[fileName] = !!(checkbox && checkbox.checked);
playlist.push(fileName);
});
fetch("/admin/playlist/" + screen, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
playlist: Array.from(items).map(i => i.dataset.file)
playlist: playlist,
enabled: enabled
})
}).then(() => location.reload());
}
@@ -471,5 +492,3 @@ document.addEventListener("DOMContentLoaded", function () {
</body>
</html>