Browse Source

setup page complete converted to static version

pull/283/head
lumapu 2 years ago
parent
commit
08d8658737
  1. 13
      tools/esp8266/api.cpp
  2. 10
      tools/esp8266/html/setup.html

13
tools/esp8266/api.cpp

@ -44,8 +44,12 @@ void api::onSystem(AsyncWebServerRequest *request) {
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();
root[F("ssid")] = mSysCfg->stationSsid;
root[F("ssid")] = mSysCfg->stationSsid;
root[F("device_name")] = mSysCfg->deviceName;
root[F("version")] = String(mVersion);
root[F("build")] = String(AUTO_GIT_HASH);
root[F("ts_uptime")] = mApp->getUptime();
root[F("ts_now")] = mApp->getTimestamp();
response->setLength();
//response->addHeader("Access-Control-Allow-Origin", "*");
@ -80,8 +84,8 @@ void api::onInverterList(AsyncWebServerRequest *request) {
obj[F("power_limit_option")] = iv->powerLimit[1];
}
}
root[F("interval")] = String(mConfig->sendInterval);
root[F("retries")] = String(mConfig->maxRetransPerPyld);
root[F("interval")] = String(mConfig->sendInterval);
root[F("retries")] = String(mConfig->maxRetransPerPyld);
root[F("max_num_inverters")] = MAX_NUM_INVERTERS;
response->setLength();
@ -150,8 +154,7 @@ void api::onSerial(AsyncWebServerRequest *request) {
AsyncJsonResponse* response = new AsyncJsonResponse();
JsonObject root = response->getRoot();
// next line cause a chrash but why?
//root[F("interval")] = mConfig->serialInterval;
root[F("interval")] = (uint16_t)mConfig->serialInterval;
root[F("show_live_data")] = mConfig->serialShowIv;
root[F("debug")] = mConfig->serialDebug;

10
tools/esp8266/html/setup.html

@ -145,7 +145,7 @@
<div id="footer">
<p class="left"><a href="/">Home</a></p>
<p class="left"><a href="/update">Update Firmware</a></p>
<p class="right">AHOY - {#VERSION}</p>
<p class="right" id="version"></p>
<p class="right"><a href="/factory">Factory Reset</a></p>
<p class="right"><a href="/reboot">Reboot</a></p>
</div>
@ -265,6 +265,7 @@
function parseSys(obj) {
for(var i of [["device", "device_name"], ["ssid", "ssid"]])
document.getElementsByName(i[0])[0].value = obj[i[1]];
document.getElementById("version").innerHTML = "Git SHA: " + obj["build"] + " :: " + obj["version"];
}
function parseIv(obj) {
@ -322,12 +323,19 @@
], obj["power_level"]));
}
function parseSerial(obj) {
for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"]])
document.getElementsByName(i[0])[0].checked = obj[i[1]];
document.getElementsByName("serIntvl")[0].value = obj["interval"];
}
getAjax("/api/system", parseSys);
getAjax("/api/inverter/list", parseIv);
getAjax("/api/mqtt", parseMqtt);
getAjax("/api/ntp", parseNtp);
getAjax("/api/pinout", parsePinout);
getAjax("/api/radio", parseRadio);
getAjax("/api/serial", parseSerial);
</script>
</body>
</html>

Loading…
Cancel
Save