From f8d60f40fc0b0a89ef2f2edb780382f36b1035ff Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Thu, 18 Apr 2024 08:32:06 +0200 Subject: [PATCH 01/10] Removing toaster at every request It is possible to explicitly request a toaster for a request by setting its config['toast'] to true --- frontend/src/rest/restConsumer.js | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/frontend/src/rest/restConsumer.js b/frontend/src/rest/restConsumer.js index 1af979e..7fce929 100644 --- a/frontend/src/rest/restConsumer.js +++ b/frontend/src/rest/restConsumer.js @@ -3,25 +3,25 @@ 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 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)}); } /** @@ -33,7 +33,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({ @@ -41,13 +41,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 ); } From 5a57fc78f3e318669a3cc02a98a82e1cf4be08d9 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Fri, 19 Apr 2024 09:31:55 +0200 Subject: [PATCH 02/10] Generalize the ExternalCurriculumList interface so it fits for inscriptionRequest, Studentlist, and inscriptionform --- .../src/Apps/Inscription/AboutRequest.vue | 2 +- .../Inscription/ExternalCurriculumList.vue | 73 +++++++++++++++---- frontend/src/Apps/Login.vue | 58 ++------------- 3 files changed, 68 insertions(+), 65 deletions(-) diff --git a/frontend/src/Apps/Inscription/AboutRequest.vue b/frontend/src/Apps/Inscription/AboutRequest.vue index 15c72f5..ec8ed74 100644 --- a/frontend/src/Apps/Inscription/AboutRequest.vue +++ b/frontend/src/Apps/Inscription/AboutRequest.vue @@ -62,7 +62,7 @@ async function editEquivalence(id, newstate){
- +
diff --git a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue index eba1cdf..c467853 100644 --- a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue +++ b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue @@ -4,15 +4,23 @@ import {getSelf} from "@/rest/Users.js"; import {createExternalCurriculum, getExternalCurriculumByUser} from "@/rest/externalCurriculum.js"; - //mode 0 = externalcurr related to inscrreq, 1 = externalcurr related to user + //mode 0 = externalcurr related to inscrreq, 1 = externalcurr related to user, 2 inscription procedure const props = defineProps(["extCurrList", "mode"]) - const extCurrList = ref(props.extCurrList) + //Only usefull to pass the external curr array in the inscription procedure + const externalCurrTab = defineModel(); + + const extCurrList = ref({}) + let extNum = 0 + const User = ref({}) + + if (props.mode === 1){ + User.value = await getSelf() + } - const User = await getSelf() const list = ref(true) - + const editmode = ref(false) const notcompletedCheck = ref(false); const externalCurr = reactive({ @@ -28,22 +36,49 @@ if (props.mode === 1){ externalCurr.userRegNo = props.extCurrList[0].user.regNo + }else if(props.mode === 2){ + extCurrList.value = externalCurrTab.value + } + + if(props.mode !== 2){ + extCurrList.value = props.extCurrList + console.log("oe") + } + + function deleteExtCursus(extcursus){ + externalCurrTab.value.splice(externalCurrTab.value.indexOf(extcursus),1) } async function postExternalCurr(){ - await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, externalCurr.justifdocUrl, externalCurr.userRegNo); - //We refresh the list - extCurrList.value = await getExternalCurriculumByUser(externalCurr.userRegNo); - list.value = !list.value; + if (props.mode === 1){ + await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, externalCurr.justifdocUrl, externalCurr.userRegNo); + //We refresh the list + extCurrList.value = await getExternalCurriculumByUser(externalCurr.userRegNo); + list.value = !list.value; + }else if (props.mode === 2){ + externalCurrTab.value.push({ + inscriptionRequestId : externalCurr.inscriptionRequestId, + school:externalCurr.school, + formation :externalCurr.formation, + completion : externalCurr.completion, + startYear : externalCurr.startYear, + endYear: externalCurr.endYear, + justifdocUrl : externalCurr.justifdocUrl, + userRegNo : externalCurr.userRegNo + }); + extCurrList.value = externalCurrTab.value + list.value = !list.value; + console.log(externalCurrTab.value) + } } diff --git a/frontend/src/Apps/Inscription/ManageRequests.vue b/frontend/src/Apps/Inscription/ManageRequests.vue index 8fd7ddf..1aa9bf0 100644 --- a/frontend/src/Apps/Inscription/ManageRequests.vue +++ b/frontend/src/Apps/Inscription/ManageRequests.vue @@ -1,6 +1,6 @@ @@ -118,6 +119,10 @@

Année de fin

+
+

Veuillez soumettre un document attestant de ce parcours

+ +
diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index 531259b..7080f26 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -108,13 +108,13 @@ const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, identityCardFile.url, new Date(), outputs.equivalenceState, justif); for (let item in externalCurrTab.value){ - await createExternalCurriculum(val.id, externalCurrTab.value[item].school, externalCurrTab.value[item].formation, externalCurrTab.value[item].completion, externalCurrTab.value[item].startYear, externalCurrTab.value[item].endYear, externalCurrTab.value[item].justifdocUrl); + const temp = await uploadFile(externalCurrTab.value[item].justifdocUrl, "JustificationDocument") + await createExternalCurriculum(val.id, externalCurrTab.value[item].school, externalCurrTab.value[item].formation, externalCurrTab.value[item].completion, externalCurrTab.value[item].startYear, externalCurrTab.value[item].endYear, temp.value.url); } } - @@ -113,4 +113,12 @@ async function editExemp(newstate){ background-color:rgb(50,50,50); border-radius:20px; } + +button{ + border:none; + background-color:rgb(239, 60, 168); + border-radius:10px; + height:35px; + margin-top:10px; +} \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/AboutRequest.vue b/frontend/src/Apps/Inscription/AboutRequest.vue index 77565ed..efe401b 100644 --- a/frontend/src/Apps/Inscription/AboutRequest.vue +++ b/frontend/src/Apps/Inscription/AboutRequest.vue @@ -31,7 +31,7 @@ async function editEquivalence(id, newstate){ diff --git a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue index 88fefbb..e608777 100644 --- a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue +++ b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue @@ -53,7 +53,7 @@ async function postExternalCurr(){ if (props.mode === 1){ const temp = await uploadFile(externalCurr.justifdocUrl, "JustificationDocument") - await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, temp.value.url, externalCurr.userRegNo); + await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, temp.url, externalCurr.userRegNo); //We refresh the list extCurrList.value = await getExternalCurriculumByUser(externalCurr.userRegNo); list.value = !list.value; @@ -77,9 +77,9 @@