diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 6c36624f..90ea27ee 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -170,22 +170,7 @@ String getOption(String& value, String& label, String& current_value) return buffer; } -static void add_button(String& str, const __FlashStringHelper* label, const __FlashStringHelper* extra) -{ - str += F(""); -} - -static void close_form(String& str) -{ - str += F("

"); -} - -static void add_form_button(String& str, const __FlashStringHelper* label, const __FlashStringHelper* action, - const __FlashStringHelper* extra) +static void add_form_button(String& str, const __FlashStringHelper* label, const __FlashStringHelper* action) { str += F("

"); // Automatic refresh + httpMessage += F("
" D_HTTP_PREV_PAGE ""); httpMessage += F("" D_HTTP_REFRESH ""); - httpMessage += F("" D_HTTP_PREV_PAGE ""); - httpMessage += F("" D_HTTP_NEXT_PAGE ""); + httpMessage += F("" D_HTTP_NEXT_PAGE "
"); httpMessage += FPSTR(MAIN_MENU_BUTTON); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); @@ -1282,7 +1267,7 @@ void webHandleMqttConfig() httpMessage += F(""); httpMessage += F(""); - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); } @@ -1375,11 +1360,11 @@ void webHandleGuiConfig() httpMessage += F(""); #if TOUCH_DRIVER == 0x2046 && defined(TOUCH_CS) - add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui?cal=1"), F("name='cal' value='1'")); + add_form_button(httpMessage, F(D_HTTP_CALIBRATE), F("/config/gui?cal=1")); #endif - add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui?brn=1"), F("name='brn' value='1'")); - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_HTTP_ANTIBURN), F("/config/gui?brn=1")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); } @@ -1430,7 +1415,7 @@ void webHandleWifiConfig() #if HASP_USE_WIFI > 0 && !defined(STM32F4xx) if(WiFi.getMode() == WIFI_STA) { - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); } #endif @@ -1473,7 +1458,7 @@ void webHandleCaptivePortalWifiConfig() #if HASP_USE_WIFI > 0 && !defined(STM32F4xx) if(WiFi.getMode() == WIFI_STA) { - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); } #endif @@ -1706,7 +1691,7 @@ void webHandleGpioConfig() httpMessage += F("'>" D_HTTP_ADD_GPIO " Output"); } - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); @@ -1969,7 +1954,7 @@ void webHandleDebugConfig() // ******************************************************************* - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); webSendPage(haspDevice.get_hostname(), httpMessage.length(), false); webServer.sendContent(httpMessage); @@ -2133,27 +2118,37 @@ void webHandleFirmware() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_FIRMWARE_UPGRADE "

"); - httpMessage += F("

"); - // httpMessage += F("

"); + // Form + httpMessage += F("
"); - httpMessage += F("Firmware   " - "Filesystem"); + // File + httpMessage += + F("
"); + httpMessage += F("
"); - add_button(httpMessage, F(D_HTTP_UPDATE_FIRMWARE), F("")); - httpMessage += F("

"); + // Destination + httpMessage += F("
"); + httpMessage += + F("
Firmware   " + "Filesystem
"); - // httpMessage += F("

"); - // httpMessage += F("

"); + // Submit & End Form + httpMessage += F(""); + httpMessage += F("
"); - httpMessage += F("
"); - httpMessage += F("
Update ESP from URL"); - httpMessage += F("


"); + // Form + httpMessage += F("
"); + + // URL + httpMessage += + F("
"); + httpMessage += F("
"); + + // Submit & End Form + httpMessage += F(""); + httpMessage += F("
"); httpMessage += FPSTR(MAIN_MENU_BUTTON); @@ -2213,39 +2208,39 @@ void httpHandleResetConfig() httpMessage += F("

"); httpMessage += haspDevice.get_hostname(); httpMessage += F("


"); + httpMessage += F("

" D_HTTP_FACTORY_RESET "

"); if(resetConfirmed) { // User has confirmed, so reset everything bool formatted = dispatch_factory_reset(); // configClearEeprom(); if(formatted) { - httpMessage += F("Resetting all saved settings and restarting device"); + httpMessage += F("
Reset all saved settings. Restarting device...
"); } else { - httpMessage += F("Failed to format the internal flash partition"); + httpMessage += + F("
Failed to reset the internal storage to factory settings!
"); resetConfirmed = false; } } else { + // Form + httpMessage += F("
"); httpMessage += - F("

Warning

This process will reset all settings to the default values. The internal flash " - "will be erased and the device is restarted. You may need to connect to the WiFi AP displayed on " - "the " - "panel to re-configure the device before accessing it again. ALL FILES WILL BE LOST!" - "


"); + F("
Warning

This process will reset all settings to the default values. " + "The internal flash will be erased and the device is restarted. You may need to connect to the WiFi " + "AP displayed on the panel to reconfigure the device before accessing it again.

" + "

ALL FILES WILL BE LOST!

"); + httpMessage += F("

"); - add_button(httpMessage, F(D_HTTP_ERASE_DEVICE), F("name='confirm' value='yes'")); - close_form(httpMessage); - - add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"), F("")); + add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config")); } webSendPage(haspDevice.get_hostname(), httpMessage.length(), resetConfirmed); webServer.sendContent(httpMessage); } - // httpMessage.clear(); webSendFooter(); if(resetConfirmed) { delay(250); - // configClearSaved(); - dispatch_reboot(false); // Do not save the current config + dispatch_reboot(false); // Do NOT save the current config } } #endif // HASP_USE_CONFIG diff --git a/src/sys/svc/hasp_http_async.cpp b/src/sys/svc/hasp_http_async.cpp index cf1fa88e..d87919af 100644 --- a/src/sys/svc/hasp_http_async.cpp +++ b/src/sys/svc/hasp_http_async.cpp @@ -2174,7 +2174,6 @@ void httpHandleResetConfig(AsyncWebServerRequest* request) if(resetConfirmed) { delay(250); - // configClearSaved(); dispatch_reboot(false); // Do not save the current config } }