From 3618b3329cf0aac460582c01eeab8463403581d9 Mon Sep 17 00:00:00 2001 From: Empire Phoenix Date: Wed, 27 May 2026 15:18:46 +0200 Subject: [PATCH] refactor tank info field names and improve null checks in UI --- Software/MainBoard/rust/src_webpack/src/api.ts | 16 ++++++++-------- Software/MainBoard/rust/src_webpack/src/main.ts | 5 +++++ .../MainBoard/rust/src_webpack/src/tankview.ts | 16 ++++++++-------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Software/MainBoard/rust/src_webpack/src/api.ts b/Software/MainBoard/rust/src_webpack/src/api.ts index cb809cb..2b2aa24 100644 --- a/Software/MainBoard/rust/src_webpack/src/api.ts +++ b/Software/MainBoard/rust/src_webpack/src/api.ts @@ -226,22 +226,22 @@ export interface Detection { } export interface TankInfo { - /// is there enough water in the tank + /// there is enough water in the tank enough_water: boolean, /// warning that water needs to be refilled soon warn_level: boolean, - /// estimation how many ml are still in tank - left_ml: number | null, - /// if there is was an issue with the water level sensor + /// estimation how many ml are still in the tank + volume_ml: number | null, + /// if there is an issue with the water level sensor sensor_error: string | null, /// raw water sensor value - raw: number | null, + fill_raw_v: number | null, /// percent value - percent: number | null, - /// water in tank might be frozen + fill_pct: number | null, + /// water in the tank might be frozen water_frozen: boolean, /// water temperature - water_temp: number | null, + water_temp_c: number | null, temp_sensor_error: string | null } diff --git a/Software/MainBoard/rust/src_webpack/src/main.ts b/Software/MainBoard/rust/src_webpack/src/main.ts index 0cd5fd4..f270740 100644 --- a/Software/MainBoard/rust/src_webpack/src/main.ts +++ b/Software/MainBoard/rust/src_webpack/src/main.ts @@ -765,6 +765,11 @@ executeTasksSequentially().then(() => { controller.progressview.removeProgress("rebooting"); window.addEventListener("beforeunload", (event) => { + // Only check for unsaved changes if initialConfig has been loaded + if (controller.initialConfig === null) { + return; + } + const currentConfig = controller.getConfig(); // Check if the current state differs from the initial configuration diff --git a/Software/MainBoard/rust/src_webpack/src/tankview.ts b/Software/MainBoard/rust/src_webpack/src/tankview.ts index 37ea517..ed42bb6 100644 --- a/Software/MainBoard/rust/src_webpack/src/tankview.ts +++ b/Software/MainBoard/rust/src_webpack/src/tankview.ts @@ -93,28 +93,28 @@ export class TankConfigView { this.tank_measure_error.innerText = JSON.stringify(tankinfo.sensor_error) ; this.tank_measure_error_container.classList.remove("hidden") } - if (tankinfo.left_ml == null){ + if (tankinfo.volume_ml == null){ this.tank_measure_ml_container.classList.add("hidden") } else { - this.tank_measure_ml.innerText = tankinfo.left_ml.toString(); + this.tank_measure_ml.innerText = tankinfo.volume_ml.toString(); this.tank_measure_ml_container.classList.remove("hidden") } - if (tankinfo.percent == null){ + if (tankinfo.fill_pct == null){ this.tank_measure_percent_container.classList.add("hidden") } else { - this.tank_measure_percent.innerText = tankinfo.percent.toString(); + this.tank_measure_percent.innerText = tankinfo.fill_pct.toString(); this.tank_measure_percent_container.classList.remove("hidden") } - if (tankinfo.water_temp == null){ + if (tankinfo.water_temp_c == null){ this.tank_measure_temperature_container.classList.add("hidden") } else { - this.tank_measure_temperature.innerText = tankinfo.water_temp.toString(); + this.tank_measure_temperature.innerText = tankinfo.water_temp_c.toString(); this.tank_measure_temperature_container.classList.remove("hidden") } - if (tankinfo.raw == null){ + if (tankinfo.fill_raw_v == null){ this.tank_measure_rawvolt_container.classList.add("hidden") } else { - this.tank_measure_rawvolt.innerText = tankinfo.raw.toString(); + this.tank_measure_rawvolt.innerText = tankinfo.fill_raw_v.toString(); this.tank_measure_rawvolt_container.classList.remove("hidden") }