remove processor reference
This commit is contained in:
parent
ea2eef0ad1
commit
093cd4506c
|
@ -209,52 +209,7 @@ void ESPMegaWebServer::dashboardHandler(AsyncWebServerRequest *request)
|
|||
{
|
||||
return request->requestAuthentication();
|
||||
}
|
||||
auto bindedDashboardProcessor = std::bind(&ESPMegaWebServer::dashboardProcessor, this, std::placeholders::_1);
|
||||
request->send_P(200, "text/html", ota_html, bindedDashboardProcessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Replace placeholders in the dashboard HTML with values
|
||||
*
|
||||
* @param var The placeholder name
|
||||
* @return The value to replace the placeholder with
|
||||
*/
|
||||
String ESPMegaWebServer::dashboardProcessor(const String &var)
|
||||
{
|
||||
if (var == "hostname")
|
||||
{
|
||||
return String(this->iot->getNetworkConfig()->hostname);
|
||||
}
|
||||
else if (var == "ip_address")
|
||||
{
|
||||
return this->iot->getIp().toString();
|
||||
}
|
||||
else if (var == "mac_address")
|
||||
{
|
||||
return this->iot->getMac();
|
||||
}
|
||||
else if (var == "model")
|
||||
{
|
||||
return String("ESPMega PRO R3.3c");
|
||||
}
|
||||
else if (var == "mqtt_connection_string")
|
||||
{
|
||||
MqttConfig *mqttConfig = this->iot->getMqttConfig();
|
||||
String connectionString;
|
||||
connectionString += mqttConfig->mqtt_server;
|
||||
connectionString += ":";
|
||||
connectionString += mqttConfig->mqtt_port;
|
||||
return connectionString;
|
||||
}
|
||||
else if (var == "base_topic")
|
||||
{
|
||||
return String(this->iot->getMqttConfig()->base_topic);
|
||||
}
|
||||
else if (var == "mqtt_connected")
|
||||
{
|
||||
return this->iot->mqttConnected() ? "Connected" : "Standalone";
|
||||
}
|
||||
return "";
|
||||
request->send_P(200, "text/html", ota_html);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,74 +223,7 @@ void ESPMegaWebServer::configHandler(AsyncWebServerRequest *request)
|
|||
{
|
||||
return request->requestAuthentication();
|
||||
}
|
||||
auto bindedConfigProcessor = std::bind(&ESPMegaWebServer::configProcessor, this, std::placeholders::_1);
|
||||
request->send_P(200, "text/html", config_html, bindedConfigProcessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Replace placeholders in the config HTML with values
|
||||
*
|
||||
* @param var The placeholder name
|
||||
*
|
||||
* @return The value to replace the placeholder with
|
||||
*/
|
||||
String ESPMegaWebServer::configProcessor(const String &var)
|
||||
{
|
||||
MqttConfig *mqttConfig = this->iot->getMqttConfig();
|
||||
NetworkConfig *networkConfig = this->iot->getNetworkConfig();
|
||||
if (var == "ip_address")
|
||||
{
|
||||
return networkConfig->ip.toString();
|
||||
}
|
||||
else if (var == "netmask")
|
||||
{
|
||||
return networkConfig->subnet.toString();
|
||||
}
|
||||
else if (var == "gateway")
|
||||
{
|
||||
return networkConfig->gateway.toString();
|
||||
}
|
||||
else if (var == "dns")
|
||||
{
|
||||
return networkConfig->dns1.toString();
|
||||
}
|
||||
else if (var == "hostname")
|
||||
{
|
||||
return String(networkConfig->hostname);
|
||||
}
|
||||
else if (var == "bms_ip")
|
||||
{
|
||||
return String(mqttConfig->mqtt_server);
|
||||
}
|
||||
else if (var == "bms_port")
|
||||
{
|
||||
return String(mqttConfig->mqtt_port);
|
||||
}
|
||||
else if (var == "bms_useauth")
|
||||
{
|
||||
return mqttConfig->mqtt_useauth ? "checked=\"checked\"" : "";
|
||||
}
|
||||
else if (var == "bms_username")
|
||||
{
|
||||
return String(mqttConfig->mqtt_user);
|
||||
}
|
||||
else if (var == "bms_password")
|
||||
{
|
||||
return String(mqttConfig->mqtt_password);
|
||||
}
|
||||
else if (var == "bms_endpoint")
|
||||
{
|
||||
return String(mqttConfig->base_topic);
|
||||
}
|
||||
else if (var == "web_username")
|
||||
{
|
||||
return String(this->webUsername);
|
||||
}
|
||||
else if (var == "web_password")
|
||||
{
|
||||
return String(this->webPassword);
|
||||
}
|
||||
return "";
|
||||
request->send_P(200, "text/html", config_html);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,9 +48,7 @@ class ESPMegaWebServer
|
|||
ESPMegaIoT *iot;
|
||||
// Endpoints Handlers
|
||||
void dashboardHandler(AsyncWebServerRequest *request);
|
||||
String dashboardProcessor(const String& var);
|
||||
void configHandler(AsyncWebServerRequest *request);
|
||||
String configProcessor(const String& var);
|
||||
AsyncCallbackJsonWebHandler *saveConfigHandler;
|
||||
void saveConfigJSONHandler(AsyncWebServerRequest *request, JsonVariant &json);
|
||||
void getConfigHandler(AsyncWebServerRequest *request);
|
||||
|
|
|
@ -72,15 +72,13 @@
|
|||
document.getElementById("fw_version").innerHTML = data.fw_version;
|
||||
document.getElementById("sdk_version").innerHTML = data.sdk_version;
|
||||
document.getElementById("idf_version").innerHTML = data.idf_version;
|
||||
document.getElementById("api_server").innerHTML = data.api_server+":"+data.api_port;
|
||||
document.getElementById("api_server").innerHTML = data.api_server + ":" + data.api_port;
|
||||
document.getElementById("api_endpoint").innerHTML = data.api_endpoint;
|
||||
document.getElementById("centrally_managed").innerHTML = data.centrally_managed;
|
||||
}).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
function sub(obj) {
|
||||
var fileName = obj.value.split("\\");
|
||||
document.getElementById("file-input").innerHTML =
|
||||
|
|
Loading…
Reference in New Issue