mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
introduced store for serial and audio devices for fixing audio related problems
This commit is contained in:
parent
0240c6cd1d
commit
eeb72faf83
11 changed files with 190 additions and 226 deletions
|
@ -42,8 +42,6 @@ InstallDirRegKey HKCU "Software\FreeDATA" "Install_Dir"
|
||||||
; Language (you can choose and configure the language(s) you want)
|
; Language (you can choose and configure the language(s) you want)
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
!define StartMenuFolder "FreeDATA"
|
|
||||||
|
|
||||||
|
|
||||||
; Installer Sections
|
; Installer Sections
|
||||||
Section "FreeData Server" SEC01
|
Section "FreeData Server" SEC01
|
||||||
|
@ -67,13 +65,13 @@ doneBackup:
|
||||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
; Create a Start Menu directory
|
; Create a Start Menu directory
|
||||||
CreateDirectory "$COMMON_STARTMENU\${StartMenuFolder}"
|
CreateDirectory "$SMPROGRAMS\FreeDATA"
|
||||||
|
|
||||||
; Create shortcut in the Start Menu directory
|
; Create shortcut in the Start Menu directory
|
||||||
CreateShortCut "$COMMON_STARTMENU\${StartMenuFolder}\FreeDATA Server.lnk" "$INSTDIR\freedata-server\freedata-server.exe"
|
CreateShortCut "$SMPROGRAMS\FreeDATA\FreeDATA Server.lnk" "$INSTDIR\freedata-server\freedata-server.exe"
|
||||||
|
|
||||||
; Create an Uninstall shortcut
|
; Create an Uninstall shortcut
|
||||||
CreateShortCut "$COMMON_STARTMENU\${StartMenuFolder}\Uninstall FreeDATA.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\FreeDATA\Uninstall FreeDATA.lnk" "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
|
|
||||||
; Backup "config.ini" before overwriting files
|
; Backup "config.ini" before overwriting files
|
||||||
|
@ -101,10 +99,10 @@ Section "FreeData x64 GUI" SEC02
|
||||||
CreateShortCut "$DESKTOP\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe"
|
CreateShortCut "$DESKTOP\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe"
|
||||||
|
|
||||||
; Create a start menu shortcut
|
; Create a start menu shortcut
|
||||||
CreateShortCut "$COMMON_STARTMENU\${StartMenuFolder}\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe"
|
CreateShortCut "$SMPROGRAMS\FreeDATA\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe"
|
||||||
|
|
||||||
; Create an Uninstall shortcut
|
; Create an Uninstall shortcut
|
||||||
CreateShortCut "$COMMON_STARTMENU\${StartMenuFolder}\Uninstall FreeDATA.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\FreeDATA\Uninstall FreeDATA.lnk" "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
@ -123,8 +121,8 @@ Section "Uninstall"
|
||||||
Delete "$DESKTOP\FreeDATA GUI.lnk"
|
Delete "$DESKTOP\FreeDATA GUI.lnk"
|
||||||
|
|
||||||
; Remove Start Menu shortcuts
|
; Remove Start Menu shortcuts
|
||||||
Delete "$COMMON_STARTMENU\${StartMenuFolder}\*.*"
|
Delete "$SMPROGRAMS\FreeDATA\*.*"
|
||||||
RMDir "$COMMON_STARTMENU\${StartMenuFolder}"
|
RMDir "$SMPROGRAMS\FreeDATA"
|
||||||
|
|
||||||
; Attempt to delete the uninstaller itself
|
; Attempt to delete the uninstaller itself
|
||||||
Delete $EXEPATH
|
Delete $EXEPATH
|
||||||
|
|
|
@ -22,15 +22,9 @@ 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 { loadAudioDevices, loadSerialDevices } from "../js/deviceFormHelper";
|
import { loadAllData } from "../js/eventHandler";
|
||||||
|
|
||||||
|
|
||||||
function getAllSettings(){
|
|
||||||
getRemote()
|
|
||||||
loadAudioDevices()
|
|
||||||
loadSerialDevices()
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -57,7 +51,7 @@ function getAllSettings(){
|
||||||
id="main-list-tab"
|
id="main-list-tab"
|
||||||
role="tablist"
|
role="tablist"
|
||||||
style="margin-top: 100px"
|
style="margin-top: 100px"
|
||||||
@click="getAllSettings"
|
@click="loadAllData"
|
||||||
>
|
>
|
||||||
<main_modem_healthcheck />
|
<main_modem_healthcheck />
|
||||||
|
|
||||||
|
@ -122,7 +116,7 @@ function getAllSettings(){
|
||||||
role="tab"
|
role="tab"
|
||||||
aria-controls="list-settings"
|
aria-controls="list-settings"
|
||||||
title="Settings"
|
title="Settings"
|
||||||
@click="getAllSettings"
|
@click="loadAllData"
|
||||||
><i class="bi bi-gear-wide-connected h3"></i
|
><i class="bi bi-gear-wide-connected h3"></i
|
||||||
></a>
|
></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,11 +9,16 @@ setActivePinia(pinia);
|
||||||
|
|
||||||
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
||||||
import { sendModemCQ } from "../js/api.js";
|
import { sendModemCQ } from "../js/api.js";
|
||||||
import { loadAudioDevices } from "../js/deviceFormHelper";
|
|
||||||
|
|
||||||
import { useStateStore } from "../store/stateStore.js";
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
|
import { useAudioStore } from "../store/audioStore";
|
||||||
|
const audioStore = useAudioStore();
|
||||||
|
import { useSerialStore } from "../store/serialStore";
|
||||||
|
const serialStore = useSerialStore();
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getVersion,
|
getVersion,
|
||||||
setConfig,
|
setConfig,
|
||||||
|
@ -21,8 +26,8 @@ import {
|
||||||
stopModem,
|
stopModem,
|
||||||
getModemState,
|
getModemState,
|
||||||
} from "../js/api";
|
} from "../js/api";
|
||||||
import { audioInputOptions, audioOutputOptions } from "../js/deviceFormHelper";
|
|
||||||
import { serialDeviceOptions } from "../js/deviceFormHelper";
|
|
||||||
|
|
||||||
const version = import.meta.env.PACKAGE_VERSION;
|
const version = import.meta.env.PACKAGE_VERSION;
|
||||||
|
|
||||||
|
@ -34,6 +39,8 @@ 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";
|
||||||
|
@ -206,73 +213,25 @@ function testHamlib() {
|
||||||
|
|
||||||
<!-- 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"
|
<label class="input-group-text w-50">Audio Input device</label>
|
||||||
>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 }}]
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
id="stopModem"
|
|
||||||
class="btn btn-sm btn-secondary"
|
|
||||||
data-bs-toggle="tooltip"
|
|
||||||
data-bs-trigger="hover"
|
|
||||||
data-bs-html="false"
|
|
||||||
title="Refresh audio devices"
|
|
||||||
@click="loadAudioDevices"
|
|
||||||
|
|
||||||
>
|
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<select
|
|
||||||
class="form-select form-select-sm"
|
|
||||||
aria-label=".form-select-sm"
|
|
||||||
@change="onChange"
|
|
||||||
v-model="settings.remote.AUDIO.input_device"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="option in audioInputOptions()"
|
|
||||||
v-bind:value="option.id"
|
|
||||||
>
|
|
||||||
{{ option.name }} [{{ option.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"
|
<label class="input-group-text w-50">Audio Output device</label>
|
||||||
>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 }}]
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
id="stopModem"
|
|
||||||
class="btn btn-sm btn-secondary"
|
|
||||||
data-bs-toggle="tooltip"
|
|
||||||
data-bs-trigger="hover"
|
|
||||||
data-bs-html="false"
|
|
||||||
title="Refresh audio devices"
|
|
||||||
@click="loadAudioDevices"
|
|
||||||
|
|
||||||
>
|
|
||||||
<i class="bi bi-arrow-clockwise"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<select
|
|
||||||
class="form-select form-select-sm"
|
|
||||||
aria-label=".form-select-sm"
|
|
||||||
@change="onChange"
|
|
||||||
v-model="settings.remote.AUDIO.output_device"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="option in audioOutputOptions()"
|
|
||||||
v-bind:value="option.id"
|
|
||||||
>
|
|
||||||
{{ option.name }} [{{ option.api }}]
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -340,21 +299,15 @@ function testHamlib() {
|
||||||
>Radio port</span
|
>Radio port</span
|
||||||
>
|
>
|
||||||
|
|
||||||
<select
|
|
||||||
class="form-select form-select-sm"
|
|
||||||
aria-label=".form-select-sm"
|
<select @change="onChange" v-model="settings.remote.RADIO.serial_port" class="form-select form-select-sm">
|
||||||
id="hamlib_deviceport"
|
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
||||||
style="width: 7rem"
|
{{ device.description }}
|
||||||
@change="onChange"
|
|
||||||
v-model="settings.remote.RADIO.serial_port"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="option in serialDeviceOptions()"
|
|
||||||
v-bind:value="option.port"
|
|
||||||
>
|
|
||||||
{{ option.description }}
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
||||||
import { serialDeviceOptions } from "../js/deviceFormHelper";
|
import { useSerialStore } from "../store/serialStore";
|
||||||
|
const serialStore = useSerialStore();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -333,21 +335,23 @@ import { serialDeviceOptions } from "../js/deviceFormHelper";
|
||||||
<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
|
|
||||||
class="form-select form-select-sm"
|
|
||||||
aria-label=".form-select-sm"
|
|
||||||
id="hamlib_deviceport"
|
|
||||||
style="width: 7rem"
|
|
||||||
@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">
|
||||||
>
|
{{ device.description }}
|
||||||
<option
|
|
||||||
v-for="option in serialDeviceOptions()"
|
|
||||||
v-bind:value="option.port"
|
|
||||||
>
|
|
||||||
{{ option.description }}
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-group input-group-sm mb-1">
|
<div class="input-group input-group-sm mb-1">
|
||||||
|
@ -422,20 +426,18 @@ import { serialDeviceOptions } from "../js/deviceFormHelper";
|
||||||
|
|
||||||
<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
|
|
||||||
class="form-select form-select-sm"
|
|
||||||
aria-label=".form-select-sm"
|
|
||||||
id="hamlib_ptt_port"
|
|
||||||
@change="onChange"
|
<select @change="onChange" v-model="settings.remote.RADIO.ptt_port" class="form-select form-select-sm">
|
||||||
v-model="settings.remote.RADIO.ptt_port"
|
<option v-for="device in serialStore.serialDevices" :value="device.port" :key="device.port">
|
||||||
>
|
{{ device.description }}
|
||||||
<option
|
|
||||||
v-for="option in serialDeviceOptions()"
|
|
||||||
v-bind:value="option.port"
|
|
||||||
>
|
|
||||||
{{ option.description }}
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</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>
|
||||||
|
|
|
@ -6,7 +6,12 @@ import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
import { startModem, stopModem } from "../js/api.js";
|
import { startModem, stopModem } from "../js/api.js";
|
||||||
import { audioInputOptions, audioOutputOptions } from "../js/deviceFormHelper";
|
|
||||||
|
import { useAudioStore } from "../store/audioStore";
|
||||||
|
const audioStore = useAudioStore();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -65,17 +70,15 @@ import { audioInputOptions, audioOutputOptions } from "../js/deviceFormHelper";
|
||||||
/>
|
/>
|
||||||
</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
|
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.input_device">
|
||||||
class="form-select form-select-sm"
|
<option v-for="device in audioStore.audioInputs" :value="device.id">
|
||||||
aria-label=".form-select-sm"
|
{{ device.name }} [{{ device.api }}]
|
||||||
@change="onChange"
|
|
||||||
v-model="settings.remote.AUDIO.input_device"
|
|
||||||
>
|
|
||||||
<option v-for="option in audioInputOptions()" v-bind:value="option.id">
|
|
||||||
{{ option.name }} [{{ option.api }}]
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -83,17 +86,15 @@ import { audioInputOptions, audioOutputOptions } from "../js/deviceFormHelper";
|
||||||
<!-- 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
|
<select class="form-select form-select-sm" aria-label=".form-select-sm" @change="onChange" v-model="settings.remote.AUDIO.output_device">
|
||||||
class="form-select form-select-sm"
|
<option v-for="device in audioStore.audioOutputs" :value="device.id">
|
||||||
aria-label=".form-select-sm"
|
{{ device.name }} [{{ device.api }}]
|
||||||
@change="onChange"
|
|
||||||
v-model="settings.remote.AUDIO.output_device"
|
|
||||||
>
|
|
||||||
<option v-for="option in audioOutputOptions()" v-bind:value="option.id">
|
|
||||||
{{ option.name }} [{{ option.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>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
import { settingsStore as settings, onChange } from "../store/settingsStore.js";
|
||||||
import { serialDeviceOptions } from "../js/deviceFormHelper";
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
import { getAudioDevices, getSerialDevices } from "./api";
|
|
||||||
|
|
||||||
let audioDevices = await getAudioDevices();
|
|
||||||
let serialDevices = await getSerialDevices();
|
|
||||||
|
|
||||||
//Dummy device data sent if unable to get devices from modem to prevent GUI crash
|
|
||||||
const skel = JSON.parse(`
|
|
||||||
[{
|
|
||||||
"api": "MME",
|
|
||||||
"id": "0000",
|
|
||||||
"name": "No devices received from modem",
|
|
||||||
"native_index": 0
|
|
||||||
}]`);
|
|
||||||
|
|
||||||
export function loadAudioDevices() {
|
|
||||||
getAudioDevices().then((devices) => {
|
|
||||||
audioDevices = devices;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadSerialDevices() {
|
|
||||||
getSerialDevices().then((devices) => {
|
|
||||||
serialDevices = devices;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function audioInputOptions() {
|
|
||||||
if (audioDevices === undefined) {
|
|
||||||
return skel;
|
|
||||||
}
|
|
||||||
return audioDevices.in;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function audioOutputOptions() {
|
|
||||||
if (audioDevices === undefined) {
|
|
||||||
return skel;
|
|
||||||
}
|
|
||||||
|
|
||||||
return audioDevices.out;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function serialDeviceOptions() {
|
|
||||||
//Return ignore option if no serialDevices
|
|
||||||
if (serialDevices === undefined)
|
|
||||||
return [{ description: "-- ignore --", port: "ignore" }];
|
|
||||||
|
|
||||||
if (serialDevices.findIndex((device) => device.port == "ignore") == -1) {
|
|
||||||
//Add an ignore option for rig and ptt for transceivers that don't require them
|
|
||||||
serialDevices.push({ description: "-- ignore --", port: "ignore" });
|
|
||||||
}
|
|
||||||
|
|
||||||
return serialDevices;
|
|
||||||
}
|
|
|
@ -11,11 +11,15 @@ import { displayToast } from "./popupHandler";
|
||||||
import {
|
import {
|
||||||
getFreedataMessages,
|
getFreedataMessages,
|
||||||
getModemState,
|
getModemState,
|
||||||
|
getAudioDevices,
|
||||||
} from "./api";
|
} from "./api";
|
||||||
import { processFreedataMessages } from "./messagesHandler.ts";
|
import { processFreedataMessages } from "./messagesHandler.ts";
|
||||||
import { processRadioStatus } from "./radioHandler.ts";
|
import { processRadioStatus } from "./radioHandler.ts";
|
||||||
import { loadAudioDevices, loadSerialDevices } from "./deviceFormHelper.ts";
|
|
||||||
|
|
||||||
|
import { useAudioStore } from "../store/audioStore";
|
||||||
|
const audioStore = useAudioStore();
|
||||||
|
import { useSerialStore } from "../store/serialStore";
|
||||||
|
const serialStore = useSerialStore();
|
||||||
|
|
||||||
// ----------------- init pinia stores -------------
|
// ----------------- init pinia stores -------------
|
||||||
import { setActivePinia } from "pinia";
|
import { setActivePinia } from "pinia";
|
||||||
|
@ -29,6 +33,19 @@ import {
|
||||||
getRemote,
|
getRemote,
|
||||||
} from "../store/settingsStore.js";
|
} from "../store/settingsStore.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function loadAllData(){
|
||||||
|
getModemState();
|
||||||
|
getRemote();
|
||||||
|
getOverallHealth();
|
||||||
|
audioStore.loadAudioDevices();
|
||||||
|
serialStore.loadSerialDevices();
|
||||||
|
getFreedataMessages();
|
||||||
|
processFreedataMessages();
|
||||||
|
processRadioStatus();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
export function connectionFailed(endpoint, event) {
|
export function connectionFailed(endpoint, event) {
|
||||||
stateStore.modem_connection = "disconnected";
|
stateStore.modem_connection = "disconnected";
|
||||||
}
|
}
|
||||||
|
@ -94,12 +111,7 @@ export function eventDispatcher(data) {
|
||||||
switch (data["modem"]) {
|
switch (data["modem"]) {
|
||||||
case "started":
|
case "started":
|
||||||
displayToast("success", "bi-arrow-left-right", "Modem started", 5000);
|
displayToast("success", "bi-arrow-left-right", "Modem started", 5000);
|
||||||
getModemState();
|
loadAllData();
|
||||||
getRemote();
|
|
||||||
loadAudioDevices();
|
|
||||||
loadSerialDevices();
|
|
||||||
getFreedataMessages();
|
|
||||||
processRadioStatus();
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "stopped":
|
case "stopped":
|
||||||
|
@ -108,12 +120,7 @@ export function eventDispatcher(data) {
|
||||||
|
|
||||||
case "restarted":
|
case "restarted":
|
||||||
displayToast("secondary", "bi-bootstrap-reboot", "Modem restarted", 5000);
|
displayToast("secondary", "bi-bootstrap-reboot", "Modem restarted", 5000);
|
||||||
getModemState();
|
loadAllData();
|
||||||
getRemote();
|
|
||||||
loadAudioDevices();
|
|
||||||
loadSerialDevices();
|
|
||||||
getFreedataMessages();
|
|
||||||
processRadioStatus();
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "failed":
|
case "failed":
|
||||||
|
@ -135,13 +142,7 @@ export function eventDispatcher(data) {
|
||||||
stateStore.modem_connection = "connected";
|
stateStore.modem_connection = "connected";
|
||||||
|
|
||||||
|
|
||||||
getModemState();
|
loadAllData();
|
||||||
getOverallHealth();
|
|
||||||
loadAudioDevices();
|
|
||||||
loadSerialDevices();
|
|
||||||
getFreedataMessages();
|
|
||||||
processFreedataMessages();
|
|
||||||
processRadioStatus();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,9 @@ const tooltipList = [...tooltipTriggerList].map(
|
||||||
import { getRemote } from "./store/settingsStore";
|
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";
|
||||||
import { loadAudioDevices, loadSerialDevices } from "./js/deviceFormHelper";
|
|
||||||
|
|
||||||
|
|
||||||
getRemote().then(() => {
|
getRemote().then(() => {
|
||||||
initConnections();
|
initConnections();
|
||||||
loadAudioDevices();
|
|
||||||
loadSerialDevices();
|
|
||||||
getModemState();
|
getModemState();
|
||||||
});
|
});
|
||||||
|
|
37
gui/src/store/audioStore.js
Normal file
37
gui/src/store/audioStore.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
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
|
||||||
|
}];
|
||||||
|
|
||||||
|
export const useAudioStore = defineStore("audioStore", () => {
|
||||||
|
const audioInputs = ref([]);
|
||||||
|
const audioOutputs = ref([]);
|
||||||
|
|
||||||
|
const loadAudioDevices = async () => {
|
||||||
|
try {
|
||||||
|
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;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load audio devices:", error);
|
||||||
|
// Use skel as fallback in case of error
|
||||||
|
audioInputs.value = skel;
|
||||||
|
audioOutputs.value = skel;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
audioInputs,
|
||||||
|
audioOutputs,
|
||||||
|
loadAudioDevices,
|
||||||
|
};
|
||||||
|
});
|
35
gui/src/store/serialStore.js
Normal file
35
gui/src/store/serialStore.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import { defineStore } from "pinia";
|
||||||
|
import { getSerialDevices } from "../js/api"; // Make sure this points to the correct file
|
||||||
|
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
|
||||||
|
}];
|
||||||
|
|
||||||
|
export const useSerialStore = defineStore("serialStore", () => {
|
||||||
|
const serialDevices = ref([]);
|
||||||
|
|
||||||
|
const loadSerialDevices = async () => {
|
||||||
|
try {
|
||||||
|
const devices = await getSerialDevices();
|
||||||
|
// Check if devices are valid and have entries, otherwise use 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
|
||||||
|
serialDevices.value = skelSerial;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the "-- ignore --" option is always available
|
||||||
|
if (!serialDevices.value.some(device => device.port === "ignore")) {
|
||||||
|
serialDevices.value.push({ description: "-- ignore --", port: "ignore" });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
serialDevices,
|
||||||
|
loadSerialDevices,
|
||||||
|
};
|
||||||
|
});
|
Loading…
Reference in a new issue