added mesh gui view

This commit is contained in:
DJ2LS 2023-05-28 17:19:21 +02:00
parent bdfb1658ba
commit a77f8f5c03
6 changed files with 209 additions and 0 deletions

View file

@ -165,6 +165,7 @@ fs.mkdir(receivedFilesFolder, {
let win = null; let win = null;
let data = null; let data = null;
let logViewer = null; let logViewer = null;
let meshViewer = null;
var daemonProcess = null; var daemonProcess = null;
// create a splash screen // create a splash screen
@ -248,6 +249,29 @@ function createWindow() {
} }
}); });
meshViewer = new BrowserWindow({
height: 900,
width: 600,
show: false,
//parent: win,
webPreferences: {
preload: require.resolve("./preload-mesh.js"),
nodeIntegration: true,
},
});
meshViewer.loadFile("src/mesh-module.html");
meshViewer.setMenuBarVisibility(false);
// Emitted when the window is closed.
meshViewer.on("close", function (evt) {
if (meshViewer !== null) {
evt.preventDefault();
meshViewer.hide();
} else {
this.close();
}
});
// Emitted when the window is closed. // Emitted when the window is closed.
win.on("closed", function () { win.on("closed", function () {
console.log("closing all windows....."); console.log("closing all windows.....");
@ -398,6 +422,7 @@ ipcMain.on("request-update-daemon-ip", (event, data) => {
ipcMain.on("request-update-tnc-state", (event, arg) => { ipcMain.on("request-update-tnc-state", (event, arg) => {
win.webContents.send("action-update-tnc-state", arg); win.webContents.send("action-update-tnc-state", arg);
meshViewer.send("action-update-mesh-table", arg)
//data.webContents.send('action-update-tnc-state', arg); //data.webContents.send('action-update-tnc-state', arg);
}); });
@ -460,6 +485,11 @@ ipcMain.on("request-open-tnc-log", () => {
logViewer.show(); logViewer.show();
}); });
ipcMain.on("request-open-mesh-module", () => {
meshViewer.show();
});
//file selector //file selector
ipcMain.on("get-file-path", (event, data) => { ipcMain.on("get-file-path", (event, data) => {
dialog dialog
@ -878,6 +908,7 @@ function close_all() {
win.destroy(); win.destroy();
chat.destroy(); chat.destroy();
logViewer.destroy(); logViewer.destroy();
meshViewer.destroy();
app.quit(); app.quit();
} }

View file

@ -1582,6 +1582,10 @@ window.addEventListener("DOMContentLoaded", () => {
ipcRenderer.send("request-open-tnc-log"); ipcRenderer.send("request-open-tnc-log");
}); });
document.getElementById("meshtable").addEventListener("click", () => {
ipcRenderer.send("request-open-mesh-module");
});
// stopTNC button clicked // stopTNC button clicked
document.getElementById("stopTNC").addEventListener("click", () => { document.getElementById("stopTNC").addEventListener("click", () => {
if (!confirm("Stop the TNC?")) return; if (!confirm("Stop the TNC?")) return;

102
gui/preload-mesh.js Normal file
View file

@ -0,0 +1,102 @@
const path = require("path");
const { ipcRenderer } = require("electron");
// https://stackoverflow.com/a/26227660
var appDataFolder =
process.env.APPDATA ||
(process.platform == "darwin"
? process.env.HOME + "/Library/Application Support"
: process.env.HOME + "/.config");
var configFolder = path.join(appDataFolder, "FreeDATA");
var configPath = path.join(configFolder, "config.json");
const config = require(configPath);
// WINDOW LISTENER
window.addEventListener("DOMContentLoaded", () => {
document
.getElementById("enable_mesh")
.addEventListener("click", () => {
if (document.getElementById("enable_mesh").checked) {
display_class("table-info", true);
} else {
display_class("table-info", false);
}
});
});
ipcRenderer.on("action-update-mesh-table", (event, arg) => {
var routes = arg.routing_table;
var tbl = document.getElementById("mesh-table");
tbl.innerHTML = "";
for (i = 0; i < routes.length; i++) {
/*
var myGrid = document.getElementById("myGrid").value;
try {
var dist = parseInt(distance(myGrid, dxGrid)) + " km";
document.getElementById("dataModalPingDistance").textContent = dist;
} catch {
document.getElementById("dataModalPingDistance").textContent = "---";
}
document.getElementById("dataModalPingDB").textContent =
arg.stations[i]["snr"];
}
*/
var row = document.createElement("tr");
var timestamp = document.createElement("td");
var timestampText = document.createElement("span");
timestampText.innerText = routes[i]["timestamp"];
timestamp.appendChild(timestampText);
var dxcall = document.createElement("td");
var dxcallText = document.createElement("span");
dxcallText.innerText = routes[i]["dxcall"];
dxcall.appendChild(dxcallText);
var router = document.createElement("td");
var routerText = document.createElement("span");
routerText.innerText = routes[i]["router"];
router.appendChild(routerText);
var hops = document.createElement("td");
var hopsText = document.createElement("span");
hopsText.innerText = routes[i]["hops"];
hops.appendChild(hopsText);
var score = document.createElement("td");
var scoreText = document.createElement("span");
scoreText.innerText = routes[i]["score"];
score.appendChild(scoreText);
var snr = document.createElement("td");
var snrText = document.createElement("span");
snrText.innerText = routes[i]["snr"];
snr.appendChild(snrText);
row.appendChild(timestamp);
row.appendChild(dxcall);
row.appendChild(router);
row.appendChild(hops);
row.appendChild(score);
row.appendChild(snr);
tbl.appendChild(row);
}
// scroll to bottom of page
// https://stackoverflow.com/a/11715670
window.scrollTo(0, document.body.scrollHeight);
});

View file

@ -218,6 +218,7 @@ client.on("data", function (socketdata) {
total_bytes: data["total_bytes"], total_bytes: data["total_bytes"],
arq_transmission_percent: data["arq_transmission_percent"], arq_transmission_percent: data["arq_transmission_percent"],
stations: data["stations"], stations: data["stations"],
routing_table: data["routing_table"],
beacon_state: data["beacon_state"], beacon_state: data["beacon_state"],
hamlib_status: data["hamlib_status"], hamlib_status: data["hamlib_status"],
listen: data["listen"], listen: data["listen"],

View file

@ -219,6 +219,10 @@
<i class="bi bi-card-text me-2"></i> <i class="bi bi-card-text me-2"></i>
TNC Live Logs TNC Live Logs
</button> </button>
<button class="dropdown-item" id="meshtable" type="button">
<i class="bi bi-rocket-takeoff me-2"></i>
Mesh Table Prototype
</button>
<li> <li>
<button <button
class="dropdown-item" class="dropdown-item"

67
gui/src/mesh-module.html Normal file
View file

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self';" />
<!-- Bootstrap CSS -->
<link
rel="stylesheet"
href="../node_modules/bootstrap/dist/css/bootstrap.min.css"
/>
<link rel="stylesheet" type="text/css" href="styles.css" />
<title>FreeDATA - Mesh Table</title>
</head>
<body>
<!-- bootstrap -->
<script src="../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<!-- chart.js -->
<nav class="navbar fixed-top bg-light">
<div class="container-fluid">
<input
type="checkbox"
class="btn-check"
id="enable_mesh"
autocomplete="off"
checked
/>
<label class="btn btn-outline-info" for="enable_mesh"
>Enable / Disable Mesh</label
>
</div>
</nav>
<div class="container-fluid mt-5">
<div class="tableFixHead">
<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">SNR</th>
<th scope="col">Score</th>
</tr>
</thead>
<tbody id="mesh-table">
<!--
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
-->
</tbody>
</table>
</div>
</div>
</body>
</html>