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>

View File

@@ -131,6 +131,9 @@ function normalizeItem(item) {
if (item.kind === "url" && !("zoom" in item)) {
item.zoom = 1.0;
}
if (!("enabled" in item)) {
item.enabled = true;
}
return item;
}
@@ -149,29 +152,31 @@ function isHtml(item) {
function getNextItem() {
const normalizedNormal = normalFiles.map(normalizeItem);
const normalizedPrio = prioFiles.map(normalizeItem);
const activeNormal = normalizedNormal.filter(item => item.enabled !== false);
const activePrio = normalizedPrio.filter(item => item.enabled !== false);
// ✅ Sonderfall: nur Priority vorhanden
if (normalizedNormal.length === 0 && normalizedPrio.length > 0) {
if (activeNormal.length === 0 && activePrio.length > 0) {
return {
item: normalizedPrio[prioIndex++ % normalizedPrio.length],
item: activePrio[prioIndex++ % activePrio.length],
isPrio: true
};
}
// ✅ Sonderfall: nur normale Playlist vorhanden
if (normalizedPrio.length === 0 && normalizedNormal.length > 0) {
if (activePrio.length === 0 && activeNormal.length > 0) {
return {
item: normalizedNormal[normalIndex++ % normalizedNormal.length],
item: activeNormal[normalIndex++ % activeNormal.length],
isPrio: false
};
}
// ✅ Normal-Phase
if (mode === "normal") {
const item = normalizedNormal[normalIndex++];
if (normalIndex >= normalizedNormal.length) {
const item = activeNormal[normalIndex++];
if (normalIndex >= activeNormal.length) {
normalIndex = 0;
if (normalizedPrio.length > 0) {
if (activePrio.length > 0) {
mode = "prio"; // ➜ nach kompletter Normal-Playlist wechseln
}
}
@@ -180,8 +185,8 @@ function getNextItem() {
// ✅ Priority-Phase
if (mode === "prio") {
const item = normalizedPrio[prioIndex++];
if (prioIndex >= normalizedPrio.length) {
const item = activePrio[prioIndex++];
if (prioIndex >= activePrio.length) {
prioIndex = 0;
mode = "normal"; // ➜ nach kompletter Priority zurück
}
@@ -280,4 +285,3 @@ setInterval(checkForUpdates, 5000);
</body>
</html>