Added useful URLs

only_http
John Hays 11 months ago
parent c3b3df5d32
commit 1b89a4c491

@ -9,15 +9,19 @@ td , caption , th {
border: 1px solid black;
background-color: PowderBlue;
}
#repeaters {
#rptrtable {
border: 1px solid black;
background-color: Yellow;
}
#urltable {
border: 1px solid black;
background-color: White;
}
#linktable {
border: 1px solid black;
background-color: Lime;
}
#lhtable caption , #linktable caption , #rptrtable caption {
#lhtable caption , #linktable caption , #rptrtable caption , #urltable caption{
font-weight : bold;
font-size : 2em;
color : white;
@ -25,6 +29,6 @@ td , caption , th {
width : 100%;
}
#linktable , #lhtable , #rptrtable {
#linktable , #lhtable , #rptrtable , #urltable {
width: 100%;
}

@ -19,10 +19,10 @@
<h1 id="intro">Dashboard</h1>
<div>
<div id="instruct"></div>
<div id="repeaters"></div>
<div id="links"></div>
<div id="lastheard"></div>
<div id="repeaters"></div>
<div id="instruct"></div>
</div>
</body>
</html>

@ -4,13 +4,24 @@ socket.addEventListener("connect", () => {
socket.emit("Hello from script.js");
});
socket.addEventListener("message", data => {
console.log(data[0]);
$("#intro").text(data);
socket.addEventListener("info", indata => {
// console.log(indata);
const data = JSON.parse(indata);
$("#instruct").empty();
$("#instruct").append("<table id=\"urltable\"><caption>Helpful URLs</caption>");
$("#urltable").append("<tr><th>Sponsor</th><th>Live</th><th>Utilities</th></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.sponsor + "\">" +
data.sponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_1 + "\">" +
data.livename_1 + "</a></td><td><a target=\"register\" href=\"" + data.registration +
"\">" + data.registersite + "</a></td></tr>");
$("#urltable").append("<tr><td><a target=\"sponsor\" href=\"" + data.cosponsor + "\">" +
data.cosponsorname + "</a></td><td><a target=\"live\" href=\"" + data.live_2 + "\">" +
data.livename_2 + "</a></td><td></td></tr>");
});
socket.addEventListener("title", data => {
console.log(data);
// console.log(data);
$("title").text(data);
$("#intro").text(data);
});

@ -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]
sponsorname=Greater Kingston Radio Club
@ -18,4 +18,4 @@ livename_2=Openquad Live
live_2=https://openquad.net/last.php
[params]
linkqueue=10
heardqueue=20
heardqueue=15

@ -20,6 +20,9 @@ const dgwconfig = ini.parse(fs.readFileSync(inifile.config.dgwconfig, 'utf-8'));
const app = express();
const buf = new CircularBuffer(heardqueue);
const linklist = new CircularBuffer(linkqueue);
const urls = inifile.urls;
var repeaterlist = [];
linklist.push({'timestamp':'0000-00-00 00:00:00' , 'protocol': 'none' , 'device':'none',
@ -50,10 +53,7 @@ app.use(express.static(path.resolve(__dirname, 'client')));
const io = socketio(server);
function senddata(dest,data,socket) {
//console.log("Enter Senddata -> " + dest);
socket.emit(dest,data);
// console.log(dest,JSON.stringify(data));
// console.log("Leave Senddata -> " + dest);
}
@ -72,22 +72,15 @@ function buildrepeaters(){
'description2':rptr.description2,'latitude':rptr.latitude, 'longitude': rptr.longitude});
}
}
// console.log(JSON.stringify(repeaterlist));
}
function 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());
while (linklist.size() > 0) {
linklist.deq();
};
// console.log("Queue Size out: " + linklist.size());
// console.log("File Length: " + lines.length);
let i = 0;
while (i < lines.length) {
if(lines[i] != "") {
@ -99,9 +92,6 @@ function updatelinks() {
}
i++;
}
// console.log("From updatelinks() " + JSON.stringify(linklist.toarray()));
// senddata("links",linklist.toarray(),io);
// console.log("Leaving updatelinks");
}
@ -109,6 +99,7 @@ function updatelinks() {
io.on('connection', (socket) => {
// console.log('WS New connection');
buildrepeaters();
senddata("info",JSON.stringify(urls),socket);
senddata("lastheard",buf.toarray(),socket);
senddata("links",linklist.toarray(),socket);
senddata("title",host + " Dashboard",socket);
@ -116,29 +107,20 @@ io.on('connection', (socket) => {
// console.log("leaving connection");
});
// io.on('message', (socket) => {
// console.log('New Message' + JSON.stringify(socket))
//});
fs.watch(headers, (curr, prev)=>{
// 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("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");
});
const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
const headerregex = /(.*) (.*) header.*My: (.*) Your: (.*) *Rpt1: (.*) *Rpt2: (.*) Flags.*\((.*)\)/;
const groups = line.match(headerregex);
// console.log(JSON.stringify(groups));
if (groups) {
var ipport = groups[7].split(':');
var my = groups[3].split('/');
@ -149,7 +131,6 @@ const tailheaders = new Tail(headers, {startPos : 'end'}, line => {
'srcip':ipport[0],'srcport':ipport[1]};
buf.push(record);
senddata("lastheard",buf.toarray(),io);
// console.log(JSON.stringify(record));
}
});

Loading…
Cancel
Save