From 6dc0a739c416f86b4101388f0e33196e9c215322 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 26 Nov 2023 06:07:52 +0000 Subject: [PATCH] [CodeFactor] Apply fixes --- gui/src/components/dynamic_components2.vue | 37 +++++++++++++++------- gui/src/js/api.js | 18 +++++------ gui/src/js/deviceFormHelper.ts | 9 ++---- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/gui/src/components/dynamic_components2.vue b/gui/src/components/dynamic_components2.vue index 25ec9c8b..c587adce 100644 --- a/gui/src/components/dynamic_components2.vue +++ b/gui/src/components/dynamic_components2.vue @@ -22,7 +22,7 @@ let color = ref("black"); let gridInfo = ref(""); let grid = null; // DO NOT use ref(null) as proxies GS will break all logic when comparing structures... see https://github.com/gridstack/gridstack.js/issues/2115 let items = ref([]); -class gridWidget{ +class gridWidget { component2; size; text; @@ -33,11 +33,23 @@ class gridWidget{ } } const gridWidgets = [ - new gridWidget(active_heard_stations,{ x: 0, y: 0, w: 7, h: 20 },"Heard stations"), - new gridWidget(active_stats,{ x: 0, y: 0, w: 5, h: 28 },"Stats (waterfall, etc)"), - new gridWidget(active_audio_level,{ x: 0, y: 0, w: 5, h: 12 },"Audio"), - new gridWidget(active_rig_control,{ x: 0, y: 0, w: 6, h: 12 },"Rig control"), - new gridWidget(active_broadcats,{ x: 1, y: 1, w: 5, h: 12 },"Broadcats"), + new gridWidget( + active_heard_stations, + { x: 0, y: 0, w: 7, h: 20 }, + "Heard stations", + ), + new gridWidget( + active_stats, + { x: 0, y: 0, w: 5, h: 28 }, + "Stats (waterfall, etc)", + ), + new gridWidget(active_audio_level, { x: 0, y: 0, w: 5, h: 12 }, "Audio"), + new gridWidget( + active_rig_control, + { x: 0, y: 0, w: 6, h: 12 }, + "Rig control", + ), + new gridWidget(active_broadcats, { x: 1, y: 1, w: 5, h: 12 }, "Broadcats"), ]; onMounted(() => { grid = GridStack.init({ @@ -78,9 +90,9 @@ function onChange(event, changeItems) { }); } function addNewWidget2(componentToAdd) { - const node = items[count.value] || {...componentToAdd.size}; + const node = items[count.value] || { ...componentToAdd.size }; node.id = "w_" + count.value++; - node.component2 = shallowRef({...componentToAdd.component2}); + node.component2 = shallowRef({ ...componentToAdd.component2 }); items.value.push(node); nextTick(() => { grid.makeWidget(node.id); @@ -116,7 +128,7 @@ function showModal() { function quickfill() { gridWidgets.forEach(async (gw) => { await addNewWidget2(gw); -}) + }); } @@ -137,9 +149,10 @@ function quickfill() { :gs-auto-position="true" >
- +
diff --git a/gui/src/js/api.js b/gui/src/js/api.js index de842d87..6d51a343 100644 --- a/gui/src/js/api.js +++ b/gui/src/js/api.js @@ -6,18 +6,16 @@ function buildURL(params, endpoint) { } async function apiGet(endpoint) { - try { - const response = await fetch(buildURL(settings.local, endpoint)); - if (!response.ok) { - throw new Error(`REST response not ok: ${response.statusText}`); - } - const data = await response.json(); - return data; - } catch(error) { + try { + const response = await fetch(buildURL(settings.local, endpoint)); + if (!response.ok) { + throw new Error(`REST response not ok: ${response.statusText}`); + } + const data = await response.json(); + return data; + } catch (error) { console.error("Error getting from REST:", error); } - - } export async function apiPost(endpoint, payload = {}) { diff --git a/gui/src/js/deviceFormHelper.ts b/gui/src/js/deviceFormHelper.ts index 09a158c1..2588acd7 100644 --- a/gui/src/js/deviceFormHelper.ts +++ b/gui/src/js/deviceFormHelper.ts @@ -10,8 +10,7 @@ const skel = JSON.parse(` "id": "0000", "name": "No devices received from modem", "native_index": 0 -}]` -) +}]`); export function loadAudioDevices() { getAudioDevices().then((devices) => { audioDevices = devices; @@ -25,16 +24,14 @@ export function loadSerialDevices() { } export function audioInputOptions() { - if ((audioDevices === undefined)) - { + if (audioDevices === undefined) { return skel; } return audioDevices.in; } export function audioOutputOptions() { - if ((audioDevices === undefined)) - { + if (audioDevices === undefined) { return skel; } return audioDevices.out;