clippy happier

This commit is contained in:
2025-05-07 00:00:21 +02:00
parent a401d4de7b
commit 26da6b39cc
17 changed files with 234 additions and 236 deletions

View File

@@ -1,4 +1,4 @@
import { Controller } from "./main";
import {Controller} from "./main";
const regex = /[^a-zA-Z0-9_.]/g;
@@ -24,7 +24,7 @@ export class FileView {
let fileuploadname = document.getElementById("fileuploadname") as HTMLInputElement
let fileuploadbtn = document.getElementById("fileuploadbtn") as HTMLInputElement
fileuploadfile.onchange = () => {
var selectedFile = fileuploadfile.files?.[0];
const selectedFile = fileuploadfile.files?.[0];
if (selectedFile == null) {
//TODO error dialog here
return
@@ -42,7 +42,7 @@ export class FileView {
}
fileuploadbtn.onclick = () => {
var selectedFile = fileuploadfile.files?.[0];
const selectedFile = fileuploadfile.files?.[0];
if (selectedFile == null) {
//TODO error dialog here
return
@@ -77,8 +77,7 @@ class FileEntry {
this.view.classList.add("fileentryouter")
const template = require('./fileviewentry.html') as string;
const fileRaw = template.replaceAll("${fileid}", String(fileid));
this.view.innerHTML = fileRaw
this.view.innerHTML = template.replaceAll("${fileid}", String(fileid))
let name = document.getElementById("file_" + fileid + "_name") as HTMLElement;
let size = document.getElementById("file_" + fileid + "_size") as HTMLElement;

View File

@@ -45,7 +45,7 @@
display: inline-block;
height: 100%;
animation: indeterminateAnimation 1s infinite linear;
transform-origin: 0% 50%;
transform-origin: 0 50%;
}

View File

@@ -1,4 +1,3 @@
import { deepEqual } from 'fast-equals';
declare var PUBLIC_URL: string;
@@ -8,7 +7,7 @@ document.body.innerHTML = require('./main.html') as string;
import { TimeView } from "./timeview";
import { PlantView, PlantViews } from "./plant";
import { PlantViews } from "./plant";
import { NetworkConfigView } from "./network";
import { NightLampView } from "./nightlightview";
import { TankConfigView } from "./tankview";
@@ -261,7 +260,6 @@ export class Controller {
configChanged() {
const current = controller.getConfig();
var pretty = JSON.stringify(current, undefined, 0);
var initial = JSON.stringify(this.initialConfig, undefined, 0);
controller.submitView.setJson(pretty);
if (deepEqual(current, controller.initialConfig)) {
@@ -307,7 +305,7 @@ export class Controller {
})
.then(response => response.text())
.then(
text => {
_ => {
clearTimeout(timerId);
controller.progressview.removeProgress("test_pump");
}
@@ -507,3 +505,16 @@ controller.populateTimezones().then(_ => {
controller.progressview.removeProgress("rebooting");
window.addEventListener("beforeunload", (event) => {
const currentConfig = controller.getConfig();
// Check if the current state differs from the initial configuration
if (!deepEqual(currentConfig, controller.initialConfig)) {
const confirmationMessage = "You have unsaved changes. Are you sure you want to leave this page?";
// Standard behavior for displaying the confirmation dialog
event.preventDefault();
event.returnValue = confirmationMessage; // This will trigger the browser's default dialog
return confirmationMessage;
}
});

View File

@@ -3,9 +3,9 @@ import { Controller } from "./main";
export class NetworkConfigView {
setScanResult(ssidList: SSIDList) {
this.ssidlist.innerHTML = ''
for (var ssid of ssidList.ssids) {
var wi = document.createElement("option");
wi.value = ssid;
for (const ssid of ssidList.ssids) {
const wi = document.createElement("option");
wi.value = ssid;
this.ssidlist.appendChild(wi);
}
}

View File

@@ -17,7 +17,7 @@ export class OTAView {
const file = document.getElementById("firmware_file") as HTMLInputElement;
this.file1Upload = file
this.file1Upload.onchange = () => {
var selectedFile = file.files?.[0];
const selectedFile = file.files?.[0];
if (selectedFile == null) {
//TODO error dialog here
return

View File

@@ -14,7 +14,7 @@
}
.plantcheckbox{
min-width: 20px;
margin: 0px;
margin: 0;
}
</style>
@@ -59,7 +59,7 @@
</div>
<div class="flexcontainer">
<div class="plantkey">Warn Pump Count:</div>
<input class="plantvalue" id="plant_${plantId}_max_consecutive_pump_count" type="number" min="1" max="50" ,
<input class="plantvalue" id="plant_${plantId}_max_consecutive_pump_count" type="number" min="1" max="50"
placeholder="10">
</div>
<div class="flexcontainer">

View File

@@ -1,7 +1,7 @@
const PLANT_COUNT = 8;
import { Controller } from "./main";
import {Controller} from "./main";
export class PlantViews {
private readonly measure_moisture: HTMLButtonElement;
@@ -61,12 +61,10 @@ export class PlantView {
constructor(plantId: number, parent:HTMLDivElement, controller:Controller) {
const dummy = this;
this.plantId = plantId;
this.plantId = plantId;
this.plantDiv = document.createElement("div")! as HTMLDivElement
const template = require('./plant.html') as string;
const plantRaw = template.replaceAll("${plantId}", String(plantId));
this.plantDiv.innerHTML = plantRaw
this.plantDiv.innerHTML = template.replaceAll("${plantId}", String(plantId))
this.plantDiv.classList.add("plantcontainer")
parent.appendChild(this.plantDiv)
@@ -184,7 +182,7 @@ export class PlantView {
}
getConfig(): PlantConfig {
const rv: PlantConfig = {
return {
mode: this.mode.value,
target_moisture: this.targetMoisture.valueAsNumber,
pump_time_s: this.pumpTimeS.valueAsNumber,
@@ -196,14 +194,5 @@ export class PlantView {
moisture_sensor_min_frequency: this.moistureSensorMinFrequency.valueAsNumber || undefined,
moisture_sensor_max_frequency: this.moistureSensorMaxFrequency.valueAsNumber || undefined,
};
return rv;
}
setMoistureA(a: number) {
this.moistureA.innerText = String(a);
}
setMoistureB(b: number) {
this.moistureB.innerText = String(b);
}
}

View File

@@ -1,14 +1,14 @@
<style>
.tankcheckbox {
min-width: 20px;
margin: 0px;
margin: 0;
}
.tankkey{
min-width: 250px;
}
.tankvalue{
flex-grow: 1;
margin: 0px;
margin: 0;
}
.hidden {
display: none;

View File

@@ -38,7 +38,7 @@ export class TimeView {
update(native: string, rtc: string) {
this.esp_time.innerText = native;
this.rtc_time.innerText = rtc;
var date = new Date();
const date = new Date();
this.browser_time.innerText = date.toISOString();
if(this.auto_refresh.checked){
this.timer = setTimeout(this.controller.updateRTCData, 1000);