diff --git a/data/logic.js b/data/logic.js index e65e61b..527a9e5 100644 --- a/data/logic.js +++ b/data/logic.js @@ -32,7 +32,6 @@ function fetchTelemetryData() { function fetchWaterData(gauge) { const apiUrl = '/water_data'; - console.log("FD"); // Fetching data from the API fetch(apiUrl) .then(response => response.json()) @@ -44,6 +43,25 @@ function fetchWaterData(gauge) { }) .catch(error => { console.error("There was an error fetching data from the API", error); + }); +} + +function fetchUpdateData(gauge) { + const apiUrl = '/ota_udpate_status'; + // Fetching data from the API + fetch(apiUrl) + .then(response => response.json()) + .then(data => { + document.getElementById('current_fw').textContent = data.current_version || 'N/A'; + document.getElementById('server_fw').textContent = data.new_version || 'N/A'; + if (data.update_available == "true") { + document.getElementById("update_button").style.visibility = 'visible'; + } else { + document.getElementById("update_button").style.visibility = 'hidden'; + }; + }) + .catch(error => { + console.error("There was an error fetching data from the API for OTA Data", error); }); } @@ -112,10 +130,12 @@ window.addEventListener('DOMContentLoaded', (event) => { fetchTelemetryData(); fetchElectricData(); fetchConnectionData(); + fetchUpdateData(); setInterval(function(){fetchWaterData(gauge);}, 5000); setInterval(fetchTelemetryData, 5000); setInterval(fetchElectricData, 5000); setInterval(fetchConnectionData, 5000); + setInterval(fetchUpdateData, 5000); }); diff --git a/data/status.html b/data/status.html index 96d1d2d..b2411c7 100644 --- a/data/status.html +++ b/data/status.html @@ -68,6 +68,28 @@ + +
| Current Version: | +WAITING | +
| Newest Version: | +WAITING | +
| UPDATE NOW | +