fehlersuche controll seite
This commit is contained in:
parent
66f46d663d
commit
9b3d3c5c8f
@ -21,35 +21,43 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
const config = window.config || {}; // Sicherstellen, dass config existiert
|
const config = window.config || {}; // Sicherstellen, dass config existiert
|
||||||
|
|
||||||
// ── Connect-Button ────────────────────────────────────────────────────────
|
// ── Connect-Button ────────────────────────────────────────────────────────
|
||||||
connectBtn.addEventListener('click', async () => {
|
connectBtn.addEventListener('click', async () => {
|
||||||
connectBtn.disabled = true;
|
connectBtn.disabled = true;
|
||||||
connectBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Verbinde...';
|
connectBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Verbinde...';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/connect', {
|
console.log("→ Sende /api/connect ...");
|
||||||
method: 'POST',
|
const response = await fetch('/api/connect', {
|
||||||
headers: { 'Content-Type': 'application/json' }
|
method: 'POST',
|
||||||
});
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
});
|
||||||
|
|
||||||
const result = await response.json();
|
console.log("→ Antwort erhalten:", response.status);
|
||||||
|
const result = await response.json();
|
||||||
|
console.log("→ Resultat:", result);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
connectSection.style.display = 'none';
|
console.log("→ Connect erfolgreich – blende Sections um");
|
||||||
controlSection.style.display = 'block';
|
connectSection.style.display = 'none';
|
||||||
reconnectSection.style.display = 'none';
|
controlSection.style.display = 'block';
|
||||||
renderChannels();
|
reconnectSection.style.display = 'none';
|
||||||
console.log('Verbindung erfolgreich');
|
|
||||||
} else {
|
console.log("→ Rufe renderChannels() auf");
|
||||||
alert('Verbindung fehlgeschlagen:\n' + (result.message || 'Unbekannter Fehler'));
|
renderChannels();
|
||||||
}
|
|
||||||
} catch (err) {
|
console.log("→ renderChannels() abgeschlossen");
|
||||||
console.error('Connect-Fehler:', err);
|
} else {
|
||||||
alert('Netzwerk- oder Verbindungsfehler: ' + err.message);
|
console.warn("→ Connect fehlgeschlagen:", result.message);
|
||||||
} finally {
|
alert('Verbindung fehlgeschlagen:\n' + (result.message || 'Unbekannter Fehler'));
|
||||||
connectBtn.disabled = false;
|
|
||||||
connectBtn.innerHTML = '<i class="bi bi-bluetooth me-2"></i> Mit Hub verbinden';
|
|
||||||
}
|
}
|
||||||
});
|
} catch (err) {
|
||||||
|
console.error("→ Connect-Fehler:", err);
|
||||||
|
alert('Netzwerk- oder Verbindungsfehler: ' + err.message);
|
||||||
|
} finally {
|
||||||
|
connectBtn.disabled = false;
|
||||||
|
connectBtn.innerHTML = '<i class="bi bi-bluetooth me-2"></i> Mit Hub verbinden';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ── Alle stoppen ──────────────────────────────────────────────────────────
|
// ── Alle stoppen ──────────────────────────────────────────────────────────
|
||||||
if (stopAllBtn) {
|
if (stopAllBtn) {
|
||||||
@ -114,13 +122,34 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
// ── Kanäle dynamisch rendern ──────────────────────────────────────────────
|
// ── Kanäle dynamisch rendern ──────────────────────────────────────────────
|
||||||
function renderChannels() {
|
function renderChannels() {
|
||||||
if (!channelsContainer) return;
|
console.log("renderChannels() START");
|
||||||
channelsContainer.innerHTML = '';
|
console.log("→ config.channels existiert?", !!config?.channels);
|
||||||
|
console.log("→ channels.length:", config?.channels?.length ?? "undefined");
|
||||||
|
|
||||||
if (!config.channels || config.channels.length === 0) {
|
if (!channelsContainer) {
|
||||||
channelsContainer.innerHTML = '<p class="text-center text-muted py-5">Keine Kanäle in der Konfiguration definiert.</p>';
|
console.error("→ channelsContainer nicht gefunden im DOM!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channelsContainer.innerHTML = '';
|
||||||
|
console.log("→ Container geleert");
|
||||||
|
|
||||||
|
if (!config?.channels || config.channels.length === 0) {
|
||||||
|
console.warn("→ Keine Kanäle erkannt – zeige leere Meldung");
|
||||||
|
channelsContainer.innerHTML = '<p class="text-center text-muted py-5">Keine Kanäle in der Konfiguration definiert.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("→ Beginne mit Rendern von", config.channels.length, "Kanälen");
|
||||||
|
|
||||||
|
// function renderChannels() {
|
||||||
|
// if (!channelsContainer) return;
|
||||||
|
// channelsContainer.innerHTML = '';
|
||||||
|
|
||||||
|
// if (!config.channels || config.channels.length === 0) {
|
||||||
|
// channelsContainer.innerHTML = '<p class="text-center text-muted py-5">Keine Kanäle in der Konfiguration definiert.</p>';
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
config.channels.forEach(channel => {
|
config.channels.forEach(channel => {
|
||||||
const col = document.createElement('div');
|
const col = document.createElement('div');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user