[Webserver] Remove & simplify duplicate code send end of page

This commit is contained in:
TD-er
2026-07-12 14:00:22 +02:00
parent 0e66898524
commit 45827f3651
28 changed files with 163 additions and 177 deletions
+1 -2
View File
@@ -402,8 +402,7 @@ void handle_advanced() {
addHtml(F("<input type='hidden' name='edit' value='1'>")); addHtml(F("<input type='hidden' name='edit' value='1'>"));
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
void addFormDstSelect(bool isStart, uint16_t choice) { void addFormDstSelect(bool isStart, uint16_t choice) {
+1 -2
View File
@@ -182,8 +182,7 @@ void handle_config() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // ifdef WEBSERVER_CONFIG #endif // ifdef WEBSERVER_CONFIG
+4 -4
View File
@@ -122,8 +122,6 @@ void handle_controllers() {
} }
} }
html_add_form();
if (controllerIndexSet) if (controllerIndexSet)
{ {
handle_controllers_ControllerSettingsPage(controllerindex); handle_controllers_ControllerSettingsPage(controllerindex);
@@ -131,8 +129,7 @@ void handle_controllers() {
handle_controllers_ShowAllControllersTable(); handle_controllers_ShowAllControllersTable();
} }
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
@@ -214,6 +211,7 @@ void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerinde
// ******************************************************************************** // ********************************************************************************
void handle_controllers_ShowAllControllersTable() void handle_controllers_ShowAllControllersTable()
{ {
html_add_form();
html_table_class_multirow(); html_table_class_multirow();
html_TR(); html_TR();
html_table_header(F(""), 70); html_table_header(F(""), 70);
@@ -282,6 +280,8 @@ void handle_controllers_ControllerSettingsPage(controllerIndex_t controllerindex
return; return;
} }
html_add_form();
// Show controller settings page // Show controller settings page
html_table_class_normal(); html_table_class_normal();
addFormHeader(F("Controller Settings")); addFormHeader(F("Controller Settings"));
+1 -2
View File
@@ -214,8 +214,7 @@ void handle_devices() {
addLogMove(LOG_LEVEL_DEBUG_DEV, concat(F("DEBUG: String size:"), static_cast<int>(TXBuffer.sentBytes))); addLogMove(LOG_LEVEL_DEBUG_DEV, concat(F("DEBUG: String size:"), static_cast<int>(TXBuffer.sentBytes)));
} }
# endif // ifndef BUILD_NO_DEBUG # endif // ifndef BUILD_NO_DEBUG
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
+68 -41
View File
@@ -123,45 +123,9 @@ void sendHeadandTail(const __FlashStringHelper *tmplName, bool Tail, bool reboot
STOP_TIMER(HANDLE_SERVING_WEBPAGE); STOP_TIMER(HANDLE_SERVING_WEBPAGE);
} }
void sendHeadandTail_stdtemplate(bool Tail, bool rebooting) { void sendTail_stdtemplate(bool rebooting) {
sendHeadandTail(F("TmplStd"), Tail, rebooting); sendHeadandTail(F("TmplStd"), _TAIL, rebooting);
TXBuffer.endStream();
if (!Tail) {
// TODO TD-er: Must check clientConnectedToAP()?
if (!clientIPinSubnetDefaultNetwork() && ESPEasy::net::wifi::wifiAPmodeActivelyUsed()) {
addHtmlError(F("Warning: Connected via AP"));
}
#ifndef BUILD_NO_DEBUG
/*
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
const int nrArgs = web_server.args();
if (nrArgs > 0) {
String log = F(" Webserver ");
log += nrArgs;
log += F(" Arguments");
if (nrArgs > 20) {
log += F(" (First 20)");
}
log += ':';
for (int i = 0; i < nrArgs && i < 20; ++i) {
log += ' ';
log += i;
log += F(": '");
log += web_server.argName(i);
log += F("' length: ");
log += webArg(i).length();
}
addLogMove(LOG_LEVEL_INFO, log);
}
}
*/
#endif // ifndef BUILD_NO_DEBUG
}
// We have sent a lot of data at once. // We have sent a lot of data at once.
// try to flush it to the connected client to free up some RAM // try to flush it to the connected client to free up some RAM
@@ -901,10 +865,62 @@ bool isLoggedIn(bool mustProvideLogin)
bool startStream_send_stdTemplate(uint8_t newNavIndex) bool startStream_send_stdTemplate(uint8_t newNavIndex)
{ {
if (!isLoggedIn()) { return false; } if (!isLoggedIn()) { return false; }
startStream_send_stdTemplate_NoLoginCheck(newNavIndex);
return true;
}
void startStream_send_stdTemplate_NoLoginCheck(uint8_t newNavIndex, bool rebooting)
{
navMenuIndex = newNavIndex; navMenuIndex = newNavIndex;
TXBuffer.startStream(); TXBuffer.startStream();
sendHeadandTail_stdtemplate(_HEAD);
sendHeadandTail(F("TmplStd"), _HEAD, rebooting);
// TODO TD-er: This should be the only place where sendHeadandTail_stdtemplate(_HEAD) is called
// TODO TD-er: Must check clientConnectedToAP()?
if (!clientIPinSubnetDefaultNetwork() && ESPEasy::net::wifi::wifiAPmodeActivelyUsed()) {
addHtmlError(F("Warning: Connected via AP"));
}
#ifndef BUILD_NO_DEBUG
/*
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
const int nrArgs = web_server.args();
if (nrArgs > 0) {
String log = F(" Webserver ");
log += nrArgs;
log += F(" Arguments");
if (nrArgs > 20) {
log += F(" (First 20)");
}
log += ':';
for (int i = 0; i < nrArgs && i < 20; ++i) {
log += ' ';
log += i;
log += F(": '");
log += web_server.argName(i);
log += F("' length: ");
log += webArg(i).length();
}
addLogMove(LOG_LEVEL_INFO, log);
}
}
*/
#endif // ifndef BUILD_NO_DEBUG
}
bool startJSON_Stream()
{
if (!isLoggedIn()) { return false; }
TXBuffer.startJsonStream();
return true; return true;
} }
@@ -918,6 +934,17 @@ String getControllerSymbol(uint8_t index)
return ret; return ret;
} }
void handle_printWebString()
{
if (printWebString.isEmpty()) return;
addRowColspan(2);
addHtml(F("Command Output<BR><textarea readonly rows='10' wrap='on'>"));
addHtml(printWebString);
addHtml(F("</textarea>"));
free_string(printWebString);
printToWeb = false;
}
/* /*
String getValueSymbol(uint8_t index) String getValueSymbol(uint8_t index)
{ {
+10 -2
View File
@@ -22,8 +22,7 @@ void sendHeadandTail(const __FlashStringHelper * tmplName,
bool Tail = false, bool Tail = false,
bool rebooting = false); bool rebooting = false);
void sendHeadandTail_stdtemplate(bool Tail, void sendTail_stdtemplate(bool rebooting = false);
bool rebooting = false);
void WebServerInit(); void WebServerInit();
@@ -132,8 +131,17 @@ bool isLoggedIn(bool mustProvideLogin = true);
// Thus not for non-HTML pages. // Thus not for non-HTML pages.
bool startStream_send_stdTemplate(uint8_t newNavIndex); bool startStream_send_stdTemplate(uint8_t newNavIndex);
void startStream_send_stdTemplate_NoLoginCheck(uint8_t newNavIndex, bool rebooting = false);
// Check isLoggedIn and start JSON stream
// JSON can be called from anywhere, so no need to update the nav index
bool startJSON_Stream();
String getControllerSymbol(uint8_t index); String getControllerSymbol(uint8_t index);
void handle_printWebString();
/* /*
String getValueSymbol(uint8_t index); String getValueSymbol(uint8_t index);
*/ */
+1 -2
View File
@@ -107,8 +107,7 @@ void handle_factoryreset() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
+4 -13
View File
@@ -140,10 +140,7 @@ void handle_filelist() {
checkRAM(F("handle_filelist")); checkRAM(F("handle_filelist"));
#endif #endif
if (!clientIPallowed()) { return; } if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
navMenuIndex = MENU_INDEX_TOOLS;
TXBuffer.startStream();
sendHeadandTail_stdtemplate(_HEAD);
if (tryDeleteFile(webArg(F("delete")))) if (tryDeleteFile(webArg(F("delete"))))
{ {
@@ -333,8 +330,7 @@ void handle_filelist_buttons(int start_prev, int start_next, bool cacheFilesPres
} }
#endif #endif
addHtml(F("<BR><BR>")); addHtml(F("<BR><BR>"));
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // ifdef WEBSERVER_FILELIST #endif // ifdef WEBSERVER_FILELIST
@@ -348,11 +344,7 @@ void handle_SDfilelist() {
checkRAM(F("handle_SDfilelist")); checkRAM(F("handle_SDfilelist"));
#endif #endif
if (!clientIPallowed()) { return; } if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
navMenuIndex = MENU_INDEX_TOOLS;
TXBuffer.startStream();
sendHeadandTail_stdtemplate(_HEAD);
String fdelete; String fdelete;
String ddelete; String ddelete;
@@ -498,8 +490,7 @@ void handle_SDfilelist() {
html_BR(); html_BR();
addButton(F("/uploadsd"), F("Upload")); addButton(F("/uploadsd"), F("Upload"));
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // if FEATURE_SD #endif // if FEATURE_SD
+1 -2
View File
@@ -122,8 +122,7 @@ void handle_hardware() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // ifdef WEBSERVER_HARDWARE #endif // ifdef WEBSERVER_HARDWARE
+3 -5
View File
@@ -109,9 +109,8 @@ void handle_i2cscanner_json() {
checkRAM(F("handle_i2cscanner")); checkRAM(F("handle_i2cscanner"));
#endif #endif
if (!isLoggedIn()) { return; } if (!startJSON_Stream()) { return; }
navMenuIndex = MENU_INDEX_TOOLS;
TXBuffer.startJsonStream();
json_init(); json_init();
json_open(true); json_open(true);
@@ -558,7 +557,6 @@ void handle_i2cscanner() {
I2CSelectHighClockSpeed(0); // By default the bus is in standard speed I2CSelectHighClockSpeed(0); // By default the bus is in standard speed
} }
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // WEBSERVER_I2C_SCANNER #endif // WEBSERVER_I2C_SCANNER
+12 -13
View File
@@ -75,26 +75,26 @@ void handle_interfaces() {
checkRAM(F("handle_interfaces")); checkRAM(F("handle_interfaces"));
# endif # endif
if (!isLoggedIn()) { return; } uint8_t newNavIndex = navMenuIndex;
if ((navMenuIndex != MENU_INDEX_INTERFACES) && (navMenuIndex <= MENU_MAX_INDEX_SHOWN)) { if ((newNavIndex != MENU_INDEX_INTERFACES) && (newNavIndex <= MENU_MAX_INDEX_SHOWN)) {
#if FEATURE_I2C #if FEATURE_I2C
navMenuIndex = MENU_INDEX_INTERFACES_I2C; newNavIndex = MENU_INDEX_INTERFACES_I2C;
#elif FEATURE_SPI #elif FEATURE_SPI
navMenuIndex = MENU_INDEX_INTERFACES_SPI; newNavIndex = MENU_INDEX_INTERFACES_SPI;
#elif FEATURE_MODBUS && FEATURE_MODBUS_INTERFACES_TAB #elif FEATURE_MODBUS && FEATURE_MODBUS_INTERFACES_TAB
navMenuIndex = MENU_INDEX_INTERFACES_MODBUS; newNavIndex = MENU_INDEX_INTERFACES_MODBUS;
#elif FEATURE_CAN #elif FEATURE_CAN
navMenuIndex = MENU_INDEX_INTERFACES_CAN; newNavIndex = MENU_INDEX_INTERFACES_CAN;
#elif FEATURE_WRMBUS #elif FEATURE_WRMBUS
navMenuIndex = MENU_INDEX_INTERFACES_WRMBUS; newNavIndex = MENU_INDEX_INTERFACES_WRMBUS;
#elif FEATURE_WIMBUS #elif FEATURE_WIMBUS
navMenuIndex = MENU_INDEX_INTERFACES_WIMBUS; newNavIndex = MENU_INDEX_INTERFACES_WIMBUS;
#else #else
navMenuIndex = MENU_INDEX_INTERFACES; // FIXME TD-er: Should we still continue here? Why not simply return;
newNavIndex = MENU_INDEX_INTERFACES;
#endif #endif
} }
TXBuffer.startStream(); if (!startStream_send_stdTemplate(newNavIndex)) return;
sendHeadandTail_stdtemplate(_HEAD);
save_interfaces(); save_interfaces();
@@ -149,8 +149,7 @@ void handle_interfaces() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
void save_interfaces() { void save_interfaces() {
+2 -4
View File
@@ -734,8 +734,7 @@ void handle_timingstats_json() {
# if FEATURE_ESPEASY_P2P # if FEATURE_ESPEASY_P2P
void handle_nodes_list_json() { void handle_nodes_list_json() {
if (!isLoggedIn()) { return; } if (!startJSON_Stream()) { return; }
TXBuffer.startJsonStream();
json_init(); json_init();
json_open(true); json_open(true);
@@ -767,8 +766,7 @@ void handle_nodes_list_json() {
# endif // if FEATURE_ESPEASY_P2P # endif // if FEATURE_ESPEASY_P2P
void handle_buildinfo() { void handle_buildinfo() {
if (!isLoggedIn()) { return; } if (!startJSON_Stream()) { return; }
TXBuffer.startJsonStream();
json_init(); json_init();
json_open(); json_open();
{ {
+4 -4
View File
@@ -42,18 +42,16 @@ void handle_log() {
#else // ifdef WEBSERVER_LOG #else // ifdef WEBSERVER_LOG
addHtml(F("Not included in build")); addHtml(F("Not included in build"));
#endif // ifdef WEBSERVER_LOG #endif // ifdef WEBSERVER_LOG
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
// Web Interface JSON log page // Web Interface JSON log page
// ******************************************************************************** // ********************************************************************************
void handle_log_JSON() { void handle_log_JSON() {
if (!isLoggedIn()) { return; }
#ifdef WEBSERVER_LOG #ifdef WEBSERVER_LOG
START_TIMER; START_TIMER;
TXBuffer.startJsonStream(); if (!startJSON_Stream()) { return; }
{ {
KeyValueWriter_JSON top(true); KeyValueWriter_JSON top(true);
{ {
@@ -145,6 +143,8 @@ void handle_log_JSON() {
updateLogLevelCache(); updateLogLevelCache();
#else // ifdef WEBSERVER_LOG #else // ifdef WEBSERVER_LOG
if (!isLoggedIn()) { return; }
handleNotFound(); handleNotFound();
#endif // ifdef WEBSERVER_LOG #endif // ifdef WEBSERVER_LOG
} }
+4 -4
View File
@@ -111,8 +111,6 @@ void handle_networks()
} }
html_add_form();
if (networkIndexSet) if (networkIndexSet)
{ {
handle_networks_NetworkSettingsPage(networkindex); handle_networks_NetworkSettingsPage(networkindex);
@@ -122,8 +120,7 @@ void handle_networks()
handle_networks_ShowAllNetworksTable(); handle_networks_ShowAllNetworksTable();
} }
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
void handle_networks_clearLoadDefaults(ESPEasy::net::networkIndex_t networkindex, NetworkSettingsStruct& NetworkSettings) { void handle_networks_clearLoadDefaults(ESPEasy::net::networkIndex_t networkindex, NetworkSettingsStruct& NetworkSettings) {
@@ -180,6 +177,7 @@ void handle_networks_CopySubmittedSettings_NWPluginCall(ESPEasy::net::networkInd
void handle_networks_ShowAllNetworksTable() void handle_networks_ShowAllNetworksTable()
{ {
html_add_form();
html_table_class_multirow(); html_table_class_multirow();
html_TR(); html_TR();
html_table_header(F(""), 70); html_table_header(F(""), 70);
@@ -317,6 +315,8 @@ void handle_networks_NetworkSettingsPage(ESPEasy::net::networkIndex_t networkind
{ {
if (!validNetworkIndex(networkindex)) { return; } if (!validNetworkIndex(networkindex)) { return; }
html_add_form();
const networkDriverIndex_t networkDriverIndex = const networkDriverIndex_t networkDriverIndex =
getNetworkDriverIndex_from_NWPluginID( getNetworkDriverIndex_from_NWPluginID(
Settings.getNWPluginID_for_network(networkindex)); Settings.getNWPluginID_for_network(networkindex));
+1 -2
View File
@@ -321,8 +321,7 @@ void handle_notifications() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
} }
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // FEATURE_NOTIFIER #endif // FEATURE_NOTIFIER
+2 -5
View File
@@ -32,9 +32,7 @@ void handle_pinstates_json() {
checkRAM(F("handle_pinstates")); checkRAM(F("handle_pinstates"));
# endif // ifndef BUILD_NO_RAM_TRACKER # endif // ifndef BUILD_NO_RAM_TRACKER
if (!isLoggedIn()) { return; } if (!startJSON_Stream()) { return; }
navMenuIndex = MENU_INDEX_TOOLS;
TXBuffer.startJsonStream();
bool first = true; bool first = true;
addHtml('['); addHtml('[');
@@ -300,8 +298,7 @@ void handle_pinstates() {
# endif // if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0) # endif // if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
# endif // ifdef ESP32 # endif // ifdef ESP32
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // ifdef WEBSERVER_PINSTATES #endif // ifdef WEBSERVER_PINSTATES
+2 -4
View File
@@ -28,8 +28,7 @@ void handle_pluginlist() {
const int colspan = 5; const int colspan = 5;
# endif // if FEATURE_MQTT_TLS || FEATURE_HTTP_TLS # endif // if FEATURE_MQTT_TLS || FEATURE_HTTP_TLS
TXBuffer.startStream(); startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_DEVICES);
sendHeadandTail_stdtemplate(_HEAD);
// the table header // the table header
html_table_class_normal(); html_table_class_normal();
@@ -196,8 +195,7 @@ void handle_pluginlist() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // if FEATURE_PLUGIN_LIST #endif // if FEATURE_PLUGIN_LIST
+10 -11
View File
@@ -79,19 +79,19 @@ void handle_root() {
const bool loggedIn = isLoggedIn(false); const bool loggedIn = isLoggedIn(false);
navMenuIndex = 0; navMenuIndex = MENU_INDEX_MAIN;
// if index.htm exists on FS serve that one (first check if gziped version exists) // if index.htm exists on FS serve that one (first check if gziped version exists)
if (loadFromFS(F("/index.htm.gz"))) { return; } if (loadFromFS(F("/index.htm.gz"))) { return; }
if (loadFromFS(F("/index.htm"))) { return; } if (loadFromFS(F("/index.htm"))) { return; }
TXBuffer.startStream();
boolean rebootCmd = false; boolean rebootCmd = false;
String sCommand = webArg(F("cmd")); String sCommand = webArg(F("cmd"));
rebootCmd = strcasecmp_P(sCommand.c_str(), PSTR("reboot")) == 0; rebootCmd = strcasecmp_P(sCommand.c_str(), PSTR("reboot")) == 0;
sendHeadandTail_stdtemplate(_HEAD, rebootCmd);
// Already checked for logged in state
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_MAIN, rebootCmd);
// TODO: move this to handle_tools, from where it is actually called? // TODO: move this to handle_tools, from where it is actually called?
@@ -211,12 +211,8 @@ void handle_root() {
addFormHeader(F("Command Argument")); addFormHeader(F("Command Argument"));
addRowLabel(F("Command")); addRowLabel(F("Command"));
addHtml(sCommand); addHtml(sCommand);
addRowColspan(2); handle_printWebString();
addHtml(F("Command Output<BR><textarea readonly rows='10' wrap='on'>"));
addHtml(printWebString);
addHtml(F("</textarea>"));
free_string(printWebString);
} }
} }
html_end_table(); html_end_table();
@@ -404,10 +400,13 @@ void handle_root() {
html_end_table(); html_end_table();
# endif // if FEATURE_ESPEASY_P2P # endif // if FEATURE_ESPEASY_P2P
html_end_form(); html_end_form();
sendTail_stdtemplate();
// FIXME TD-er: Is this still needed?
free_string(printWebString); free_string(printWebString);
printToWeb = false; printToWeb = false;
sendHeadandTail_stdtemplate(_TAIL);
return; // TXBuffer.endStream() was already sent
} }
TXBuffer.endStream(); TXBuffer.endStream();
} }
+8 -15
View File
@@ -55,8 +55,8 @@ void handle_rules() {
if (f) { f.close(); } if (f) { f.close(); }
} }
TXBuffer.startStream(); // Already checked for login
sendHeadandTail_stdtemplate(_HEAD); startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_RULES);
addHtmlError(error); addHtmlError(error);
html_table_class_normal(); html_table_class_normal();
@@ -104,8 +104,7 @@ void handle_rules() {
addButton(fileName, F("Download to file")); addButton(fileName, F("Download to file"));
html_end_table(); html_end_table();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
checkRuleSets(); checkRuleSets();
} }
@@ -127,10 +126,8 @@ void handle_rules_new() {
# ifndef BUILD_NO_RAM_TRACKER # ifndef BUILD_NO_RAM_TRACKER
checkRAM(F("handle_rules")); checkRAM(F("handle_rules"));
# endif // ifndef BUILD_NO_RAM_TRACKER # endif // ifndef BUILD_NO_RAM_TRACKER
navMenuIndex = 5; if (!startStream_send_stdTemplate(MENU_INDEX_RULES)) { return; }
TXBuffer.startStream();
sendHeadandTail(F("TmplStd"), _HEAD);
// define macro // define macro
# if defined(ESP8266) # if defined(ESP8266)
String rootPath = F("rules"); String rootPath = F("rules");
@@ -254,8 +251,7 @@ void handle_rules_new() {
} }
// TXBuffer += F("<BR><BR>"); // TXBuffer += F("<BR><BR>");
sendHeadandTail(F("TmplStd"), _TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
# ifndef BUILD_NO_RAM_TRACKER # ifndef BUILD_NO_RAM_TRACKER
checkRAM(F("handle_rules")); checkRAM(F("handle_rules"));
# endif // ifndef BUILD_NO_RAM_TRACKER # endif // ifndef BUILD_NO_RAM_TRACKER
@@ -477,9 +473,7 @@ bool handle_rules_edit(String originalUri, bool isAddNew) {
} }
} }
} }
navMenuIndex = 5; startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_RULES);
TXBuffer.startStream();
sendHeadandTail(F("TmplStd"));
if (error.length() > 0) { if (error.length() > 0) {
addHtmlError(error); addHtmlError(error);
@@ -529,8 +523,7 @@ bool handle_rules_edit(String originalUri, bool isAddNew) {
addHtml(F("</table></form>")); addHtml(F("</table></form>"));
sendHeadandTail(F("TmplStd"), true); sendTail_stdtemplate();
TXBuffer.endStream();
# endif // WEBSERVER_NEW_RULES # endif // WEBSERVER_NEW_RULES
} }
# ifndef BUILD_NO_RAM_TRACKER # ifndef BUILD_NO_RAM_TRACKER
+1 -2
View File
@@ -232,8 +232,7 @@ void handle_settingsarchive() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
+5 -6
View File
@@ -43,15 +43,15 @@ void handle_setup() {
checkRAM(F("handle_setup")); checkRAM(F("handle_setup"));
# endif // ifndef BUILD_NO_RAM_TRACKER # endif // ifndef BUILD_NO_RAM_TRACKER
// Do not check client IP range allowed.
TXBuffer.startStream();
const bool connected = ESPEasy::net::NetworkConnected(); const bool connected = ESPEasy::net::NetworkConnected();
// if (connected) { // if (connected) {
navMenuIndex = MENU_INDEX_SETUP;
sendHeadandTail_stdtemplate(_HEAD); // TODO TD-er: Should also check for logged in state here?
// if (!startStream_send_stdTemplate(MENU_INDEX_SETUP)) { return; }
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_SETUP);
/* } else { /* } else {
sendHeadandTail(F("TmplAP")); sendHeadandTail(F("TmplAP"));
@@ -260,13 +260,12 @@ void handle_setup() {
} }
// if (connected) { // if (connected) {
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
/* } else { /* } else {
sendHeadandTail(F("TmplAP"), true); sendHeadandTail(F("TmplAP"), true);
} }
*/ */
TXBuffer.endStream();
delay(10); delay(10);
if (clearWiFiCredentials) { if (clearWiFiCredentials) {
+2 -4
View File
@@ -56,8 +56,7 @@ void handle_sysinfo_json() {
checkRAM(F("handle_sysinfo")); checkRAM(F("handle_sysinfo"));
# endif // ifndef BUILD_NO_RAM_TRACKER # endif // ifndef BUILD_NO_RAM_TRACKER
if (!isLoggedIn()) { return; } if (!startJSON_Stream()) { return; }
TXBuffer.startJsonStream();
{ {
KeyValueWriter_JSON mainLevelWriter(true); KeyValueWriter_JSON mainLevelWriter(true);
{ {
@@ -292,8 +291,7 @@ void handle_sysinfo() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
void handle_sysinfo_basicInfo() { void handle_sysinfo_basicInfo() {
+1 -2
View File
@@ -543,8 +543,7 @@ void handle_sysvars() {
} }
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
void addSysVar_html(const __FlashStringHelper *input) { void addSysVar_html(const __FlashStringHelper *input) {
+4 -5
View File
@@ -17,9 +17,9 @@ void handle_timingstats() {
#ifndef BUILD_NO_RAM_TRACKER #ifndef BUILD_NO_RAM_TRACKER
checkRAM(F("handle_timingstats")); checkRAM(F("handle_timingstats"));
#endif #endif
navMenuIndex = MENU_INDEX_TOOLS;
TXBuffer.startStream(); startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_TOOLS);
sendHeadandTail_stdtemplate(_HEAD);
html_table_class_multirow(); html_table_class_multirow();
html_TR(); html_TR();
{ {
@@ -55,8 +55,7 @@ void handle_timingstats() {
addHtml(F("Duty cycle based on average < 1 msec is highly unreliable")); addHtml(F("Duty cycle based on average < 1 msec is highly unreliable"));
html_end_table(); html_end_table();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
// ******************************************************************************** // ********************************************************************************
+4 -11
View File
@@ -48,15 +48,7 @@ void handle_tools() {
addRTDHelpButton(F("Reference/Command.html")); addRTDHelpButton(F("Reference/Command.html"));
html_TR_TD(); html_TR_TD();
if (printWebString.length() > 0) handle_printWebString();
{
addRowColspan(2);
addHtml(F("Command Output<BR><textarea readonly rows='10' wrap='on'>"));
addHtml(printWebString);
addHtml(F("</textarea>"));
free_string(printWebString);
}
addFormSubHeader(F("System")); addFormSubHeader(F("System"));
@@ -201,8 +193,9 @@ void handle_tools() {
html_end_table(); html_end_table();
html_end_form(); html_end_form();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
// FIXME TD-er: Is this still needed?
free_string(printWebString); free_string(printWebString);
printToWeb = false; printToWeb = false;
} }
+2 -4
View File
@@ -29,8 +29,7 @@ void handle_upload() {
addHtml(F( addHtml(F(
"<form enctype='multipart/form-data' method='post'><p>Upload settings file:<br><input type='file' name='datafile' size='40'></p><div><input class='button link' type='submit' value='Upload'></div><input type='hidden' name='edit' value='1'></form>")); "<form enctype='multipart/form-data' method='post'><p>Upload settings file:<br><input type='file' name='datafile' size='40'></p><div><input class='button link' type='submit' value='Upload'></div><input type='hidden' name='edit' value='1'></form>"));
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
free_string(printWebString); free_string(printWebString);
printToWeb = false; printToWeb = false;
} }
@@ -77,8 +76,7 @@ void handle_upload_post() {
} }
addHtml(F("Upload finished")); addHtml(F("Upload finished"));
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
free_string(printWebString); free_string(printWebString);
printToWeb = false; printToWeb = false;
} }
+3 -3
View File
@@ -15,10 +15,10 @@
#define MENU_INDEX_INTERFACES 3 #define MENU_INDEX_INTERFACES 3
#define MENU_INDEX_INTERFACES_I2C 30 #define MENU_INDEX_INTERFACES_I2C 30
#define MENU_INDEX_INTERFACES_SPI 31 #define MENU_INDEX_INTERFACES_SPI 31
#define MENU_INDEX_INTERFACES_MODBUS 32 #define MENU_INDEX_INTERFACES_MODBUS 32 // For now Modbus-RTU, maybe later also Modbus-TCP
#define MENU_INDEX_INTERFACES_CAN 33 #define MENU_INDEX_INTERFACES_CAN 33
#define MENU_INDEX_INTERFACES_WRMBUS 34 #define MENU_INDEX_INTERFACES_WRMBUS 34 // Wired M-Bus
#define MENU_INDEX_INTERFACES_WIMBUS 35 #define MENU_INDEX_INTERFACES_WIMBUS 35 // Wireless M-Bus
#define MENU_INDEX_NETWORK 4 #define MENU_INDEX_NETWORK 4
#define MENU_INDEX_CONTROLLERS 5 #define MENU_INDEX_CONTROLLERS 5
#define MENU_INDEX_BUSES 6 #define MENU_INDEX_BUSES 6
+2 -3
View File
@@ -71,7 +71,7 @@ void handle_wifiscanner() {
ESPEasy::net::wifi::setWifiMode(cur_wifimode); ESPEasy::net::wifi::setWifiMode(cur_wifimode);
if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; } if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
html_table_class_multirow(); html_table_class_multirow();
html_TR(); html_TR();
html_table_header(getLabel(LabelType::SSID)); html_table_header(getLabel(LabelType::SSID));
@@ -97,8 +97,7 @@ void handle_wifiscanner() {
} }
html_end_table(); html_end_table();
sendHeadandTail_stdtemplate(_TAIL); sendTail_stdtemplate();
TXBuffer.endStream();
} }
#endif // ifdef WEBSERVER_WIFI_SCANNER #endif // ifdef WEBSERVER_WIFI_SCANNER