Tank level in red inf below limit

This commit is contained in:
Etienne Chassaing 2025-08-28 10:48:54 +02:00
parent 1c603a5cb1
commit dd6cc73cf0

View File

@ -596,13 +596,19 @@
if (dsData) { if (dsData) {
const tankLevelElement = document.querySelector("#TankLevel .monitor-value"); const tankLevelElement = document.querySelector("#TankLevel .monitor-value");
const qconsoElement = document.querySelector("#Qconso .monitor-value"); const qconsoElement = document.querySelector("#Qconso .monitor-value");
if (tankLevelElement) { if (tankLevelElement) {
tankLevelElement.innerHTML = `<br>${dsData.TankLevel.toFixed(1)}`; const tankLevelValue = dsData.TankLevel;
} else { tankLevelElement.innerHTML = `<br>${tankLevelValue.toFixed(1)} %`;
console.error('Element with selector "#TankLevel .monitor-value" not found.');
}
// ✅ Make it red if below 35
if (tankLevelValue < 35) {
tankLevelElement.style.color = "red";
tankLevelElement.style.fontWeight = "bold";
} else {
tankLevelElement.style.color = "white"; // reset to normal
tankLevelElement.style.fontWeight = "normal";
}
}
if (qconsoElement) { if (qconsoElement) {
qconsoElement.innerHTML = `<br>${dsData.Qconso.toFixed(1)} L/h`; qconsoElement.innerHTML = `<br>${dsData.Qconso.toFixed(1)} L/h`;
} else { } else {
@ -610,6 +616,9 @@
} }
} }
} catch (error) { } catch (error) {
console.error('Error fetching monitor data:', error); console.error('Error fetching monitor data:', error);
} }