diff --git a/Arduino/CanGrow/include/CanGrow.h b/Arduino/CanGrow/include/CanGrow.h
index 12f56db..b7384a3 100644
--- a/Arduino/CanGrow/include/CanGrow.h
+++ b/Arduino/CanGrow/include/CanGrow.h
@@ -207,8 +207,8 @@ struct Config_System_Output {
char name[Max_Outputs][32];
bool enabled[Max_Outputs];
byte gpio[Max_Outputs];
- bool gpio_invert[Max_Outputs];
bool gpio_pwm[Max_Outputs];
+ bool gpio_invert[Max_Outputs];
char i2c[Max_Outputs][8];
char webcall_host[Max_Outputs][32];
char webcall_path_on[Max_Outputs][32];
diff --git a/Arduino/CanGrow/include/CanGrow_LittleFS.h b/Arduino/CanGrow/include/CanGrow_LittleFS.h
index e8cbdd3..f4bdcaf 100644
--- a/Arduino/CanGrow/include/CanGrow_LittleFS.h
+++ b/Arduino/CanGrow/include/CanGrow_LittleFS.h
@@ -353,7 +353,7 @@ bool SaveConfig(bool writeToSerial = false) {
file.close();
} else {
Serial.printf(":: [LittleFS:SaveConfig] --- %s ---\n", CANGROW_CFG);
- serializeJson(doc, Serial);
+ serializeJsonPretty(doc, Serial);
Serial.println("");
Serial.printf(":: [LittleFS:SaveConfig] ----------------------\n", CANGROW_CFG);
}
diff --git a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h
index 1926b56..76797e2 100644
--- a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h
+++ b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h
@@ -209,6 +209,16 @@ input[type=text], input[type=date], input[type=number], input[type=password], se
border-radius: 3px;
}
+.linkForm {
+ display: inline-block;
+}
+
+.linkForm input[type=submit] {
+ background: #262B27;
+ padding: 5px;
+
+}
+
.hidden {
display: none;
}
diff --git a/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h b/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h
index 358200c..9047212 100644
--- a/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h
+++ b/Arduino/CanGrow/include/Webserver/File_cangrow_JS.h
@@ -58,6 +58,10 @@ function showSelect(selectId, prefix, hideClass = '') {
if(document.getElementById(toggleId) !== null ) {
toggleDisplay(toggleId);
}
+}
+
+function confirmDelete(name) {
+ return confirm('Delete ' + name + '?');
})";
void WebFile_cangrow_JS(AsyncWebServerRequest *request) {
diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h
index 5b6fff3..327feeb 100644
--- a/Arduino/CanGrow/include/Webserver/Page_system.h
+++ b/Arduino/CanGrow/include/Webserver/Page_system.h
@@ -306,7 +306,9 @@ String Proc_WebPage_system_output(const String& var) {
String output_tr_td;
for(byte i=0; i < Max_Outputs; i++) {
if(config.system.output.type[i] > 0) {
+ #ifndef DEBUG
Serial.printf("DB [Webserver:system:output(Proc)] OutputID %d Type %d\n", i, config.system.output.type[i]);
+ #endif
output_tr_td += "
";
output_tr_td += i;
output_tr_td += " | ";
@@ -317,11 +319,26 @@ String Proc_WebPage_system_output(const String& var) {
output_tr_td += Output_Device_descr[config.system.output.device[i]];
output_tr_td += " | ";
output_tr_td += config.system.output.enabled[i];
- output_tr_td += " | ";
+ output_tr_td += "✏️ ";
+ output_tr_td += " ";
+
+
+ // delete button
+ output_tr_td += " |
";
+ output_tr_td += "'>";
+ output_tr_td += "";
+
+ output_tr_td += "";
}
}
@@ -341,6 +358,34 @@ String Proc_WebPage_system_output_POST(const String& var) {
void WebPage_system_output(AsyncWebServerRequest *request) {
if(request->method() == HTTP_POST) {
+ if(request->hasParam("delete_output", true)) {
+ byte outputId;
+
+ const AsyncWebParameter* p_delete_output = request->getParam("delete_output", true);
+ Serial.printf(":: [Webserver:system:output] POST[%s]: %s\n", p_delete_output->name().c_str(), p_delete_output->value().c_str());
+
+ outputId = p_delete_output->value().toInt();
+
+ Serial.printf(":: [Webserver:system:output] Deleting output: %d\n", outputId);
+
+ // we ensure that every field is empty
+ config.system.output.type[outputId] = 0;
+ config.system.output.device[outputId] = 0;
+ // set every field of char array to 0x00 with memset
+ memset(config.system.output.name[outputId], '\0', sizeof config.system.output.name[outputId]);
+ config.system.output.enabled[outputId] = 0;
+ config.system.output.gpio[outputId] = 0;
+ config.system.output.gpio_pwm[outputId] = 0;
+ config.system.output.gpio_invert[outputId] = 0;
+ memset(config.system.output.i2c[outputId], '\0', sizeof config.system.output.i2c[outputId]);
+ memset(config.system.output.webcall_host[outputId], '\0', sizeof config.system.output.webcall_host[outputId]);
+ memset(config.system.output.webcall_path_on[outputId], '\0', sizeof config.system.output.webcall_path_on[outputId]);
+ memset(config.system.output.webcall_path_off[outputId], '\0', sizeof config.system.output.webcall_path_off[outputId]);
+
+ SaveConfig();
+ }
+
+
request->send_P(200, "text/html", Page_system_output_HTML, Proc_WebPage_system_output_POST);
Serial.println(":: [Webserver:system:output] [POST] hello");
diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h
index 74a1b86..09cd12a 100644
--- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h
+++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h
@@ -137,6 +137,7 @@ const char* Page_system_wipe_HTML_WIPE_MSG_POST PROGMEM = R"(Restarting...)";
*/
const char* Page_system_output_HTML PROGMEM = R"(%HEADER%
%SUBNAV%
+%SAVE_MSG%
➕ Add output
diff --git a/playground/html/root/index.html b/playground/html/root/index.html
index 9198747..fdc67d0 100644
--- a/playground/html/root/index.html
+++ b/playground/html/root/index.html
@@ -127,7 +127,7 @@
6 |
Test |