fix config always assumed changed
This commit is contained in:
parent
bfc3fbc6e1
commit
171b130a29
@ -79,10 +79,11 @@ interface PlantConfig {
|
||||
pump_cooldown_min: number,
|
||||
pump_hour_start: number,
|
||||
pump_hour_end: number,
|
||||
sensor_a: boolean,
|
||||
sensor_b: boolean,
|
||||
max_consecutive_pump_count: number,
|
||||
moisture_sensor_min_frequency?: number;
|
||||
moisture_sensor_max_frequency?: number;
|
||||
moisture_sensor_min_frequency: number | null;
|
||||
moisture_sensor_max_frequency: number | null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 1.5em;
|
||||
height: 2.5em;
|
||||
width: 100%;
|
||||
background-color: #555;
|
||||
position: relative;
|
||||
@ -29,7 +29,7 @@
|
||||
font-size: 0.8em;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 5px;
|
||||
top: 10px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
@ -205,18 +205,16 @@ export class Controller {
|
||||
})
|
||||
}
|
||||
|
||||
downloadConfig() :Promise<void> {
|
||||
async downloadConfig(): Promise<void> {
|
||||
controller.progressview.addIndeterminate("get_config", "Downloading Config")
|
||||
return fetch(PUBLIC_URL + "/get_config")
|
||||
.then(response => response.json())
|
||||
.then(loaded => {
|
||||
const response = await fetch(PUBLIC_URL + "/get_config");
|
||||
const loaded = await response.json();
|
||||
var currentConfig = loaded as PlantControllerConfig;
|
||||
controller.setInitialConfig(currentConfig);
|
||||
controller.setConfig(currentConfig);
|
||||
//sync json view initially
|
||||
this.configChanged();
|
||||
controller.progressview.removeProgress("get_config")
|
||||
})
|
||||
controller.configChanged();
|
||||
controller.progressview.removeProgress("get_config");
|
||||
}
|
||||
setInitialConfig(currentConfig: PlantControllerConfig) {
|
||||
this.initialConfig = currentConfig
|
||||
@ -262,6 +260,7 @@ export class Controller {
|
||||
var pretty = JSON.stringify(current, undefined, 0);
|
||||
controller.submitView.setJson(pretty);
|
||||
|
||||
|
||||
if (deepEqual(current, controller.initialConfig)) {
|
||||
document.title = "PlantCtrl"
|
||||
} else {
|
||||
@ -471,36 +470,42 @@ export class Controller {
|
||||
const controller = new Controller();
|
||||
controller.progressview.removeProgress("rebooting");
|
||||
|
||||
controller.progressview.addProgress("initial", 0, "read timezones");
|
||||
controller.populateTimezones().then(_ => {
|
||||
controller.progressview.addProgress("initial", 10, "read rtc");
|
||||
controller.updateRTCData().then(_ => {
|
||||
controller.progressview.addProgress("initial", 20, "read battery");
|
||||
controller.updateBatteryData().then(_ => {
|
||||
controller.progressview.addProgress("initial", 40, "read config");
|
||||
controller.downloadConfig().then(_ => {
|
||||
controller.progressview.addProgress("initial", 50, "read version");
|
||||
controller.version().then(_ => {
|
||||
controller.progressview.addProgress("initial", 70, "read filelist");
|
||||
controller.updateFileList().then(_ => {
|
||||
controller.progressview.addProgress("initial", 90, "read backupinfo");
|
||||
controller.getBackupInfo().then(_ => {
|
||||
controller.loadLogLocaleConfig().then(_ => {
|
||||
controller.loadTankInfo().then(_ => {
|
||||
|
||||
|
||||
|
||||
const tasks = [
|
||||
{ task: controller.populateTimezones, displayString: "Populating Timezones" },
|
||||
{ task: controller.updateRTCData, displayString: "Updating RTC Data" },
|
||||
{ task: controller.updateBatteryData, displayString: "Updating Battery Data" },
|
||||
{ task: controller.downloadConfig, displayString: "Downloading Configuration" },
|
||||
{ task: controller.version, displayString: "Fetching Version Information" },
|
||||
{ task: controller.updateFileList, displayString: "Updating File List" },
|
||||
{ task: controller.getBackupInfo, displayString: "Fetching Backup Information" },
|
||||
{ task: controller.loadLogLocaleConfig, displayString: "Loading Log Localization Config" },
|
||||
{ task: controller.loadTankInfo, displayString: "Loading Tank Information" },
|
||||
];
|
||||
|
||||
async function executeTasksSequentially() {
|
||||
let current = 0;
|
||||
for (const { task, displayString } of tasks) {
|
||||
current++;
|
||||
let ratio = current / tasks.length;
|
||||
controller.progressview.addProgress("initial", ratio * 100, displayString);
|
||||
try {
|
||||
await task();
|
||||
} catch (error) {
|
||||
console.error(`Error executing task '${displayString}':`, error);
|
||||
// Optionally, you can decide whether to continue or break on errors
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executeTasksSequentially().then(r => {
|
||||
controller.progressview.removeProgress("initial")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//controller.measure_moisture();
|
||||
|
||||
|
||||
|
||||
controller.progressview.removeProgress("rebooting");
|
||||
|
@ -183,6 +183,8 @@ export class PlantView {
|
||||
|
||||
getConfig(): PlantConfig {
|
||||
return {
|
||||
// hardcoded for now
|
||||
sensor_a: true,
|
||||
mode: this.mode.value,
|
||||
target_moisture: this.targetMoisture.valueAsNumber,
|
||||
pump_time_s: this.pumpTimeS.valueAsNumber,
|
||||
@ -191,8 +193,8 @@ export class PlantView {
|
||||
pump_hour_end: +this.pumpHourEnd.value,
|
||||
sensor_b: this.sensorBInstalled.checked,
|
||||
max_consecutive_pump_count: this.maxConsecutivePumpCount.valueAsNumber,
|
||||
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || undefined,
|
||||
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || undefined,
|
||||
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || null,
|
||||
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || null
|
||||
};
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user