209 lines
4.4 KiB
Vue
Raw Normal View History

<!----------------------------------------------------
File: Msg.vue
Author: Anthony Debucquoy
Scope: Extension messagerie
Description: Main msg page
----------------------------------------------------->
2024-03-22 13:54:52 +01:00
<script setup>
import { ref, reactive } from 'vue'
2024-03-29 14:30:46 +01:00
import { discussionsList, currentDiscussion, fetchDiscussion, createDiscussion, sendMessage, updateDiscussionName, invite, removeMember} from '@/rest/msg.js'
2024-03-27 19:52:48 +01:00
const msgContent = ref("");
2024-03-27 23:54:59 +01:00
const addMember = ref(false);
2024-03-22 13:54:52 +01:00
</script>
<template>
<div id="msg">
<div id="discList">
<div @click="fetchDiscussion(discussion.id)" class="discItem" v-for="discussion in discussionsList" :key="discussion.id">{{ discussion.name }}</div>
2024-03-27 19:52:48 +01:00
<button id="createDiscussion" @click="createDiscussion('New Discussion')">+</button>
</div>
2024-03-27 23:54:59 +01:00
<div id="discussion" v-if="currentDiscussion.length != 0">
<h1 id=msgName ><input class="InputTitle" type="text" @change="updateDiscussionName(currentDiscussion.id, currentDiscussion.name)" v-model="currentDiscussion.name"></h1>
<div id=msgs>
<div class="msg" v-for="msg in currentDiscussion.msgs" :sender="msg.sender" :key="msg.id">
2024-04-02 10:03:47 +02:00
{{ msg.content }}<br/>
<span class="sender" v-if="!msg.sender">{{msg.author.firstName}}</span>
</div>
</div>
<div id=messageBox>
2024-03-27 19:52:48 +01:00
<input type="text" v-model="msgContent">
<input type="submit" @click="sendMessage(currentDiscussion.id, msgContent, null)" value="send">
</div>
</div>
2024-03-27 23:54:59 +01:00
<div id="members" v-if="currentDiscussion.length != 0">
2024-03-29 14:30:46 +01:00
<div class="memberItem" v-for="member in currentDiscussion.members" @click="removeMember(currentDiscussion.id, member.regNo)" :key="member.id"><span>{{ member.firstName }} {{ member.lastName.toUpperCase() }}</span></div>
2024-03-27 23:54:59 +01:00
<input type=text id="addMembers" @focus="addMember = true" @blur="addMember = false;$event.target.value = ''" @change="invite(currentDiscussion.id, $event.target.value)" :placeholder="addMember ? 'Regno' : '+'"/>
</div>
2024-03-22 13:54:52 +01:00
</div>
</template>
<style scoped>
div#msg{
position: relative;
width: 100%;
height: 100%;
display: grid;
2024-03-27 23:54:59 +01:00
grid-template-columns: 20% auto 10%;
2024-03-22 13:54:52 +01:00
}
div#discList{
margin: 30px 0 30px 30px;
background-color: rgba(255, 255, 255, 0.05);
border-radius: 10px;
overflow: hidden;
padding: 10px;
display: flex;
flex-direction: column;
2024-03-27 23:54:59 +01:00
}
2024-03-22 13:54:52 +01:00
2024-03-27 23:54:59 +01:00
div#members{
margin: 30px 0;
border-radius: 10px 0 0 10px;
background-color: red;
background-color: rgba(255, 255, 255, 0.05);
overflow: hidden;
display: flex;
padding: 10px 0 0 10px;
flex-direction: column;
2024-03-22 13:54:52 +01:00
}
2024-03-27 19:52:48 +01:00
.InputTitle{
all: inherit;
margin: auto;
}
.discItem{
color: darkorange;
display: flex;
font-family: sans-serif;
font-weight: bold;
height: 4vh;
margin: 5px;
border-radius: 0 30px 30px 0;
align-items: center;
justify-content: center;
border: 1px solid darkorange;
}
2024-03-27 23:54:59 +01:00
.memberItem{
color: darkorange;
display: flex;
font-family: sans-serif;
font-weight: bold;
height: 4vh;
margin: 5px;
border-radius: 30px 0 0 30px;
align-items: center;
justify-content: center;
border: 1px solid darkorange;
}
2024-03-29 14:30:46 +01:00
.memberItem:hover span{
display: none;
}
.memberItem:hover{
background-color: red;
}
.memberItem:hover:before{
color: white;
content: "X"
}
#createDiscussion{
height: 4vh;
margin: 5px;
color: white;
background-color: green;
border-radius: 0 30px 30px 0;
border: none;
font-weight: 900;
font-size: 2em;
}
2024-03-27 23:54:59 +01:00
#addMembers{
height: 4vh;
margin: 5px;
text-align: center;
color: white;
background-color: green;
border-radius: 30px 0 0 30px;
border: none;
font-weight: 900;
font-size: 2em;
}
2024-03-22 13:54:52 +01:00
div#discussion{
display: flex;
flex-direction: column;
2024-03-22 13:54:52 +01:00
margin: 30px;
background-color: rgba(255, 255, 255, 0.05);
border-radius: 10px;
2024-03-29 14:31:22 +01:00
overflow: hidden;
2024-03-22 13:54:52 +01:00
}
#msgName{
text-align: center;
display: block;
2024-03-27 19:52:48 +01:00
background-color: #2a1981;
border-radius: 5px;
color: white;
width: 75%;
margin: 30px auto;
}
.discItem:hover{
background-color: gray;
}
#msgs{
display: flex;
flex-grow: 1;
flex-direction: column;
}
.msg {
background-color: aliceblue;
font-family: sans-serif;
margin: 10px;
padding: 5px;
border-radius: 3px;
max-width: 50%;
align-self: start;
}
2024-04-02 10:03:47 +02:00
.sender{
display: inline-block;
color: gray;
font-size: 0.5em;
}
.msg[sender=true]{
background-color: darkorange;
align-self: end;
}
#messageBox{
2024-03-29 14:31:22 +01:00
width: 100%;
height: 30px;
background-color: white;
display: flex;
}
#messageBox input[type="text"]{
2024-03-29 14:31:22 +01:00
all: inherit;
padding: 0 10px;
}
#messageBox input[type="submit"]{
2024-03-29 14:31:22 +01:00
border: inherit;
padding: 0 10px;
}
2024-03-22 13:54:52 +01:00
</style>