diff --git a/static/app.js b/static/app.js
index 1cd1494..35a2175 100644
--- a/static/app.js
+++ b/static/app.js
@@ -21,6 +21,35 @@ function updateDeviceStatus() {
});
}
+function updateInterfaceStatus(deviceName, interfaces) {
+ const interfaceList = document.querySelector(`.interface-group[data-device-name="${deviceName}"] .interface-list`);
+ if (interfaceList && interfaces) {
+ interfaceList.innerHTML = '';
+ Object.entries(interfaces.ports || {}).forEach(([portName, port]) => {
+ interfaceList.innerHTML += `
+
+ ${portName}
+ ${port.speed.current}/${port.speed.max} Mbps
+ ${port.state}
+
+ `;
+ });
+ }
+}
+
+function updateSystemHealth(deviceName, diagnostics) {
+ const metricsContainer = document.querySelector(`.health-metrics[data-device-name="${deviceName}"] .metrics-list`);
+ if (metricsContainer && diagnostics) {
+ const cpu = metricsContainer.querySelector('.cpu');
+ const memory = metricsContainer.querySelector('.memory');
+ const temperature = metricsContainer.querySelector('.temperature');
+
+ cpu.innerHTML = `CPU: ${diagnostics.system?.cpu || 'N/A'}%`;
+ memory.innerHTML = `Memory: ${diagnostics.system?.memory || 'N/A'}%`;
+ temperature.innerHTML = `Temp: ${diagnostics.system?.temperature || 'N/A'}°C`;
+ }
+}
+
function updateSystemMetrics() {
fetch('/api/metrics')
.then(response => response.json())
@@ -32,18 +61,14 @@ function updateSystemMetrics() {
}
//Metric updates like interfaces, power, and health
+
function updateDiagnostics() {
- console.log('Updating diagnostics...');
fetch('/api/diagnostics')
.then(response => response.json())
.then(data => {
- console.log('Received diagnostic data:', data);
- const diagnosticsPanel = document.querySelector('.diagnostics-content');
- diagnosticsPanel.innerHTML = '';
-
- Object.entries(data).forEach(([device, diagnostics]) => {
- const diagElement = createDiagnosticElement(device, diagnostics);
- diagnosticsPanel.appendChild(diagElement);
+ Object.entries(data).forEach(([deviceName, diagnostics]) => {
+ updateInterfaceStatus(deviceName, diagnostics.interfaces);
+ updateSystemHealth(deviceName, diagnostics);
});
});
}