[CodeFactor] Apply fixes

This commit is contained in:
codefactor-io 2024-05-01 10:38:28 +00:00
parent 38427429dd
commit efff46b4eb
No known key found for this signature in database
GPG key ID: B66B2D63282C190F
4 changed files with 75 additions and 87 deletions

View file

@ -6,7 +6,7 @@ import chat_conversations from "./chat_conversations.vue";
import chat_messages from "./chat_messages.vue"; import chat_messages from "./chat_messages.vue";
import chat_new_message from "./chat_new_message.vue"; import chat_new_message from "./chat_new_message.vue";
import {getStationInfo} from "./../js/api"; import { getStationInfo } from "./../js/api";
import { setActivePinia } from "pinia"; import { setActivePinia } from "pinia";
import pinia from "../store/index"; import pinia from "../store/index";
@ -119,33 +119,30 @@ watch(
); );
const stationInfo = ref({ const stationInfo = ref({
callsign: 'N/A', // Default value for callsign callsign: "N/A", // Default value for callsign
location: { location: {
gridsquare: 'N/A', // Default value for gridsquare gridsquare: "N/A", // Default value for gridsquare
}, },
}); });
async function getStationInfoByCallsign(){ async function getStationInfoByCallsign() {
try { try {
const data = await getStationInfo(chat.selectedCallsign); const data = await getStationInfo(chat.selectedCallsign);
stationInfo.value = { stationInfo.value = {
callsign: data.callsign || 'N/A', // Default if not present callsign: data.callsign || "N/A", // Default if not present
location: { location: {
gridsquare: data.location?.gridsquare || 'N/A', // Default if not present gridsquare: data.location?.gridsquare || "N/A", // Default if not present
}, },
}; };
} catch (error) { } catch (error) {
console.error("Error fetching station info:", error); console.error("Error fetching station info:", error);
} }
} }
</script> </script>
<template> <template>
<!-- Station Info Modal -->
<!-- Station Info Modal --> <div
<div
class="modal fade" class="modal fade"
ref="modalEle" ref="modalEle"
id="stationInfoModal" id="stationInfoModal"
@ -155,23 +152,19 @@ async function getStationInfoByCallsign(){
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="p-0 m-0">{{ stationInfo.callsign }}</h4> <h4 class="p-0 m-0">{{ stationInfo.callsign }}</h4>
<button <button
type="button" type="button"
class="btn-close" class="btn-close"
data-bs-dismiss="modal" data-bs-dismiss="modal"
aria-label="Close" aria-label="Close"
></button> ></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>
<strong>Location:</strong> {{ stationInfo.location.gridsquare }}
</p>
<p><strong>Location:</strong> {{ stationInfo.location.gridsquare }}</p> <p><strong>Details:</strong> {{ stationInfo.details }}</p>
<p><strong>Details:</strong> {{ stationInfo.details }}</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -187,64 +180,62 @@ async function getStationInfoByCallsign(){
</div> </div>
</div> </div>
<div class="container-fluid d-flex p-0"> <div class="container-fluid d-flex p-0">
<!-- Chat Conversations --> <!-- Chat Conversations -->
<div class="bg-light p-0" style="width: 250px"> <div class="bg-light p-0" style="width: 250px">
<div class="container-fluid overflow-auto p-0"> <div class="container-fluid overflow-auto p-0">
<chat_conversations /> <chat_conversations />
</div>
<div class="list-group overflow-auto" id="list-tab-chat" role="tablist"></div>
</div> </div>
<div
class="list-group overflow-auto"
id="list-tab-chat"
role="tablist"
></div>
</div>
<!-- Chat Messages -->
<!-- Chat Messages --> <div class="flex-grow-1 border-start p-0">
<div class="flex-grow-1 border-start p-0"> <div class="d-flex flex-column">
<div class="d-flex flex-column"> <!-- Top Navbar -->
<!-- Top Navbar --> <nav class="navbar sticky-top z-0 bg-body-tertiary border-bottom p-1">
<nav class="navbar sticky-top z-0 bg-body-tertiary border-bottom p-1"> <button
<button class="btn btn-sm btn-outline-secondary ms-2 border-0"
class="btn btn-sm btn-outline-secondary ms-2 border-0" data-bs-target="#stationInfoModal"
data-bs-target="#stationInfoModal" data-bs-toggle="modal"
data-bs-toggle="modal" @click="getStationInfoByCallsign()"
@click="getStationInfoByCallsign()"
>
<h4 class="p-0 m-0">{{ chat.selectedCallsign }}</h4>
</button>
<div class="input-group mb-0 p-0 w-25">
<button type="button" class="btn btn-outline-secondary" disabled>
Beacons
</button>
<div
class="form-floating border border-secondary-subtle border-1 rounded-end"
>
<Bar
:data="beaconHistogramData"
:options="beaconHistogramOptions"
width="300"
height="50"
/>
</div>
</div>
</nav>
<!-- Chat Messages Area -->
<div
class="overflow-auto"
style="height: calc(100vh - 156px)"
ref="messagesContainer"
> >
<chat_messages /> <h4 class="p-0 m-0">{{ chat.selectedCallsign }}</h4>
</div> </button>
<!-- New Message Area --> <div class="input-group mb-0 p-0 w-25">
<chat_new_message /> <button type="button" class="btn btn-outline-secondary" disabled>
Beacons
</button>
<div
class="form-floating border border-secondary-subtle border-1 rounded-end"
>
<Bar
:data="beaconHistogramData"
:options="beaconHistogramOptions"
width="300"
height="50"
/>
</div>
</div>
</nav>
<!-- Chat Messages Area -->
<div
class="overflow-auto"
style="height: calc(100vh - 156px)"
ref="messagesContainer"
>
<chat_messages />
</div> </div>
<!-- New Message Area -->
<chat_new_message />
</div> </div>
</div>
</div> </div>
</template> </template>

View file

@ -35,7 +35,6 @@ function newChat() {
if (callsign === "") return; if (callsign === "") return;
this.newChatCall.value = ""; this.newChatCall.value = "";
} }
</script> </script>
<template> <template>

View file

@ -211,7 +211,6 @@ const transmissionSpeedChartDataMessageInfo = computed(() => ({
</div> </div>
</div> </div>
<!-- Message Info Modal --> <!-- Message Info Modal -->
<div <div
class="modal fade" class="modal fade"

View file

@ -34,12 +34,11 @@ export async function processFreedataMessages(data) {
chatStore.callsign_list = createCallsignListFromAPI(data); chatStore.callsign_list = createCallsignListFromAPI(data);
chatStore.sorted_chat_list = createSortedMessagesList(data); chatStore.sorted_chat_list = createSortedMessagesList(data);
console.log(chatStore.sorted_chat_list) console.log(chatStore.sorted_chat_list);
// also update the selectedCallsign - if its undefined, then we select the first available callsign // also update the selectedCallsign - if its undefined, then we select the first available callsign
if (typeof chatStore.selectedCallsign == "undefined"){ if (typeof chatStore.selectedCallsign == "undefined") {
chatStore.selectedCallsign = Object.keys(chatStore.sorted_chat_list)[0] chatStore.selectedCallsign = Object.keys(chatStore.sorted_chat_list)[0];
} }
} }
} }