From b28c71c9a4c39df34b4095a8e93218d3da7464f8 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 29 Oct 2024 00:15:28 +0100 Subject: [PATCH] basic work done for editing output i had to use a global variable to put the outputId to edit in I receive from the GET param edit. I havent found another solution. I wish I could just pass the GET param to the template processor, but it seems this is not possible at the moment or I havent seen the correct solution yet. --- .../CanGrow/include/Webserver/Page_system.h | 119 +++++++++++++++++- .../include/Webserver/Page_system_HTML.h | 6 +- 2 files changed, 116 insertions(+), 9 deletions(-) diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index b0c4a01..f815382 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -30,6 +30,23 @@ #include "Page_system_HTML.h" +/* global runtime variables */ + +/* VERY VERY DIRTY WORKAROUND + * I have the problem, that I cannot pass a parameter I receive from a http + * request to it's template processor. In my case i want to edit an output, + * the user should click an edit button on the system/output overview page. + * I am lazy so i want to reuse the output_add page, because it is quite + * kinda exactly the same. so i want to call GET /system/output/add?edit=ID + * I have searched and came to the conclusion, that at this point i see no + * other way then giving the parameter I need, the outputId, to an global + * variable, so the template processor can read it. + */ +byte tmpParam_editOutputId = 255; + + + + /* subnav processor */ bool Test_WebPage_system_SUBNAV(const String& var) { @@ -391,7 +408,12 @@ void WebPage_system_output(AsyncWebServerRequest *request) { } else { - request->send_P(200, "text/html", Page_system_output_HTML, Proc_WebPage_system_output); + if(request->hasParam("success")) { + // when GET param success is present, we use the _POST processor for the save message + request->send_P(200, "text/html", Page_system_output_HTML, Proc_WebPage_system_output_POST); + } else { + request->send_P(200, "text/html", Page_system_output_HTML, Proc_WebPage_system_output); + } } } @@ -401,7 +423,7 @@ void WebPage_system_output(AsyncWebServerRequest *request) { */ /* returns select