mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
GUI startup fixes if modem is not running
This commit is contained in:
parent
750d01bc92
commit
a5c9014a15
|
@ -6,12 +6,18 @@ function buildURL(params, endpoint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function apiGet(endpoint) {
|
async function apiGet(endpoint) {
|
||||||
|
try {
|
||||||
const response = await fetch(buildURL(settings.local, endpoint));
|
const response = await fetch(buildURL(settings.local, endpoint));
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`REST response not ok: ${response.statusText}`);
|
throw new Error(`REST response not ok: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
return data;
|
||||||
|
} catch(error) {
|
||||||
|
console.error("Error getting from REST:", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiPost(endpoint, payload = {}) {
|
export async function apiPost(endpoint, payload = {}) {
|
||||||
|
|
|
@ -3,6 +3,15 @@ import { getAudioDevices, getSerialDevices } from "./api";
|
||||||
let audioDevices = await getAudioDevices();
|
let audioDevices = await getAudioDevices();
|
||||||
let serialDevices = await getSerialDevices();
|
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() {
|
export function loadAudioDevices() {
|
||||||
getAudioDevices().then((devices) => {
|
getAudioDevices().then((devices) => {
|
||||||
audioDevices = devices;
|
audioDevices = devices;
|
||||||
|
@ -16,10 +25,18 @@ export function loadSerialDevices() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function audioInputOptions() {
|
export function audioInputOptions() {
|
||||||
|
if ((audioDevices === undefined))
|
||||||
|
{
|
||||||
|
return skel;
|
||||||
|
}
|
||||||
return audioDevices.in;
|
return audioDevices.in;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function audioOutputOptions() {
|
export function audioOutputOptions() {
|
||||||
|
if ((audioDevices === undefined))
|
||||||
|
{
|
||||||
|
return skel;
|
||||||
|
}
|
||||||
return audioDevices.out;
|
return audioDevices.out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue