39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
async function fetchInfo() {
|
|
try {
|
|
const response = await fetch('/api/info');
|
|
const data = await response.json();
|
|
document.getElementById('brain-ip').textContent = `${data.ip}:${data.port}`;
|
|
document.getElementById('brain-host').textContent = data.hostname;
|
|
} catch (error) {
|
|
console.error('Fehler beim Abrufen der Info:', error);
|
|
}
|
|
}
|
|
|
|
async function updateDashboard() {
|
|
try {
|
|
const response = await fetch('/api/latest');
|
|
const data = await response.json();
|
|
|
|
if (data.timestamp) {
|
|
document.getElementById('last-update').textContent = data.timestamp;
|
|
document.getElementById('room-name').textContent = data.room;
|
|
document.getElementById('analysis-text').textContent = data.comment;
|
|
|
|
const img = document.getElementById('latest-image');
|
|
if (data.image_url) {
|
|
img.src = data.image_url;
|
|
img.classList.remove('fallback-img');
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error('Fehler beim Abrufen der Daten:', error);
|
|
}
|
|
}
|
|
|
|
// Alle 2 Sekunden aktualisieren
|
|
setInterval(updateDashboard, 2000);
|
|
|
|
// Initialer Aufruf
|
|
fetchInfo();
|
|
updateDashboard();
|