implemented highlighting active system subnav entry
This commit is contained in:
parent
1765748422
commit
7da5bc38d7
2 changed files with 57 additions and 18 deletions
|
@ -30,17 +30,56 @@
|
||||||
|
|
||||||
#include "Page_system_HTML.h"
|
#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
|
* Main system page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// https://techtutorialsx.com/2018/07/23/esp32-arduino-http-server-template-processing-with-multiple-placeholders/
|
// https://techtutorialsx.com/2018/07/23/esp32-arduino-http-server-template-processing-with-multiple-placeholders/
|
||||||
String Proc_WebPage_system(const String& var) {
|
String Proc_WebPage_system(const String& var) {
|
||||||
if(TestHeaderFooter(var)) {
|
if(TestHeaderFooter(var)) {
|
||||||
return AddHeaderFooter(var, 2);
|
return AddHeaderFooter(var, 2);
|
||||||
} else if(var == "SUBNAV") {
|
} else if(Test_WebPage_system_SUBNAV(var)) {
|
||||||
return String(Page_system_HTML_SUBNAV);
|
return Proc_WebPage_system_SUBNAV(var);
|
||||||
} else {
|
} else {
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
@ -100,8 +139,8 @@ void WebPage_system(AsyncWebServerRequest *request) {
|
||||||
String Proc_WebPage_system_restart(const String& var) {
|
String Proc_WebPage_system_restart(const String& var) {
|
||||||
if(TestHeaderFooter(var)) {
|
if(TestHeaderFooter(var)) {
|
||||||
return AddHeaderFooter(var, 2);
|
return AddHeaderFooter(var, 2);
|
||||||
} else if(var == "SUBNAV") {
|
} else if(Test_WebPage_system_SUBNAV(var)) {
|
||||||
return String(Page_system_HTML_SUBNAV);
|
return Proc_WebPage_system_SUBNAV(var, 3);
|
||||||
} else if(var == "RESTART_MSG") {
|
} else if(var == "RESTART_MSG") {
|
||||||
return String(Page_system_restart_HTML_RESTART_MSG);
|
return String(Page_system_restart_HTML_RESTART_MSG);
|
||||||
} else {
|
} else {
|
||||||
|
@ -174,8 +213,8 @@ void WebPage_system_update_ApplyUpdate(AsyncWebServerRequest *request, String fi
|
||||||
String Proc_WebPage_system_update(const String& var) {
|
String Proc_WebPage_system_update(const String& var) {
|
||||||
if(TestHeaderFooter(var)) {
|
if(TestHeaderFooter(var)) {
|
||||||
return AddHeaderFooter(var, 2);
|
return AddHeaderFooter(var, 2);
|
||||||
} else if(var == "SUBNAV") {
|
} else if(Test_WebPage_system_SUBNAV(var)) {
|
||||||
return String(Page_system_HTML_SUBNAV);
|
return Proc_WebPage_system_SUBNAV(var, 2);
|
||||||
} else {
|
} else {
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
@ -213,9 +252,9 @@ void WebPage_system_update(AsyncWebServerRequest *request) {
|
||||||
*/
|
*/
|
||||||
String Proc_WebPage_system_wipe(const String& var) {
|
String Proc_WebPage_system_wipe(const String& var) {
|
||||||
if(TestHeaderFooter(var)) {
|
if(TestHeaderFooter(var)) {
|
||||||
return AddHeaderFooter(var);
|
return AddHeaderFooter(var, 2);
|
||||||
} else if(var == "SUBNAV") {
|
} else if(Test_WebPage_system_SUBNAV(var)) {
|
||||||
return String(Page_system_HTML_SUBNAV);
|
return Proc_WebPage_system_SUBNAV(var, 4);
|
||||||
} else if(var == "WIPE_MSG") {
|
} else if(var == "WIPE_MSG") {
|
||||||
return String(Page_system_wipe_HTML_WIPE_MSG);
|
return String(Page_system_wipe_HTML_WIPE_MSG);
|
||||||
} else {
|
} else {
|
||||||
|
@ -254,9 +293,9 @@ void WebPage_system_wipe(AsyncWebServerRequest *request) {
|
||||||
*/
|
*/
|
||||||
String Proc_WebPage_system_output(const String& var) {
|
String Proc_WebPage_system_output(const String& var) {
|
||||||
if(TestHeaderFooter(var)) {
|
if(TestHeaderFooter(var)) {
|
||||||
return AddHeaderFooter(var);
|
return AddHeaderFooter(var, 2);
|
||||||
} else if(var == "SUBNAV") {
|
} else if(Test_WebPage_system_SUBNAV(var)) {
|
||||||
return String(Page_system_HTML_SUBNAV);
|
return Proc_WebPage_system_SUBNAV(var, 1);
|
||||||
} else{
|
} else{
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,10 +55,10 @@ const char* Page_system_HTML PROGMEM = R"(%HEADER%
|
||||||
%FOOTER%)";
|
%FOOTER%)";
|
||||||
|
|
||||||
const char* Page_system_HTML_SUBNAV PROGMEM = R"(<ul class='subnav'>
|
const char* Page_system_HTML_SUBNAV PROGMEM = R"(<ul class='subnav'>
|
||||||
<li><a href='/system/output'>⚡ Output configuration</a></li>
|
<li><a class='%ACTIVE_SUBNAV_OUTPUT%' href='/system/output'>⚡ Output configuration</a></li>
|
||||||
<li><a href='/system/update'>🔄 Firmware update</a></li>
|
<li><a class='%ACTIVE_SUBNAV_UPDATE%' href='/system/update'>🔄 Firmware update</a></li>
|
||||||
<li><a href='/system/restart' >🔁 CanGrow restart</a></li>
|
<li><a class='%ACTIVE_SUBNAV_RESTART%' href='/system/restart' >🔁 CanGrow restart</a></li>
|
||||||
<li><a href='/system/wipe' >💣 Factory reset</a></li>
|
<li><a class='%ACTIVE_SUBNAV_WIPE%' href='/system/wipe' >💣 Factory reset</a></li>
|
||||||
</ul>)";
|
</ul>)";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue