first version of the frontend for messages
This commit is contained in:
parent
2dfa0a0ee0
commit
7b9f021c24
@ -1,12 +1,35 @@
|
||||
<!----------------------------------------------------
|
||||
File: Msg.vue
|
||||
Author: Anthony Debucquoy
|
||||
Scope: Extension messagerie
|
||||
Description: Main msg page
|
||||
----------------------------------------------------->
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { getDiscussions, currentDiscussion, fetchDiscussion } from '@/rest/msg.js'
|
||||
|
||||
const discussionsList = reactive(await getDiscussions());
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="msg">
|
||||
<div id="discList"></div>
|
||||
<div id="discussion"></div>
|
||||
<div id="discList">
|
||||
<div @click="fetchDiscussion(discussion.id)" class="discItem" v-for="discussion in discussionsList" :key="discussion.id">{{ discussion.name }}</div>
|
||||
</div>
|
||||
<div id="discussion">
|
||||
<h1 id=msgName >{{currentDiscussion.name}}</h1>
|
||||
<div id=msgs>
|
||||
<div class="msg" v-for="msg in currentDiscussion.msgs" :sender="msg.sender" :key="msg.id">
|
||||
{{ msg.text }}
|
||||
</div>
|
||||
</div>
|
||||
<div id=messageBox>
|
||||
<input type="text" name="messageBox" value="">
|
||||
<input type="submit" name="" id="" value="send">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -25,13 +48,84 @@ div#discList{
|
||||
margin: 30px 0 30px 30px;
|
||||
background-color: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
div#discussion{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 30px;
|
||||
background-color: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#msgName{
|
||||
text-align: center;
|
||||
display: block;
|
||||
background-color: #0202f755;
|
||||
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;
|
||||
}
|
||||
|
||||
.msg[sender=true]{
|
||||
background-color: darkorange;
|
||||
align-self: end;
|
||||
}
|
||||
|
||||
#messageBox{
|
||||
display: flex;
|
||||
margin: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#messageBox input[type="text"]{
|
||||
align-self: end;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
#messageBox input[type="submit"]{
|
||||
position: absolute;
|
||||
right: 50px;
|
||||
margin: 2px;
|
||||
border: none;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@ -6,6 +6,9 @@
|
||||
*******************************************************/
|
||||
|
||||
import { restGet } from './restConsumer.js'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const currentDiscussion = ref({});
|
||||
|
||||
export async function getDiscussions(){
|
||||
return [
|
||||
@ -18,8 +21,65 @@ export async function getDiscussions(){
|
||||
id: 2,
|
||||
name: "Discussion#2",
|
||||
members: [1, 4],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Discussion#3",
|
||||
members: [1, 3],
|
||||
}
|
||||
]
|
||||
return restGet("/discussions");
|
||||
// return restGet("/discussions");
|
||||
}
|
||||
|
||||
export async function fetchDiscussion(id){
|
||||
currentDiscussion.value = {
|
||||
id: id,
|
||||
name: "Discussion#2",
|
||||
msgs: [
|
||||
{
|
||||
id: 1,
|
||||
author: 1,
|
||||
sender: true,
|
||||
attachment: null,
|
||||
text: "Hello world!"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
author: 2,
|
||||
sender: false,
|
||||
attachment: null,
|
||||
text: "Hello What?"
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
author: 2,
|
||||
sender: false,
|
||||
attachment: null,
|
||||
text: "You morron"
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
author: 1,
|
||||
sender: true,
|
||||
attachment: null,
|
||||
text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
},
|
||||
// {
|
||||
// id: 5,
|
||||
// author: 1,
|
||||
// sender: true,
|
||||
// attachment: null,
|
||||
// text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
// },
|
||||
{
|
||||
id: 6,
|
||||
author: 2,
|
||||
sender: false,
|
||||
attachment: null,
|
||||
text: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
||||
}
|
||||
]
|
||||
}
|
||||
// currentDiscussion.value = restGet("/discussion/" + id);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user