From b1fbcc597a80e0f574b5cf70fbc134d660838fb4 Mon Sep 17 00:00:00 2001
From: fvanroie <15969459+fvanroie@users.noreply.github.com>
Date: Tue, 9 Nov 2021 04:02:02 +0100
Subject: [PATCH] Convert forms to CSS format
---
src/sys/svc/hasp_http.cpp | 107 +++++++++++++++-----------------
src/sys/svc/hasp_http_async.cpp | 1 -
2 files changed, 51 insertions(+), 57 deletions(-)
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("");
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("");
+ // Form
+ httpMessage += F("");
+ // Destination
+ httpMessage += F("
");
- // httpMessage += F("
");
+ // Submit & End Form
+ httpMessage += F("
");
+ httpMessage += F("
");
- httpMessage += F("");
+ // Form
+ 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("");
- 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
}
}