show message info

This commit is contained in:
DJ2LS 2023-10-14 15:32:30 +02:00
parent cae51b2ad4
commit bdc9ddf50b
7 changed files with 172 additions and 4 deletions

View file

@ -59,7 +59,7 @@
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.4", "@typescript-eslint/eslint-plugin": "^6.7.4",
"@vitejs/plugin-vue": "^4.4.0", "@vitejs/plugin-vue": "^4.4.0",
"electron": "^26.0.0", "electron": "^27.0.0",
"electron-builder": "^24.6.3", "electron-builder": "^24.6.3",
"eslint": "^8.50.0", "eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0", "eslint-config-prettier": "^9.0.0",

View file

@ -44,8 +44,6 @@ function chatSelected(callsign) {
chat.beaconLabelArray = []; chat.beaconLabelArray = [];
chat.beaconDataArray = []; chat.beaconDataArray = [];
} }
console.log(chat.beaconDataArray);
} }
</script> </script>
<template> <template>

View file

@ -8,6 +8,16 @@
> >
<i class="bi bi-arrow-repeat"></i> <i class="bi bi-arrow-repeat"></i>
</button> </button>
<button
class="btn btn-outline-secondary border-0 me-1"
@click="showMessageInfo"
data-bs-target="#messageInfoModal"
data-bs-toggle="modal"
>
<i class="bi bi-info-circle"></i>
</button>
<button class="btn btn-outline-secondary border-0" @click="deleteMessage"> <button class="btn btn-outline-secondary border-0" @click="deleteMessage">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>
@ -53,18 +63,32 @@
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { Modal } from "bootstrap";
import { onMounted, ref } from "vue";
import { import {
repeatMessageTransmission, repeatMessageTransmission,
deleteMessageFromDB, deleteMessageFromDB,
requestMessageInfo,
} from "../js/chatHandler"; } from "../js/chatHandler";
export default { export default {
props: { props: {
message: Object, message: Object,
}, },
computed: { computed: {
getFileContent() { getFileContent() {
var filename = Object.keys(this.message._attachments)[0]; var filename = Object.keys(this.message._attachments)[0];
@ -99,6 +123,13 @@ export default {
deleteMessage() { deleteMessage() {
deleteMessageFromDB(this.message._id); deleteMessageFromDB(this.message._id);
}, },
showMessageInfo() {
requestMessageInfo(this.message._id);
//let infoModal = Modal.getOrCreateInstance(document.getElementById('messageInfoModal'))
//console.log(this.infoModal)
//this.infoModal.show()
},
getDateTime() { getDateTime() {
var datetime = new Date(this.message.timestamp * 1000).toLocaleString( var datetime = new Date(this.message.timestamp * 1000).toLocaleString(

View file

@ -7,6 +7,10 @@ setActivePinia(pinia);
import { useStateStore } from "../store/stateStore.js"; import { useStateStore } from "../store/stateStore.js";
const state = useStateStore(pinia); const state = useStateStore(pinia);
import { useChatStore } from "../store/chatStore.js";
const chat = useChatStore(pinia);
import { sendTestFrame, setTxAudioLevel } from "../js/sock.js"; import { sendTestFrame, setTxAudioLevel } from "../js/sock.js";
function tuneAudio() { function tuneAudio() {
@ -16,9 +20,75 @@ function tuneAudio() {
function set_audio_level() { function set_audio_level() {
setTxAudioLevel(state.audio_level); setTxAudioLevel(state.audio_level);
} }
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
} from 'chart.js'
import { Line } from "vue-chartjs";
import { ref, computed } from "vue";
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
)
</script> </script>
<template> <template>
<!-- Message Info Modal -->
<div class="modal fade" ref="modalEle" id="messageInfoModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="messageInfoModalLabel">{{chat.selectedMessageObject["uuid"]}}</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
{{chat.selectedMessageObject}}
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">Status</span>
<span class="input-group-text" id="basic-addon1">{{chat.selectedMessageObject["status"]}}</span>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">Attempts</span>
<span class="input-group-text" id="basic-addon1">{{chat.selectedMessageObject["attempt"]}}</span>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">Bytes per Minute</span>
<span class="input-group-text" id="basic-addon1">{{chat.selectedMessageObject["bytesperminute"]}}</span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<!-- HELP MODALS AUDIO --> <!-- HELP MODALS AUDIO -->
<div <div
class="modal fade" class="modal fade"

View file

@ -259,6 +259,9 @@ function sortChatList() {
//repeat a message //repeat a message
export function repeatMessageTransmission(id) { export function repeatMessageTransmission(id) {
console.log(id); console.log(id);
// 1. get message object by ID
// 2. Upsert Attempts
// 3. send message
} }
// delete a message from databse and gui // delete a message from databse and gui
@ -285,13 +288,26 @@ export function updateTransmissionStatus(obj) {
databaseUpsert(obj.uuid, "bytesperminute", obj.bytesperminute); databaseUpsert(obj.uuid, "bytesperminute", obj.bytesperminute);
databaseUpsert(obj.uuid, "status", obj.status); databaseUpsert(obj.uuid, "status", obj.status);
// update screen rendering / messages // update screen rendering / messages
updateUnsortedChatListEntry(obj.uuid, "percent", obj.percent); updateUnsortedChatListEntry(obj.uuid, "percent", obj.percent);
updateUnsortedChatListEntry(obj.uuid, "bytesperminute", obj.bytesperminute); updateUnsortedChatListEntry(obj.uuid, "bytesperminute", obj.bytesperminute);
updateUnsortedChatListEntry(obj.uuid, "status", obj.status); updateUnsortedChatListEntry(obj.uuid, "status", obj.status);
} }
export function updateUnsortedChatListEntry(uuid, object, value) { export function updateUnsortedChatListEntry(uuid, object, value) {
var data = getFromUnsortedChatListByUUID(uuid)
if(data){
data[object] = value;
console.log("Entry updated:", data[object]);
chat.sorted_chat_list = sortChatList();
return data;
}
/*
for (const entry of chat.unsorted_chat_list) { for (const entry of chat.unsorted_chat_list) {
if (entry.uuid === uuid) { if (entry.uuid === uuid) {
entry[object] = value; entry[object] = value;
@ -300,11 +316,23 @@ export function updateUnsortedChatListEntry(uuid, object, value) {
return entry; return entry;
} }
} }
*/
console.log("Entry not updated:", object); console.log("Entry not updated:", object);
return null; // Return null if not found return null; // Return null if not found
} }
function getFromUnsortedChatListByUUID(uuid){
for (const entry of chat.unsorted_chat_list) {
if (entry.uuid === uuid) {
return entry;
}
}
return false;
}
export function databaseUpsert(id, object, value) { export function databaseUpsert(id, object, value) {
db.upsert(id, function (doc) { db.upsert(id, function (doc) {
if (!doc[object]) { if (!doc[object]) {
@ -708,6 +736,20 @@ export function setStateSuccess() {
state.arq_seconds_until_timeout_percent = 100; state.arq_seconds_until_timeout_percent = 100;
} }
export function requestMessageInfo(id){
console.log(id)
// id and uuid are the same
var data = getFromUnsortedChatListByUUID(id)
console.log(data)
chat.selectedMessageObject = data
}
// CRC CHECKSUMS // CRC CHECKSUMS
// https://stackoverflow.com/a/50579690 // https://stackoverflow.com/a/50579690
// crc32 calculation // crc32 calculation

View file

@ -28,7 +28,7 @@ export function addDataToWaterfall(data){
try { try {
spectrum.addData(data); spectrum.addData(data);
} catch (e) { } catch (e) {
console.log(e); //console.log(e);
} }
} }

View file

@ -14,6 +14,32 @@ export const useChatStore = defineStore("chatStore", () => {
]); ]);
var selectedCallsign = ref(); var selectedCallsign = ref();
// we need a default value in our ref because of our message info modal
var selectedMessageObject = ref({
"command": "msg",
"hmac_signed": false,
"percent": 0,
"is_new": false,
"_id": "2ead6698",
"timestamp": 1697289795,
"dxcallsign": "DJ2LS-0",
"dxgrid": "null",
"msg": "test",
"checksum": "",
"type": "transmit",
"status": "transmitting",
"attempt": 1,
"uuid": "2ead6698",
"duration": 0,
"nacks": 0,
"speed_list": "null",
"_attachments": {
"": {
"content_type": "text",
"data": ""
}
}
});
var inputText = ref(); var inputText = ref();
var inputFile = ref(); var inputFile = ref();
var inputFileName = ref(); var inputFileName = ref();
@ -38,6 +64,7 @@ export const useChatStore = defineStore("chatStore", () => {
return { return {
selectedCallsign, selectedCallsign,
selectedMessageObject,
inputText, inputText,
chat_filter, chat_filter,
callsign_list, callsign_list,