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
|
@ -74,7 +74,7 @@ async function createWindow() {
|
||||||
|
|
||||||
// Test actively push message to the Electron-Renderer
|
// Test actively push message to the Electron-Renderer
|
||||||
//win.webContents.on("did-finish-load", () => {
|
//win.webContents.on("did-finish-load", () => {
|
||||||
// win?.webContents.send("main-process-message", new Date().toLocaleString());
|
// win?.webContents.send("main-process-message", new Date().toLocaleString());
|
||||||
//});
|
//});
|
||||||
|
|
||||||
// Make all links open with the browser, not with the application
|
// Make all links open with the browser, not with the application
|
||||||
|
@ -96,60 +96,62 @@ app.whenReady().then(() => {
|
||||||
console.log(platform());
|
console.log(platform());
|
||||||
//Generate daemon binary path
|
//Generate daemon binary path
|
||||||
var serverPath = "";
|
var serverPath = "";
|
||||||
console.log(process.env)
|
console.log(process.env);
|
||||||
|
|
||||||
// Attempt to find Installation Folder
|
// Attempt to find Installation Folder
|
||||||
console.log(app.getAppPath())
|
console.log(app.getAppPath());
|
||||||
console.log(join(app.getAppPath(), '..', '..'))
|
console.log(join(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(), '..', '..', '..') || 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()) {
|
switch (platform().toLowerCase()) {
|
||||||
//case "darwin":
|
//case "darwin":
|
||||||
//serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
//serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
||||||
//serverProcess = spawn(serverPath, [], { detached: true });
|
//serverProcess = spawn(serverPath, [], { detached: true });
|
||||||
//serverProcess.unref(); // Allow the server process to continue running independently of the parent process
|
//serverProcess.unref(); // Allow the server process to continue running independently of the parent process
|
||||||
// break;
|
// break;
|
||||||
//case "linux":
|
//case "linux":
|
||||||
//serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
//serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
||||||
//serverProcess = spawn(serverPath, [], { detached: true });
|
//serverProcess = spawn(serverPath, [], { detached: true });
|
||||||
//serverProcess.unref(); // Allow the server process to continue running independently of the parent process
|
//serverProcess.unref(); // Allow the server process to continue running independently of the parent process
|
||||||
// break;
|
// break;
|
||||||
case "win32":
|
case "win32":
|
||||||
serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
serverPath = join(basePath, "freedata-server", "freedata-server.exe");
|
||||||
console.log(`Starting server with path: ${serverPath}`);
|
console.log(`Starting server with path: ${serverPath}`);
|
||||||
serverProcess = spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/c', serverPath], { shell: true });
|
serverProcess = spawn(
|
||||||
console.log(`Started server | PID: ${serverProcess.pid}`);
|
"cmd.exe",
|
||||||
break;
|
["/c", "start", "cmd.exe", "/c", serverPath],
|
||||||
|
{ shell: true },
|
||||||
|
);
|
||||||
|
console.log(`Started server | PID: ${serverProcess.pid}`);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log("Unhandled OS Platform: ", platform());
|
console.log("Unhandled OS Platform: ", platform());
|
||||||
serverProcess = null;
|
serverProcess = null;
|
||||||
serverPath = null;
|
serverPath = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
serverProcess.on('error', (err) => {
|
serverProcess.on("error", (err) => {
|
||||||
console.error('Failed to start server process:', err);
|
console.error("Failed to start server process:", err);
|
||||||
serverProcess = null;
|
serverProcess = null;
|
||||||
serverPath = null;
|
serverPath = null;
|
||||||
});
|
});
|
||||||
serverProcess.stdout.on('data', (data) => {
|
serverProcess.stdout.on("data", (data) => {
|
||||||
//console.log(`stdout: ${data}`);
|
//console.log(`stdout: ${data}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
serverProcess.stderr.on("data", (data) => {
|
||||||
|
console.error(`stderr: ${data}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
serverProcess.stderr.on('data', (data) => {
|
app.on("before-quit", () => {
|
||||||
console.error(`stderr: ${data}`);
|
close_sub_processes();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
app.on('before-quit', () => {
|
|
||||||
close_sub_processes();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
win = null;
|
win = null;
|
||||||
if (process.platform !== "darwin") app.quit();
|
if (process.platform !== "darwin") app.quit();
|
||||||
|
@ -190,33 +192,32 @@ ipcMain.handle("open-win", (_, arg) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function close_sub_processes() {
|
function close_sub_processes() {
|
||||||
console.log("Closing sub processes...");
|
console.log("Closing sub processes...");
|
||||||
|
|
||||||
if (serverProcess != null) {
|
if (serverProcess != null) {
|
||||||
try {
|
try {
|
||||||
console.log(`Killing server process with PID: ${serverProcess.pid}`);
|
console.log(`Killing server process with PID: ${serverProcess.pid}`);
|
||||||
|
|
||||||
switch (platform().toLowerCase()) {
|
switch (platform().toLowerCase()) {
|
||||||
//case "darwin":
|
//case "darwin":
|
||||||
// process.kill(serverProcess.pid);
|
// process.kill(serverProcess.pid);
|
||||||
// break;
|
// break;
|
||||||
//case "linux":
|
//case "linux":
|
||||||
// process.kill(serverProcess.pid);
|
// process.kill(serverProcess.pid);
|
||||||
// break;
|
// break;
|
||||||
case "win32":
|
case "win32":
|
||||||
// For Windows, use taskkill to ensure all child processes are also terminated
|
// For Windows, use taskkill to ensure all child processes are also terminated
|
||||||
spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]);
|
spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log("Unhandled OS Platform: ", platform());
|
console.log("Unhandled OS Platform: ", platform());
|
||||||
serverProcess = null;
|
serverProcess = null;
|
||||||
serverPath = null;
|
serverPath = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
} catch (error) {
|
console.error(`Error killing server process: ${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 { getFreedataMessages } from "../js/api";
|
||||||
import { getRemote } from "../store/settingsStore.js";
|
import { getRemote } from "../store/settingsStore.js";
|
||||||
import { loadAllData } from "../js/eventHandler";
|
import { loadAllData } from "../js/eventHandler";
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-------------------------------- INFO TOASTS ---------------->
|
<!-------------------------------- INFO TOASTS ---------------->
|
||||||
<div
|
<div aria-live="polite" aria-atomic="true" class="position-relative z-3">
|
||||||
aria-live="polite"
|
|
||||||
aria-atomic="true"
|
|
||||||
class="position-relative z-3"
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
class="toast-container position-absolute top-0 end-0 p-3"
|
class="toast-container position-absolute top-0 end-0 p-3"
|
||||||
id="mainToastContainer"
|
id="mainToastContainer"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { Modal } from "bootstrap";
|
import { Modal } from "bootstrap";
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
|
|
||||||
|
|
||||||
import { setActivePinia } from "pinia";
|
import { setActivePinia } from "pinia";
|
||||||
import pinia from "../store/index";
|
import pinia from "../store/index";
|
||||||
setActivePinia(pinia);
|
setActivePinia(pinia);
|
||||||
|
@ -18,7 +17,6 @@ const audioStore = useAudioStore();
|
||||||
import { useSerialStore } from "../store/serialStore";
|
import { useSerialStore } from "../store/serialStore";
|
||||||
const serialStore = useSerialStore();
|
const serialStore = useSerialStore();
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getVersion,
|
getVersion,
|
||||||
setConfig,
|
setConfig,
|
||||||
|
@ -27,8 +25,6 @@ import {
|
||||||
getModemState,
|
getModemState,
|
||||||
} from "../js/api";
|
} from "../js/api";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const version = import.meta.env.PACKAGE_VERSION;
|
const version = import.meta.env.PACKAGE_VERSION;
|
||||||
|
|
||||||
// start modemCheck modal once on startup
|
// start modemCheck modal once on startup
|
||||||
|
@ -39,8 +35,6 @@ onMounted(() => {
|
||||||
new Modal("#modemCheck", {}).show();
|
new Modal("#modemCheck", {}).show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getModemStateLocal() {
|
function getModemStateLocal() {
|
||||||
// Returns active/inactive if modem is running for modem status label
|
// Returns active/inactive if modem is running for modem status label
|
||||||
if (state.is_modem_running == true) return "Active";
|
if (state.is_modem_running == true) return "Active";
|
||||||
|
@ -210,28 +204,45 @@ function testHamlib() {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Audio Input Device -->
|
<!-- Audio Input Device -->
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<label class="input-group-text w-50">Audio Input device</label>
|
<label class="input-group-text w-50"
|
||||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.input_device">
|
>Audio Input device</label
|
||||||
<option v-for="device in audioStore.audioInputs" :value="device.id">
|
>
|
||||||
{{ device.name }} [{{ device.api }}]
|
<select
|
||||||
</option>
|
class="form-select form-select-sm"
|
||||||
</select>
|
aria-label=".form-select-sm"
|
||||||
</div>
|
@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>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Audio Output Device -->
|
<!-- Audio Output Device -->
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<label class="input-group-text w-50">Audio Output device</label>
|
<label class="input-group-text w-50"
|
||||||
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.output_device">
|
>Audio Output device</label
|
||||||
<option v-for="device in audioStore.audioOutputs" :value="device.id">
|
>
|
||||||
{{ device.name }} [{{ device.api }}]
|
<select
|
||||||
</option>
|
class="form-select form-select-sm"
|
||||||
</select>
|
aria-label=".form-select-sm"
|
||||||
</div>
|
@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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -299,15 +310,19 @@ function testHamlib() {
|
||||||
>Radio port</span
|
>Radio port</span
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<select
|
||||||
|
@change="onChange"
|
||||||
<select @change="onChange" v-model="settings.remote.RADIO.serial_port" class="form-select form-select-sm">
|
v-model="settings.remote.RADIO.serial_port"
|
||||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
class="form-select form-select-sm"
|
||||||
{{ device.description }}
|
>
|
||||||
</option>
|
<option
|
||||||
</select>
|
v-for="device in serialStore.serialDevices"
|
||||||
|
:value="device.port"
|
||||||
|
:key="device.port"
|
||||||
|
>
|
||||||
|
{{ device.description }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
@ -376,7 +391,6 @@ function testHamlib() {
|
||||||
data-bs-toggle="collapse"
|
data-bs-toggle="collapse"
|
||||||
>
|
>
|
||||||
Version
|
Version
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
</h2>
|
</h2>
|
||||||
<div
|
<div
|
||||||
|
@ -399,7 +413,6 @@ function testHamlib() {
|
||||||
>
|
>
|
||||||
Modem version | {{ state.modem_version }}
|
Modem version | {{ state.modem_version }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,7 +19,6 @@ import settings_exp from "./settings_exp.vue";
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<!-- SETTINGS Nav tabs -->
|
<!-- SETTINGS Nav tabs -->
|
||||||
<ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
|
<ul class="nav nav-tabs card-header-tabs" id="myTab" role="tablist">
|
||||||
|
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button
|
<button
|
||||||
class="nav-link active"
|
class="nav-link active"
|
||||||
|
@ -127,8 +126,6 @@ import settings_exp from "./settings_exp.vue";
|
||||||
>
|
>
|
||||||
<!-- SETTINGS Nav Tab panes -->
|
<!-- SETTINGS Nav Tab panes -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Station tab contents-->
|
<!-- Station tab contents-->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
||||||
import { useSerialStore } from "../store/serialStore";
|
import { useSerialStore } from "../store/serialStore";
|
||||||
const serialStore = useSerialStore();
|
const serialStore = useSerialStore();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -335,23 +334,19 @@ const serialStore = useSerialStore();
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<span class="input-group-text" style="width: 180px">Radio port</span>
|
<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"
|
||||||
|
>
|
||||||
<select @change="onChange" v-model="settings.remote.RADIO.serial_port" class="form-select form-select-sm">
|
<option
|
||||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
v-for="device in serialStore.serialDevices"
|
||||||
{{ device.description }}
|
:value="device.port"
|
||||||
</option>
|
:key="device.port"
|
||||||
</select>
|
>
|
||||||
|
{{ device.description }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group input-group-sm mb-1">
|
<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">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<span class="input-group-text" style="width: 180px">PTT device port</span>
|
<span class="input-group-text" style="width: 180px">PTT device port</span>
|
||||||
|
|
||||||
|
<select
|
||||||
|
@change="onChange"
|
||||||
|
v-model="settings.remote.RADIO.ptt_port"
|
||||||
<select @change="onChange" v-model="settings.remote.RADIO.ptt_port" class="form-select form-select-sm">
|
class="form-select form-select-sm"
|
||||||
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
>
|
||||||
{{ device.description }}
|
<option
|
||||||
</option>
|
v-for="device in serialStore.serialDevices"
|
||||||
</select>
|
:value="device.port"
|
||||||
|
:key="device.port"
|
||||||
|
>
|
||||||
|
{{ device.description }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<span class="input-group-text" style="width: 180px">PTT type</span>
|
<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";
|
import { useAudioStore } from "../store/audioStore";
|
||||||
const audioStore = useAudioStore();
|
const audioStore = useAudioStore();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -70,31 +67,36 @@ const audioStore = useAudioStore();
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Audio Input Device -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Audio Input Device -->
|
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<label class="input-group-text w-50">Audio Input device</label>
|
<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">
|
<option v-for="device in audioStore.audioInputs" :value="device.id">
|
||||||
{{ device.name }} [{{ device.api }}]
|
{{ device.name }} [{{ device.api }}]
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Audio Output Device -->
|
<!-- Audio Output Device -->
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<label class="input-group-text w-50">Audio Output device</label>
|
<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">
|
<option v-for="device in audioStore.audioOutputs" :value="device.id">
|
||||||
{{ device.name }} [{{ device.api }}]
|
{{ device.name }} [{{ device.api }}]
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Audio rx level-->
|
<!-- Audio rx level-->
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
<span class="input-group-text w-25">RX Audio Level</span>
|
<span class="input-group-text w-25">RX Audio Level</span>
|
||||||
|
|
|
@ -8,11 +8,7 @@ import {
|
||||||
} from "./chatHandler";
|
} from "./chatHandler";
|
||||||
*/
|
*/
|
||||||
import { displayToast } from "./popupHandler";
|
import { displayToast } from "./popupHandler";
|
||||||
import {
|
import { getFreedataMessages, getModemState, getAudioDevices } from "./api";
|
||||||
getFreedataMessages,
|
|
||||||
getModemState,
|
|
||||||
getAudioDevices,
|
|
||||||
} from "./api";
|
|
||||||
import { processFreedataMessages } from "./messagesHandler.ts";
|
import { processFreedataMessages } from "./messagesHandler.ts";
|
||||||
import { processRadioStatus } from "./radioHandler.ts";
|
import { processRadioStatus } from "./radioHandler.ts";
|
||||||
|
|
||||||
|
@ -33,17 +29,15 @@ import {
|
||||||
getRemote,
|
getRemote,
|
||||||
} from "../store/settingsStore.js";
|
} from "../store/settingsStore.js";
|
||||||
|
|
||||||
|
export function loadAllData() {
|
||||||
export function loadAllData(){
|
getModemState();
|
||||||
getModemState();
|
getRemote();
|
||||||
getRemote();
|
getOverallHealth();
|
||||||
getOverallHealth();
|
audioStore.loadAudioDevices();
|
||||||
audioStore.loadAudioDevices();
|
serialStore.loadSerialDevices();
|
||||||
serialStore.loadSerialDevices();
|
getFreedataMessages();
|
||||||
getFreedataMessages();
|
processFreedataMessages();
|
||||||
processFreedataMessages();
|
processRadioStatus();
|
||||||
processRadioStatus();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function connectionFailed(endpoint, event) {
|
export function connectionFailed(endpoint, event) {
|
||||||
|
@ -141,7 +135,6 @@ export function eventDispatcher(data) {
|
||||||
displayToast("success", "bi-ethernet", message, 5000);
|
displayToast("success", "bi-ethernet", message, 5000);
|
||||||
stateStore.modem_connection = "connected";
|
stateStore.modem_connection = "connected";
|
||||||
|
|
||||||
|
|
||||||
loadAllData();
|
loadAllData();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -33,7 +33,6 @@ import { getRemote } from "./store/settingsStore";
|
||||||
import { initConnections } from "./js/event_sock.js";
|
import { initConnections } from "./js/event_sock.js";
|
||||||
import { getModemState } from "./js/api";
|
import { getModemState } from "./js/api";
|
||||||
|
|
||||||
|
|
||||||
getRemote().then(() => {
|
getRemote().then(() => {
|
||||||
initConnections();
|
initConnections();
|
||||||
getModemState();
|
getModemState();
|
||||||
|
|
|
@ -2,14 +2,15 @@ import { defineStore } from "pinia";
|
||||||
import { getAudioDevices } from "../js/api";
|
import { getAudioDevices } from "../js/api";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
|
||||||
|
|
||||||
// Define skel fallback data
|
// Define skel fallback data
|
||||||
const skel = [{
|
const skel = [
|
||||||
"api": "ERR",
|
{
|
||||||
"id": "0000",
|
api: "ERR",
|
||||||
"name": "No devices received from modem",
|
id: "0000",
|
||||||
"native_index": 0
|
name: "No devices received from modem",
|
||||||
}];
|
native_index: 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const useAudioStore = defineStore("audioStore", () => {
|
export const useAudioStore = defineStore("audioStore", () => {
|
||||||
const audioInputs = ref([]);
|
const audioInputs = ref([]);
|
||||||
|
@ -20,7 +21,8 @@ export const useAudioStore = defineStore("audioStore", () => {
|
||||||
const devices = await getAudioDevices();
|
const devices = await getAudioDevices();
|
||||||
// Check if devices are valid and have entries, otherwise use skel
|
// Check if devices are valid and have entries, otherwise use skel
|
||||||
audioInputs.value = devices && devices.in.length > 0 ? devices.in : 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) {
|
} catch (error) {
|
||||||
console.error("Failed to load audio devices:", error);
|
console.error("Failed to load audio devices:", error);
|
||||||
// Use skel as fallback in case of 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";
|
import { ref } from "vue";
|
||||||
|
|
||||||
// Define "skel" fallback data for serial devices
|
// Define "skel" fallback data for serial devices
|
||||||
const skelSerial = [{
|
const skelSerial = [
|
||||||
"description": "No devices received from modem",
|
{
|
||||||
"port": "ignore" // Using "ignore" as a placeholder value
|
description: "No devices received from modem",
|
||||||
}];
|
port: "ignore", // Using "ignore" as a placeholder value
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const useSerialStore = defineStore("serialStore", () => {
|
export const useSerialStore = defineStore("serialStore", () => {
|
||||||
const serialDevices = ref([]);
|
const serialDevices = ref([]);
|
||||||
|
@ -15,7 +17,8 @@ export const useSerialStore = defineStore("serialStore", () => {
|
||||||
try {
|
try {
|
||||||
const devices = await getSerialDevices();
|
const devices = await getSerialDevices();
|
||||||
// Check if devices are valid and have entries, otherwise use skelSerial
|
// 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) {
|
} catch (error) {
|
||||||
console.error("Failed to load serial devices:", error);
|
console.error("Failed to load serial devices:", error);
|
||||||
// Use skelSerial as fallback in case of 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
|
// 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" });
|
serialDevices.value.push({ description: "-- ignore --", port: "ignore" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue