Merge remote-tracking branch 'origin/master'
This commit is contained in:
		@ -10,6 +10,7 @@ import Courses from "@/Apps/ManageCourses.vue"
 | 
			
		||||
import Users from "@/Apps/UsersList.vue"
 | 
			
		||||
import Students from "@/Apps/StudentsList.vue"
 | 
			
		||||
import ResearcherProfile from "@/Apps/ScientificPublications/ResearcherProfile.vue";
 | 
			
		||||
import Msg from "@/Apps/Msg.vue"
 | 
			
		||||
 | 
			
		||||
const apps = {
 | 
			
		||||
		'/login': LoginPage,
 | 
			
		||||
@ -19,6 +20,7 @@ const apps = {
 | 
			
		||||
		'/users-list' : Users,
 | 
			
		||||
		'/students-list' : Students,
 | 
			
		||||
		'/researcher-profile' : ResearcherProfile,
 | 
			
		||||
		'/msg' : Msg,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const appsList = {
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								frontend/src/rest/msg.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								frontend/src/rest/msg.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
			
		||||
/*******************************************************
 | 
			
		||||
 * File: msg.js
 | 
			
		||||
 * Author: Anthony Debucquoy
 | 
			
		||||
 * Scope: Extension messagerie
 | 
			
		||||
 * Description: Messages frontend api consumer
 | 
			
		||||
 *******************************************************/
 | 
			
		||||
 | 
			
		||||
import { restGet, restPost, restPatch } from './restConsumer.js'
 | 
			
		||||
import { ref } from 'vue'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * - id
 | 
			
		||||
 * - name
 | 
			
		||||
 * - members
 | 
			
		||||
 */
 | 
			
		||||
export const discussionsList = ref();
 | 
			
		||||
export const currentDiscussion = ref([]);
 | 
			
		||||
let timerSet = false
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export async function createDiscussion(name){
 | 
			
		||||
	let disc = await restPost("/discussion", {name: name});
 | 
			
		||||
	discussionsList.value.push(disc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export async function invite(id, regNo){
 | 
			
		||||
	restPatch("/discussion/"+ id+ "/add", {regNo: parseInt(regNo)}).then(() => fetchDiscussion(id))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function removeMember(id, regNo){
 | 
			
		||||
	restPatch("/discussion/"+ id+ "/remove", {regNo: parseInt(regNo)}).then(() => fetchDiscussion(id))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function sendMessage(id, content, responseId){
 | 
			
		||||
	let data = {
 | 
			
		||||
		content: content,
 | 
			
		||||
		response: responseId,
 | 
			
		||||
	}
 | 
			
		||||
	restPost("/discussion/" + id, data).then(() => fetchDiscussion(id));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function updateDiscussionName(id, name){
 | 
			
		||||
	restPatch("/discussion/" + id, {name: name}).then(() => fetchDiscussions());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async function fetchDiscussions(){
 | 
			
		||||
	discussionsList.value = await restGet("/discussions");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function fetchDiscussion(id){
 | 
			
		||||
	currentDiscussion.value = await restGet("/discussion/" + id);
 | 
			
		||||
	if(!timerSet){
 | 
			
		||||
		timerSet = true;
 | 
			
		||||
		setTimeout(() => {timerSet = false;fetchDiscussion(currentDiscussion.value.id)} , 5000);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
await fetchDiscussions();
 | 
			
		||||
		Reference in New Issue
	
	Block a user