From 9c979657bf157b497498f5ffd51d7b91c5e970c3 Mon Sep 17 00:00:00 2001 From: andreas Date: Sun, 13 Oct 2024 16:10:03 +0200 Subject: [PATCH] restructure boat data display handling, allow for more flexible user formatters --- lib/exampletask/index.js | 31 +++++- web/index.css | 5 +- web/index.html | 186 ++++++++++++++++++------------------ web/index.js | 199 ++++++++++++++++++++++++++++++++------- 4 files changed, 290 insertions(+), 131 deletions(-) diff --git a/lib/exampletask/index.js b/lib/exampletask/index.js index 0224a73..6c5322b 100644 --- a/lib/exampletask/index.js +++ b/lib/exampletask/index.js @@ -1,12 +1,39 @@ (function(){ + const api=window.esp32nmea2k; + if (! api) return; let isActive=false; - window.esp32nmea2k.registerListener((id,data)=>{ - if (id === 0){ + const tabName="example"; + const configName="exampleBDSel"; + let boatItemName; + api.registerListener((id,data)=>{ + if (id === api.EVENTS.init){ //data is capabilities if (data.testboard) isActive=true; + if (isActive){ + let page=api.addTabPage(tabName,"Example"); + api.addEl('div','',page,"this is a test tab"); + } } if (isActive){ console.log("exampletask listener",id,data); + if (id === api.EVENTS.tab){ + if (data === tabName){ + console.log("example tab activated"); + } + } + if (id == api.EVENTS.config){ + let nextboatItemName=data[configName]; + console.log("value of "+configName,nextboatItemName); + if (nextboatItemName){ + api.addUserFormatter(nextboatItemName,"xxx",function(v){ + return "X"+v+"X"; + }) + } + if (boatItemName !== undefined && boatItemName != nextboatItemName){ + api.removeUserFormatter(boatItemName); + } + boatItemName=nextboatItemName; + } } }) })(); diff --git a/web/index.css b/web/index.css index eb3b1ca..f248d97 100644 --- a/web/index.css +++ b/web/index.css @@ -22,7 +22,7 @@ body { overflow: hidden; } -.tabPage{ +#tabPages{ overflow: auto; } @@ -120,6 +120,9 @@ body { .hidden{ display: none !important; } + .dash.invalid{ + display: none; + } #xdrPage .row>.label{ display: none; } diff --git a/web/index.html b/web/index.html index e7d784d..0862868 100644 --- a/web/index.html +++ b/web/index.html @@ -23,104 +23,106 @@
Update
Help
-
-
-
- VERSION - --- - -
+
+
+
+
+ VERSION + --- + +
-
- Access Point IP - --- +
+ Access Point IP + --- +
+
+ wifi client connected + --- [---] +
+
+ wifi client IP + --- +
+
+ # clients + --- +
+
+ TCP client connected + --- +
+
+ TCP client error + --- +
+
+ Free heap + --- +
+
+ NMEA2000 State + [---]  + UNKNOWN +
-
- wifi client connected - --- [---] -
-
- wifi client IP - --- -
-
- # clients - --- -
-
- TCP client connected - --- -
-
- TCP client error - --- -
-
- Free heap - --- -
-
- NMEA2000 State - [---]  - UNKNOWN -
+
- -
-