+status page

This commit is contained in:
Hansi Reiser 2019-04-10 23:59:41 +02:00
parent 26eed1ff77
commit 2fe668727c
3 changed files with 46 additions and 0 deletions

View File

@ -233,6 +233,32 @@ const char *handleWIFIPost(AsyncWebServerRequest *request) {
setupWifiList();
}
// Show current status
void addSondeStatus(char *ptr, int i)
{
SondeInfo *s = &sonde.sondeList[i];
strcat(ptr, "<table>");
sprintf(ptr+strlen(ptr),"<tr><td id=\"sfreq\">%3.3f MHz, Type: %s</td><tr><td>ID: %s</td></tr><tr><td>QTH: %.6f,%.6f h=%.0fm</td></tr>\n",
s->freq, sondeTypeStr[s->type],
s->validID?s->id:"<??>",
s->lat, s->lon, s->hei);
sprintf(ptr+strlen(ptr), "<tr><td><a target=\"_empty\" href=\"geo:%.6f,%.6f\">Geo-Ref</a> -", s->lat, s->lon);
sprintf(ptr+strlen(ptr), "<a target=\"_empty\" href=\"https://www.google.com/maps/search/?api=1&query=%.6f,%.6f\">Google map</a> - ", s->lat, s->lon);
sprintf(ptr+strlen(ptr), "<a target=\"_empty\" href=\"https://www.openstreetmap.org/?mlat=%.6f&mlon=%.6f&zoom=14\">OSM</a></td></tr>", s->lat, s->lon);
strcat(ptr, "</table><p/>\n");
}
const char *createStatusForm() {
char *ptr = message;
strcpy(ptr,"<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"><meta http-equiv=\"refresh\" content=\"5\"></head><body>");
for(int i=0; i<sonde.nSonde; i++) {
addSondeStatus(ptr, (i+sonde.currentSonde)%sonde.nSonde);
}
strcat(ptr,"</body></html>");
return message;
}
const char* PARAM_MESSAGE = "message";
void SetupAsyncServer() {
// Route for root / web page
@ -264,6 +290,10 @@ void SetupAsyncServer() {
request->send(200, "text/html", createWIFIForm());
});
server.on("/status.html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/html", createStatusForm());
});
// Route to load style.css file
server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/style.css", "text/css");

View File

@ -17,6 +17,7 @@
<div class="tab">
<button class="tablinks" onclick="selTab(event,'QRG')" id="defaultTab">QRG</button>
<button class="tablinks" onclick="selTab(event,'WIFI')">WLAN</button>
<button class="tablinks" onclick="selTab(event,'Data')">Data</button>
<button class="tablinks" onclick="selTab(event,'About')">About</button>
</div>
@ -30,6 +31,11 @@
<iframe src="wifi.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div>
<div id="Data" class="tabcontent">
<h3>Data</h3>
<iframe src="status.html" style="border:none;" width="100%%" height="100%%"></iframe>
</div>
<div id="About" class="tabcontent">
<h3>About</h3>
RDZSonde

View File

@ -4,6 +4,16 @@ body, html {
font-family: Arial;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
background-color: #ddd
}
td#sfreq {
background-color: #ccc;
}
.tab {
overflow: hidden;
border: 1px solid #ccc;