diff --git a/server/backend/internal/httpapi/manage/templates.go b/server/backend/internal/httpapi/manage/templates.go index 3893d70..17a7382 100644 --- a/server/backend/internal/httpapi/manage/templates.go +++ b/server/backend/internal/httpapi/manage/templates.go @@ -777,6 +777,12 @@ const manageTmpl = ` .morz-toast.show { transform:translateX(0); } .morz-toast.is-success { background:#f0fdf4; color:#166534; border:1px solid #bbf7d0; } .morz-toast.is-danger { background:#fef2f2; color:#991b1b; border:1px solid #fecaca; } + /* Display control box */ + .display-ctrl { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; } + .display-state-badge { font-size:.75rem; padding:.2em .65em; border-radius:99px; font-weight:700; } + .display-state-badge.on { background:#dcfce7; color:#166534; } + .display-state-badge.off { background:#fee2e2; color:#991b1b; } + .display-state-badge.unknown { background:#f3f4f6; color:#6b7280; } @@ -932,6 +938,19 @@ const manageTmpl = `
+ +
+

Display

+
+ + {{if eq .DisplayState "on"}}An{{else if eq .DisplayState "off"}}Aus{{else}}Unbekannt{{end}} + + + +
+
@@ -1085,6 +1104,31 @@ function showToast(msg, type) { setTimeout(function() { t.classList.remove('show'); setTimeout(function() { t.remove(); }, 300); }, 3500); } +// ─── Display control ───────────────────────────────────────────── +function sendDisplayCmd(state) { + var slug = {{.Screen.Slug | printf "%q"}}; + fetch('/api/v1/screens/' + slug + '/display', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRF-Token': getCsrf(), + 'X-Requested-With': 'fetch' + }, + body: JSON.stringify({state: state}) + }).then(function(r) { + if (r.ok) { + var badge = document.getElementById('display-state-badge'); + if (badge) { + badge.className = 'display-state-badge ' + state; + badge.textContent = state === 'on' ? 'An' : 'Aus'; + } + showToast('Display ' + (state === 'on' ? 'eingeschaltet' : 'ausgeschaltet'), 'is-success'); + } else { + showToast('Fehler beim Schalten', 'is-danger'); + } + }).catch(function() { showToast('Netzwerkfehler', 'is-danger'); }); +} + // ─── ?msg= toast ───────────────────────────────────────────────── (function() { var msg = new URLSearchParams(window.location.search).get('msg'); @@ -1158,7 +1202,11 @@ if (sortableEl) { var ids = Array.from(sortableEl.querySelectorAll('.pl-item[data-id]')).map(function(el) { return el.dataset.id; }); fetch('/manage/' + SCREEN_SLUG + '/reorder', { method: 'POST', - headers: {'Content-Type':'application/json'}, + headers: { + 'Content-Type':'application/json', + 'X-CSRF-Token': getCsrf(), + 'X-Requested-With': 'fetch' + }, body: JSON.stringify(ids) }).then(function(r) { if (!r.ok) { showToast('⚠ Reihenfolge nicht gespeichert.','is-danger'); window.location.reload(); }