Added updating shit
All checks were successful
Test compiling project / test (push) Successful in 2m32s
All checks were successful
Test compiling project / test (push) Successful in 2m32s
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user