dashboard gauge settings wip
This commit is contained in:
parent
46beff09fe
commit
5415e7df91
3 changed files with 69 additions and 7 deletions
include/Webserver
|
@ -9,6 +9,10 @@
|
|||
#include "Page_grow_HTML.h"
|
||||
|
||||
|
||||
/* dirty tmpParam hack again */
|
||||
byte tmpParam_editGaugeId = 255;
|
||||
|
||||
|
||||
/* subnav processor */
|
||||
const byte WEB_GROW_SUBNAV_GENERAL = 1;
|
||||
const byte WEB_GROW_SUBNAV_LIGHT = 2;
|
||||
|
@ -1048,7 +1052,12 @@ void WebPage_grow_dashboard(AsyncWebServerRequest *request) {
|
|||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard_POST);
|
||||
|
||||
} else {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard);
|
||||
if(request->hasParam("success")) {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard_POST);
|
||||
} else {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_HTML, Proc_WebPage_grow_dashboard);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1083,6 +1092,36 @@ String Proc_WebPage_grow_dashboard_gaugeAdd(const String& var) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
String Proc_WebPage_grow_dashboard_gaugeAddEdit(const String& var) {
|
||||
const static char LogLoc[] PROGMEM = "[Webserver:grow:dashboard:gaugeAdd(Proc)]";
|
||||
|
||||
if(TestHeaderFooter(var)) {
|
||||
return AddHeaderFooter(var, 1);
|
||||
} else if(Test_WebPage_grow_SUBNAV(var)) {
|
||||
return Proc_WebPage_grow_SUBNAV(var, WEB_GROW_SUBNAV_DASHBOARD);
|
||||
} else if(var == "ACTION") {
|
||||
return FPSTR(Common_HTML_ACTION_ADD);
|
||||
} else if(var == "GAUGE_ID") {
|
||||
return String(tmpParam_editGaugeId);
|
||||
} else if(var == "SELECT_SENSOR_READ") {
|
||||
String html;
|
||||
html += Html_SelectOpt_Sensor_Read(config.grow.dashboard.gaugeSensor[tmpParam_editGaugeId], config.grow.dashboard.gaugeRead[tmpParam_editGaugeId]);
|
||||
return html;
|
||||
} else if(var == "SENSOR_ID") {
|
||||
return String(config.grow.dashboard.gaugeSensor[tmpParam_editGaugeId]);
|
||||
} else if(var == "READ_ID") {
|
||||
return String(config.grow.dashboard.gaugeRead[tmpParam_editGaugeId]);
|
||||
} else if(var == "MIN") {
|
||||
return String(config.grow.dashboard.gaugeMin[tmpParam_editGaugeId]);
|
||||
} else if(var == "MAX") {
|
||||
return String(config.grow.dashboard.gaugeMax[tmpParam_editGaugeId]);
|
||||
} else {
|
||||
return String();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String Proc_WebPage_grow_dashboard_gaugeAdd_POST(const String& var) {
|
||||
/* This is the processor for POST
|
||||
* Its exactly the same, just looking for SAVE_MSG string.
|
||||
|
@ -1139,6 +1178,20 @@ void WebPage_grow_dashboard_gaugeAdd(AsyncWebServerRequest *request) {
|
|||
//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);
|
||||
/* GET REQUEST */
|
||||
/* when in edit mode */
|
||||
if(request->hasParam("edit")) {
|
||||
const AsyncWebParameter* param = request->getParam("edit");
|
||||
tmpParam_editGaugeId = param->value().toInt();
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAddEdit);
|
||||
/* if we want to add new sensor, check if a sensor id is available. if not send error */
|
||||
} else if(Give_Free_SensorId() > Max_Sensors) {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML_NO_ID_AVAILABLE, Proc_WebPage_grow_dashboard_gaugeAdd);
|
||||
/* Otherwise let the user create new sensor */
|
||||
} else {
|
||||
request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd);
|
||||
}
|
||||
|
||||
//request->send_P(200, TEXT_HTML, Page_grow_dashboard_gaugeAdd_HTML, Proc_WebPage_grow_dashboard_gaugeAdd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ const char Page_grow_dashboard_gaugeAdd_HTML[] PROGMEM = R"(%HEADER%
|
|||
%SUBNAV%
|
||||
%SAVE_MSG%
|
||||
|
||||
<h3>%ACTION% Gauge Id %GAUGE_ID%</h3>
|
||||
<h3>%ACTION% Gauge ID %GAUGE_ID%</h3>
|
||||
<p>Select which Sensor Reading to use for the gauge<br></p>
|
||||
|
||||
<form method='post' action='/grow/dashboard/gaugeAdd'>
|
||||
|
@ -155,12 +155,21 @@ const char Page_grow_dashboard_gaugeAdd_HTML[] PROGMEM = R"(%HEADER%
|
|||
</select><br>
|
||||
|
||||
<u>Min</u><br>
|
||||
<input type='number' name='min' step='1' value='%MIN%' required><br>
|
||||
<input type='number' name='gaugeMin' step='1' value='%MIN%' required><br>
|
||||
|
||||
<u>Max</u><br>
|
||||
<input type='number' name='min' step='1' value='%MAX%' required><br>
|
||||
<input type='number' name='gaugeMax' step='1' value='%MAX%' required><br>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<input type='submit' value='💾 Save settings'>
|
||||
|
||||
%FOOTER% )";
|
||||
|
||||
|
||||
const char Page_grow_dashboard_gaugeAdd_HTML_NO_ID_AVAILABLE[] PROGMEM = R"(%HEADER%
|
||||
%SUBNAV%
|
||||
%SAVE_MSG%
|
||||
|
||||
<h3>You cannot create more gauges, limit reached.</h3>
|
||||
|
||||
%FOOTER% )";
|
||||
|
|
|
@ -1389,7 +1389,7 @@ void WebPage_system_sensor_add(AsyncWebServerRequest *request) {
|
|||
// I like it more when user gets redirected to the output overview after saving
|
||||
request->redirect("/system/sensor/?success");
|
||||
} else {
|
||||
|
||||
/* GET REQUEST */
|
||||
/* when in edit mode */
|
||||
if(request->hasParam("edit")) {
|
||||
const AsyncWebParameter* param = request->getParam("edit");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue