first values saving foir the output ports.

This commit is contained in:
Marcus 2024-10-26 06:26:42 +02:00
parent b0f3d05576
commit bc15bbab46
2 changed files with 40 additions and 3 deletions

View file

@ -314,6 +314,8 @@ String Proc_WebPage_system_output(const String& var) {
output_tr_td += config.system.output.type[i]; output_tr_td += config.system.output.type[i];
output_tr_td += "</td><td>"; output_tr_td += "</td><td>";
output_tr_td += config.system.output.device[i]; output_tr_td += config.system.output.device[i];
output_tr_td += "</td><td>";
output_tr_td += config.system.output.enabled[i];
output_tr_td += "</td><td><a href='#"; output_tr_td += "</td><td><a href='#";
output_tr_td += i; output_tr_td += i;
output_tr_td += "'>&#x270F;&#xFE0F;</a> <a href='#"; output_tr_td += "'>&#x270F;&#xFE0F;</a> <a href='#";
@ -439,6 +441,39 @@ auto Chunk_system_output_add_HTML(uint8_t *buffer, size_t maxlen, size_t index)
void WebPage_system_output_add(AsyncWebServerRequest *request) { void WebPage_system_output_add(AsyncWebServerRequest *request) {
if(request->method() == HTTP_POST) { if(request->method() == HTTP_POST) {
Serial.println(":: [Webserver:system:output:add] [POST] hello"); Serial.println(":: [Webserver:system:output:add] [POST] hello");
byte outputId;
if(request->hasParam("outputId", true)) {
const AsyncWebParameter* p_outputId = request->getParam("outputId", true);
Serial.printf(":: [Webserver:system] POST[%s]: %s\n", p_outputId->name().c_str(), p_outputId->value().c_str());
outputId = p_outputId->value().toInt();
}
if(request->hasParam("type", true)) {
const AsyncWebParameter* p_type = request->getParam("type", true);
Serial.printf(":: [Webserver:system] POST[%s]: %s\n", p_type->name().c_str(), p_type->value().c_str());
config.system.output.type[outputId] = p_type->value().toInt();
}
if(request->hasParam("device", true)) {
const AsyncWebParameter* p_device = request->getParam("device", true);
Serial.printf(":: [Webserver:system] POST[%s]: %s\n", p_device->name().c_str(), p_device->value().c_str());
config.system.output.device[outputId] = p_device->value().toInt();
}
if(request->hasParam("name", true)) {
const AsyncWebParameter* p_name = request->getParam("name", true);
Serial.printf(":: [Webserver:system] POST[%s]: %s\n", p_name->name().c_str(), p_name->value().c_str());
strlcpy(config.system.output.name[outputId], p_name->value().c_str(), sizeof(config.system.output.name[outputId]));
}
if(request->hasParam("enabled", true)) {
const AsyncWebParameter* p_enabled = request->getParam("enabled", true);
Serial.printf(":: [Webserver:system] POST[%s]: %s\n", p_enabled->name().c_str(), p_enabled->value().c_str());
config.system.output.enabled[outputId] = p_enabled->value().toInt();
}
SaveConfig();
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", Chunk_system_output_add_HTML, Proc_WebPage_system_output_add_POST); AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", Chunk_system_output_add_HTML, Proc_WebPage_system_output_add_POST);
request->send(response); request->send(response);
} else { } else {

View file

@ -144,6 +144,7 @@ const char* Page_system_output_HTML PROGMEM = R"(%HEADER%
<th>Name</th> <th>Name</th>
<th>Type</th> <th>Type</th>
<th>Device</th> <th>Device</th>
<th>Enabled</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
%OUTPUT_TR_TD% %OUTPUT_TR_TD%
@ -155,11 +156,12 @@ const char* Page_system_output_HTML PROGMEM = R"(%HEADER%
*/ */
const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER% const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER%
%SUBNAV% %SUBNAV%
<h3>&#10133; Add output</h3> <h3>&#10133; Add output ID %OUTPUT_ID%</h3>
%SAVE_MSG%
<p>Add a new output to CanGrow.</p> <p>Add a new output to CanGrow.</p>
<form method='post' action='/system/output/add'> <form method='post' action='/system/output/add'>
<input type='hidden' name='gpioId' value='%OUTPUT_ID%' /> <input type='hidden' name='outputId' value='%OUTPUT_ID%' />
<u>Type</u>:<br> <u>Type</u>:<br>
<select id='type_sel' name='type' onchange="showSelect('type_sel', 'type_', 'hidden');" required> <select id='type_sel' name='type' onchange="showSelect('type_sel', 'type_', 'hidden');" required>
<option disabled value='' selected hidden>---</option> <option disabled value='' selected hidden>---</option>
@ -183,7 +185,7 @@ const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER%
<input type='text' name='name' maxlength='16' value='' required><br> <input type='text' name='name' maxlength='16' value='' required><br>
<u>Enable</u>:<br> <u>Enable</u>:<br>
<select name='enable' required> <select name='enabled' required>
<option disabled value='' selected hidden>---</option> <option disabled value='' selected hidden>---</option>
<option value='1'>Yes</option> <option value='1'>Yes</option>
<option value='0'>No</option> <option value='0'>No</option>