mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
[CodeFactor] Apply fixes
This commit is contained in:
parent
eeb72faf83
commit
a258f4b16f
10 changed files with 182 additions and 181 deletions
|
@ -96,15 +96,15 @@ app.whenReady().then(() => {
|
|||
console.log(platform());
|
||||
//Generate daemon binary path
|
||||
var serverPath = "";
|
||||
console.log(process.env)
|
||||
console.log(process.env);
|
||||
|
||||
// Attempt to find Installation Folder
|
||||
console.log(app.getAppPath())
|
||||
console.log(join(app.getAppPath(), '..', '..'))
|
||||
console.log(join(app.getAppPath(), '..', '..', '..'))
|
||||
console.log(app.getAppPath());
|
||||
console.log(join(app.getAppPath(), "..", ".."));
|
||||
console.log(join(app.getAppPath(), "..", "..", ".."));
|
||||
|
||||
//var basePath = join(app.getAppPath(), '..', '..', '..') || join(process.env.PWD, '..') || join(process.env.INIT_CWD, '..') || join(process.env.DIST, '..', '..', '..');
|
||||
var basePath = join(app.getAppPath(), '..', '..', '..')
|
||||
var basePath = join(app.getAppPath(), "..", "..", "..");
|
||||
switch (platform().toLowerCase()) {
|
||||
//case "darwin":
|
||||
//serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
||||
|
@ -119,7 +119,11 @@ app.whenReady().then(() => {
|
|||
case "win32":
|
||||
serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
||||
console.log(`Starting server with path: ${serverPath}`);
|
||||
serverProcess = spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/c', serverPath], { shell: true });
|
||||
serverProcess = spawn(
|
||||
"cmd.exe",
|
||||
["/c", "start", "cmd.exe", "/c", serverPath],
|
||||
{ shell: true },
|
||||
);
|
||||
console.log(`Started server | PID: ${serverProcess.pid}`);
|
||||
break;
|
||||
|
||||
|
@ -130,26 +134,24 @@ app.whenReady().then(() => {
|
|||
break;
|
||||
}
|
||||
|
||||
serverProcess.on('error', (err) => {
|
||||
console.error('Failed to start server process:', err);
|
||||
serverProcess.on("error", (err) => {
|
||||
console.error("Failed to start server process:", err);
|
||||
serverProcess = null;
|
||||
serverPath = null;
|
||||
});
|
||||
serverProcess.stdout.on('data', (data) => {
|
||||
serverProcess.stdout.on("data", (data) => {
|
||||
//console.log(`stdout: ${data}`);
|
||||
});
|
||||
|
||||
serverProcess.stderr.on('data', (data) => {
|
||||
serverProcess.stderr.on("data", (data) => {
|
||||
console.error(`stderr: ${data}`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.on('before-quit', () => {
|
||||
app.on("before-quit", () => {
|
||||
close_sub_processes();
|
||||
});
|
||||
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
win = null;
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
|
@ -214,7 +216,6 @@ function close_sub_processes() {
|
|||
serverPath = null;
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`Error killing server process: ${error}`);
|
||||
}
|
||||
|
|
|
@ -23,17 +23,11 @@ import Dynamic_components from "./dynamic_components.vue";
|
|||
import { getFreedataMessages } from "../js/api";
|
||||
import { getRemote } from "../store/settingsStore.js";
|
||||
import { loadAllData } from "../js/eventHandler";
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-------------------------------- INFO TOASTS ---------------->
|
||||
<div
|
||||
aria-live="polite"
|
||||
aria-atomic="true"
|
||||
class="position-relative z-3"
|
||||
>
|
||||
<div aria-live="polite" aria-atomic="true" class="position-relative z-3">
|
||||
<div
|
||||
class="toast-container position-absolute top-0 end-0 p-3"
|
||||
id="mainToastContainer"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { Modal } from "bootstrap";
|
||||
import { onMounted } from "vue";
|
||||
|
||||
|
||||
import { setActivePinia } from "pinia";
|
||||
import pinia from "../store/index";
|
||||
setActivePinia(pinia);
|
||||
|
@ -18,7 +17,6 @@ const audioStore = useAudioStore();
|
|||
import { useSerialStore } from "../store/serialStore";
|
||||
const serialStore = useSerialStore();
|
||||
|
||||
|
||||
import {
|
||||
getVersion,
|
||||
setConfig,
|
||||
|
@ -27,8 +25,6 @@ import {
|
|||
getModemState,
|
||||
} from "../js/api";
|
||||
|
||||
|
||||
|
||||
const version = import.meta.env.PACKAGE_VERSION;
|
||||
|
||||
// start modemCheck modal once on startup
|
||||
|
@ -39,8 +35,6 @@ onMounted(() => {
|
|||
new Modal("#modemCheck", {}).show();
|
||||
});
|
||||
|
||||
|
||||
|
||||
function getModemStateLocal() {
|
||||
// Returns active/inactive if modem is running for modem status label
|
||||
if (state.is_modem_running == true) return "Active";
|
||||
|
@ -210,12 +204,21 @@ function testHamlib() {
|
|||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Audio Input Device -->
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<label class="input-group-text w-50">Audio Input device</label>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.input_device">
|
||||
<option v-for="device in audioStore.audioInputs" :value="device.id">
|
||||
<label class="input-group-text w-50"
|
||||
>Audio Input device</label
|
||||
>
|
||||
<select
|
||||
class="form-select form-select-sm"
|
||||
aria-label=".form-select-sm"
|
||||
@change="onChange"
|
||||
v-model="settings.remote.AUDIO.input_device"
|
||||
>
|
||||
<option
|
||||
v-for="device in audioStore.audioInputs"
|
||||
:value="device.id"
|
||||
>
|
||||
{{ device.name }} [{{ device.api }}]
|
||||
</option>
|
||||
</select>
|
||||
|
@ -223,15 +226,23 @@ function testHamlib() {
|
|||
|
||||
<!-- Audio Output Device -->
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<label class="input-group-text w-50">Audio Output device</label>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.output_device">
|
||||
<option v-for="device in audioStore.audioOutputs" :value="device.id">
|
||||
<label class="input-group-text w-50"
|
||||
>Audio Output device</label
|
||||
>
|
||||
<select
|
||||
class="form-select form-select-sm"
|
||||
aria-label=".form-select-sm"
|
||||
@change="onChange"
|
||||
v-model="settings.remote.AUDIO.output_device"
|
||||
>
|
||||
<option
|
||||
v-for="device in audioStore.audioOutputs"
|
||||
:value="device.id"
|
||||
>
|
||||
{{ device.name }} [{{ device.api }}]
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -299,15 +310,19 @@ function testHamlib() {
|
|||
>Radio port</span
|
||||
>
|
||||
|
||||
|
||||
|
||||
<select @change="onChange" v-model="settings.remote.RADIO.serial_port" class="form-select form-select-sm">
|
||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
||||
<select
|
||||
@change="onChange"
|
||||
v-model="settings.remote.RADIO.serial_port"
|
||||
class="form-select form-select-sm"
|
||||
>
|
||||
<option
|
||||
v-for="device in serialStore.serialDevices"
|
||||
:value="device.port"
|
||||
:key="device.port"
|
||||
>
|
||||
{{ device.description }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
|
@ -376,7 +391,6 @@ function testHamlib() {
|
|||
data-bs-toggle="collapse"
|
||||
>
|
||||
Version
|
||||
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
|
@ -399,7 +413,6 @@ function testHamlib() {
|
|||
>
|
||||
Modem version | {{ state.modem_version }}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -19,7 +19,6 @@ import settings_exp from "./settings_exp.vue";
|
|||
<div class="card-header">
|
||||
<!-- SETTINGS Nav tabs -->
|
||||
<ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
|
||||
|
||||
<li class="nav-item" role="presentation">
|
||||
<button
|
||||
class="nav-link active"
|
||||
|
@ -127,8 +126,6 @@ import settings_exp from "./settings_exp.vue";
|
|||
>
|
||||
<!-- SETTINGS Nav Tab panes -->
|
||||
|
||||
|
||||
|
||||
<!-- Station tab contents-->
|
||||
<div class="tab-content">
|
||||
<div
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
||||
import { useSerialStore } from "../store/serialStore";
|
||||
const serialStore = useSerialStore();
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -335,23 +334,19 @@ const serialStore = useSerialStore();
|
|||
<div class="input-group input-group-sm mb-1">
|
||||
<span class="input-group-text" style="width: 180px">Radio port</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<select @change="onChange" v-model="settings.remote.RADIO.serial_port" class="form-select form-select-sm">
|
||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
||||
<select
|
||||
@change="onChange"
|
||||
v-model="settings.remote.RADIO.serial_port"
|
||||
class="form-select form-select-sm"
|
||||
>
|
||||
<option
|
||||
v-for="device in serialStore.serialDevices"
|
||||
:value="device.port"
|
||||
:key="device.port"
|
||||
>
|
||||
{{ device.description }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
|
@ -427,17 +422,19 @@ const serialStore = useSerialStore();
|
|||
<div class="input-group input-group-sm mb-1">
|
||||
<span class="input-group-text" style="width: 180px">PTT device port</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<select @change="onChange" v-model="settings.remote.RADIO.ptt_port" class="form-select form-select-sm">
|
||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
||||
<select
|
||||
@change="onChange"
|
||||
v-model="settings.remote.RADIO.ptt_port"
|
||||
class="form-select form-select-sm"
|
||||
>
|
||||
<option
|
||||
v-for="device in serialStore.serialDevices"
|
||||
:value="device.port"
|
||||
:key="device.port"
|
||||
>
|
||||
{{ device.description }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<span class="input-group-text" style="width: 180px">PTT type</span>
|
||||
|
|
|
@ -9,9 +9,6 @@ import { startModem, stopModem } from "../js/api.js";
|
|||
|
||||
import { useAudioStore } from "../store/audioStore";
|
||||
const audioStore = useAudioStore();
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -70,13 +67,15 @@ const audioStore = useAudioStore();
|
|||
/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Audio Input Device -->
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<label class="input-group-text w-50">Audio Input device</label>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.input_device">
|
||||
<select
|
||||
class="form-select form-select-sm"
|
||||
aria-label=".form-select-sm"
|
||||
@change="onChange"
|
||||
v-model="settings.remote.AUDIO.input_device"
|
||||
>
|
||||
<option v-for="device in audioStore.audioInputs" :value="device.id">
|
||||
{{ device.name }} [{{ device.api }}]
|
||||
</option>
|
||||
|
@ -86,15 +85,18 @@ const audioStore = useAudioStore();
|
|||
<!-- Audio Output Device -->
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<label class="input-group-text w-50">Audio Output device</label>
|
||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.output_device">
|
||||
<select
|
||||
class="form-select form-select-sm"
|
||||
aria-label=".form-select-sm"
|
||||
@change="onChange"
|
||||
v-model="settings.remote.AUDIO.output_device"
|
||||
>
|
||||
<option v-for="device in audioStore.audioOutputs" :value="device.id">
|
||||
{{ device.name }} [{{ device.api }}]
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Audio rx level-->
|
||||
<div class="input-group input-group-sm mb-1">
|
||||
<span class="input-group-text w-25">RX Audio Level</span>
|
||||
|
|
|
@ -8,11 +8,7 @@ import {
|
|||
} from "./chatHandler";
|
||||
*/
|
||||
import { displayToast } from "./popupHandler";
|
||||
import {
|
||||
getFreedataMessages,
|
||||
getModemState,
|
||||
getAudioDevices,
|
||||
} from "./api";
|
||||
import { getFreedataMessages, getModemState, getAudioDevices } from "./api";
|
||||
import { processFreedataMessages } from "./messagesHandler.ts";
|
||||
import { processRadioStatus } from "./radioHandler.ts";
|
||||
|
||||
|
@ -33,7 +29,6 @@ import {
|
|||
getRemote,
|
||||
} from "../store/settingsStore.js";
|
||||
|
||||
|
||||
export function loadAllData() {
|
||||
getModemState();
|
||||
getRemote();
|
||||
|
@ -43,7 +38,6 @@ export function loadAllData(){
|
|||
getFreedataMessages();
|
||||
processFreedataMessages();
|
||||
processRadioStatus();
|
||||
|
||||
}
|
||||
|
||||
export function connectionFailed(endpoint, event) {
|
||||
|
@ -141,7 +135,6 @@ export function eventDispatcher(data) {
|
|||
displayToast("success", "bi-ethernet", message, 5000);
|
||||
stateStore.modem_connection = "connected";
|
||||
|
||||
|
||||
loadAllData();
|
||||
|
||||
return;
|
||||
|
|
|
@ -33,7 +33,6 @@ import { getRemote } from "./store/settingsStore";
|
|||
import { initConnections } from "./js/event_sock.js";
|
||||
import { getModemState } from "./js/api";
|
||||
|
||||
|
||||
getRemote().then(() => {
|
||||
initConnections();
|
||||
getModemState();
|
||||
|
|
|
@ -2,14 +2,15 @@ import { defineStore } from "pinia";
|
|||
import { getAudioDevices } from "../js/api";
|
||||
import { ref } from "vue";
|
||||
|
||||
|
||||
// Define skel fallback data
|
||||
const skel = [{
|
||||
"api": "ERR",
|
||||
"id": "0000",
|
||||
"name": "No devices received from modem",
|
||||
"native_index": 0
|
||||
}];
|
||||
const skel = [
|
||||
{
|
||||
api: "ERR",
|
||||
id: "0000",
|
||||
name: "No devices received from modem",
|
||||
native_index: 0,
|
||||
},
|
||||
];
|
||||
|
||||
export const useAudioStore = defineStore("audioStore", () => {
|
||||
const audioInputs = ref([]);
|
||||
|
@ -20,7 +21,8 @@ export const useAudioStore = defineStore("audioStore", () => {
|
|||
const devices = await getAudioDevices();
|
||||
// Check if devices are valid and have entries, otherwise use skel
|
||||
audioInputs.value = devices && devices.in.length > 0 ? devices.in : skel;
|
||||
audioOutputs.value = devices && devices.out.length > 0 ? devices.out : skel;
|
||||
audioOutputs.value =
|
||||
devices && devices.out.length > 0 ? devices.out : skel;
|
||||
} catch (error) {
|
||||
console.error("Failed to load audio devices:", error);
|
||||
// Use skel as fallback in case of error
|
||||
|
|
|
@ -3,10 +3,12 @@ import { getSerialDevices } from "../js/api"; // Make sure this points to the co
|
|||
import { ref } from "vue";
|
||||
|
||||
// Define "skel" fallback data for serial devices
|
||||
const skelSerial = [{
|
||||
"description": "No devices received from modem",
|
||||
"port": "ignore" // Using "ignore" as a placeholder value
|
||||
}];
|
||||
const skelSerial = [
|
||||
{
|
||||
description: "No devices received from modem",
|
||||
port: "ignore", // Using "ignore" as a placeholder value
|
||||
},
|
||||
];
|
||||
|
||||
export const useSerialStore = defineStore("serialStore", () => {
|
||||
const serialDevices = ref([]);
|
||||
|
@ -15,7 +17,8 @@ export const useSerialStore = defineStore("serialStore", () => {
|
|||
try {
|
||||
const devices = await getSerialDevices();
|
||||
// Check if devices are valid and have entries, otherwise use skelSerial
|
||||
serialDevices.value = devices && devices.length > 0 ? devices : skelSerial;
|
||||
serialDevices.value =
|
||||
devices && devices.length > 0 ? devices : skelSerial;
|
||||
} catch (error) {
|
||||
console.error("Failed to load serial devices:", error);
|
||||
// Use skelSerial as fallback in case of error
|
||||
|
@ -23,7 +26,7 @@ export const useSerialStore = defineStore("serialStore", () => {
|
|||
}
|
||||
|
||||
// Ensure the "-- ignore --" option is always available
|
||||
if (!serialDevices.value.some(device => device.port === "ignore")) {
|
||||
if (!serialDevices.value.some((device) => device.port === "ignore")) {
|
||||
serialDevices.value.push({ description: "-- ignore --", port: "ignore" });
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue