From 2a2cb891f4028d82954fabac8f6825e97bb2d57a Mon Sep 17 00:00:00 2001 From: technyon Date: Fri, 17 Jun 2022 22:58:54 +0200 Subject: [PATCH] add method to build navigation button --- Version.h | 2 +- WebCfgServer.cpp | 40 ++++++++++++++++++---------------------- WebCfgServer.h | 1 + 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Version.h b/Version.h index c184fc7..b20657e 100644 --- a/Version.h +++ b/Version.h @@ -1,3 +1,3 @@ #pragma once -#define nuki_hub_version "4.0" \ No newline at end of file +#define nuki_hub_version "4.1" \ No newline at end of file diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 5faaae3..bded4a5 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -357,31 +357,21 @@ void WebCfgServer::buildHtml(String& response) response.concat("

"); response.concat("

MQTT and Network Configuration

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Edit", "/mqttconfig"); response.concat("

NUKI Configuration

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Edit", "/nukicfg"); response.concat("

Credentials

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Edit", "/cred"); response.concat("

Firmware update

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Open", "/ota"); if(_allowRestartToPortal) { response.concat("

WiFi

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Restart and configure wifi", "/wifi"); } response.concat(""); @@ -540,12 +530,9 @@ void WebCfgServer::buildConfigureWifiHtml(String &response) response.concat("

WiFi

"); response.concat("Click confirm to restart ESP into WiFi configuration mode. After restart, connect to ESP access point to reconfigure WiFI.

"); - response.concat("
"); - response.concat(""); - response.concat("
"); + buildNavigationButton(response, "Confirm", "/wifimanager"); - response.concat("\n"); - response.concat("\n"); + response.concat(""); } void WebCfgServer::processUnpair(bool opener) @@ -670,6 +657,17 @@ void WebCfgServer::printTextarea(String& response, response.concat(""); } +void WebCfgServer::buildNavigationButton(String &response, const char *caption, const char *targetPath) +{ + response.concat("
"); + response.concat(""); + response.concat("
"); +} + void WebCfgServer::printParameter(String& response, const char *description, const char *value) { response.concat(""); @@ -731,5 +729,3 @@ void WebCfgServer::handleOtaUpload() Serial.print("handleFileUpload Size: "); Serial.println(upload.totalSize); } } - - diff --git a/WebCfgServer.h b/WebCfgServer.h index 1216954..f1d981d 100644 --- a/WebCfgServer.h +++ b/WebCfgServer.h @@ -45,6 +45,7 @@ private: void printInputField(String& response, const char* token, const char* description, const int value, size_t maxLength); void printCheckBox(String& response, const char* token, const char* description, const bool value); void printTextarea(String& response, const char *token, const char *description, const char *value, const size_t maxLength); + void buildNavigationButton(String& response, const char* caption, const char* targetPath); void printParameter(String& response, const char* description, const char* value);