From 4b3451c2fae4730e9a465b21b91451eb45c18d1f Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 17 Nov 2024 05:00:18 +0100 Subject: [PATCH] sensor edit now works too --- .../CanGrow/include/Webserver/Page_system.h | 56 +++++-------------- .../include/Webserver/Page_system_HTML.h | 6 +- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index 5963d51..a9de976 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -949,7 +949,7 @@ String Proc_WebPage_system_sensor_add(const String& var) { String Proc_WebPage_system_sensor_addEdit(const String& var) { #ifndef DEBUG - Serial.print("DB [Webserver:system:output:addEdit(Proc)] var: "); + Serial.print("DB [Webserver:system:sensor:addEdit(Proc)] var: "); Serial.println(var); #endif if(TestHeaderFooter(var)) { @@ -959,56 +959,28 @@ String Proc_WebPage_system_sensor_addEdit(const String& var) { } else if(var == "ACTION") { return String("✏️ Edit"); - } else if(var == "OUTPUT_ID") { - // return the outputId we got from GET .../add?edit=ID + } else if(var == "SENSOR_ID") { + // return the sensorId we got from GET .../add?edit=ID // dirty workaround to put this in a global variable - return String(tmpParam_editOutputId); + return String(tmpParam_editSensorId); - } else if(var == "OUTPUT_TYPE") { - return Html_SelOpt_type_WebPage_system_output_add(config.system.output.type[tmpParam_editOutputId]); + } else if(var == "SENSOR_TYPE") { + return Html_SelOpt_type_WebPage_system_sensor_add(config.system.sensor.type[tmpParam_editSensorId]); - } else if(var == "OUTPUT_DEVICE") { - return Html_SelOpt_device_WebPage_system_output_add(config.system.output.device[tmpParam_editOutputId]); - - } else if(var == "OUTPUT_NAME") { + } else if(var == "SENSOR_NAME") { // "escape" % character, because it would break the template processor. // tasmote webcall for example has percentage char in its path - String outputName = config.system.output.name[tmpParam_editOutputId];; - outputName.replace("%", "%"); - return outputName; - - } else if(var == "OUTPUT_ENABLED") { - return Html_SelectOpt_bool(config.system.output.enabled[tmpParam_editOutputId]); + String sensorName = config.system.sensor.name[tmpParam_editSensorId];; + sensorName.replace("%", "%"); + return sensorName; } else if(var == "GPIO_INDEX") { - return Html_SelectOpt_GPIOindex(config.system.output.gpio[tmpParam_editOutputId]); - - } else if(var == "GPIO_PWM") { - return Html_SelectOpt_bool(config.system.output.gpio_pwm[tmpParam_editOutputId]); - - } else if(var == "GPIO_INVERT") { - return Html_SelectOpt_bool(config.system.output.gpio_invert[tmpParam_editOutputId]); - - } else if(var == "I2C") { - return String(config.system.output.i2c[tmpParam_editOutputId]); - - } else if(var == "WEBCALL_HOST") { - return String(config.system.output.webcall_host[tmpParam_editOutputId]); - - } else if(var == "WEBCALL_PATH_ON") { - String webcallPathOn = config.system.output.webcall_path_on[tmpParam_editOutputId]; - webcallPathOn.replace("%", "%"); - return webcallPathOn; - - } else if(var == "WEBCALL_PATH_OFF") { - String webcallPathOff = config.system.output.webcall_path_off[tmpParam_editOutputId]; - webcallPathOff.replace("%", "%"); - return webcallPathOff; + return Html_SelectOpt_GPIOindex(config.system.sensor.gpio[tmpParam_editSensorId]); } else if( - ((var == "CLASS_TYPE_1") && (config.system.output.type[tmpParam_editOutputId] == 1)) || - ((var == "CLASS_TYPE_2") && (config.system.output.type[tmpParam_editOutputId] == 2)) || - ((var == "CLASS_TYPE_3") && (config.system.output.type[tmpParam_editOutputId] == 3))) { + ((var == "CLASS_TYPE_1") && (config.system.sensor.type[tmpParam_editSensorId] == 1)) || + ((var == "CLASS_TYPE_2") && (config.system.sensor.type[tmpParam_editSensorId] == 2)) || + ((var == "CLASS_TYPE_3") && (config.system.sensor.type[tmpParam_editSensorId] == 3))) { // add class 'visible' which overwrites display with flex!important and justify center return String("visible"); diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h index f97c142..25a6740 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h @@ -247,7 +247,7 @@ const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER% const char* Page_system_sensor_HTML PROGMEM = R"(%HEADER% %SUBNAV% %SAVE_MSG% -➕ Add output +➕ Add sensor @@ -278,7 +278,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER% Name:
-
+
GPIO:
ID