dashboard gauge settings wip

This commit is contained in:
DeltaLima 2025-04-07 01:46:31 +02:00
parent 0bb586b28c
commit ec71d1b553

View file

@ -969,6 +969,12 @@ String Proc_WebPage_grow_dashboard(const String& var) {
html += F("</td><td>");
html += FPSTR(Sensor_Read_descr[config.grow.dashboard.gaugeRead[i]]);
html += F("</td><td>");
// edit button
html += F("<form class='linkForm' action='/grow/dashboard/gaugeAdd' method='get'>");
html += F("<input type='hidden' name='edit' value='");
html += i;
html += F("'>");
html += F("<input type='submit' value='&#x270F;&#xFE0F;' title='Edit'></form> ");
// delete button
html += F("<form class='linkForm' action='/grow/dashboard/' method='post'>");
html += F("<input type='hidden' name='delete_gauge' value='");
@ -1068,12 +1074,6 @@ String Proc_WebPage_grow_dashboard_gaugeAdd(const String& var) {
return FPSTR(Common_HTML_ACTION_ADD);
} else if(var == "GAUGE_ID") {
return String(Give_Free_Dashboard_GaugeId());
} else if(var == "SENSOR_ID") {
String html;
return html;
} else if(var == "READ_ID") {
String html;
return html;
} else if(var == "SELECT_SENSOR_READ") {
String html;
html += Html_SelectOpt_Sensor_Read();
@ -1104,9 +1104,39 @@ void WebPage_grow_dashboard_gaugeAdd(AsyncWebServerRequest *request) {
/* Which kind of Request */
if(request->method() == HTTP_POST) {
byte gaugeId;
if(request->hasParam("gaugeId", true)) {
const AsyncWebParameter* param = request->getParam("gaugeId", true);
gaugeId = param->value().toInt();
/* set gaugeId to configured = true */
config.grow.dashboard.gaugeConfigured[gaugeId] = true;
}
if(request->hasParam("gaugeSensor", true)) {
const AsyncWebParameter* param = request->getParam("gaugeSensor", true);
config.grow.dashboard.gaugeSensor[gaugeId] = param->value().toInt();
}
if(request->hasParam("gaugeRead", true)) {
const AsyncWebParameter* param = request->getParam("gaugeRead", true);
config.grow.dashboard.gaugeRead[gaugeId] = param->value().toInt();
}
if(request->hasParam("gaugeMin", true)) {
const AsyncWebParameter* param = request->getParam("gaugeMin", true);
config.grow.dashboard.gaugeMin[gaugeId] = param->value().toInt();
}
if(request->hasParam("gaugeMax", true)) {
const AsyncWebParameter* param = request->getParam("gaugeMax", true);
config.grow.dashboard.gaugeMax[gaugeId] = param->value().toInt();
}
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd_POST);
SaveConfig();
request->redirect("/grow/dashboard/?success");
//request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd_POST);
} else {
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd);