From 38427429dd6112322b2c3f7ed087c13d8ce4ee75 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Wed, 1 May 2024 12:38:02 +0200 Subject: [PATCH] add station info api --- freedata_gui/src/components/chat.vue | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/freedata_gui/src/components/chat.vue b/freedata_gui/src/components/chat.vue index 5cfe607e..5b1be158 100644 --- a/freedata_gui/src/components/chat.vue +++ b/freedata_gui/src/components/chat.vue @@ -118,9 +118,25 @@ watch( }, ); -const stationInfo = ref({}); +const stationInfo = ref({ + callsign: 'N/A', // Default value for callsign + location: { + gridsquare: 'N/A', // Default value for gridsquare + }, +}); + async function getStationInfoByCallsign(){ - stationInfo.value = await getStationInfo(chat.selectedCallsign); + try { + const data = await getStationInfo(chat.selectedCallsign); + stationInfo.value = { + callsign: data.callsign || 'N/A', // Default if not present + location: { + gridsquare: data.location?.gridsquare || 'N/A', // Default if not present + }, + }; + } catch (error) { + console.error("Error fetching station info:", error); + } }