1
0
forked from PGL/Clyde

Final Schedule - merge

This commit is contained in:
2024-04-21 18:10:00 +02:00
52 changed files with 1688 additions and 629 deletions

View File

@ -13,6 +13,7 @@ import ManageSchedule from "@/Apps/ManageSchedule.vue"
import ManageOwnedLessons from "@/Apps/ManageOwnLessons.vue";
import LessonRequests from "@/Apps/LessonRequests.vue";
import Msg from "@/Apps/Msg.vue"
import Forums from '@/Apps/Forums.vue'
import Payments from "@/Apps/Inscription/PaymentInfo.vue";
import ManageRequests from "@/Apps/Inscription/ManageRequests.vue";
@ -28,13 +29,14 @@ const apps = {
'/manage-owned-lessons': ManageOwnedLessons,
'/manage-schedule-requests' : LessonRequests,
'/msg' : Msg,
'/forums': Forums,
'/payments': Payments
}
const appsList = {
'Msg': { path: '#/msg', icon: 'fa-comment', text: i18n("app.messages") },
'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") },
'Forum': { path: '#/forum', icon: 'fa-envelope', text: i18n("app.forum") },
'Forum': { path: '#/forums', icon: 'fa-envelope', text: i18n("app.forum") },
'Schedule': { path: '#/schedule', icon: 'fa-calendar-days', text: i18n("app.schedules") },
'ManageSchedules': { path: '#/manage-schedule', icon: 'fa-calendar-days', text: i18n("app.manageSchedules")},
'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") },

View File

@ -69,3 +69,11 @@ export async function getCourses(role){
export async function alterCourse(id, changes){
return restPatch("/course/" + id, changes);
}
/**
* Return a list containing all the actual courses of a user
*/
export async function getUserActualCourses(){
return restGet("/usercourses")
}

View File

@ -0,0 +1,50 @@
/*******************************************************
* File: forum.js
* Author: Anthony Debucquoy
* Scope: Extension messagerie
* Description: Forum related functions and calls
*******************************************************/
import { ref } from 'vue'
import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
/**
* List forums of a course
*/
export async function getForumsOfCourse(id){
ForumsOfCurrentCourse.value = await restGet("/forums/" + id)
}
export const ForumsOfCurrentCourse = ref();
export function createForum(id, name){
restPost("/forums/" + id, {name: name}).then(_ => getForumsOfCourse(id));
}
/**
* List post of a specified forum
*/
export async function getPostsOfForum(id){
if(id != null){
PostsOfCurrentForum.value = await restGet("/forum/" + id);
}
}
export function createPost(id, subject, content){
restPost("/forum/" + id, {subject: subject, content: content}).then(_ => getPostsOfForum(id));
}
export const PostsOfCurrentForum = ref();
/**
* Get a post and its responses
*/
export async function fetchPost(id){
fetchedPost.value = await restGet("/forum/post/" + id);
}
export function sendAnswer(id, content){
restPost("/forum/post/" + id, {content: content}).then(_ => fetchPost(id))
}
export const fetchedPost = ref();

View File

@ -74,4 +74,8 @@ export async function getExempReq(id){
export async function editExempReqState(id, newstate){
return restPatch("/exemptionsreq/"+id+"/"+newstate)
}
export async function getExempByUser(userId){
return restGet("/exemptionreq/"+userId)
}

View File

@ -3,29 +3,28 @@ import { toast } from 'vue3-toastify'
const restURL = import.meta.env.VITE_CLYDE_MODE === 'container' ? "http://localhost:8080": import.meta.env.DEV ? "http://localhost:8080" : "https://clyde.herisson.ovh/api"
export async function restGet(endPoint) {
return await _rest(endPoint, {method: "GET"});
export function restGet(endPoint) {
return _rest(endPoint, {method: "GET"});
}
export async function restPost(endPoint, data) {
return await _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
export function restPost(endPoint, data) {
return _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
}
export async function restPostFile(endPoint, file){
export function restPostFile(endPoint, file){
let headers = new Headers();
return await _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
return _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
}
export async function restDelete(endPoint) {
return await _rest(endPoint, {method: "DELETE"});
export function restDelete(endPoint) {
return _rest(endPoint, {method: "DELETE"});
}
export async function restDeleteItem(endPoint, data){
return await _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
export function restDeleteItem(endPoint, data){
return _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
}
export async function restPatch(endPoint, data) {
return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
export function restPatch(endPoint, data) {
return _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
}
/**
@ -37,7 +36,7 @@ export async function restPatch(endPoint, data) {
*
* @Example _rest("/ping", {user: data}) -> {id:0, txt:"pong"}
*/
async function _rest(endPoint, config){
function _rest(endPoint, config){
endPoint.at(0) != "/" ? console.error("Carefull, you certainly should put a / at the begenning of your endPoint ") : true;
let session_token = getCookie("session_token");
let headers = new Headers({
@ -45,13 +44,16 @@ async function _rest(endPoint, config){
'Content-Type': 'application/json',
});
config['headers'] = config['headers'] == null ? headers : config['headers'];
return toast.promise(fetch(restURL + endPoint, config),
{
let ret = fetch(restURL + endPoint, config);
if(config['toast']){
ret = toast.promise(ret,
{
pending: config['pending'] != null ? config['pending'] : 'pending',
error: config['error'] != null ? config['error'] : 'Network Failure...',
success: config['success'] != null ? config['success'] : {render(res){
return res.data.ok ? "Success" : "error";
}},
})
.then( e => e.json()).catch( e => e );
}}})
}
return ret.then( e => e.json()).catch( e => e );
}

View File

@ -13,11 +13,11 @@ export async function uploadProfilePicture(file){
/**
* More generic version of the upload method
* More generic version of the uploadProfilePicture method
*/
export async function uploadFile(file, type){
const formData = new FormData();
formData.append("file", file[0]);
return restPostFile("/upload/"+type, formData)
}
}