fixxed ui-channels.js
This commit is contained in:
parent
93bd4cc06d
commit
d8d23b0c08
@ -1,5 +1,25 @@
|
|||||||
// static/js/ui-channels.js – Kanal-Rendering & Listener
|
// 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() {
|
function renderChannels() {
|
||||||
console.log("renderChannels() START");
|
console.log("renderChannels() START");
|
||||||
console.log("→ config.channels existiert?", !!config?.channels);
|
console.log("→ config.channels existiert?", !!config?.channels);
|
||||||
|
|||||||
@ -167,14 +167,14 @@
|
|||||||
|
|
||||||
<!-- Seiten-spezifische Config setzen (nur wenn config existiert) -->
|
<!-- Seiten-spezifische Config setzen (nur wenn config existiert) -->
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }} <!-- Ruft den Basis-Block auf (Module laden + Initialisierung) -->
|
|
||||||
|
|
||||||
<script>
|
<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.mkConfig = {{ config | tojson | safe }};
|
||||||
window.mkGlobalSounds = {{ global_sounds | tojson | safe }};
|
window.mkGlobalSounds = {{ global_sounds | tojson | safe }};
|
||||||
|
|
||||||
console.log("control.html → mkConfig gesetzt:", window.mkConfig);
|
console.log("control.html → mkConfig gesetzt:", window.mkConfig);
|
||||||
console.log("control.html → mkGlobalSounds:", window.mkGlobalSounds);
|
console.log("control.html → mkGlobalSounds:", window.mkGlobalSounds);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{{ super() }} <!-- Basis-Skripte + Initialisierung -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user