Refresh properly when rebooting, Auto-update dump page

This commit is contained in:
Owen 2020-10-28 14:05:22 +01:00
parent 824b27806b
commit b4038a92c5
2 changed files with 14 additions and 6 deletions

View File

@ -623,9 +623,9 @@ static esp_err_t cmd_handler(httpd_req_t *req){
}
else if(!strcmp(variable, "reboot")) {
Serial.print("REBOOT requested");
for (int i=0; i<20; i++) {
for (int i=0; i<16; i++) {
flashLED(50);
delay(150);
delay(120);
Serial.print('.');
}
Serial.printf(" Thats all folks!\n\n");
@ -730,7 +730,7 @@ static esp_err_t dump_handler(httpd_req_t *req){
Serial.println("\nDump Requested");
Serial.print("Preferences file: ");
dumpPrefs(SPIFFS);
static char dumpOut[1200] = "";
static char dumpOut[1500] = "";
char * d = dumpOut;
// Header
d+= sprintf(d,"<html><head><meta charset=\"utf-8\">\n");
@ -817,9 +817,12 @@ static esp_err_t dump_handler(httpd_req_t *req){
// Footer
d+= sprintf(d,"<br><div class=\"input-group\">\n");
d+= sprintf(d,"<button title=\"Refresh this page\" onclick=\"location.replace(document.URL)\">Refresh</button>\n");
d+= sprintf(d,"<button title=\"Instant Refresh; the page reloads every minute anyway\" onclick=\"location.replace(document.URL)\">Refresh</button>\n");
d+= sprintf(d,"<button title=\"Close this page\" onclick=\"javascript:window.close()\">Close</button>\n");
d+= sprintf(d,"</div>\n</body>\n</html>\n");
d+= sprintf(d,"</div>\n</body>\n");
// A javascript timer to refresh the page every minute.
d+= sprintf(d,"<script>\nsetTimeout(function(){\nlocation.replace(document.URL);\n}, 60000);\n");
d+= sprintf(d,"</script>\n</html>\n");
*d++ = 0;
httpd_resp_set_type(req, "text/html");
httpd_resp_set_hdr(req, "Content-Encoding", "identity");

View File

@ -293,6 +293,7 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
var streamURL = 'Undefined';
var viewerURL = 'Undefined';
const header = document.getElementById('logo')
const settings = document.getElementById('sidebar')
const waitSettings = document.getElementById('wait-settings')
const lampGroup = document.getElementById('lamp-group')
@ -632,7 +633,11 @@ const uint8_t index_ov2640_html[] = R"=====(<!doctype html>
if (confirm("Reboot the Camera Module?")) {
updateConfig(rebootButton);
// Some sort of countdown here?
location.reload();
hide(settings);
header.innerHTML = '<h1>Rebooting!</h1><hr>Page will reload after 20 seconds.';
setTimeout(function() {
location.replace(document.URL);
}, 20000);
}
}