[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io 2023-11-26 06:07:52 +00:00
parent a5c9014a15
commit 6dc0a739c4
No known key found for this signature in database
GPG key ID: B66B2D63282C190F
3 changed files with 36 additions and 28 deletions

View file

@ -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);
})
});
}
</script>
@ -137,9 +149,10 @@ function quickfill() {
:gs-auto-position="true"
>
<div class="grid-stack-item-content">
<button @click="remove(w)" class="btn-close grid-stack-floaty-btn">
</button>
<button
@click="remove(w)"
class="btn-close grid-stack-floaty-btn"
></button>
<component :is="w.component2" />
</div>
</div>

View file

@ -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 = {}) {

View file

@ -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;