mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-04 03:31:42 +02:00
improved GUI password handling
fix serial console uptime fix #384 round total values
This commit is contained in:
parent
6a6d522d3b
commit
74f4a114cd
8 changed files with 19 additions and 14 deletions
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 30
|
||||
#define VERSION_PATCH 31
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="pad">
|
||||
<form action="/login" method="post">
|
||||
<h2>AhoyDTU</h2>
|
||||
<input type="password" name="pwd" value="">
|
||||
<input type="password" name="pwd" value="" autofocus>
|
||||
<input type="submit" name="login" value="login" class="btn">
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -307,6 +307,9 @@
|
|||
function parseSys(obj) {
|
||||
for(var i of [["device", "device_name"], ["ssid", "ssid"]])
|
||||
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
||||
var e = document.getElementsByName("adminpwd")[0];
|
||||
if(!obj["pwd_set"])
|
||||
e.value = "";
|
||||
parseVersion(obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
getAjax("/api" + window.location.pathname, parse);
|
||||
getAjax("/api/html" + window.location.pathname, parse);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
// total
|
||||
if(obj.length > 1) {
|
||||
for(var j = 0; j < root.ch0_fld_names.length; j++) {
|
||||
var val = total[j];
|
||||
var val = Math.round(total[j] * 100) / 100;
|
||||
if(val > 0) {
|
||||
var sub = div(["subgrp"]);
|
||||
sub.appendChild(span(val + " " + span(root["ch0_fld_units"][j], ["unit"]).innerHTML, ["value"]));
|
||||
|
|
|
@ -327,7 +327,7 @@ void web::showSave(AsyncWebServerRequest *request) {
|
|||
request->arg("device").toCharArray(mSysCfg->deviceName, DEVNAME_LEN);
|
||||
if(request->arg("adminpwd") != "{PWD}") {
|
||||
request->arg("adminpwd").toCharArray(mConfig->password, PWD_LEN);
|
||||
mProtected = true;
|
||||
mProtected = (strlen(mConfig->password) > 0);
|
||||
}
|
||||
|
||||
// inverter
|
||||
|
|
|
@ -43,9 +43,10 @@ void webApi::onApi(AsyncWebServerRequest *request) {
|
|||
|
||||
Inverter<> *iv = mApp->mSys->getInverterByPos(0, false);
|
||||
String path = request->url().substring(5);
|
||||
if(path == "system") getSystem(root);
|
||||
else if(path == "logout") getLogout(root);
|
||||
else if(path == "save") getSave(root);
|
||||
if(path == "html/system") getHtmlSystem(root);
|
||||
else if(path == "html/logout") getHtmlLogout(root);
|
||||
else if(path == "html/save") getHtmlSave(root);
|
||||
else if(path == "system") getSysInfo(root);
|
||||
else if(path == "reboot") getReboot(root);
|
||||
else if(path == "statistics") getStatistics(root);
|
||||
else if(path == "inverter/list") getInverterList(root);
|
||||
|
@ -153,6 +154,7 @@ void webApi::getSysInfo(JsonObject obj) {
|
|||
obj[F("ts_sun_upd")] = mApp->getLatestSunTimestamp();
|
||||
obj[F("wifi_rssi")] = WiFi.RSSI();
|
||||
obj[F("disclaimer")] = mConfig->disclaimer;
|
||||
obj[F("pwd_set")] = (strlen(mConfig->password) > 0);
|
||||
#if defined(ESP32)
|
||||
obj[F("esp_type")] = F("ESP32");
|
||||
#else
|
||||
|
@ -162,7 +164,7 @@ void webApi::getSysInfo(JsonObject obj) {
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void webApi::getSystem(JsonObject obj) {
|
||||
void webApi::getHtmlSystem(JsonObject obj) {
|
||||
getMenu(obj.createNestedObject(F("menu")));
|
||||
getSysInfo(obj.createNestedObject(F("system")));
|
||||
obj[F("html")] = F("<a href=\"/factory\" class=\"btn\">Factory Reset</a><br/><br/><a href=\"/reboot\" class=\"btn\">Reboot</a>");
|
||||
|
@ -170,7 +172,7 @@ void webApi::getSystem(JsonObject obj) {
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void webApi::getLogout(JsonObject obj) {
|
||||
void webApi::getHtmlLogout(JsonObject obj) {
|
||||
getMenu(obj.createNestedObject(F("menu")));
|
||||
getSysInfo(obj.createNestedObject(F("system")));
|
||||
obj[F("refresh")] = 3;
|
||||
|
@ -180,7 +182,7 @@ void webApi::getLogout(JsonObject obj) {
|
|||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void webApi::getSave(JsonObject obj) {
|
||||
void webApi::getHtmlSave(JsonObject obj) {
|
||||
getMenu(obj.createNestedObject(F("menu")));
|
||||
getSysInfo(obj.createNestedObject(F("system")));
|
||||
obj[F("refresh")] = 2;
|
||||
|
|
|
@ -33,9 +33,9 @@ class webApi {
|
|||
void onDwnldSetup(AsyncWebServerRequest *request);
|
||||
|
||||
void getSysInfo(JsonObject obj);
|
||||
void getSystem(JsonObject obj);
|
||||
void getLogout(JsonObject obj);
|
||||
void getSave(JsonObject obj);
|
||||
void getHtmlSystem(JsonObject obj);
|
||||
void getHtmlLogout(JsonObject obj);
|
||||
void getHtmlSave(JsonObject obj);
|
||||
void getReboot(JsonObject obj);
|
||||
void getStatistics(JsonObject obj);
|
||||
void getInverterList(JsonObject obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue