firmware wip - web ui stuff

This commit is contained in:
Marcus 2024-04-16 02:33:06 +02:00
parent 0becdf380a
commit 819f3f3750

View file

@ -156,7 +156,7 @@ const char HTMLheader[] PROGMEM = R"EOF(
<li><a id="growSettings" href="/growSettings">Grow settings</a></li> <li><a id="growSettings" href="/growSettings">Grow settings</a></li>
<li><a id="systemSettings" href="/systemSettings">System settings</a></li> <li><a id="systemSettings" href="/systemSettings">System settings</a></li>
<li><a href="/wifiSettings">WiFi settings</a></li> <li><a href="/wifiSettings">WiFi settings</a></li>
<li><a href="#">Help</a></li> <li><a href="/help">Help</a></li>
</ul> </ul>
<div class="center"> <div class="center">
@ -176,7 +176,7 @@ body {
} }
.center { .center {
width: 60%; min-width: 200px; width: 60%; min-width: 420px;
margin: auto; margin: auto;
} }
@ -213,7 +213,7 @@ a:active {
/* from https://gist.github.com/iamhelenliu/5755179 - thank you! */ /* from https://gist.github.com/iamhelenliu/5755179 - thank you! */
.nav { .nav {
background: #333; background: #333;
width: 60%; min-width: 200px; width: 60%; min-width: 420px;
margin: auto; margin: auto;
margin-bottom: 10px; margin-bottom: 10px;
padding: 0; padding: 0;
@ -253,10 +253,6 @@ a:active {
)EOF";
const char HTMLjsNoWifi[] PROGMEM = R"EOF(
<script>document.getElementById('growSettings').style.display = 'none'; document.getElementById('systemSettings').style.display = 'none';</script>
)EOF"; )EOF";
const char HTMLhelp[] PROGMEM = R"EOF( const char HTMLhelp[] PROGMEM = R"EOF(
@ -817,7 +813,8 @@ void WebHandler() {
webserver.on("/wifiSettings/save", HTTP_POST, POSTwifiSettings); webserver.on("/wifiSettings/save", HTTP_POST, POSTwifiSettings);
webserver.on("/style.css", HTTP_GET, WEBstyleCSS); webserver.on("/style.css", HTTP_GET, WEBstyleCSS);
// help
webserver.on("/help", HTTP_GET, WEBhelp);
// does not work atm TODO // does not work atm TODO
webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); }); webserver.on("/logout", [](){ webserver.send(401, "text/html", "logged out!"); });
@ -828,21 +825,29 @@ void WebHandler() {
webserver.onNotFound(WEB404); webserver.onNotFound(WEB404);
// when wifi is unconfigured (WIFIssid <1) then root are Wifi settings
if(strlen(WIFIssid) < 1) { if(strlen(WIFIssid) < 1) {
webserver.on("/", HTTP_GET, WEBwifiSettings); webserver.on("/", HTTP_GET, WEBwifiSettings);
} webserver.on("/systemSettings", HTTP_GET, WEBwifiSettings);
webserver.on("/growSettings", HTTP_GET, WEBwifiSettings);
} else {
if(configured == false) { // when system settings are unconfigured , then system settings are root
webserver.on("/", HTTP_GET, WEBsystemSettings); if(configured == false) {
webserver.on("/growSettings", HTTP_GET, WEBsystemSettings); webserver.on("/", HTTP_GET, WEBsystemSettings);
webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings);
webserver.on("/growSettings", HTTP_GET, WEBsystemSettings);
} else {
webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings);
}
// when grow is unconfigured (GrowStart <1) then Grow settings are root
if(GrowStart < 1) {
webserver.on("/", HTTP_GET, WEBgrowSettings);
} else {
webserver.on("/growSettings", HTTP_GET, WEBgrowSettings);
}
} }
webserver.on("/systemSettings", HTTP_GET, WEBsystemSettings);
if(GrowStart < 1) {
webserver.on("/", HTTP_GET, WEBgrowSettings);
}
webserver.on("/growSettings", HTTP_GET, WEBgrowSettings);
} }
@ -933,9 +938,9 @@ void WEBwifiSettings() {
byte ssidsAvail = WiFi.scanNetworks(); byte ssidsAvail = WiFi.scanNetworks();
String body = FPSTR(HTMLheader); String body = FPSTR(HTMLheader);
if(strlen(WIFIssid) == 0) { if(strlen(WIFIssid) == 0) {
body += "<h1>CanGrow</h1>"; body += "<h1>Welcome!</h1>";
body += "<p>CanGrow is actually unconfigured. You need to Setup your WiFi below first.<br>"; body += "<p>CanGrow is actually unconfigured. You need to Setup your WiFi first down below.<br>";
body += "<br>After you configured the WiFi connection successfully, you can start your grow &#129382;"; body += "<br>After you entered your WiFi connection details, you need to restart and are step closer to your grow &#129382;";
body += "<br>"; body += "<br>";
body += "</p>"; body += "</p>";
} }
@ -966,7 +971,6 @@ void WEBwifiSettings() {
body += "DNS: <input type='text' name='WIFIdns'><br>\n"; body += "DNS: <input type='text' name='WIFIdns'><br>\n";
body += "<input type='submit' value='Save'>\n"; body += "<input type='submit' value='Save'>\n";
body += "</form>\n"; body += "</form>\n";
body += FPSTR(HTMLjsNoWifi);
body += FPSTR(HTMLfooter); body += FPSTR(HTMLfooter);
webserver.send(200, "text/html", body); webserver.send(200, "text/html", body);