Merge pull request #457 from DJ2LS/ls-gui

This commit is contained in:
DJ2LS 2023-07-10 10:22:17 +02:00 committed by GitHub
commit ee396ed58e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 117 additions and 45 deletions

View file

@ -1,4 +1,5 @@
const { app, BrowserWindow, ipcMain, dialog, shell } = require("electron");
const https = require('https');
const { autoUpdater } = require("electron-updater");
const path = require("path");
const fs = require("fs");
@ -1048,3 +1049,32 @@ ipcMain.on("request-check-rigctld", (event, data) => {
console.log(e);
}
});
function downloadJsonUrlToFile(url, callsignPath) {
// https://nodejs.org/api/https.html#httpsgetoptions-callback
https.get(url, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
console.log(d);
let json = JSON.parse(d);
fs.writeFileSync(callsignPath, JSON.stringify(json, null, 2));
});
}).on('error', (e) => {
console.error(e);
});
}
function downloadCallsignReverseLookupData(){
var callsignPath = path.join(configFolder, "callsigns.json");
downloadJsonUrlToFile('https://api.freedata.app/callsign_lookup.php', callsignPath)
}
downloadCallsignReverseLookupData();

View file

@ -2642,7 +2642,7 @@ function sendUserData(dxcallsign) {
ipcRenderer.send("run-tnc-command", {
command: "responseUserInfo",
dxcallsign: selected_callsign,
dxcallsign: dxcallsign,
userinfo: info,
});
}
@ -2877,6 +2877,7 @@ async function dbClean() {
)
) {
} else {
ipcRenderer.send("request-update-dbclean-spinner");
return;
}

View file

@ -3865,3 +3865,6 @@ function showOsPopUp(title, message) {
const NOTIFICATION_BODY = message;
new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY });
}

View file

@ -11,6 +11,10 @@ var configFolder = path.join(appDataFolder, "FreeDATA");
var configPath = path.join(configFolder, "config.json");
const config = require(configPath);
var callsignPath = path.join(configFolder, "callsigns.json");
const callsigns = require(callsignPath);
// WINDOW LISTENER
window.addEventListener("DOMContentLoaded", () => {
// startPing button clicked
@ -64,11 +68,27 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
var dxcall = document.createElement("td");
var dxcallText = document.createElement("span");
dxcallText.innerText = routes[i]["dxcall"];
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["dxcall"]){
dxcallText.innerText +=' (' + call + ')';
continue;
}
}
dxcall.appendChild(dxcallText);
var router = document.createElement("td");
var routerText = document.createElement("span");
routerText.innerText = routes[i]["router"];
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["router"]){
routerText.innerText += ' (' + call + ')';
continue;
}
}
router.appendChild(routerText);
var hops = document.createElement("td");
@ -98,7 +118,7 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
/*-------------------------------------------*/
var routes = arg.mesh_signalling_table;
console.log(routes);
//console.log(routes);
if (typeof routes == "undefined") {
return;
}
@ -130,6 +150,13 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
var destination = document.createElement("td");
var destinationText = document.createElement("span");
destinationText.innerText = routes[i]["destination"];
// check for callsign in callsign list, else use checksum
for (let call in callsigns) {
if(callsigns[call] == routes[i]["destination"]){
destinationText.innerText += ' (' + call + ')';
continue;
}
}
destination.appendChild(destinationText);
var router = document.createElement("td");
@ -167,10 +194,4 @@ ipcRenderer.on("action-update-mesh-table", (event, arg) => {
tbl.appendChild(row);
}
if (tbl !== null) {
// scroll to bottom of page
// https://stackoverflow.com/a/11715670
//window.scrollTo(0, document.body.scrollHeight);
}
});

View file

@ -19,46 +19,39 @@
<script src="../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<!-- chart.js -->
<nav class="navbar fixed-top bg-light ms-2 me-2">
<div class="input-group">
<input
type="text"
class="form-control"
style="max-width: 6rem; text-transform: uppercase"
placeholder="DXcall"
pattern="[A-Z]*"
id="dxCallMesh"
maxlength="11"
aria-label="Input group"
aria-describedby="btnGroupAddon"
/>
<button id="transmit_mesh_ping" type="button" class="btn btn-primary">
mesh ping
</button>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-route-tab" data-bs-toggle="tab" data-bs-target="#nav-route" type="button" role="tab" aria-controls="nav-route" aria-selected="true">Routes</button>
<button class="nav-link" id="nav-signaling-tab" data-bs-toggle="tab" data-bs-target="#nav-signaling" type="button" role="tab" aria-controls="nav-signaling" aria-selected="false">Signaling</button>
<button class="nav-link" id="nav-actions-tab" data-bs-toggle="tab" data-bs-target="#nav-actions" type="button" role="tab" aria-controls="nav-actions" aria-selected="false">Actions</button>
</div>
</nav>
<div class="container-fluid h-100 mt-5">
<div class="tableFixHead h-50">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">DXCall</th>
<th scope="col">Router</th>
<th scope="col">Hops</th>
<th scope="col">Score</th>
<th scope="col">SNR</th>
</tr>
</thead>
<tbody id="mesh-table">
<!-- ... -->
</tbody>
</table>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active vw-100 vh-90 overflow-auto" id="nav-route" role="tabpanel" aria-labelledby="nav-route-tab">
<div class="container-fluid">
<div class="table-responsive overflow-auto" style="max-width: 99vw;max-height: 99vh;">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
<th scope="col">DXCall</th>
<th scope="col">Router</th>
<th scope="col">Hops</th>
<th scope="col">Score</th>
<th scope="col">SNR</th>
</tr>
</thead>
<tbody id="mesh-table">
</tbody>
</table>
</div>
</div>
<div class="tableFixHead h-50">
<table class="table table-hover">
</div>
<div class="tab-pane fade" id="nav-signaling" role="tabpanel" aria-labelledby="nav-signaling-tab">
<div class="container-fluid">
<div class="table-responsive overflow-auto" style="max-width: 99vw;max-height: 99vh;">
<table class="table table-hover table-sm">
<thead>
<tr>
<th scope="col">Timestamp</th>
@ -73,6 +66,30 @@
<tbody id="mesh-signalling-table"></tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane fade" id="nav-actions" role="tabpanel" aria-labelledby="nav-actions-tab">
<div class="input-group mt-1">
<input
type="text"
class="form-control"
style="max-width: 6rem; text-transform: uppercase"
placeholder="DXcall"
pattern="[A-Z]*"
id="dxCallMesh"
maxlength="11"
aria-label="Input group"
aria-describedby="btnGroupAddon"
/>
<button id="transmit_mesh_ping" type="button" class="btn btn-primary">
mesh ping
</button>
</div>
</div>
</div>
</body>
</html>