Browse Source

Merge branch 'tastendruecker123-dev4' into development03

pull/903/head
lumapu 2 years ago
parent
commit
c3728a8303
  1. 4
      src/app.h
  2. 1
      src/appInterface.h
  3. 1
      src/web/RestApi.h
  4. 8
      src/web/html/api.js
  5. 39
      src/web/html/save.html
  6. 1
      src/web/html/setup.html
  7. 2
      src/web/web.h

4
src/app.h

@ -92,6 +92,10 @@ class app : public IApp, public ah::Scheduler {
return mSettings.getLastSaveSucceed(); return mSettings.getLastSaveSucceed();
} }
bool getShouldReboot() {
return mSaveReboot;
}
statistics_t *getStatistics() { statistics_t *getStatistics() {
return &mStat; return &mStat;
} }

1
src/appInterface.h

@ -20,6 +20,7 @@ class IApp {
virtual bool eraseSettings(bool eraseWifi) = 0; virtual bool eraseSettings(bool eraseWifi) = 0;
virtual bool getSavePending() = 0; virtual bool getSavePending() = 0;
virtual bool getLastSaveSucceed() = 0; virtual bool getLastSaveSucceed() = 0;
virtual bool getShouldReboot() = 0;
virtual void setOnUpdate() = 0; virtual void setOnUpdate() = 0;
virtual void setRebootFlag() = 0; virtual void setRebootFlag() = 0;
virtual const char *getVersion() = 0; virtual const char *getVersion() = 0;

1
src/web/RestApi.h

@ -276,6 +276,7 @@ class RestApi {
getGeneric(request, obj.createNestedObject(F("generic"))); getGeneric(request, obj.createNestedObject(F("generic")));
obj["pending"] = (bool)mApp->getSavePending(); obj["pending"] = (bool)mApp->getSavePending();
obj["success"] = (bool)mApp->getLastSaveSucceed(); obj["success"] = (bool)mApp->getLastSaveSucceed();
obj["reboot"] = (bool)mApp->getShouldReboot();
} }
void getReboot(AsyncWebServerRequest *request, JsonObject obj) { void getReboot(AsyncWebServerRequest *request, JsonObject obj) {

8
src/web/html/api.js

@ -103,9 +103,11 @@ function parseVersion(obj) {
} }
function parseESP(obj) { function parseESP(obj) {
document.getElementById("esp_type").append( if(document.getElementById("esp_type").childNodes.length < 1) {
document.createTextNode("Board: " + obj["esp_type"]) document.getElementById("esp_type").append(
); document.createTextNode("Board: " + obj["esp_type"])
);
}
} }
function parseRssi(obj) { function parseRssi(obj) {

39
src/web/html/save.html

@ -8,11 +8,14 @@
{#HTML_NAV} {#HTML_NAV}
<div id="wrapper"> <div id="wrapper">
<div id="content"> <div id="content">
<div id="html" class="mt-3 mb-3"></div> <div id="html" class="mt-3 mb-3">Saving settings...</div>
</div> </div>
</div> </div>
{#HTML_FOOTER} {#HTML_FOOTER}
<script type="text/javascript"> <script type="text/javascript">
var intervalId = null;
function parseGeneric(obj) { function parseGeneric(obj) {
parseNav(obj); parseNav(obj);
parseESP(obj); parseESP(obj);
@ -22,17 +25,27 @@
function parseHtml(obj) { function parseHtml(obj) {
var html = ""; var html = "";
if(obj.pending) if(obj.pending)
html = "saving settings ..."; html = "Saving settings ...";
else { else {
if(obj.success) if(intervalId != null) {
html = "settings successfully saved"; clearInterval(intervalId);
else }
html = "failed saving settings"; if(obj.success) {
var meta = document.createElement('meta');
var meta = document.createElement('meta'); meta.httpEquiv = "refresh"
meta.httpEquiv = "refresh" if(!obj.reboot) {
meta.content = 1 + "; URL=/setup"; html = "Settings successfully saved. Automatic page reload in 3 seconds.";
document.getElementsByTagName('head')[0].appendChild(meta); meta.content = 3;
}
else {
html = "Settings successfully saved. Rebooting. Automatic redirect in 20 seconds.";
meta.content = 20 + "; URL=/";
}
document.getElementsByTagName('head')[0].appendChild(meta);
}
else {
html = "Failed saving settings.";
}
} }
document.getElementById("html").innerHTML = html; document.getElementById("html").innerHTML = html;
} }
@ -41,11 +54,9 @@
if(null != obj) { if(null != obj) {
parseGeneric(obj["generic"]); parseGeneric(obj["generic"]);
parseHtml(obj); parseHtml(obj);
window.setInterval("getAjax('/api/html/save', parse)", 1100);
} }
} }
intervalId = window.setInterval("getAjax('/api/html/save', parse)", 2500);
getAjax("/api/html/save", parse);
</script> </script>
</body> </body>
</html> </html>

1
src/web/html/setup.html

@ -31,6 +31,7 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-8 col-sm-3">Dark Mode</div> <div class="col-8 col-sm-3">Dark Mode</div>
<div class="col-4 col-sm-9"><input type="checkbox" name="darkMode"/></div> <div class="col-4 col-sm-9"><input type="checkbox" name="darkMode"/></div>
<div class="col-8 col-sm-3">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
</div> </div>
</fieldset> </fieldset>
<fieldset class="mb-4"> <fieldset class="mb-4">

2
src/web/web.h

@ -515,7 +515,7 @@ class Web {
// pinout // pinout
uint8_t pin; uint8_t pin;
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 9; i++) {
pin = request->arg(String(pinArgNames[i])).toInt(); pin = request->arg(String(pinArgNames[i])).toInt();
switch(i) { switch(i) {
default: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); break; default: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); break;

Loading…
Cancel
Save