Fix the profilepicture url issue (it wasn't sent to the db)
add a prototype of a more generic uploadfile function in uploads.js makes the distinction between a master cursus and a bachelor cursus in display
This commit is contained in:
		| @ -9,10 +9,10 @@ let request = await getRegisters(props.target); | ||||
| const cursus = await getcurriculum(request.curriculum); | ||||
|  | ||||
| function getPP(){ | ||||
|   if(request.profilePicture === null){ | ||||
|   if(request.profilePictureUrl === null){ | ||||
|     return "/Clyde.png" | ||||
|   } | ||||
|   return request.profilePicture; | ||||
|   return request.profilePictureUrl; | ||||
| } | ||||
| </script> | ||||
|  | ||||
|  | ||||
| @ -13,7 +13,6 @@ | ||||
|   async function upPage(id,review){ | ||||
|     await validateRegister(id,review); | ||||
|     requests.value = await getAllRegisters(); | ||||
|  | ||||
|   } | ||||
| </script> | ||||
|  | ||||
|  | ||||
| @ -24,9 +24,12 @@ | ||||
|  | ||||
|   const submitValue= ref(i18n("login.guest.submit")) | ||||
|   const passwordConfirm=ref("") | ||||
|   | ||||
|  | ||||
|   //Allows to display MA or BAB for years | ||||
|   let yearprefix = ""; | ||||
|  | ||||
|   const imageSaved = ref(false) | ||||
|   const ppData = ref(false) | ||||
|   let ppData = ""; | ||||
|  | ||||
|   const curricula= await getAllCurriculums(); | ||||
|    | ||||
| @ -50,7 +53,20 @@ | ||||
|   disconnect(); | ||||
|   window.location.reload();} | ||||
|  | ||||
|    | ||||
|   async function uploadPP(arg){ | ||||
|     const data = await uploadProfilePicture(arg); | ||||
|     ppData = data.url; | ||||
|     console.log(ppData); | ||||
|   } | ||||
|  | ||||
|   //This functions makes the distinction between a master cursus (year 4 or more) and a bachelor cursus (year 3 or less) | ||||
|   function getCursusDisplay(cursus){ | ||||
|     if (cursus.year <= 3){ | ||||
|       return "BAB " + cursus.year + " " + cursus.option; | ||||
|     }else{ | ||||
|       return "MA" + (parseInt(cursus.year)-3).toString() + " " + cursus.option; | ||||
|     } | ||||
|   } | ||||
|  | ||||
| </script> | ||||
|  | ||||
| @ -130,16 +146,16 @@ | ||||
|               </div> | ||||
|               <form novalidate enctype="multipart/form-data" class="inputBox"> | ||||
|               	<p>{{i18n("profile.picture").toUpperCase()}}</p>  | ||||
| 				<input type="file" :disabled="imageSaved" @change="ppData = uploadProfilePicture($event.target.files); imageSaved = true;" accept="image/*"> | ||||
| 				        <input type="file" @change="uploadPP($event.target.files); imageSaved = true;" accept="image/*"> | ||||
|               </form> | ||||
|               <div class="inputBox"> | ||||
|                 <p>{{i18n("Curriculum").toUpperCase()}}</p>  | ||||
|                   <select v-model="outputs.curriculum"> | ||||
|                     <option v-for="item in curricula">{{item.curriculumId}}</option> | ||||
|                     <option v-for="item in curricula">{{getCursusDisplay(item)}}</option> | ||||
|                   </select> | ||||
|               </div> | ||||
|               <div style="align-self:center;" class="inputBox"> | ||||
|                 <button style="margin-top:25px;" @click="page++"> | ||||
|                 <button style="margin-top:25px;" @click="page++; register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, null, new Date());"> | ||||
|                   {{i18n("login.guest.nextpage")}} | ||||
|                 </button> | ||||
|               </div> | ||||
| @ -153,7 +169,6 @@ | ||||
|             <div v-if="page === 2"> | ||||
|               <form novalidate enctype="multipart/form-data" class="inputBox"> | ||||
|                 Carte d'identité : | ||||
|  | ||||
|               </form> | ||||
|             </div> | ||||
|           </form> | ||||
|  | ||||
| @ -26,7 +26,7 @@ export function disconnect(){ | ||||
|  * @param curriculum  | ||||
|  * @param imageId	id of the image in database returned when uploaded | ||||
|  */ | ||||
| export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId){ | ||||
| export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId, identityCardId, submissionDate){ | ||||
| 	return restPost("/register", { | ||||
| 		firstName: firstname, | ||||
| 		lastName: lastname, | ||||
| @ -36,7 +36,9 @@ export async function register(firstname, lastname, birthDate, password, email, | ||||
| 		address: address, | ||||
| 		country: country, | ||||
| 		curriculumId: curriculumId, | ||||
|     profilePictureUrl: imageId, | ||||
|     	profilePicture: imageId, | ||||
| 		identityCard : identityCardId, | ||||
| 		submissionDate : submissionDate | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| @ -52,7 +54,7 @@ export async function register(firstname, lastname, birthDate, password, email, | ||||
|  * @param country | ||||
|  * @param imageId	id of the image in database returned when uploaded | ||||
|  * | ||||
|  * PS: the password is not is not required as it is generated by the backend and sent to the user | ||||
|  * PS: the password is not required as it is generated by the backend and sent to the user | ||||
|  * by mail. it's up to the user to change it if he cares about security | ||||
|  */ | ||||
| export async function createUser(firstname, lastname, birthDate, email, address, country, role, imageId){ | ||||
|  | ||||
| @ -7,5 +7,17 @@ import { restPostFile } from '@/rest/restConsumer.js' | ||||
| export async function uploadProfilePicture(file){ | ||||
| 	const formData = new FormData(); | ||||
| 	formData.append("file", file[0]); | ||||
| 	return restPostFile("/upload/ProfilePicture", formData) | ||||
|  | ||||
| 	return restPostFile("/upload/ProfilePicture", formData); | ||||
| } | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * More generic version of the upload method | ||||
|  */ | ||||
|  | ||||
| export async function uploadFile(file, type){ | ||||
| 	const formData = new FormData(); | ||||
| 	formData.append("file", file[0]); | ||||
| 	return restPostFile("/upload/"+type, formData) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user