Merge pull request #387 from DJ2LS/qm-385

This commit is contained in:
DJ2LS 2023-03-31 12:42:48 +02:00 committed by GitHub
commit 2136d6174c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 160 additions and 86 deletions

View File

@ -95,7 +95,8 @@ const configDefaultSettings =
"shared_folder_path" : ".", \
"enable_request_profile" : "True", \
"enable_request_shared_folder" : "False", \
"tx_delay" : 0 \
"tx_delay" : 0, \
"auto_start": 0 \
}';
if (!fs.existsSync(configPath)) {
@ -950,6 +951,7 @@ ipcMain.on("request-check-rigctld", (event, data) => {
rigctld_connection_state = true;
Data["state"] =
"connection possible - (" + data.ip + ":" + data.port + ")";
Data["active"] = true;
if (win !== null && win !== "" && typeof win != "undefined") {
// try catch for being sure we have a clean app close
try {
@ -963,6 +965,7 @@ ipcMain.on("request-check-rigctld", (event, data) => {
rigctld_connection.on("error", function () {
rigctld_connection_state = false;
Data["state"] = "unknown/stopped - (" + data.ip + ":" + data.port + ")";
Data["active"] = false;
if (win !== null && win !== "" && typeof win != "undefined") {
// try catch for being sure we have a clean app close
try {

View File

@ -336,6 +336,13 @@ window.addEventListener("DOMContentLoaded", () => {
} else {
document.getElementById("autoTuneSwitch").checked = false;
}
if (config.auto_start == 1) {
document.getElementById("AutoStartSwitch").checked = true;
} else {
document.getElementById("AutoStartSwitch").checked = false;
}
// theme selector
changeGuiDesign(config.theme);
@ -577,7 +584,24 @@ window.addEventListener("DOMContentLoaded", () => {
.addEventListener("click", () => {
hamlib_params();
let rigctld = document.getElementById("hamlib_rigctld_path").value;
rigctld += " " + document.getElementById("hamlib_rigctld_command").value;
//Escape spaces in executable file
switch (os.platform().toLowerCase()) {
case "darwin":
case "linux":
rigctld = rigctld.replace(" ", "\\ ");
break;
case "win32":
case "win64":
if (rigctld.indexOf(" ") > -1) rigctld = '"' + rigctld + '"';
break;
default:
console.log("Unhandled OS Platform: ", os.platform());
break;
}
rigctld +=
" " + document.getElementById("hamlib_rigctld_command").value + " -vv";
document.getElementById("btnHamlibCopyCommandBi").classList =
"bi bi-clipboard2-check-fill";
clipboard.writeText(rigctld);
@ -1064,6 +1088,8 @@ window.addEventListener("DOMContentLoaded", () => {
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD.saveConfig(config, configPath);
});
//Handle change of fancy graphics
document.getElementById("GraphicsSwitch").addEventListener("click", () => {
if (document.getElementById("GraphicsSwitch").checked == true) {
config.high_graphics = "True";
@ -1075,6 +1101,17 @@ window.addEventListener("DOMContentLoaded", () => {
set_CPU_mode();
});
//Handle change of Auto-start settings
document.getElementById("AutoStartSwitch").addEventListener("click", () => {
if (document.getElementById("AutoStartSwitch").checked == true) {
config.auto_start = "1";
} else {
config.auto_start = "0";
}
//fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
FD.saveConfig(config, configPath);
});
// enable fsk Switch clicked
document.getElementById("fskModeSwitch").addEventListener("click", () => {
if (document.getElementById("fskModeSwitch").checked == true) {
@ -2286,6 +2323,7 @@ function updateHeardStations(arg) {
}
}
var populateSerial = false;
ipcRenderer.on("action-update-daemon-state", (event, arg) => {
/*
// deactivetd RAM und CPU view so we dont get errors. We need to find a new place for this feature
@ -2322,93 +2360,90 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => {
document.getElementById("node_version").className = "btn btn-sm btn-success";
*/
// UPDATE AUDIO INPUT
if (arg.tnc_running_state == "stopped") {
if (
document.getElementById("audio_input_selectbox").length !=
arg.input_devices.length
) {
document.getElementById("audio_input_selectbox").innerHTML = "";
for (i = 0; i < arg.input_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.input_devices[i]["name"];
option.value = arg.input_devices[i]["id"];
// set device from config if available
if (config.rx_audio == option.text) {
option.setAttribute("selected", true);
}
document.getElementById("audio_input_selectbox").add(option);
}
}
}
// UPDATE AUDIO OUTPUT
if (arg.tnc_running_state == "stopped") {
if (
document.getElementById("audio_output_selectbox").length !=
arg.output_devices.length
) {
document.getElementById("audio_output_selectbox").innerHTML = "";
for (i = 0; i < arg.output_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.output_devices[i]["name"];
option.value = arg.output_devices[i]["id"];
// set device from config if available
if (config.tx_audio == option.text) {
option.setAttribute("selected", true);
}
document.getElementById("audio_output_selectbox").add(option);
}
}
}
if (arg.tnc_running_state != "stopped" && populateSerial == true) return;
// UPDATE SERIAL DEVICES
if (arg.tnc_running_state == "stopped") {
if (
document.getElementById("hamlib_deviceport").length !=
arg.serial_devices.length
) {
document.getElementById("hamlib_deviceport").innerHTML = "";
var ignore = document.createElement("option");
ignore.text = "-- ignore --";
ignore.value = "ignore";
document.getElementById("hamlib_deviceport").add(ignore);
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text =
arg.serial_devices[i]["port"] +
" -- " +
arg.serial_devices[i]["description"];
option.value = arg.serial_devices[i]["port"];
document.getElementById("hamlib_deviceport").add(option);
}
if (
document.getElementById("hamlib_deviceport").length !=
arg.serial_devices.length
) {
document.getElementById("hamlib_deviceport").innerHTML = "";
var ignore = document.createElement("option");
ignore.text = "-- ignore --";
ignore.value = "ignore";
document.getElementById("hamlib_deviceport").add(ignore);
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text =
arg.serial_devices[i]["port"] +
" -- " +
arg.serial_devices[i]["description"];
option.value = arg.serial_devices[i]["port"];
document.getElementById("hamlib_deviceport").add(option);
}
// set device from config if available
document.getElementById("hamlib_deviceport").value =
config.hamlib_deviceport;
}
if (
document.getElementById("hamlib_ptt_port").length !=
arg.serial_devices.length
) {
document.getElementById("hamlib_ptt_port").innerHTML = "";
var ignore = document.createElement("option");
ignore.text = "-- ignore --";
ignore.value = "ignore";
document.getElementById("hamlib_ptt_port").add(ignore);
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text =
arg.serial_devices[i]["port"] +
" -- " +
arg.serial_devices[i]["description"];
option.value = arg.serial_devices[i]["port"];
document.getElementById("hamlib_ptt_port").add(option);
}
// set device from config if available
document.getElementById("hamlib_ptt_port").value = config.hamlib_ptt_port;
}
//Serial devices are updated on first pass
populateSerial = true;
if (arg.tnc_running_state != "stopped") return;
// UPDATE AUDIO INPUT
if (
document.getElementById("audio_input_selectbox").length !=
arg.input_devices.length
) {
document.getElementById("audio_input_selectbox").innerHTML = "";
for (i = 0; i < arg.input_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.input_devices[i]["name"];
option.value = arg.input_devices[i]["id"];
// set device from config if available
document.getElementById("hamlib_deviceport").value =
config.hamlib_deviceport;
if (config.rx_audio == option.text) {
option.setAttribute("selected", true);
}
document.getElementById("audio_input_selectbox").add(option);
}
}
if (arg.tnc_running_state == "stopped") {
if (
document.getElementById("hamlib_ptt_port").length !=
arg.serial_devices.length
) {
document.getElementById("hamlib_ptt_port").innerHTML = "";
var ignore = document.createElement("option");
ignore.text = "-- ignore --";
ignore.value = "ignore";
document.getElementById("hamlib_ptt_port").add(ignore);
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text =
arg.serial_devices[i]["port"] +
" -- " +
arg.serial_devices[i]["description"];
option.value = arg.serial_devices[i]["port"];
document.getElementById("hamlib_ptt_port").add(option);
}
// UPDATE AUDIO OUTPUT
if (
document.getElementById("audio_output_selectbox").length !=
arg.output_devices.length
) {
document.getElementById("audio_output_selectbox").innerHTML = "";
for (i = 0; i < arg.output_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.output_devices[i]["name"];
option.value = arg.output_devices[i]["id"];
// set device from config if available
document.getElementById("hamlib_ptt_port").value = config.hamlib_ptt_port;
if (config.tx_audio == option.text) {
option.setAttribute("selected", true);
}
document.getElementById("audio_output_selectbox").add(option);
}
}
});
@ -3164,6 +3199,7 @@ function set_setting_switch(setting_switch, enable_object, state) {
enable_setting(setting_switch, enable_object);
}
var rigctldActive = false;
setInterval(checkRigctld, 500);
function checkRigctld() {
var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value;
@ -3182,6 +3218,7 @@ function checkRigctld() {
ipcRenderer.on("action-check-rigctld", (event, data) => {
document.getElementById("hamlib_rigctld_status").value = data["state"];
rigctldActive = data["active"];
});
ipcRenderer.on("action-set-app-version", (event, data) => {
@ -3421,4 +3458,20 @@ function changeGuiDesign(design) {
//update path to css file
document.getElementById("bootstrap_theme").href = escape(theme_path);
function autostart() {
//Auto start stuff if option is enabled
if (config.auto_start == 1) {
//Start rigctld if radiocontrol is in correct mode and is not active
if (config.radiocontrol == "rigctld" && rigctldActive == false) {
//console.log("Autostarting rigctld");
document.getElementById("hamlib_rigctld_start").click();
}
//Now start TNC
document.getElementById("startTNC").click();
}
}
setTimeout(() => {
autostart();
}, 1250);
}

View File

@ -1781,8 +1781,25 @@
<option value="alpha">alpha</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<label class="input-group-text w-50"
>Auto-start TNC/rigctld</label
>
<label class="input-group-text w-50">
<div class="form-check form-switch form-check-inline">
<input
class="form-check-input"
type="checkbox"
id="AutoStartSwitch"
/>
<label class="form-check-label" for="AutoStartSwitch"
>Start on launch</label
>
</div>
</label>
</div>
</div>
<!-- Chat tab contents -->
<div
class="tab-pane"
id="chat"
@ -1873,6 +1890,7 @@
class="btn btn-outline-secondary"
type="button"
id="btnHamlibCopyCommand"
title="Copy exe and arguments to clipboard to run in terminal for troubleshooting"
>
<i id="btnHamlibCopyCommandBi" class="bi bi-clipboard"></i>
</button>
@ -2605,8 +2623,8 @@
</div>
<div class="center">
<div class="badge text-bg-danger">
<i class="bi bi-shield-exclamation"></i> These options may
not work and are for experienced users only!
<i class="bi bi-shield-exclamation"></i> These options are
experimental and may not work as expected.
</div>
</div>
</div>