html stuff

This commit is contained in:
Marcus 2024-04-17 01:44:41 +02:00
parent c321695d92
commit af9847ceb7

View file

@ -34,7 +34,8 @@ float valTemperature;
// valTemperature - contains the value of getHumidity() // valTemperature - contains the value of getHumidity()
float valHumidity; float valHumidity;
// valWaterlevel - contains the value of getWaterlevel() // 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; color: #04AA6D;
} }
.infomsg { .infomsg , .warnmsg {
background: #04AA6D;
color: #fff; color: #fff;
border-radius: 3px; border-radius: 3px;
padding: 4px; padding: 4px;
width: fit-content; min-width: 200px; max-width: 420px; width: fit-content; min-width: 200px; max-width: 420px;
margin: auto; margin: auto;
margin-bottom: 5px;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5); 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! */ /* from https://gist.github.com/iamhelenliu/5755179 - thank you! */
.nav { .nav {
background: #333; 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"; )EOF";
const char HTMLhelp[] PROGMEM = R"EOF( const char HTMLhelp[] PROGMEM = R"EOF(
@ -1109,8 +1126,11 @@ void WEBwifiSettings() {
body += "</p>"; body += "</p>";
} }
body += "<h2>WiFi config</h2>\n"; body += "<h2>WiFi config</h2>\n";
if(NeedRestart == true) {
body += FPSTR(HTMLneedRestart);
}
if(webserver.hasArg("success")) { 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 += "<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"; body += "<form method='post' action='/wifiSettings/save'>\n";
@ -1126,9 +1146,9 @@ void WEBwifiSettings() {
} }
body += "</select><br>\n"; body += "</select><br>\n";
if(strlen(WIFIssid) > 0) { if(strlen(WIFIssid) > 0) {
body += "Currently connected to: "; body += "Currently connected to: <b>";
body += WIFIssid; body += WIFIssid;
body += "<br>\n"; body += "</b><br>\n";
} }
body += "Password: <input type='password' name='WIFIpassword'><br>\n"; body += "Password: <input type='password' name='WIFIpassword'><br>\n";
body += "IP: <input type='text' name='WIFIip'><br>\n"; body += "IP: <input type='text' name='WIFIip'><br>\n";
@ -1153,7 +1173,7 @@ void WEBsystemSettings() {
body += "<h2>System settings</h2>"; body += "<h2>System settings</h2>";
if(webserver.hasArg("success")) { 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>here you can set which features and sensors you use<br>";
body += "</p>"; body += "</p>";
@ -1229,8 +1249,8 @@ void WEBgrowSettings() {
body += "<h2>Grow Settings</h2>"; body += "<h2>Grow Settings</h2>";
if(webserver.hasArg("success")) { 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>Here you can set everything grow related, like light hours, how much water, LED brightness<br>";
body += "</p>"; body += "</p>";
@ -1371,6 +1391,7 @@ void POSTsystemSettings() {
PumpOnTime = webserver.arg("PumpOnTime").toInt(); PumpOnTime = webserver.arg("PumpOnTime").toInt();
UseFan = webserver.arg("UseFan").toInt(); UseFan = webserver.arg("UseFan").toInt();
UseLEDrelais = webserver.arg("UseLEDrelais").toInt(); UseLEDrelais = webserver.arg("UseLEDrelais").toInt();
configured = true; configured = true;
// size is 1 byte // size is 1 byte
@ -1438,7 +1459,8 @@ void POSTwifiSettings() {
WIFIuseDHCP = true; WIFIuseDHCP = true;
} }
// restart is needed to load the new settings
NeedRestart = true;
EEPROM.put(0, WIFIssid); EEPROM.put(0, WIFIssid);
EEPROM.put(32, WIFIpassword); EEPROM.put(32, WIFIpassword);