v4 board impl
This commit is contained in:
@@ -17,6 +17,19 @@ import { OTAView } from "./ota";
|
||||
import { BatteryView } from "./batteryview";
|
||||
import { FileView } from './fileview';
|
||||
import { LogView } from './log';
|
||||
import {HardwareConfigView} from "./hardware";
|
||||
import {
|
||||
BackupHeader,
|
||||
BatteryState,
|
||||
GetTime, LogArray, LogLocalisation,
|
||||
Moistures,
|
||||
NightLampCommand,
|
||||
PlantControllerConfig,
|
||||
SetTime, SSIDList, TankInfo,
|
||||
TestPump,
|
||||
VersionInfo,
|
||||
FileList
|
||||
} from "./api";
|
||||
|
||||
export class Controller {
|
||||
loadTankInfo() : Promise<void> {
|
||||
@@ -66,7 +79,7 @@ export class Controller {
|
||||
}
|
||||
|
||||
populateTimezones(): Promise<void> {
|
||||
return fetch('/timezones')
|
||||
return fetch(PUBLIC_URL+'/timezones')
|
||||
.then(response => response.json())
|
||||
.then(json => json as string[])
|
||||
.then(timezones => {
|
||||
@@ -268,6 +281,12 @@ export class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
selfTest(){
|
||||
fetch(PUBLIC_URL + "/boardtest", {
|
||||
method: "POST"
|
||||
})
|
||||
}
|
||||
|
||||
testNightLamp(active: boolean){
|
||||
var body: NightLampCommand = {
|
||||
active: active
|
||||
@@ -313,6 +332,7 @@ export class Controller {
|
||||
|
||||
getConfig(): PlantControllerConfig {
|
||||
return {
|
||||
hardware: controller.hardwareView.getConfig(),
|
||||
network: controller.networkView.getConfig(),
|
||||
tank: controller.tankView.getConfig(),
|
||||
night_lamp: controller.nightLampView.getConfig(),
|
||||
@@ -360,6 +380,7 @@ export class Controller {
|
||||
this.nightLampView.setConfig(current.night_lamp);
|
||||
this.plantViews.setConfig(current.plants);
|
||||
this.timeView.setTimeZone(current.timezone);
|
||||
this.hardwareView.setConfig(current.hardware);
|
||||
}
|
||||
|
||||
measure_moisture() {
|
||||
@@ -437,6 +458,7 @@ export class Controller {
|
||||
readonly timeView: TimeView;
|
||||
readonly plantViews: PlantViews;
|
||||
readonly networkView: NetworkConfigView;
|
||||
readonly hardwareView: HardwareConfigView;
|
||||
readonly tankView: TankConfigView;
|
||||
readonly nightLampView: NightLampView;
|
||||
readonly submitView: SubmitView;
|
||||
@@ -457,6 +479,7 @@ export class Controller {
|
||||
this.progressview = new ProgressView(this)
|
||||
this.fileview = new FileView(this)
|
||||
this.logView = new LogView(this)
|
||||
this.hardwareView = new HardwareConfigView(this)
|
||||
this.rebootBtn = document.getElementById("reboot") as HTMLButtonElement
|
||||
this.rebootBtn.onclick = () => {
|
||||
controller.reboot();
|
||||
@@ -466,6 +489,10 @@ export class Controller {
|
||||
controller.exit();
|
||||
}
|
||||
}
|
||||
|
||||
selftest() {
|
||||
|
||||
}
|
||||
}
|
||||
const controller = new Controller();
|
||||
controller.progressview.removeProgress("rebooting");
|
||||
@@ -505,9 +532,6 @@ executeTasksSequentially().then(r => {
|
||||
controller.progressview.removeProgress("initial")
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
controller.progressview.removeProgress("rebooting");
|
||||
|
||||
window.addEventListener("beforeunload", (event) => {
|
||||
|
||||
Reference in New Issue
Block a user