fixxed ui-channels.js

This commit is contained in:
oberon 2026-02-16 20:59:54 +01:00
parent 93bd4cc06d
commit d8d23b0c08
2 changed files with 24 additions and 4 deletions

View File

@ -1,5 +1,25 @@
// static/js/ui-channels.js Kanal-Rendering & Listener
// Gemeinsame Helper-Funktion zum Senden von Steuerbefehlen
async function sendControl(port, value) {
try {
const res = await fetch('/api/control', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ port, value })
});
const data = await res.json();
if (!data.success) {
throw new Error(data.message || 'Unbekannter Fehler');
}
} catch (err) {
console.error(`sendControl(${port}, ${value}) fehlgeschlagen:`, err);
alert(`Steuerbefehl fehlgeschlagen: ${err.message}`);
updateStatus(false, 'Steuerfehler');
}
}
function renderChannels() {
console.log("renderChannels() START");
console.log("→ config.channels existiert?", !!config?.channels);

View File

@ -167,14 +167,14 @@
<!-- Seiten-spezifische Config setzen (nur wenn config existiert) -->
{% block scripts %}
{{ super() }} <!-- Ruft den Basis-Block auf (Module laden + Initialisierung) -->
<script>
// Config + globale Sounds global verfügbar machen (nur auf dieser Seite)
// Config + globale Sounds global verfügbar machen (muss VOR initConfig passieren)
window.mkConfig = {{ config | tojson | safe }};
window.mkGlobalSounds = {{ global_sounds | tojson | safe }};
console.log("control.html → mkConfig gesetzt:", window.mkConfig);
console.log("control.html → mkGlobalSounds:", window.mkGlobalSounds);
</script>
{{ super() }} <!-- Basis-Skripte + Initialisierung -->
{% endblock %}