wip min
This commit is contained in:
@@ -105,6 +105,7 @@ export interface PlantControllerConfig {
|
||||
export interface PlantConfig {
|
||||
mode: string,
|
||||
target_moisture: number,
|
||||
min_moisture: number,
|
||||
pump_time_s: number,
|
||||
pump_cooldown_min: number,
|
||||
pump_hour_start: number,
|
||||
|
@@ -55,6 +55,7 @@
|
||||
<select class="plantvalue" id="plant_${plantId}_mode">
|
||||
<option value="OFF">Off</option>
|
||||
<option value="TargetMoisture">Target</option>
|
||||
<option value="MinMoisture">Min Moisture</option>
|
||||
<option value="TimerOnly">Timer</option>
|
||||
</select>
|
||||
|
||||
@@ -63,6 +64,10 @@
|
||||
<div class="plantkey">Target Moisture:</div>
|
||||
<input class="plantvalue" id="plant_${plantId}_target_moisture" type="number" min="0" max="100" placeholder="0">
|
||||
</div>
|
||||
<div class="flexcontainer plantMinEnabledOnly_${plantId}">
|
||||
<div class="plantkey">Minimum Moisture:</div>
|
||||
<input class="plantvalue" id="plant_${plantId}_min_moisture" type="number" min="0" max="100" placeholder="0">
|
||||
</div>
|
||||
<div class="flexcontainer plantPumpEnabledOnly_${plantId}">
|
||||
<div class="plantkey">Pump Time (s):</div>
|
||||
<input class="plantvalue" id="plant_${plantId}_pump_time_s" type="number" min="0" max="600" placeholder="30">
|
||||
|
@@ -59,6 +59,7 @@ export class PlantView {
|
||||
private readonly header: HTMLElement;
|
||||
private readonly testButton: HTMLButtonElement;
|
||||
private readonly targetMoisture: HTMLInputElement;
|
||||
private readonly minMoisture: HTMLInputElement;
|
||||
private readonly pumpTimeS: HTMLInputElement;
|
||||
private readonly pumpCooldown: HTMLInputElement;
|
||||
private readonly pumpHourStart: HTMLSelectElement;
|
||||
@@ -118,6 +119,11 @@ export class PlantView {
|
||||
controller.configChanged()
|
||||
}
|
||||
|
||||
this.minMoisture = document.getElementById("plant_" + plantId + "_min_moisture")! as HTMLInputElement;
|
||||
this.minMoisture.onchange = function () {
|
||||
controller.configChanged()
|
||||
}
|
||||
|
||||
this.pumpTimeS = document.getElementById("plant_" + plantId + "_pump_time_s") as HTMLInputElement;
|
||||
this.pumpTimeS.onchange = function () {
|
||||
controller.configChanged()
|
||||
@@ -203,13 +209,15 @@ export class PlantView {
|
||||
let sensorOnly = document.getElementsByClassName("plantSensorEnabledOnly_"+ this.plantId)
|
||||
let pumpOnly = document.getElementsByClassName("plantPumpEnabledOnly_"+ this.plantId)
|
||||
let targetOnly = document.getElementsByClassName("plantTargetEnabledOnly_"+ this.plantId)
|
||||
let minOnly = document.getElementsByClassName("plantMinEnabledOnly_"+ this.plantId)
|
||||
|
||||
console.log("updateVisibility plantConfig: " + plantConfig.mode)
|
||||
let showSensor = plantConfig.sensor_a || plantConfig.sensor_b
|
||||
let showPump = plantConfig.mode !== "OFF"
|
||||
let showTarget = plantConfig.mode === "TargetMoisture"
|
||||
let showMin = plantConfig.mode === "MinMoisture"
|
||||
|
||||
console.log("updateVisibility showsensor: " + showSensor + " pump " + showPump + " target " +showTarget)
|
||||
console.log("updateVisibility showsensor: " + showSensor + " pump " + showPump + " target " +showTarget + " min " + showMin)
|
||||
|
||||
for (const element of Array.from(sensorOnly)) {
|
||||
if (showSensor) {
|
||||
@@ -234,6 +242,14 @@ export class PlantView {
|
||||
element.classList.add("plantHidden_" + this.plantId)
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of Array.from(minOnly)) {
|
||||
if (showMin) {
|
||||
element.classList.remove("plantHidden_" + this.plantId)
|
||||
} else {
|
||||
element.classList.add("plantHidden_" + this.plantId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTestResult(result: PumpTestResult) {
|
||||
@@ -255,6 +271,7 @@ export class PlantView {
|
||||
setConfig(plantConfig: PlantConfig) {
|
||||
this.mode.value = plantConfig.mode;
|
||||
this.targetMoisture.value = plantConfig.target_moisture.toString();
|
||||
this.minMoisture.value = plantConfig.min_moisture?.toString() || "";
|
||||
this.pumpTimeS.value = plantConfig.pump_time_s.toString();
|
||||
this.pumpCooldown.value = plantConfig.pump_cooldown_min.toString();
|
||||
this.pumpHourStart.value = plantConfig.pump_hour_start.toString();
|
||||
@@ -280,6 +297,7 @@ export class PlantView {
|
||||
let conv: PlantConfig = {
|
||||
mode: this.mode.value,
|
||||
target_moisture: this.targetMoisture.valueAsNumber,
|
||||
min_moisture: this.minMoisture.valueAsNumber,
|
||||
pump_time_s: this.pumpTimeS.valueAsNumber,
|
||||
pump_cooldown_min: this.pumpCooldown.valueAsNumber,
|
||||
pump_hour_start: +this.pumpHourStart.value,
|
||||
|
Reference in New Issue
Block a user