added functionality
This commit is contained in:
18
static/app.js
Normal file
18
static/app.js
Normal file
@ -0,0 +1,18 @@
|
||||
function updateDeviceStatus() {
|
||||
fetch('/api/status')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
Object.entries(data).forEach(([deviceName, isUp]) => {
|
||||
const deviceElement = document.querySelector(`.device-status:has(span:contains("${deviceName}"))`);
|
||||
if (deviceElement) {
|
||||
const indicator = deviceElement.querySelector('.status-indicator');
|
||||
indicator.className = `status-indicator status-${isUp ? 'up' : 'down'}`;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Update every 30 seconds
|
||||
setInterval(updateDeviceStatus, 30000);
|
||||
// Initial update
|
||||
updateDeviceStatus();
|
||||
Reference in New Issue
Block a user