diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index 94edb1c..1cdaa63 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -30,17 +30,56 @@ #include "Page_system_HTML.h" +/* subnav processor */ + +bool Test_WebPage_system_SUBNAV(const String& var) { + if( + (var == "SUBNAV") || + (var == "ACTIVE_SUBNAV_OUTPUT") || + (var == "ACTIVE_SUBNAV_UPDATE") || + (var == "ACTIVE_SUBNAV_RESTART") || + (var == "ACTIVE_SUBNAV_WIPE")) { + return true; + } else { + return false; + } +} + +/* + * Proc_WebPage_system_SUBNAV - subnav processor for system + * this function works as same as AddHeaderFooter from Common.h + * byte activeSubnav: + * 1 - Output + * 2 - Update + * 3 - Restart + * 4 - Wipe + */ +String Proc_WebPage_system_SUBNAV(const String& var, byte activeSubnav = 0) { + String activeSubnav_ClassName = "activeNav"; + if(var == "SUBNAV") { + return String(Page_system_HTML_SUBNAV); + } else if((var == "ACTIVE_SUBNAV_OUTPUT") && (activeSubnav == 1)) { + return activeSubnav_ClassName; + } else if((var == "ACTIVE_SUBNAV_UPDATE") && (activeSubnav == 2)) { + return activeSubnav_ClassName; + } else if((var == "ACTIVE_SUBNAV_RESTART") && (activeSubnav == 3)) { + return activeSubnav_ClassName; + } else if((var == "ACTIVE_SUBNAV_WIPE") && (activeSubnav == 4)) { + return activeSubnav_ClassName; + } else { + return String(); + } +} + /* * Main system page */ - - // https://techtutorialsx.com/2018/07/23/esp32-arduino-http-server-template-processing-with-multiple-placeholders/ String Proc_WebPage_system(const String& var) { if(TestHeaderFooter(var)) { return AddHeaderFooter(var, 2); - } else if(var == "SUBNAV") { - return String(Page_system_HTML_SUBNAV); + } else if(Test_WebPage_system_SUBNAV(var)) { + return Proc_WebPage_system_SUBNAV(var); } else { return String(); } @@ -100,8 +139,8 @@ void WebPage_system(AsyncWebServerRequest *request) { String Proc_WebPage_system_restart(const String& var) { if(TestHeaderFooter(var)) { return AddHeaderFooter(var, 2); - } else if(var == "SUBNAV") { - return String(Page_system_HTML_SUBNAV); + } else if(Test_WebPage_system_SUBNAV(var)) { + return Proc_WebPage_system_SUBNAV(var, 3); } else if(var == "RESTART_MSG") { return String(Page_system_restart_HTML_RESTART_MSG); } else { @@ -174,8 +213,8 @@ void WebPage_system_update_ApplyUpdate(AsyncWebServerRequest *request, String fi String Proc_WebPage_system_update(const String& var) { if(TestHeaderFooter(var)) { return AddHeaderFooter(var, 2); - } else if(var == "SUBNAV") { - return String(Page_system_HTML_SUBNAV); + } else if(Test_WebPage_system_SUBNAV(var)) { + return Proc_WebPage_system_SUBNAV(var, 2); } else { return String(); } @@ -213,9 +252,9 @@ void WebPage_system_update(AsyncWebServerRequest *request) { */ String Proc_WebPage_system_wipe(const String& var) { if(TestHeaderFooter(var)) { - return AddHeaderFooter(var); - } else if(var == "SUBNAV") { - return String(Page_system_HTML_SUBNAV); + return AddHeaderFooter(var, 2); + } else if(Test_WebPage_system_SUBNAV(var)) { + return Proc_WebPage_system_SUBNAV(var, 4); } else if(var == "WIPE_MSG") { return String(Page_system_wipe_HTML_WIPE_MSG); } else { @@ -254,9 +293,9 @@ void WebPage_system_wipe(AsyncWebServerRequest *request) { */ String Proc_WebPage_system_output(const String& var) { if(TestHeaderFooter(var)) { - return AddHeaderFooter(var); - } else if(var == "SUBNAV") { - return String(Page_system_HTML_SUBNAV); + return AddHeaderFooter(var, 2); + } else if(Test_WebPage_system_SUBNAV(var)) { + return Proc_WebPage_system_SUBNAV(var, 1); } else{ return String(); } diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h index f7bb52b..69601e2 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h @@ -55,10 +55,10 @@ const char* Page_system_HTML PROGMEM = R"(%HEADER% %FOOTER%)"; const char* Page_system_HTML_SUBNAV PROGMEM = R"()"; /*