FreeDATA/gui/src/components/chat_messages_broadcast_sent.vue

115 lines
3.2 KiB
Vue
Raw Normal View History

2023-09-27 12:51:33 +00:00
<template>
<div class="row justify-content-end mb-2">
<!-- control area -->
<div class="col-auto p-0 m-0">
2023-10-03 13:15:17 +00:00
<button
class="btn btn-outline-secondary border-0 me-1"
@click="repeatMessage"
>
<i class="bi bi-arrow-repeat"></i>
</button>
<button class="btn btn-outline-secondary border-0" @click="deleteMessage">
<i class="bi bi-trash"></i>
</button>
2023-09-27 12:51:33 +00:00
</div>
<!-- message area -->
<div :class="messageWidthClass">
<div class="card bg-primary text-white">
<div class="card-header" v-if="getFileContent['filesize'] !== 0">
2023-10-03 13:15:17 +00:00
<p class="card-text">
{{ getFileContent["filename"] }} |
{{ getFileContent["filesize"] }} Bytes |
{{ getFileContent["filetype"] }}
</p>
2023-09-27 12:51:33 +00:00
</div>
<div class="card-body">
<p class="card-text">{{ message.msg }}</p>
</div>
<div class="card-footer p-0 bg-primary border-top-0">
2023-10-03 13:15:17 +00:00
<p class="text p-0 m-0 me-1 text-end">{{ getDateTime }}</p>
<!-- Display formatted timestamp in card-footer -->
2023-09-27 12:51:33 +00:00
</div>
<div class="card-footer p-0 border-top-0" v-if="message.percent < 100">
<div class="progress bg-secondary" :style="{ height: '10px' }">
<div
class="progress-bar progress-bar-striped overflow-visible"
role="progressbar"
:style="{ width: message.percent + '%', height: '10px' }"
:aria-valuenow="message.percent"
aria-valuemin="0"
aria-valuemax="100"
>
2023-10-26 10:12:53 +00:00
{{ message.percent }} % with {{ message.bytesperminute }} bpm (
{{ message.status }} )
2023-09-27 12:51:33 +00:00
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
2023-10-03 13:15:17 +00:00
import {
repeatMessageTransmission,
deleteMessageFromDB,
} from "../js/chatHandler";
2023-09-27 12:51:33 +00:00
export default {
props: {
message: Object,
},
computed: {
2023-10-03 13:15:17 +00:00
getFileContent() {
var filename = Object.keys(this.message._attachments)[0];
var filesize = this.message._attachments[filename]["length"];
var filetype = filename.split(".")[1];
// ensure filesize is 0 for hiding message header if no data is available
if (
typeof filename === "undefined" ||
filename === "" ||
filename === "-" ||
filename === "null"
) {
filesize = 0;
}
2023-09-27 12:51:33 +00:00
2023-10-03 13:15:17 +00:00
return { filename: filename, filesize: filesize, filetype: filetype };
2023-09-27 12:51:33 +00:00
},
messageWidthClass() {
// Calculate a Bootstrap grid class based on message length
// Adjust the logic as needed to fit your requirements
if (this.message.msg.length <= 50) {
2023-10-03 13:15:17 +00:00
return "col-4";
2023-09-27 12:51:33 +00:00
} else if (this.message.msg.length <= 100) {
2023-10-03 13:15:17 +00:00
return "col-6";
2023-09-27 12:51:33 +00:00
} else {
2023-10-03 13:15:17 +00:00
return "col-9";
2023-09-27 12:51:33 +00:00
}
},
2023-10-03 13:15:17 +00:00
repeatMessage() {
repeatMessageTransmission(this.message._id);
2023-09-27 12:51:33 +00:00
},
2023-10-03 13:15:17 +00:00
deleteMessage() {
deleteMessageFromDB(this.message._id);
2023-09-27 12:51:33 +00:00
},
getDateTime() {
var datetime = new Date(this.message.timestamp * 1000).toLocaleString(
navigator.language,
{
2023-10-03 13:15:17 +00:00
hour: "2-digit",
minute: "2-digit",
},
2023-09-27 12:51:33 +00:00
);
return datetime;
},
},
};
</script>