From 326391ccd8d7925aa5b6f6a33624c27c6ddd7bca Mon Sep 17 00:00:00 2001 From: dj2ls Date: Tue, 22 Feb 2022 21:05:48 +0100 Subject: [PATCH] moved to native bootstrap-icon usage also introduced a speed level field for tnc_state --- gui/main.js | 3 +- gui/package.json | 13 ++- gui/preload-main.js | 48 +++++++--- gui/sock.js | 3 +- gui/src/index.html | 210 +++++++++++++++++--------------------------- tnc/data_handler.py | 11 ++- tnc/sock.py | 1 + tnc/static.py | 1 + 8 files changed, 141 insertions(+), 149 deletions(-) diff --git a/gui/main.js b/gui/main.js index bdac45dc..361bf776 100644 --- a/gui/main.js +++ b/gui/main.js @@ -375,7 +375,8 @@ autoUpdater.on('update-downloaded', () => { autoUpdater.on('checking-for-update', () => { let arg = { - status: "checking-for-update" + status: "checking-for-update", + version: app.getVersion() }; win.webContents.send('action-updater', arg); }); diff --git a/gui/package.json b/gui/package.json index b169a724..109badef 100644 --- a/gui/package.json +++ b/gui/package.json @@ -30,6 +30,7 @@ "homepage": "https://freedata.app", "dependencies": { "bootstrap": "^5.1.0", + "bootstrap-icons": "^1.8.1", "bootswatch": "^5.1.3", "chart.js": "^3.5.1", "chartjs-plugin-annotation": "^1.0.2", @@ -44,7 +45,9 @@ "productName": "FreeDATA", "appId": "app.freedata", "dmg": { - "publish": ["github"], + "publish": [ + "github" + ], "icon": "./src/icon_cube_border.png", "contents": [ { @@ -60,14 +63,18 @@ ] }, "win": { - "publish": ["github"], + "publish": [ + "github" + ], "icon": "./src/icon_cube_border.png", "target": [ "nsis" ] }, "linux": { - "publish": ["github"], + "publish": [ + "github" + ], "icon": "./src/icon_cube_border.png", "target": [ "AppImage" diff --git a/gui/preload-main.js b/gui/preload-main.js index 9e576e64..3ed31ab6 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -867,11 +867,11 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => { // PTT STATE if (arg.ptt_state == 'True') { - document.getElementById("ptt_state").className = "btn btn-danger"; + document.getElementById("ptt_state").className = "btn btn-sm btn-danger"; } else if (arg.ptt_state == 'False') { - document.getElementById("ptt_state").className = "btn btn-success"; + document.getElementById("ptt_state").className = "btn btn-sm btn-success"; } else { - document.getElementById("ptt_state").className = "btn btn-secondary"; + document.getElementById("ptt_state").className = "btn btn-sm btn-secondary"; } // CHANNEL BUSY STATE @@ -888,47 +888,47 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => { // BUSY STATE if (arg.busy_state == 'BUSY') { - document.getElementById("busy_state").className = "btn btn-danger"; + document.getElementById("busy_state").className = "btn btn-sm btn-danger"; document.getElementById("startTransmission").disabled = true; //document.getElementById("stopTransmission").disabled = false; } else if (arg.busy_state == 'IDLE') { - document.getElementById("busy_state").className = "btn btn-success"; + document.getElementById("busy_state").className = "btn btn-sm btn-success"; } else { - document.getElementById("busy_state").className = "btn btn-secondary"; + document.getElementById("busy_state").className = "btn btn-sm btn-secondary"; document.getElementById("startTransmission").disabled = true; //document.getElementById("stopTransmission").disabled = false; } // ARQ STATE if (arg.arq_state == 'True') { - document.getElementById("arq_state").className = "btn btn-warning"; + document.getElementById("arq_state").className = "btn btn-sm btn-warning"; document.getElementById("startTransmission").disabled = true; //document.getElementById("stopTransmission").disabled = false; } else if (arg.arq_state == 'False') { - document.getElementById("arq_state").className = "btn btn-secondary"; + document.getElementById("arq_state").className = "btn btn-sm btn-secondary"; document.getElementById("startTransmission").disabled = false; //document.getElementById("stopTransmission").disabled = true; } else { - document.getElementById("arq_state").className = "btn btn-secondary"; + document.getElementById("arq_state").className = "btn btn-sm btn-secondary"; document.getElementById("startTransmission").disabled = true; //document.getElementById("stopTransmission").disabled = false; } // BEACON STATE if (arg.beacon_state == 'True') { - document.getElementById("startBeacon").className = "btn btn-success spinner-grow"; + document.getElementById("startBeacon").className = "btn btn-sm btn-success spinner-grow"; document.getElementById("startBeacon").disabled = true; document.getElementById("beaconInterval").disabled = true; document.getElementById("stopBeacon").disabled = false; } else if (arg.beacon_state == 'False') { - document.getElementById("startBeacon").className = "btn btn-success"; + document.getElementById("startBeacon").className = "btn btn-sm btn-success"; document.getElementById("startBeacon").disabled = false; document.getElementById("beaconInterval").disabled = false; document.getElementById("stopBeacon").disabled = true; } else { - document.getElementById("startBeacon").className = "btn btn-success"; + document.getElementById("startBeacon").className = "btn btn-sm btn-success"; document.getElementById("startBeacon").disabled = false; document.getElementById("stopBeacon").disabled = true; document.getElementById("beaconInterval").disabled = false; @@ -964,6 +964,27 @@ ipcRenderer.on('action-update-tnc-state', (event, arg) => { document.getElementById("bytes_per_min_compressed").innerHTML = arq_bytes_per_minute_compressed; + // SET SPEED LEVEL + console.log(arg.speed_level) + + if(arg.speed_level >= 0) { + document.getElementById("speed_level").className = "bi bi-reception-1"; + } + if(arg.speed_level >= 1) { + document.getElementById("speed_level").className = "bi bi-reception-2"; + } + if(arg.speed_level >= 2) { + document.getElementById("speed_level").className = "bi bi-reception-3"; + } + if(arg.speed_level >= 3) { + document.getElementById("speed_level").className = "bi bi-reception-4"; + } + if(arg.speed_level >= 4) { + document.getElementById("speed_level").className = "bi bi-reception-4"; + } + + + // SET TOTAL BYTES if (typeof(arg.total_bytes) == 'undefined') { var total_bytes = 0; @@ -1641,9 +1662,10 @@ ipcRenderer.on('action-updater', (event, arg) => { if (arg.status == "checking-for-update"){ var toast = bootstrap.Toast.getOrCreateInstance( - document.getElementById('toastUpdateChecking') + document.getElementById('toastUpdateChecking') ); // Returns a Bootstrap toast instance toast.show(); + document.title = "FreeDATA by DJ2LS" + ' - v' + arg.version; } if (arg.status == "update-downloaded"){ var toast = bootstrap.Toast.getOrCreateInstance( diff --git a/gui/sock.js b/gui/sock.js index b733f985..0038e581 100644 --- a/gui/sock.js +++ b/gui/sock.js @@ -23,7 +23,7 @@ var rxMsgBufferLengthTnc = 0 var rxMsgBufferLengthGui = 0 // network connection Timeout -setTimeout(connectTNC, 3000) +setTimeout(connectTNC, 2000) function connectTNC() { //exports.connectTNC = function(){ @@ -182,6 +182,7 @@ client.on('data', function(socketdata) { arq_state: data['arq_state'], //channel_state: data['CHANNEL_STATE'], frequency: data['frequency'], + speed_level: data['speed_level'], mode: data['mode'], bandwith: data['bandwith'], rms_level: (data['audio_rms'] / 1000) * 100, diff --git a/gui/src/index.html b/gui/src/index.html index 989c3f2f..7f7e52fe 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -9,6 +9,9 @@ + + + @@ -22,66 +25,57 @@ @@ -96,7 +90,7 @@ @@ -121,14 +115,14 @@