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
|
||||
|
||||
// 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);
|
||||
@ -87,4 +107,4 @@ function renderChannels() {
|
||||
}
|
||||
|
||||
// Am Ende von ui-channels.js
|
||||
window.initChannels = renderChannels;
|
||||
window.initChannels = renderChannels;
|
||||
|
||||
@ -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 %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user