added solar ina handling, adjusted website

This commit is contained in:
2025-06-20 23:29:44 +02:00
parent 34b20b1f8f
commit 04849162cd
16 changed files with 301 additions and 42 deletions

View File

@@ -28,8 +28,9 @@ import {
SetTime, SSIDList, TankInfo,
TestPump,
VersionInfo,
FileList
FileList, SolarState
} from "./api";
import {SolarView} from "./solarview";
export class Controller {
loadTankInfo() : Promise<void> {
@@ -160,7 +161,7 @@ export class Controller {
console.log(error);
});
}
updateBatteryData(): Promise<void> {
updateBatteryData() {
return fetch(PUBLIC_URL + "/battery")
.then(response => response.json())
.then(json => json as BatteryState)
@@ -172,6 +173,18 @@ export class Controller {
console.log(error);
})
}
updateSolarData() {
return fetch(PUBLIC_URL + "/solar")
.then(response => response.json())
.then(json => json as SolarState)
.then(solar => {
controller.solarView.update(solar)
})
.catch(error => {
controller.solarView.update(null)
console.log(error);
})
}
uploadNewFirmware(file: File) {
var current = 0;
var max = 100;
@@ -244,6 +257,7 @@ export class Controller {
//load from remote to be clean
controller.downloadConfig()
}
backupConfig(json: string, statusCallback: (status: string) => void) {
controller.progressview.addIndeterminate("backup_config", "Backingup Config")
fetch(PUBLIC_URL + "/backup_config", {
@@ -465,6 +479,7 @@ export class Controller {
readonly firmWareView: OTAView;
readonly progressview: ProgressView;
readonly batteryView: BatteryView;
readonly solarView: SolarView;
readonly fileview: FileView;
readonly logView: LogView
constructor() {
@@ -473,6 +488,7 @@ export class Controller {
this.networkView = new NetworkConfigView(this, PUBLIC_URL)
this.tankView = new TankConfigView(this)
this.batteryView = new BatteryView(this)
this.solarView = new SolarView(this)
this.nightLampView = new NightLampView(this)
this.submitView = new SubmitView(this)
this.firmWareView = new OTAView(this)
@@ -489,21 +505,16 @@ export class Controller {
controller.exit();
}
}
selftest() {
}
}
const controller = new Controller();
controller.progressview.removeProgress("rebooting");
const tasks = [
{ task: controller.populateTimezones, displayString: "Populating Timezones" },
{ task: controller.updateRTCData, displayString: "Updating RTC Data" },
{ task: controller.updateBatteryData, displayString: "Updating Battery Data" },
{ task: controller.updateSolarData, displayString: "Updating Solar Data" },
{ task: controller.downloadConfig, displayString: "Downloading Configuration" },
{ task: controller.version, displayString: "Fetching Version Information" },
{ task: controller.updateFileList, displayString: "Updating File List" },