mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[Webserver] Remove & simplify duplicate code send end of page
This commit is contained in:
@@ -402,8 +402,7 @@ void handle_advanced() {
|
||||
addHtml(F("<input type='hidden' name='edit' value='1'>"));
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
void addFormDstSelect(bool isStart, uint16_t choice) {
|
||||
|
||||
@@ -182,8 +182,7 @@ void handle_config() {
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // ifdef WEBSERVER_CONFIG
|
||||
@@ -122,8 +122,6 @@ void handle_controllers() {
|
||||
}
|
||||
}
|
||||
|
||||
html_add_form();
|
||||
|
||||
if (controllerIndexSet)
|
||||
{
|
||||
handle_controllers_ControllerSettingsPage(controllerindex);
|
||||
@@ -131,8 +129,7 @@ void handle_controllers() {
|
||||
handle_controllers_ShowAllControllersTable();
|
||||
}
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
@@ -214,6 +211,7 @@ void handle_controllers_CopySubmittedSettings_CPluginCall(uint8_t controllerinde
|
||||
// ********************************************************************************
|
||||
void handle_controllers_ShowAllControllersTable()
|
||||
{
|
||||
html_add_form();
|
||||
html_table_class_multirow();
|
||||
html_TR();
|
||||
html_table_header(F(""), 70);
|
||||
@@ -282,6 +280,8 @@ void handle_controllers_ControllerSettingsPage(controllerIndex_t controllerindex
|
||||
return;
|
||||
}
|
||||
|
||||
html_add_form();
|
||||
|
||||
// Show controller settings page
|
||||
html_table_class_normal();
|
||||
addFormHeader(F("Controller Settings"));
|
||||
|
||||
@@ -214,8 +214,7 @@ void handle_devices() {
|
||||
addLogMove(LOG_LEVEL_DEBUG_DEV, concat(F("DEBUG: String size:"), static_cast<int>(TXBuffer.sentBytes)));
|
||||
}
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
@@ -123,45 +123,9 @@ void sendHeadandTail(const __FlashStringHelper *tmplName, bool Tail, bool reboot
|
||||
STOP_TIMER(HANDLE_SERVING_WEBPAGE);
|
||||
}
|
||||
|
||||
void sendHeadandTail_stdtemplate(bool Tail, bool rebooting) {
|
||||
sendHeadandTail(F("TmplStd"), Tail, rebooting);
|
||||
|
||||
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
|
||||
}
|
||||
void sendTail_stdtemplate(bool rebooting) {
|
||||
sendHeadandTail(F("TmplStd"), _TAIL, rebooting);
|
||||
TXBuffer.endStream();
|
||||
|
||||
// We have sent a lot of data at once.
|
||||
// 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)
|
||||
{
|
||||
if (!isLoggedIn()) { return false; }
|
||||
|
||||
|
||||
startStream_send_stdTemplate_NoLoginCheck(newNavIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
void startStream_send_stdTemplate_NoLoginCheck(uint8_t newNavIndex, bool rebooting)
|
||||
{
|
||||
navMenuIndex = newNavIndex;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -918,6 +934,17 @@ String getControllerSymbol(uint8_t index)
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,7 @@ void sendHeadandTail(const __FlashStringHelper * tmplName,
|
||||
bool Tail = false,
|
||||
bool rebooting = false);
|
||||
|
||||
void sendHeadandTail_stdtemplate(bool Tail,
|
||||
bool rebooting = false);
|
||||
void sendTail_stdtemplate(bool rebooting = false);
|
||||
|
||||
|
||||
void WebServerInit();
|
||||
@@ -132,8 +131,17 @@ bool isLoggedIn(bool mustProvideLogin = true);
|
||||
// Thus not for non-HTML pages.
|
||||
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);
|
||||
|
||||
|
||||
void handle_printWebString();
|
||||
|
||||
/*
|
||||
String getValueSymbol(uint8_t index);
|
||||
*/
|
||||
|
||||
@@ -107,8 +107,7 @@ void handle_factoryreset() {
|
||||
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
@@ -140,10 +140,7 @@ void handle_filelist() {
|
||||
checkRAM(F("handle_filelist"));
|
||||
#endif
|
||||
|
||||
if (!clientIPallowed()) { return; }
|
||||
navMenuIndex = MENU_INDEX_TOOLS;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
|
||||
|
||||
if (tryDeleteFile(webArg(F("delete"))))
|
||||
{
|
||||
@@ -333,8 +330,7 @@ void handle_filelist_buttons(int start_prev, int start_next, bool cacheFilesPres
|
||||
}
|
||||
#endif
|
||||
addHtml(F("<BR><BR>"));
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // ifdef WEBSERVER_FILELIST
|
||||
@@ -348,11 +344,7 @@ void handle_SDfilelist() {
|
||||
checkRAM(F("handle_SDfilelist"));
|
||||
#endif
|
||||
|
||||
if (!clientIPallowed()) { return; }
|
||||
navMenuIndex = MENU_INDEX_TOOLS;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
|
||||
if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
|
||||
|
||||
String fdelete;
|
||||
String ddelete;
|
||||
@@ -498,8 +490,7 @@ void handle_SDfilelist() {
|
||||
|
||||
html_BR();
|
||||
addButton(F("/uploadsd"), F("Upload"));
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // if FEATURE_SD
|
||||
|
||||
@@ -122,8 +122,7 @@ void handle_hardware() {
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // ifdef WEBSERVER_HARDWARE
|
||||
|
||||
@@ -109,9 +109,8 @@ void handle_i2cscanner_json() {
|
||||
checkRAM(F("handle_i2cscanner"));
|
||||
#endif
|
||||
|
||||
if (!isLoggedIn()) { return; }
|
||||
navMenuIndex = MENU_INDEX_TOOLS;
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
|
||||
json_init();
|
||||
json_open(true);
|
||||
|
||||
@@ -558,7 +557,6 @@ void handle_i2cscanner() {
|
||||
I2CSelectHighClockSpeed(0); // By default the bus is in standard speed
|
||||
|
||||
}
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
#endif // WEBSERVER_I2C_SCANNER
|
||||
|
||||
@@ -75,26 +75,26 @@ void handle_interfaces() {
|
||||
checkRAM(F("handle_interfaces"));
|
||||
# endif
|
||||
|
||||
if (!isLoggedIn()) { return; }
|
||||
if ((navMenuIndex != MENU_INDEX_INTERFACES) && (navMenuIndex <= MENU_MAX_INDEX_SHOWN)) {
|
||||
uint8_t newNavIndex = navMenuIndex;
|
||||
if ((newNavIndex != MENU_INDEX_INTERFACES) && (newNavIndex <= MENU_MAX_INDEX_SHOWN)) {
|
||||
#if FEATURE_I2C
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_I2C;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_I2C;
|
||||
#elif FEATURE_SPI
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_SPI;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_SPI;
|
||||
#elif FEATURE_MODBUS && FEATURE_MODBUS_INTERFACES_TAB
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_MODBUS;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_MODBUS;
|
||||
#elif FEATURE_CAN
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_CAN;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_CAN;
|
||||
#elif FEATURE_WRMBUS
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_WRMBUS;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_WRMBUS;
|
||||
#elif FEATURE_WIMBUS
|
||||
navMenuIndex = MENU_INDEX_INTERFACES_WIMBUS;
|
||||
newNavIndex = MENU_INDEX_INTERFACES_WIMBUS;
|
||||
#else
|
||||
navMenuIndex = MENU_INDEX_INTERFACES;
|
||||
// FIXME TD-er: Should we still continue here? Why not simply return;
|
||||
newNavIndex = MENU_INDEX_INTERFACES;
|
||||
#endif
|
||||
}
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
if (!startStream_send_stdTemplate(newNavIndex)) return;
|
||||
|
||||
save_interfaces();
|
||||
|
||||
@@ -149,8 +149,7 @@ void handle_interfaces() {
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
void save_interfaces() {
|
||||
|
||||
@@ -734,8 +734,7 @@ void handle_timingstats_json() {
|
||||
# if FEATURE_ESPEASY_P2P
|
||||
|
||||
void handle_nodes_list_json() {
|
||||
if (!isLoggedIn()) { return; }
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
json_init();
|
||||
json_open(true);
|
||||
|
||||
@@ -767,8 +766,7 @@ void handle_nodes_list_json() {
|
||||
# endif // if FEATURE_ESPEASY_P2P
|
||||
|
||||
void handle_buildinfo() {
|
||||
if (!isLoggedIn()) { return; }
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
json_init();
|
||||
json_open();
|
||||
{
|
||||
|
||||
@@ -42,18 +42,16 @@ void handle_log() {
|
||||
#else // ifdef WEBSERVER_LOG
|
||||
addHtml(F("Not included in build"));
|
||||
#endif // ifdef WEBSERVER_LOG
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// Web Interface JSON log page
|
||||
// ********************************************************************************
|
||||
void handle_log_JSON() {
|
||||
if (!isLoggedIn()) { return; }
|
||||
#ifdef WEBSERVER_LOG
|
||||
START_TIMER;
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
{
|
||||
KeyValueWriter_JSON top(true);
|
||||
{
|
||||
@@ -145,6 +143,8 @@ void handle_log_JSON() {
|
||||
updateLogLevelCache();
|
||||
|
||||
#else // ifdef WEBSERVER_LOG
|
||||
if (!isLoggedIn()) { return; }
|
||||
|
||||
handleNotFound();
|
||||
#endif // ifdef WEBSERVER_LOG
|
||||
}
|
||||
|
||||
@@ -111,8 +111,6 @@ void handle_networks()
|
||||
|
||||
}
|
||||
|
||||
html_add_form();
|
||||
|
||||
if (networkIndexSet)
|
||||
{
|
||||
handle_networks_NetworkSettingsPage(networkindex);
|
||||
@@ -122,8 +120,7 @@ void handle_networks()
|
||||
handle_networks_ShowAllNetworksTable();
|
||||
}
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
html_add_form();
|
||||
html_table_class_multirow();
|
||||
html_TR();
|
||||
html_table_header(F(""), 70);
|
||||
@@ -317,6 +315,8 @@ void handle_networks_NetworkSettingsPage(ESPEasy::net::networkIndex_t networkind
|
||||
{
|
||||
if (!validNetworkIndex(networkindex)) { return; }
|
||||
|
||||
html_add_form();
|
||||
|
||||
const networkDriverIndex_t networkDriverIndex =
|
||||
getNetworkDriverIndex_from_NWPluginID(
|
||||
Settings.getNWPluginID_for_network(networkindex));
|
||||
|
||||
@@ -321,8 +321,7 @@ void handle_notifications() {
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
}
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // FEATURE_NOTIFIER
|
||||
|
||||
@@ -32,9 +32,7 @@ void handle_pinstates_json() {
|
||||
checkRAM(F("handle_pinstates"));
|
||||
# endif // ifndef BUILD_NO_RAM_TRACKER
|
||||
|
||||
if (!isLoggedIn()) { return; }
|
||||
navMenuIndex = MENU_INDEX_TOOLS;
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
|
||||
bool first = true;
|
||||
addHtml('[');
|
||||
@@ -300,8 +298,7 @@ void handle_pinstates() {
|
||||
# endif // if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
||||
|
||||
# endif // ifdef ESP32
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // ifdef WEBSERVER_PINSTATES
|
||||
|
||||
@@ -28,8 +28,7 @@ void handle_pluginlist() {
|
||||
const int colspan = 5;
|
||||
# endif // if FEATURE_MQTT_TLS || FEATURE_HTTP_TLS
|
||||
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_DEVICES);
|
||||
|
||||
// the table header
|
||||
html_table_class_normal();
|
||||
@@ -196,8 +195,7 @@ void handle_pluginlist() {
|
||||
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // if FEATURE_PLUGIN_LIST
|
||||
|
||||
@@ -79,19 +79,19 @@ void handle_root() {
|
||||
|
||||
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 (loadFromFS(F("/index.htm.gz"))) { return; }
|
||||
|
||||
if (loadFromFS(F("/index.htm"))) { return; }
|
||||
|
||||
TXBuffer.startStream();
|
||||
|
||||
boolean rebootCmd = false;
|
||||
String sCommand = webArg(F("cmd"));
|
||||
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?
|
||||
|
||||
@@ -211,12 +211,8 @@ void handle_root() {
|
||||
addFormHeader(F("Command Argument"));
|
||||
addRowLabel(F("Command"));
|
||||
addHtml(sCommand);
|
||||
|
||||
addRowColspan(2);
|
||||
addHtml(F("Command Output<BR><textarea readonly rows='10' wrap='on'>"));
|
||||
addHtml(printWebString);
|
||||
addHtml(F("</textarea>"));
|
||||
free_string(printWebString);
|
||||
|
||||
handle_printWebString();
|
||||
}
|
||||
}
|
||||
html_end_table();
|
||||
@@ -404,10 +400,13 @@ void handle_root() {
|
||||
html_end_table();
|
||||
# endif // if FEATURE_ESPEASY_P2P
|
||||
html_end_form();
|
||||
sendTail_stdtemplate();
|
||||
|
||||
// FIXME TD-er: Is this still needed?
|
||||
free_string(printWebString);
|
||||
printToWeb = false;
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
|
||||
return; // TXBuffer.endStream() was already sent
|
||||
}
|
||||
TXBuffer.endStream();
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ void handle_rules() {
|
||||
if (f) { f.close(); }
|
||||
}
|
||||
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
// Already checked for login
|
||||
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_RULES);
|
||||
addHtmlError(error);
|
||||
|
||||
html_table_class_normal();
|
||||
@@ -104,8 +104,7 @@ void handle_rules() {
|
||||
addButton(fileName, F("Download to file"));
|
||||
html_end_table();
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
|
||||
checkRuleSets();
|
||||
}
|
||||
@@ -127,10 +126,8 @@ void handle_rules_new() {
|
||||
# ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("handle_rules"));
|
||||
# endif // ifndef BUILD_NO_RAM_TRACKER
|
||||
navMenuIndex = 5;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"), _HEAD);
|
||||
|
||||
if (!startStream_send_stdTemplate(MENU_INDEX_RULES)) { return; }
|
||||
|
||||
// define macro
|
||||
# if defined(ESP8266)
|
||||
String rootPath = F("rules");
|
||||
@@ -254,8 +251,7 @@ void handle_rules_new() {
|
||||
}
|
||||
|
||||
// TXBuffer += F("<BR><BR>");
|
||||
sendHeadandTail(F("TmplStd"), _TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
# ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("handle_rules"));
|
||||
# endif // ifndef BUILD_NO_RAM_TRACKER
|
||||
@@ -477,9 +473,7 @@ bool handle_rules_edit(String originalUri, bool isAddNew) {
|
||||
}
|
||||
}
|
||||
}
|
||||
navMenuIndex = 5;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail(F("TmplStd"));
|
||||
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_RULES);
|
||||
|
||||
if (error.length() > 0) {
|
||||
addHtmlError(error);
|
||||
@@ -529,8 +523,7 @@ bool handle_rules_edit(String originalUri, bool isAddNew) {
|
||||
|
||||
addHtml(F("</table></form>"));
|
||||
|
||||
sendHeadandTail(F("TmplStd"), true);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
# endif // WEBSERVER_NEW_RULES
|
||||
}
|
||||
# ifndef BUILD_NO_RAM_TRACKER
|
||||
|
||||
@@ -232,8 +232,7 @@ void handle_settingsarchive() {
|
||||
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
@@ -43,15 +43,15 @@ void handle_setup() {
|
||||
checkRAM(F("handle_setup"));
|
||||
# endif // ifndef BUILD_NO_RAM_TRACKER
|
||||
|
||||
// Do not check client IP range allowed.
|
||||
TXBuffer.startStream();
|
||||
|
||||
const bool connected = ESPEasy::net::NetworkConnected();
|
||||
|
||||
|
||||
// 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 {
|
||||
sendHeadandTail(F("TmplAP"));
|
||||
@@ -260,13 +260,12 @@ void handle_setup() {
|
||||
}
|
||||
|
||||
// if (connected) {
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
sendTail_stdtemplate();
|
||||
|
||||
/* } else {
|
||||
sendHeadandTail(F("TmplAP"), true);
|
||||
}
|
||||
*/
|
||||
TXBuffer.endStream();
|
||||
delay(10);
|
||||
|
||||
if (clearWiFiCredentials) {
|
||||
|
||||
@@ -56,8 +56,7 @@ void handle_sysinfo_json() {
|
||||
checkRAM(F("handle_sysinfo"));
|
||||
# endif // ifndef BUILD_NO_RAM_TRACKER
|
||||
|
||||
if (!isLoggedIn()) { return; }
|
||||
TXBuffer.startJsonStream();
|
||||
if (!startJSON_Stream()) { return; }
|
||||
{
|
||||
KeyValueWriter_JSON mainLevelWriter(true);
|
||||
{
|
||||
@@ -292,8 +291,7 @@ void handle_sysinfo() {
|
||||
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
void handle_sysinfo_basicInfo() {
|
||||
|
||||
@@ -543,8 +543,7 @@ void handle_sysvars() {
|
||||
}
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
void addSysVar_html(const __FlashStringHelper *input) {
|
||||
|
||||
@@ -17,9 +17,9 @@ void handle_timingstats() {
|
||||
#ifndef BUILD_NO_RAM_TRACKER
|
||||
checkRAM(F("handle_timingstats"));
|
||||
#endif
|
||||
navMenuIndex = MENU_INDEX_TOOLS;
|
||||
TXBuffer.startStream();
|
||||
sendHeadandTail_stdtemplate(_HEAD);
|
||||
|
||||
startStream_send_stdTemplate_NoLoginCheck(MENU_INDEX_TOOLS);
|
||||
|
||||
html_table_class_multirow();
|
||||
html_TR();
|
||||
{
|
||||
@@ -55,8 +55,7 @@ void handle_timingstats() {
|
||||
addHtml(F("Duty cycle based on average < 1 msec is highly unreliable"));
|
||||
html_end_table();
|
||||
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
|
||||
@@ -48,15 +48,7 @@ void handle_tools() {
|
||||
addRTDHelpButton(F("Reference/Command.html"));
|
||||
html_TR_TD();
|
||||
|
||||
if (printWebString.length() > 0)
|
||||
{
|
||||
addRowColspan(2);
|
||||
addHtml(F("Command Output<BR><textarea readonly rows='10' wrap='on'>"));
|
||||
addHtml(printWebString);
|
||||
addHtml(F("</textarea>"));
|
||||
free_string(printWebString);
|
||||
}
|
||||
|
||||
handle_printWebString();
|
||||
|
||||
addFormSubHeader(F("System"));
|
||||
|
||||
@@ -201,8 +193,9 @@ void handle_tools() {
|
||||
|
||||
html_end_table();
|
||||
html_end_form();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
|
||||
// FIXME TD-er: Is this still needed?
|
||||
free_string(printWebString);
|
||||
printToWeb = false;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ void handle_upload() {
|
||||
|
||||
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>"));
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
free_string(printWebString);
|
||||
printToWeb = false;
|
||||
}
|
||||
@@ -77,8 +76,7 @@ void handle_upload_post() {
|
||||
}
|
||||
|
||||
addHtml(F("Upload finished"));
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
free_string(printWebString);
|
||||
printToWeb = false;
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
#define MENU_INDEX_INTERFACES 3
|
||||
#define MENU_INDEX_INTERFACES_I2C 30
|
||||
#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_WRMBUS 34
|
||||
#define MENU_INDEX_INTERFACES_WIMBUS 35
|
||||
#define MENU_INDEX_INTERFACES_WRMBUS 34 // Wired M-Bus
|
||||
#define MENU_INDEX_INTERFACES_WIMBUS 35 // Wireless M-Bus
|
||||
#define MENU_INDEX_NETWORK 4
|
||||
#define MENU_INDEX_CONTROLLERS 5
|
||||
#define MENU_INDEX_BUSES 6
|
||||
|
||||
@@ -71,7 +71,7 @@ void handle_wifiscanner() {
|
||||
ESPEasy::net::wifi::setWifiMode(cur_wifimode);
|
||||
|
||||
if (!startStream_send_stdTemplate(MENU_INDEX_TOOLS)) { return; }
|
||||
|
||||
|
||||
html_table_class_multirow();
|
||||
html_TR();
|
||||
html_table_header(getLabel(LabelType::SSID));
|
||||
@@ -97,8 +97,7 @@ void handle_wifiscanner() {
|
||||
}
|
||||
|
||||
html_end_table();
|
||||
sendHeadandTail_stdtemplate(_TAIL);
|
||||
TXBuffer.endStream();
|
||||
sendTail_stdtemplate();
|
||||
}
|
||||
|
||||
#endif // ifdef WEBSERVER_WIFI_SCANNER
|
||||
Reference in New Issue
Block a user