html stuff

This commit is contained in:
Marcus 2024-04-17 01:44:41 +02:00
parent c321695d92
commit af9847ceb7
1 changed files with 32 additions and 10 deletions

View File

@ -34,7 +34,8 @@ float valTemperature;
// valTemperature - contains the value of getHumidity()
float valHumidity;
// valWaterlevel - contains the value of getWaterlevel()
// do we need a restart? (e.g. after wifi settings change)
bool NeedRestart;
@ -212,19 +213,27 @@ a:active {
color: #04AA6D;
}
.infomsg {
background: #04AA6D;
.infomsg , .warnmsg {
color: #fff;
border-radius: 3px;
padding: 4px;
width: fit-content; min-width: 200px; max-width: 420px;
margin: auto;
margin-bottom: 5px;
font-weight: bold;
text-align: center;
text-decoration: none;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
}
.infomsg {
background: #04AA6D;
}
.warnmsg {
background: #aa4204;
}
/* from https://gist.github.com/iamhelenliu/5755179 - thank you! */
.nav {
background: #333;
@ -268,6 +277,14 @@ a:active {
)EOF";
const char HTMLsuccess[] PROGMEM = R"EOF(
<div class='infomsg'>Successfully saved!</div>
)EOF";
const char HTMLneedRestart[] PROGMEM = R"EOF(
<div class='warnmsg'>Restart is required to apply new WiFi settings!</div>
)EOF";
const char HTMLhelp[] PROGMEM = R"EOF(
@ -1109,8 +1126,11 @@ void WEBwifiSettings() {
body += "</p>";
}
body += "<h2>WiFi config</h2>\n";
if(NeedRestart == true) {
body += FPSTR(HTMLneedRestart);
}
if(webserver.hasArg("success")) {
body += "<div class='infomsg'>Successfully saved!<br>Please restart the device.</div>";
body += FPSTR(HTMLsuccess);
}
body += "<p>Select your wifi network from the SSID list.<br>To use DHCP leave IP, Subnet, Gateway and DNS fields blank!</p>";
body += "<form method='post' action='/wifiSettings/save'>\n";
@ -1126,9 +1146,9 @@ void WEBwifiSettings() {
}
body += "</select><br>\n";
if(strlen(WIFIssid) > 0) {
body += "Currently connected to: ";
body += "Currently connected to: <b>";
body += WIFIssid;
body += "<br>\n";
body += "</b><br>\n";
}
body += "Password: <input type='password' name='WIFIpassword'><br>\n";
body += "IP: <input type='text' name='WIFIip'><br>\n";
@ -1153,7 +1173,7 @@ void WEBsystemSettings() {
body += "<h2>System settings</h2>";
if(webserver.hasArg("success")) {
body += "<div class='infomsg'>Successfully saved!<br>Please restart the device.</div>";
body += FPSTR(HTMLsuccess);
}
body += "<p>here you can set which features and sensors you use<br>";
body += "</p>";
@ -1229,8 +1249,8 @@ void WEBgrowSettings() {
body += "<h2>Grow Settings</h2>";
if(webserver.hasArg("success")) {
body += "<div class='infomsg'>Successfully saved!<br>Please restart the device.</div>";
}
body += FPSTR(HTMLsuccess);
}
body += "<p>Here you can set everything grow related, like light hours, how much water, LED brightness<br>";
body += "</p>";
@ -1371,6 +1391,7 @@ void POSTsystemSettings() {
PumpOnTime = webserver.arg("PumpOnTime").toInt();
UseFan = webserver.arg("UseFan").toInt();
UseLEDrelais = webserver.arg("UseLEDrelais").toInt();
configured = true;
// size is 1 byte
@ -1438,7 +1459,8 @@ void POSTwifiSettings() {
WIFIuseDHCP = true;
}
// restart is needed to load the new settings
NeedRestart = true;
EEPROM.put(0, WIFIssid);
EEPROM.put(32, WIFIpassword);