From 9147359b904a5b917d24bccf8374453493a49101 Mon Sep 17 00:00:00 2001 From: andreas Date: Sun, 7 Nov 2021 17:00:40 +0100 Subject: [PATCH] improved counter display on status page --- lib/counter/GwCounter.h | 11 ++-- src/main.cpp | 4 +- web/index.css | 11 ++++ web/index.html | 122 +++++++--------------------------------- web/index.js | 51 ++++++++++++++++- 5 files changed, 88 insertions(+), 111 deletions(-) diff --git a/lib/counter/GwCounter.h b/lib/counter/GwCounter.h index 4a66aea..6d4be4f 100644 --- a/lib/counter/GwCounter.h +++ b/lib/counter/GwCounter.h @@ -42,17 +42,18 @@ template class GwCounter{ } int getJsonSize(){ return JSON_OBJECT_SIZE(4)+JSON_OBJECT_SIZE(okCounter.size()+1)+ - JSON_OBJECT_SIZE(failCounter.size()+1); + JSON_OBJECT_SIZE(failCounter.size()+1)+ + okCounter.size()*5+failCounter.size()*5; } void toJson(JsonDocument &json){ JsonObject jo=json.createNestedObject(name); - jo["sumOk"]=globalOk; - jo["sumFail"]=globalFail; - JsonObject jok=jo.createNestedObject("ok"); + jo[F("sumOk")]=globalOk; + jo[F("sumFail")]=globalFail; + JsonObject jok=jo.createNestedObject(F("ok")); for (auto it=okCounter.begin();it!=okCounter.end();it++){ jok[String(it->first)]=it->second; } - JsonObject jfail=jo.createNestedObject("fail"); + JsonObject jfail=jo.createNestedObject(F("fail")); for (auto it=failCounter.begin();it!=failCounter.end();it++){ jfail[String(it->first)]=it->second; } diff --git a/src/main.cpp b/src/main.cpp index 79b21ba..4b52b9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,7 @@ GwRequestQueue mainQueue(&logger,20); GwWebServer webserver(&logger,&mainQueue,80); GwCounter countNMEA2KIn("count2Kin"); -GwCounter countNMEA2KOut("count2kout"); +GwCounter countNMEA2KOut("count2Kout"); GwCounter countUSBIn("countUSBin"); GwCounter countUSBOut("countUSBout"); @@ -595,8 +595,8 @@ void SendNMEA0183Message(const tNMEA0183Msg &NMEA0183Msg, int sourceId) { } void handleReceivedNmeaMessage(const char *buf, int sourceId){ - updateNMEACounter(sourceId,buf,true); if (! checkFilter(buf,sourceId,true)) return; + updateNMEACounter(sourceId,buf,true); if ((sourceId == USB_CHANNEL_ID && n2kFromUSB->asBoolean())|| (sourceId >= MIN_TCP_CHANNEL_ID && n2kFromTCP->asBoolean())|| (sourceId == SERIAL1_CHANNEL_ID && n2kFromSerial->asBoolean()) diff --git a/web/index.css b/web/index.css index 29588fa..d82d7b2 100644 --- a/web/index.css +++ b/web/index.css @@ -13,6 +13,16 @@ body{ #statusPage .even { background-color: rgb(211 211 211 / 43%); } + #statusPageContent { + margin-bottom: 0.5em; + } + .counter-row .value{ + text-align: right; + width: 6em; + } + .icon-row .label{ + width: 8.7em; + } .category .title .label { opacity: 1; margin-left: 1em; @@ -50,6 +60,7 @@ body{ display: flex; flex-direction: row; flex-wrap: wrap; + align-items: center; } input,select { border: 1px solid #808080a1; diff --git a/web/index.html b/web/index.html index a4a1f8a..9778541 100644 --- a/web/index.html +++ b/web/index.html @@ -20,109 +20,27 @@
Data
-
- VERSION - --- - -
+
+
+ VERSION + --- + +
-
- Access Point IP - --- -
-
- wifi client connected - --- -
-
- wifi client IP - --- -
-
- # NMEA2000 in - --- -
-
- NMEA2000 in details - -
- -
- # NMEA2000 out - --- -
-
- NMEA2000 out details - -
- -
- # TCP clients - --- -
-
- # TCP in - --- -
-
- TCP in details - -
- -
- # TCP out - --- -
-
- TCP out details - -
- -
- # USB in - --- -
-
- USB in details - -
- -
- # USB out - --- -
-
- USB out details - -
- -
- # Serial in - --- -
-
- Serial in details - -
- -
- # Serial out - --- -
-
- Serial out details - -
- - +
+ Access Point IP + --- +
+
+ wifi client connected + --- +
+
+ wifi client IP + --- +
+
+