whatsapp_bridge/ui/index.html aktualisiert

This commit is contained in:
2026-04-15 18:18:53 +00:00
parent 9c5964147d
commit 1c656b87ed

View File

@@ -1,51 +1,98 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bahmcloud Bridge Manager</title>
<style>
body { font-family: -apple-system, system-ui, sans-serif; background: #111; color: white; text-align: center; padding: 20px; }
.card { background: #222; border-radius: 15px; padding: 25px; max-width: 400px; margin: 40px auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 1px solid #333; }
h1 { color: #25D366; margin-bottom: 5px; }
.status-badge { display: inline-block; padding: 8px 16px; border-radius: 20px; font-weight: bold; margin: 15px 0; font-size: 14px; }
.connected { background: #25D366; color: black; }
.disconnected { background: #e74c3c; color: white; }
.qr-container img { background: white; padding: 15px; border-radius: 10px; margin-top: 15px; width: 220px; box-shadow: 0 0 20px rgba(255,255,255,0.1); }
.btn { display: block; width: 100%; padding: 12px; margin: 12px 0; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.2s; font-size: 14px; }
.btn-orange { background: #f39c12; color: white; }
.btn-orange:hover { background: #e67e22; }
.btn-red { background: #e74c3c; color: white; }
.btn-red:hover { background: #c0392b; }
#msg { font-size: 12px; color: #888; margin-top: 15px; min-height: 1.2em; }
</style>
</head>
<body>
<div class="card">
<h1>Bahmcloud Bridge</h1>
<p style="color: #666; font-size: 13px; margin-bottom: 20px;">WhatsApp Management Interface</p>
<div id="status" class="status-badge disconnected">Initialisiere...</div>
<div id="qr-section" class="qr-container" style="display:none;">
<p style="font-size: 14px;">Bitte QR-Code scannen:</p>
<div id="qr-code"></div>
</div>
<div style="margin-top: 30px; border-top: 1px solid #333; padding-top: 10px;">
<button class="btn btn-orange" onclick="cmd('auth/logout', 'POST', 'Möchtest du die aktuelle Nummer abmelden?')">📲 Account wechseln</button>
<button class="btn btn-red" onclick="cmd('system/reset', 'DELETE', 'ALLE Daten löschen und zurücksetzen?')">⚠️ Werkseinstellungen</button>
</div>
<p id="msg"></p>
</div>
<script> <script>
// Wir nutzen relative Pfade (ohne führenden Slash), // Erkennt den aktuellen Pfad (wichtig für HA Ingress)
// damit Ingress den Pfad korrekt auflöst. const getBaseUrl = () => {
const path = window.location.pathname;
return path.endsWith('/') ? path : path + '/';
};
async function update() { async function update() {
try { try {
const res = await fetch('api/status'); // Geändert von /api/status const response = await fetch(getBaseUrl() + 'api/status');
if (!res.ok) throw new Error('Network error'); const data = await response.json();
const data = await res.json();
const statusEl = document.getElementById('status'); const statusEl = document.getElementById('status');
const qrSection = document.getElementById('qr-section'); const qrSection = document.getElementById('qr-section');
if (data.isReady) { if (data.isReady) {
statusEl.innerText = "CONNECTED ✅"; statusEl.innerText = "VERBUNDEN ✅";
statusEl.className = "status-badge connected"; statusEl.className = "status-badge connected";
qrSection.style.display = "none"; qrSection.style.display = "none";
} else if (data.hasQr) { } else if (data.hasQr) {
statusEl.innerText = "WAITING FOR SCAN 📱"; statusEl.innerText = "WARTE AUF SCAN 📱";
statusEl.className = "status-badge disconnected"; statusEl.className = "status-badge disconnected";
qrSection.style.display = "block"; qrSection.style.display = "block";
document.getElementById('qr-code').innerHTML = `<img src="${data.qrCode}">`; document.getElementById('qr-code').innerHTML = `<img src="${data.qrCode}">`;
} else { } else {
statusEl.innerText = "INITIALIZING..."; statusEl.innerText = "LADE CLIENT...";
qrSection.style.display = "none"; qrSection.style.display = "none";
} }
} catch (e) { } catch (e) {
console.error("Update failed", e); document.getElementById('status').innerText = "VERBINDUNG VERLOREN ❌";
document.getElementById('status').innerText = "OFFLINE ❌"; document.getElementById('status').className = "status-badge disconnected";
} }
} }
async function cmd(url, method, msg) { async function cmd(endpoint, method, confirmMsg) {
if (!confirm(msg)) return; if (!confirm(confirmMsg)) return;
document.getElementById('msg').innerText = "Working...";
// Auch hier: Slash am Anfang entfernen für relative Pfade const msgEl = document.getElementById('msg');
const relativeUrl = url.startsWith('/') ? url.substring(1) : url; msgEl.innerText = "Befehl wird gesendet...";
try { try {
const res = await fetch(relativeUrl, { method }); const res = await fetch(getBaseUrl() + endpoint, { method });
const data = await res.json(); const data = await res.json();
alert(data.message); alert(data.message);
location.reload(); location.reload();
} catch (e) { } catch (e) {
alert("Error: " + e.message); alert("Fehler: " + e.message);
msgEl.innerText = "";
} }
} }
// Alle 3 Sekunden aktualisieren
setInterval(update, 3000); setInterval(update, 3000);
update(); update();
</script> </script>
</body>
</html>