2023-09-12 15:52:16 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
|
|
|
|
import {saveSettingsToFile} from '../js/settingsHandler';
|
|
|
|
|
|
|
|
import { setActivePinia } from 'pinia';
|
|
|
|
import pinia from '../store/index';
|
|
|
|
setActivePinia(pinia);
|
|
|
|
|
|
|
|
import { useSettingsStore } from '../store/settingsStore.js';
|
|
|
|
const settings = useSettingsStore(pinia);
|
|
|
|
|
|
|
|
import { useStateStore } from '../store/stateStore.js';
|
|
|
|
const state = useStateStore(pinia);
|
|
|
|
|
|
|
|
import { useChatStore } from '../store/chatStore.js';
|
|
|
|
const chat = useChatStore(pinia);
|
|
|
|
|
2023-09-13 21:28:20 +00:00
|
|
|
import SentMessage from './chat_messages_sent.vue'; // Import the chat_messages_sent component
|
|
|
|
import ReceivedMessage from './chat_messages_received.vue'; // Import the chat_messages_sent component
|
2023-09-27 12:51:33 +00:00
|
|
|
import ReceivedBroadcastMessage from './chat_messages_broadcast_received.vue'; // Import the chat_messages_sent component for broadcasts
|
|
|
|
import SentBroadcastMessage from './chat_messages_broadcast_sent.vue'; // Import the chat_messages_sent component for broadcasts
|
2023-09-13 21:28:20 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
//helper function for saving the last messages day for disaplying the day based divider
|
|
|
|
var prevChatMessageDay = ''
|
|
|
|
|
|
|
|
function getDateTime(timestampRaw){
|
|
|
|
var datetime = new Date(timestampRaw * 1000).toLocaleString(
|
|
|
|
navigator.language,
|
|
|
|
{
|
|
|
|
hourCycle: "h23",
|
|
|
|
year: "numeric",
|
|
|
|
month: "2-digit",
|
|
|
|
day: "2-digit",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
return datetime
|
|
|
|
}
|
|
|
|
|
2023-09-30 18:30:19 +00:00
|
|
|
function addBeaconDataToStore(item){
|
|
|
|
|
|
|
|
//chat.beaconDataArray.push(item.snr)
|
|
|
|
//chat.beaconLabelArray.push(item.timestamp)
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
2023-09-13 21:28:20 +00:00
|
|
|
|
2023-09-12 15:52:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="tab-content" id="nav-tabContent-chat-messages">
|
2023-09-14 20:45:29 +00:00
|
|
|
<template v-for="(callsign, key) in chat.callsign_list">
|
|
|
|
<div class="tab-pane fade show" :class="{ active: key==0 }" :id="`list-${callsign}-messages`" role="tabpanel" :aria-labelledby="`list-chat-list-${callsign}`">
|
2023-09-14 19:17:05 +00:00
|
|
|
<template v-for="item in chat.sorted_chat_list[callsign]" :key="item._id">
|
2023-09-13 21:28:20 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
<div v-if="prevChatMessageDay !== getDateTime(item.timestamp)">
|
|
|
|
<div class="separator my-2">{{prevChatMessageDay = getDateTime(item.timestamp)}}</div>
|
|
|
|
</div>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-30 18:30:19 +00:00
|
|
|
<div v-if="item.type === 'beacon' && item.status === 'received'">
|
2023-09-27 12:51:33 +00:00
|
|
|
{{item}}
|
2023-09-30 18:30:19 +00:00
|
|
|
{{item.snr}}
|
|
|
|
{{addBeaconDataToStore(item)}}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="item.type === 'ping'">
|
|
|
|
{{item.snr}}
|
|
|
|
|
|
|
|
{{chat.beaconDataArray}}
|
2023-09-27 12:51:33 +00:00
|
|
|
</div>
|
|
|
|
|
2023-09-30 18:30:19 +00:00
|
|
|
<div v-if="item.type === 'ping-ack'">
|
|
|
|
{{item.snr}}
|
2023-09-27 12:51:33 +00:00
|
|
|
|
2023-09-30 18:30:19 +00:00
|
|
|
{{chat.beaconDataArray}}
|
|
|
|
</div>
|
2023-09-27 12:51:33 +00:00
|
|
|
|
|
|
|
|
2023-09-13 21:28:20 +00:00
|
|
|
<div v-if="item.type === 'transmit'">
|
|
|
|
<sent-message :message="item" />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="item.type === 'received'">
|
2023-09-30 18:30:19 +00:00
|
|
|
|
2023-09-13 21:28:20 +00:00
|
|
|
<received-message :message="item" />
|
|
|
|
</div>
|
2023-09-27 12:51:33 +00:00
|
|
|
<div v-if="item.type === 'broadcast_transmit'">
|
|
|
|
<sent-broadcast-message :message="item" />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="item.type === 'broadcast_received'">
|
|
|
|
<received-broadcast-message :message="item" />
|
|
|
|
</div>
|
|
|
|
|
2023-09-13 21:28:20 +00:00
|
|
|
</template>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
<style>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
/* https://stackoverflow.com/a/26634224 */
|
|
|
|
.separator {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
.separator::before,
|
|
|
|
.separator::after {
|
|
|
|
content: '';
|
|
|
|
flex: 1;
|
|
|
|
border-bottom: 1px solid #000;
|
|
|
|
}
|
2023-09-12 15:52:16 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
.separator:not(:empty)::before {
|
|
|
|
margin-right: .25em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.separator:not(:empty)::after {
|
|
|
|
margin-left: .25em;
|
|
|
|
}
|
|
|
|
</style>
|