Link back and front all get #115

Merged
tonitch merged 40 commits from wal/front/listingUsers into master 2024-03-18 20:20:37 +01:00
3 changed files with 106 additions and 53 deletions
Showing only changes of commit 36fc33c3e9 - Show all commits

View File

@ -1,53 +1,39 @@
<script setup>
import {reactive, ref } from 'vue'
import {getSelf} from '../rest/Users.js'
import {getSelf,alterSelf} from '../rest/Users.js'
import i18n from "@/i18n.js"
import { uploadProfilePicture } from '@/rest/uploads.js'
const user = await getSelf();
console.log(user)
console.log(user.role)
console.log("test")
/*
Teacher user
const user =reactive({
profilPicture:"../assets/clyde.png",
lastName:"Ghost",
firstName:"Clyde",
role:"teacher",
address: "Radiator Springs",
email:"ClydeGhost@gmail.com",
coursesOwned:[
{
"id": 12,
"name": "Math pour l'info",
"faculty": "science",
"teacher": 42,
"Assistants": []},
{
"id": 42,
"name": "Fonctionnement des ordinateurs",
"credits": 11,
"faculty": "science",
"teacher": 42,
"Assistants": []},
console.log(user);
],
faculty:"Science",
})*/
const modif = ref(false);
const curric = ref(false);
const unreg = ref(false);
const reg = ref(false);
const toModify = Object.assign({}, user);
function getPP(){
return user.profilePicture
}
const modif = ref(false);
const curric = ref(false);
const unreg = ref(false);
const reg = ref(false);
const toModify = {
profilPictureUrl:null,
email:null,
adress:null,
password:null,
};
function ChangeInfos(){
for (const [key, value] in Object.entries(toModify)){
if(value !== null){
alterSelf({key:value})
}
}
}
function getPP(){
return user.profilePictureUrl
}
</script>
<template>
<div class="body">
<div class="container">
@ -56,7 +42,7 @@ function getPP(){
</div>
<div class="globalInfos">
<div v-if="modif==false" class="infosContainer" >
<div v-if="modif==false && curric==false && unreg==false && reg==false " class="infosContainer" >
<div>
{{user.firstName}} {{user.lastName}}
</div>
@ -75,12 +61,12 @@ function getPP(){
<div v-if="(user.role==='Student')">
<button @click="reg=!reg">{{i18n("profile.reRegister")}}</button>
<button @click="unreg=!unreg" style="float:right;background-color:rgb(150,0,0);">{{i18n("profile.unRegister")}}</button>
</div>
<div v-if="(user.role==='Student')">
<button @click="curric=!curric">{{i18n("profile.change.curriculum")}}</button>
</div>
</div>
<div v-else class="infosContainer">
<div v-else-if="modif" class="infosContainer">
<div>
{{i18n("profile.picture")}}:
<input type="file" @change="user.profilPicture = uploadProfilePicture($event.target.files);" accept="image/*">
@ -102,17 +88,87 @@ function getPP(){
<input type="password" id="confirm">
</div>
<div>
<button @click=" modif=!modif">{{i18n("courses.confirm")}}</button>
<button @click=" modif=!modif; ChangeInfos();">{{i18n("courses.confirm")}}</button>
</div>
</div>
<div v-else-if="curric" class="infosContainer">
<div>
{{i18n("curriculum")}}:
<select v-model="curriculum">
<option v-for="item in currcula">{{item}}</option>
</select>
</div>
<div>
E-mail:
<input type="mail" v-model="mail">
</div>
<div>
{{i18n("login.password")}}:
<input type="password" v-model="assword">
</div>
<div>
{{i18n("login.cPassword")}}:
<input type="password" id="confirm">
</div>
<div>
<button @click=" curric=!curric;">{{i18n("courses.confirm")}}</button>
</div>
</div>
<div v-else-if="reg" class="infosContainer">
<div>
E-mail:
<input type="mail" v-model="toModify.email" />
</div>
<div>
{{i18n("profile.address")}}:
<input type="text" v-model="toModify.address">
</div>
<div>
{{i18n("login.password")}}:
<input type="password" v-model="toModify.password">
</div>
<div>
{{i18n("login.cPassword")}}:
<input type="password" id="confirm">
</div>
<div>
<button @click=" reg=!reg;">{{i18n("courses.confirm")}}</button>
</div>
</div>
<div v-else-if="unreg" class="infosContainer">
<div>
E-mail:
<input type="mail" v-model="toModify.email" />
</div>
<div>
{{i18n("profile.address")}}:
<input type="text" v-model="toModify.address">
</div>
<div>
{{i18n("login.password")}}:
<input type="password" v-model="toModify.password">
</div>
<div>
{{i18n("login.cPassword")}}:
<input type="password" id="confirm">
</div>
<div>
<button @click=" unreg=!unreg;">{{i18n("courses.confirm")}}</button>
</div>
</div>
</div>
<div v-if="modif==false"class="moreInfos">
<div v-if="modif==false && curric==false && unreg==false && reg==false "class="moreInfos">
<div v-if="(user.role==='Student')">
<div class="listTitle">
{{i18n("profile.course.list")}}
</div>
<div class="listElement "
<div class="listElement "
v-for="item in user.curriculum">
<div class=" containerElement">
<div class="name"> {{item.name}} </div>
@ -133,10 +189,6 @@ function getPP(){
{{item.name}}
</div>
</div>
<div>
</div>
</div>
</div>
</div>

View File

@ -4,7 +4,8 @@
import { reactive } from 'vue'
import { getAllUsers } from '../rest/Users.js'
const users = getAllUsers();
const users = await getAllUsers();
</script>
<template>
<div v-for="item in users">

View File

@ -1,4 +1,4 @@
import { restGet, restPost } from './restConsumer.js'
import { restGet, restPost, restPatch} from './restConsumer.js'
import { getCookie, setCookie } from '@/utils.js'
export async function login(user, pass, exp){