2024-04-05 08:57:19 +02:00
|
|
|
<!----------------------------------------------------
|
|
|
|
File: Forums.vue
|
|
|
|
Author: Anthony Debucquoy
|
|
|
|
Scope: Extension messagerie
|
|
|
|
Description: Forum des étudiants
|
|
|
|
----------------------------------------------------->
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, reactive } from 'vue'
|
|
|
|
import { getCourses } from '@/rest/courses.js'
|
2024-04-09 17:27:26 +02:00
|
|
|
import { ForumsOfCurrentCourse, getForumsOfCourse, createForum } from '@/rest/forum.js'
|
2024-04-05 08:57:19 +02:00
|
|
|
import { PostsOfCurrentForum, getPostsOfForum } from '@/rest/forum.js'
|
|
|
|
import { fetchedPost, fetchPost } from '@/rest/forum.js'
|
2024-04-09 17:27:26 +02:00
|
|
|
import { getSelf } from '@/rest/Users.js'
|
2024-04-05 08:57:19 +02:00
|
|
|
|
|
|
|
const courses = await reactive(getCourses());
|
|
|
|
const selectedCourse = ref();
|
|
|
|
const selectedForum = ref();
|
2024-04-09 17:27:26 +02:00
|
|
|
const Role = (await getSelf()).role;
|
|
|
|
|
|
|
|
const addForum = ref(false);
|
|
|
|
const addForumName = ref("");
|
2024-04-05 08:57:19 +02:00
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div id="app">
|
|
|
|
<div id="ForumSelector">
|
|
|
|
<select id="cours" value="" v-model="selectedCourse" @change="getForumsOfCourse(selectedCourse)">
|
|
|
|
<option v-for="course in courses" :value="course.courseId">{{course.title}}</option>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="forum" value="" v-model="selectedForum" @change="getPostsOfForum(selectedForum)" v-if="ForumsOfCurrentCourse != null">
|
|
|
|
<option v-for="forum in ForumsOfCurrentCourse" :value=forum.id>{{forum.name}}</option>
|
|
|
|
</select>
|
2024-04-09 17:27:26 +02:00
|
|
|
<button v-if="(Role === 'Admin' || Role === 'Teacher') && ForumsOfCurrentCourse != null " id="createPost" @click="addForum = true">+</button>
|
2024-04-05 08:57:19 +02:00
|
|
|
</div>
|
|
|
|
<div id="PostSelector" v-if="PostsOfCurrentForum != null">
|
|
|
|
<div @click="fetchPost(post.id)" class="postItem" v-for="post in PostsOfCurrentForum" :key="post.id">{{ post.name }}</div>
|
2024-04-09 17:27:26 +02:00
|
|
|
<button v-if="Role === 'Admin' || Role === 'Teacher' " id="createPost" @click="createPost()">+</button>
|
2024-04-05 08:57:19 +02:00
|
|
|
</div>
|
|
|
|
<div id="PostViewer" v-if="fetchedPost != null">
|
|
|
|
<div id="Post">
|
|
|
|
<h1>{{ fetchedPost.subject }}</h1>
|
|
|
|
{{fetchedPost.content}}
|
|
|
|
</div>
|
|
|
|
<div id="Messages">
|
|
|
|
<p v-for="msg in fetchedPost.messages">{{msg.author}} - {{msg.content}}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-09 17:27:26 +02:00
|
|
|
<div id="forumAdder" v-if=addForum @click.self="addForum = false">
|
|
|
|
<div id="addForumForm">
|
|
|
|
<label>New Forum:</label>
|
|
|
|
<input type="text" placeholder="Name" v-model=addForumName @keyup.enter="createForum(selectedCourse, $event.target.value); addForum = false;" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-05 08:57:19 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
2024-04-09 17:27:26 +02:00
|
|
|
#forumAdder{
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
background-color: #00000022;
|
|
|
|
z-index: 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
#addForumForm{
|
|
|
|
position: relative;
|
|
|
|
width: 30%;
|
|
|
|
left: calc(50% - 30% / 2);
|
|
|
|
top: calc(50% - 10% / 2);
|
|
|
|
border-radius: 10px;
|
|
|
|
height: 10%;
|
|
|
|
background-color: white;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
gap: 10px;
|
|
|
|
}
|
|
|
|
|
2024-04-05 08:57:19 +02:00
|
|
|
#app{
|
|
|
|
display: grid;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
grid-template: 5em auto / 25% 75%;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ForumSelector{
|
|
|
|
background-color: #FFFFFF0E;
|
|
|
|
grid-column: 1 / 3;
|
|
|
|
border-radius: 100px;
|
|
|
|
margin: 10px;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-around;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ForumSelector select{
|
|
|
|
background-color: #ffa000;
|
|
|
|
border: none;
|
|
|
|
margin: 10px;
|
|
|
|
border-radius: 10px;
|
|
|
|
width: 200px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ForumSelector button{
|
|
|
|
background-color: green;
|
|
|
|
border: none;
|
|
|
|
border-radius: 25%;
|
|
|
|
margin: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#PostSelector{
|
|
|
|
background-color: #FFFFFF0E;
|
|
|
|
border-radius: 0 25px 25px 0;
|
|
|
|
margin: 10px 0 10px 10px;
|
|
|
|
overflow: hidden;
|
|
|
|
padding: 10px;
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.postItem{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
.postItem:hover{
|
|
|
|
background-color: gray;
|
|
|
|
}
|
|
|
|
|
|
|
|
#PostViewer{
|
|
|
|
background-color: #FFFFFF0E;
|
|
|
|
border-radius: 25px;
|
|
|
|
margin: 10px;
|
|
|
|
|
|
|
|
max-height: 100%;
|
|
|
|
|
|
|
|
overflow: scroll;
|
|
|
|
}
|
|
|
|
|
|
|
|
#Post{
|
|
|
|
padding: 25px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#Messages{
|
|
|
|
padding: 25px;
|
|
|
|
border-top: 3px dotted white;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#Messages > p {
|
|
|
|
|
|
|
|
background-color: orange;
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|