Merge pull request 'UploadAPI and profilePicture' (#102) from tonitch/front/apiUpload into master
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m13s
deploy to production / deploy-backend (push) Successful in 2m21s
Build and test FrontEnd / Build-frontend (push) Successful in 24s
Build and test backend / Test-backend (push) Successful in 1m24s
deploy to production / deploy-frontend (push) Successful in 26s
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m13s
deploy to production / deploy-backend (push) Successful in 2m21s
Build and test FrontEnd / Build-frontend (push) Successful in 24s
Build and test backend / Test-backend (push) Successful in 1m24s
deploy to production / deploy-frontend (push) Successful in 26s
Reviewed-on: #102 Reviewed-by: LeoMoulin <leomoulin125@gmail.com> Reviewed-by: Wal <karpinskiwal@gmail.com> Reviewed-by: Maxime <231026@umons.ac.be>
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
<script setup>
|
||||
import { login , register} from '@/rest/Users.js'
|
||||
import { ref } from 'vue'
|
||||
import i18n from '@/i18n.js'
|
||||
import { login , register } from '@/rest/Users.js'
|
||||
import { uploadProfilePicture } from '@/rest/uploads.js'
|
||||
|
||||
const loginPage= ref(true)
|
||||
const page = ref(0)
|
||||
|
||||
@ -23,6 +25,8 @@
|
||||
const registerInfos= [{_surname:surname},{_firstname:firstname},{_birthday:birthday},{_passwordOUT:passwordOUT},
|
||||
{_passwordConfirm:passwordConfirm},{_emailOUT:emailOUT},{_address:address},{_country:country},{_cursus:cursus}]
|
||||
|
||||
const imageSaved = ref(false)
|
||||
const ppData = ref(false)
|
||||
</script>
|
||||
|
||||
|
||||
@ -99,6 +103,10 @@
|
||||
<p>{{i18n("login.guest.country")}}</p>
|
||||
<input type="text" v-model="country">
|
||||
</div>
|
||||
<form novalidate enctype="multipart/form-data" class="inputBox">
|
||||
<p>ProfilePicture</p>
|
||||
<input type="file" :disabled="imageSaved" @change="ppData = uploadProfilePicture($event.target.files); imageSaved = true;" accept="image/*">
|
||||
</form>
|
||||
<div class="inputBox">
|
||||
<p>{{i18n("curriculum").toUpperCase()}}</p>
|
||||
<select v-model="cursus">
|
||||
|
@ -11,6 +11,11 @@ export async function restPost(endPoint, data) {
|
||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: JSON.stringify(data)});
|
||||
}
|
||||
|
||||
export async function restPostFile(endPoint, file){
|
||||
let headers = new Headers();
|
||||
return await _rest(endPoint, {method: "POST", credentials: 'include', body: file, headers: headers });
|
||||
}
|
||||
|
||||
export async function restDelete(endPoint, data) {
|
||||
return await _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
|
||||
}
|
||||
@ -35,7 +40,7 @@ async function _rest(endPoint, config){
|
||||
'Authorization': session_token,
|
||||
'Content-Type': 'application/json',
|
||||
});
|
||||
config['headers'] = headers;
|
||||
config['headers'] = config['headers'] == null ? headers : config['headers'];
|
||||
return toast.promise(fetch(restURL + endPoint, config),
|
||||
{
|
||||
pending: config['pending'] != null ? config['pending'] : 'pending',
|
||||
|
11
frontend/src/rest/uploads.js
Normal file
11
frontend/src/rest/uploads.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { restPostFile } from '@/rest/restConsumer.js'
|
||||
|
||||
|
||||
/**
|
||||
* Upload a file to the server and return the url of this image
|
||||
*/
|
||||
export async function uploadProfilePicture(file){
|
||||
const formData = new FormData();
|
||||
formData.append("file", file[0]);
|
||||
return restPostFile("/upload/ProfilePicture", formData)
|
||||
}
|
Reference in New Issue
Block a user