sensor edit now works too

This commit is contained in:
Marcus 2024-11-17 05:00:18 +01:00
parent de0cf2390c
commit 4b3451c2fa
2 changed files with 17 additions and 45 deletions

View file

@ -949,7 +949,7 @@ String Proc_WebPage_system_sensor_add(const String& var) {
String Proc_WebPage_system_sensor_addEdit(const String& var) { String Proc_WebPage_system_sensor_addEdit(const String& var) {
#ifndef DEBUG #ifndef DEBUG
Serial.print("DB [Webserver:system:output:addEdit(Proc)] var: "); Serial.print("DB [Webserver:system:sensor:addEdit(Proc)] var: ");
Serial.println(var); Serial.println(var);
#endif #endif
if(TestHeaderFooter(var)) { if(TestHeaderFooter(var)) {
@ -959,56 +959,28 @@ String Proc_WebPage_system_sensor_addEdit(const String& var) {
} else if(var == "ACTION") { } else if(var == "ACTION") {
return String("✏️ Edit"); return String("✏️ Edit");
} else if(var == "OUTPUT_ID") { } else if(var == "SENSOR_ID") {
// return the outputId we got from GET .../add?edit=ID // return the sensorId we got from GET .../add?edit=ID
// dirty workaround to put this in a global variable // dirty workaround to put this in a global variable
return String(tmpParam_editOutputId); return String(tmpParam_editSensorId);
} else if(var == "OUTPUT_TYPE") { } else if(var == "SENSOR_TYPE") {
return Html_SelOpt_type_WebPage_system_output_add(config.system.output.type[tmpParam_editOutputId]); return Html_SelOpt_type_WebPage_system_sensor_add(config.system.sensor.type[tmpParam_editSensorId]);
} else if(var == "OUTPUT_DEVICE") { } else if(var == "SENSOR_NAME") {
return Html_SelOpt_device_WebPage_system_output_add(config.system.output.device[tmpParam_editOutputId]);
} else if(var == "OUTPUT_NAME") {
// "escape" % character, because it would break the template processor. // "escape" % character, because it would break the template processor.
// tasmote webcall for example has percentage char in its path // tasmote webcall for example has percentage char in its path
String outputName = config.system.output.name[tmpParam_editOutputId];; String sensorName = config.system.sensor.name[tmpParam_editSensorId];;
outputName.replace("%", "%"); sensorName.replace("%", "%");
return outputName; return sensorName;
} else if(var == "OUTPUT_ENABLED") {
return Html_SelectOpt_bool(config.system.output.enabled[tmpParam_editOutputId]);
} else if(var == "GPIO_INDEX") { } else if(var == "GPIO_INDEX") {
return Html_SelectOpt_GPIOindex(config.system.output.gpio[tmpParam_editOutputId]); return Html_SelectOpt_GPIOindex(config.system.sensor.gpio[tmpParam_editSensorId]);
} 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;
} else if( } else if(
((var == "CLASS_TYPE_1") && (config.system.output.type[tmpParam_editOutputId] == 1)) || ((var == "CLASS_TYPE_1") && (config.system.sensor.type[tmpParam_editSensorId] == 1)) ||
((var == "CLASS_TYPE_2") && (config.system.output.type[tmpParam_editOutputId] == 2)) || ((var == "CLASS_TYPE_2") && (config.system.sensor.type[tmpParam_editSensorId] == 2)) ||
((var == "CLASS_TYPE_3") && (config.system.output.type[tmpParam_editOutputId] == 3))) { ((var == "CLASS_TYPE_3") && (config.system.sensor.type[tmpParam_editSensorId] == 3))) {
// add class 'visible' which overwrites display with flex!important and justify center // add class 'visible' which overwrites display with flex!important and justify center
return String("visible"); return String("visible");

View file

@ -247,7 +247,7 @@ const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER%
const char* Page_system_sensor_HTML PROGMEM = R"(%HEADER% const char* Page_system_sensor_HTML PROGMEM = R"(%HEADER%
%SUBNAV% %SUBNAV%
%SAVE_MSG% %SAVE_MSG%
<a class='button' href='/system/sensor/add'>&#10133; Add output</a> <a class='button' href='/system/sensor/add'>&#10133; Add sensor</a>
<table class='centered'> <table class='centered'>
<tr> <tr>
<th>ID</th> <th>ID</th>
@ -278,7 +278,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER%
<u>Name</u>:<br> <u>Name</u>:<br>
<input type='text' name='name' maxlength='16' value='%OUTPUT_NAME%' required><br> <input type='text' name='name' maxlength='16' value='%SENSOR_NAME%' required><br>
<u>GPIO</u>:<br> <u>GPIO</u>:<br>
<select name='gpio'> <select name='gpio'>
@ -295,7 +295,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER%
<span>Special 2</span> <span>Special 2</span>
</div> </div>
<div class='hidden %CLASS_TYPE_3%' id='type_3'> <div class='hidden %CLASS_TYPE_3% %CLASS_TYPE_1%' id='type_3'>
<span>Special 3</span> <span>Special 3</span>
</div> </div>