sensor edit now works too
This commit is contained in:
parent
de0cf2390c
commit
4b3451c2fa
2 changed files with 17 additions and 45 deletions
|
@ -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");
|
||||
|
||||
|
|
|
@ -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%
|
||||
<a class='button' href='/system/sensor/add'>➕ Add output</a>
|
||||
<a class='button' href='/system/sensor/add'>➕ Add sensor</a>
|
||||
<table class='centered'>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
|
@ -278,7 +278,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER%
|
|||
|
||||
|
||||
<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>
|
||||
<select name='gpio'>
|
||||
|
@ -295,7 +295,7 @@ const char* Page_system_sensor_add_HTML PROGMEM = R"(%HEADER%
|
|||
<span>Special 2</span>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue