From bdaac4fa61b7e66f3e86508e85dfdd3be6e245c7 Mon Sep 17 00:00:00 2001 From: John Hays Date: Sat, 6 Jan 2024 15:24:43 -0800 Subject: [PATCH] Updates --- client/dashboard.css | 14 +++++++------ client/index.html | 5 +++-- client/script.js | 10 +++++++++ dashboard.ini | 2 +- index.js | 49 ++++++++++++++++++++++++++++++++------------ 5 files changed, 58 insertions(+), 22 deletions(-) diff --git a/client/dashboard.css b/client/dashboard.css index 1bd94d6..8d04e20 100644 --- a/client/dashboard.css +++ b/client/dashboard.css @@ -2,27 +2,29 @@ body { background-color : LightGrey; font-family: sans-serif; } -td { +td , caption , th { text-align: center; } #lhtable { border: 1px solid black; background-color: PowderBlue; } +#repeaters { + border: 1px solid black; + background-color: Yellow; +} #linktable { border: 1px solid black; background-color: Lime; } -#lhtable caption , #linktable caption { +#lhtable caption , #linktable caption , #repeaters caption { font-weight : bold; font-size : 2em; color : white; background-color : black; + width : 100%; } -#linktable { - width: 100%; -} -#lhtable { +#linktable , #lhtable , #repeaters { width: 100%; } diff --git a/client/index.html b/client/index.html index 0be9cdf..1421a7a 100644 --- a/client/index.html +++ b/client/index.html @@ -17,11 +17,12 @@ -

Hi from the Dashboard

+

Dashboard

-
+
+
diff --git a/client/script.js b/client/script.js index aa8f742..4f3c438 100644 --- a/client/script.js +++ b/client/script.js @@ -29,6 +29,16 @@ socket.addEventListener("links", data => { }); }); +socket.addEventListener("repeaters", data => { + $("#repeaters").empty(); + $("#repeaters").append(""); + $("#rptrtable").append(""); + $.each(data, function(index,val){ + $("#rptrtable").append(""); + }); +}); + socket.addEventListener("lastheard", data => { // console.log("lastheard " + data); $("#lastheard").empty(); diff --git a/dashboard.ini b/dashboard.ini index 7618834..1d27e76 100644 --- a/dashboard.ini +++ b/dashboard.ini @@ -3,7 +3,7 @@ headers=/var/log/dstargateway/Headers.log links=/var/log/dstargateway/Links.log [config] dgwconfig=/usr/local/etc/dstargateway.cfg -host=nw7dr.ampr.org +host=kf7ufz.ampr.org port=443 [urls] sponsor=https://groups.io/g/gkrc diff --git a/index.js b/index.js index 104b550..f467915 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,7 @@ const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8')); const app = express(); const buf = new CircularBuffer(heardqueue); const linklist = new CircularBuffer(linkqueue); +var repeaterlist = []; linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none', 'repeater': 'none', 'reflector': 'none' , 'direction' : '' }); @@ -47,28 +48,48 @@ app.use(express.static(path.resolve(__dirname, 'client'))); const io = socketio(server); function senddata(dest,data,socket) { - console.log("Enter Senddata -> " + dest); + //console.log("Enter Senddata -> " + dest); socket.emit(dest,data); // console.log(dest,JSON.stringify(data)); - console.log("Leave Senddata -> " + dest); + // console.log("Leave Senddata -> " + dest); +} + + +function buildrepeaters(){ + repeaterlist = []; + for (i=1;i < 5;i++) { + let rptr = eval("dgwconfig.Repeater_"+i); + if (rptr.enabled) { + let callsign = dgwconfig.Gateway.callsign; + if (rptr.callsign !== ""){ + callsign = rptr.callsign; + } + callsign += " " + rptr.band; + repeaterlist.push({'callsign':callsign,'frequency':rptr.frequency, + 'offset':rptr.offset,'type':rptr.type}); + } + } + +// console.log(JSON.stringify(repeaterlist)); + } function updatelinks() { - console.log("Entering updatelinks"); + // console.log("Entering updatelinks"); const linksregex = /(.*) (.*) (.*) - Type: (.*) Rptr: (.*) Refl: (.*) Dir: (.*)/; const linkfile = fs.readFileSync(links).toString(); const lines = linkfile.split(/\n|\r\n/); - console.log("Queue Size in: " + linklist.size()); + // console.log("Queue Size in: " + linklist.size()); while (linklist.size() > 0) { linklist.deq(); }; - console.log("Queue Size out: " + linklist.size()); - console.log("File Length: " + lines.length); + // console.log("Queue Size out: " + linklist.size()); + // console.log("File Length: " + lines.length); let i = 0; while (i < lines.length) { if(lines[i] != "") { var mylinks = lines[i].match(linksregex); - console.log(JSON.stringify(lines[i])); + // console.log(JSON.stringify(lines[i])); var linkrec = {'timestamp':mylinks[1].substr(0,19) , 'protocol':mylinks[2] , 'device':mylinks[4], 'repeater':mylinks[5] , 'reflector':mylinks[6] , 'direction' : mylinks[7] }; linklist.push(linkrec); @@ -77,17 +98,19 @@ function updatelinks() { } // console.log("From updatelinks() " + JSON.stringify(linklist.toarray())); // senddata("links",linklist.toarray(),io); - console.log("Leaving updatelinks"); + // console.log("Leaving updatelinks"); } io.on('connection', (socket) => { - console.log('WS New connection'); + // console.log('WS New connection'); + buildrepeaters(); senddata("lastheard",buf.toarray(),socket); senddata("links",linklist.toarray(),socket); senddata("title",host + " Dashboard",socket); - console.log("leaving connection"); + senddata("repeaters",repeaterlist,socket); + // console.log("leaving connection"); }); // io.on('message', (socket) => { @@ -95,18 +118,18 @@ io.on('connection', (socket) => { //}); fs.watch(headers, (curr, prev)=>{ - console.log(headers + ' file changed'); + // console.log(headers + ' file changed'); // console.log("from fs.watch headers " + JSON.stringify(buf.toarray())); senddata("lastheard",buf.toarray(),io); }); fs.watch(links, (curr, prev)=>{ - console.log(links + ' file changed'); + // console.log(links + ' file changed'); // console.log("from fs.watch links " + JSON.stringify(linklist.toarray())); updatelinks(); // console.log("from fs.watch links " + JSON.stringify(linklist.toarray())); senddata("links",linklist.toarray(),io); - console.log("Leaving links watch"); + // console.log("Leaving links watch"); }); const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
Repeaters
CallsignFrequencyOffset
" + val.callsign + "" + val.frequency + + " Mhz." + val.offset + " Mhz.