2023-09-12 15:52:16 +00:00
|
|
|
<script setup lang="ts">
|
2023-10-03 13:15:17 +00:00
|
|
|
import { setActivePinia } from "pinia";
|
|
|
|
import pinia from "../store/index";
|
2023-09-12 15:52:16 +00:00
|
|
|
setActivePinia(pinia);
|
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
import { useChatStore } from "../store/chatStore.js";
|
2023-09-12 15:52:16 +00:00
|
|
|
const chat = useChatStore(pinia);
|
|
|
|
|
2023-10-03 13:15:17 +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
|
|
|
|
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
|
2023-10-03 13:15:17 +00:00
|
|
|
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-14 19:17:05 +00:00
|
|
|
}
|
2023-09-12 15:52:16 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-10-03 13:15:17 +00:00
|
|
|
<div class="tab-content" id="nav-tabContent-chat-messages">
|
|
|
|
<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}`"
|
|
|
|
>
|
|
|
|
<template
|
|
|
|
v-for="item in chat.sorted_chat_list[callsign]"
|
|
|
|
:key="item._id"
|
|
|
|
>
|
2023-09-14 19:17:05 +00:00
|
|
|
<div v-if="prevChatMessageDay !== getDateTime(item.timestamp)">
|
2023-10-03 13:15:17 +00:00
|
|
|
<div class="separator my-2">
|
|
|
|
{{ (prevChatMessageDay = getDateTime(item.timestamp)) }}
|
2023-09-30 18:30:19 +00:00
|
|
|
</div>
|
2023-10-03 13:15:17 +00:00
|
|
|
</div>
|
2023-09-30 18:30:19 +00:00
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
<div v-if="item.type === 'beacon' && item.status === 'received'">
|
2023-10-22 08:12:00 +00:00
|
|
|
<!-- {{ item }} -->
|
2023-10-03 13:15:17 +00:00
|
|
|
</div>
|
2023-09-27 12:51:33 +00:00
|
|
|
|
2023-10-22 08:12:00 +00:00
|
|
|
<div v-if="item.type === 'ping'">{{ item.snr }} dB ping received</div>
|
2023-09-30 18:30:19 +00:00
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
<div v-if="item.type === 'ping-ack'">
|
2023-10-22 08:12:00 +00:00
|
|
|
{{ item.snr }} dB ping-ack received
|
2023-10-03 13:15:17 +00:00
|
|
|
</div>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-10-03 13:15:17 +00:00
|
|
|
<div v-if="item.type === 'transmit'">
|
|
|
|
<sent-message :message="item" />
|
|
|
|
</div>
|
|
|
|
<div v-else-if="item.type === 'received'">
|
|
|
|
<received-message :message="item" />
|
2023-09-14 19:17:05 +00:00
|
|
|
</div>
|
2023-10-03 13:15:17 +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>
|
|
|
|
</template>
|
|
|
|
</div>
|
2023-09-14 19:17:05 +00:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
<style>
|
|
|
|
/* https://stackoverflow.com/a/26634224 */
|
|
|
|
.separator {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
text-align: center;
|
2023-10-19 14:54:24 +00:00
|
|
|
color: #6c757d;
|
2023-09-14 19:17:05 +00:00
|
|
|
}
|
2023-09-12 20:49:41 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
.separator::before,
|
|
|
|
.separator::after {
|
2023-10-03 13:15:17 +00:00
|
|
|
content: "";
|
2023-09-14 19:17:05 +00:00
|
|
|
flex: 1;
|
2023-10-19 14:54:24 +00:00
|
|
|
border-bottom: 1px solid #adb5bd;
|
2023-09-14 19:17:05 +00:00
|
|
|
}
|
2023-09-12 15:52:16 +00:00
|
|
|
|
2023-09-14 19:17:05 +00:00
|
|
|
.separator:not(:empty)::before {
|
2023-10-03 13:15:17 +00:00
|
|
|
margin-right: 0.25em;
|
2023-09-14 19:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.separator:not(:empty)::after {
|
2023-10-03 13:15:17 +00:00
|
|
|
margin-left: 0.25em;
|
2023-09-14 19:17:05 +00:00
|
|
|
}
|
2023-10-03 13:15:17 +00:00
|
|
|
</style>
|