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
8 changed files with 46 additions and 33 deletions
Showing only changes of commit 4715441afd - Show all commits

View File

@ -53,9 +53,9 @@ public class MockController {
User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
User joke = new User("hhoo","yeay","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
User jojo = new User("hhoo","yeay","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService"));
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena));
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo));
userRepo.saveAll(mockUsers);

View File

@ -125,7 +125,7 @@ public class UserController {
@DeleteMapping("/user/{id}")
public ResponseEntity<String> deleteStudent(@RequestHeader("Authorization") String token, @PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token) || id.equals(authServ.getUserFromToken(token).getRegNo()))
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token) && !id.equals(authServ.getUserFromToken(token).getRegNo()))
return new UnauthorizedResponse<>(null);
User toDelete = userService.getUserById(id);

View File

@ -36,7 +36,6 @@
}, "500");
}
function verifyInputs(pass){
console.log(pass)
if(pass==passwordConfirm.value){
page.value++;
return toast('Password and Confirm Password are correct.', {
@ -141,7 +140,7 @@
</select>
</div>
<div style="align-self:center;" class="inputBox">
<button style="margin-top:25px;" @click="console.log(outputs);register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData);">
<button style="margin-top:25px;" @click="register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData);">
{{i18n("login.guest.submit")}}
</button>
</div>

View File

@ -10,8 +10,6 @@
const curriculum = ref(await getCourses(self.role));
const profList = await getTeachers();
console.log(curriculum)
console.log(profList)
const createMod = ref(false)
const deleteMod = ref(false)

View File

@ -6,19 +6,15 @@
import i18n from "@/i18n.js"
import { uploadProfilePicture } from '@/rest/uploads.js'
const user = await getSelf();
console.log(user);
const user = ref(await getSelf());
const UserCurriculum = ref("");
const curricula = ref (await getAllCurriculums());
console.log(curricula)
console.log(user.role === "Teacher")
if(user.role === "Student"){
if(user.value.role === "Student"){
UserCurriculum.value = await getSelfCurriculum();
}
if(user.role === "Teacher"){
UserCurriculum.value = await getCourses("Teacher");
console.log(UserCurriculum.value)
}
const modif = ref(false);
const curric = ref(false);
@ -27,7 +23,7 @@
const pattern = {
profilPictureUrl:null,
email:null,
adress:null,
address:null,
password:null,
};
@ -46,17 +42,38 @@
inputs=Object.assign({},list);
}
function ChangeInfos(){
for (const [key, value] in Object.entries(toModify)){
if(value !== null){
alterSelf({key:value});
}
async function ChangeInfos(){
for (let element in toModify){
if (element =="email" && (toModify[element] !== null)){
await alterSelf(user.value.regNo,{email : toModify[element]});
}
if (element =="profilPictureUrl" && (toModify[element] !== null)){
await alterSelf(user.value.regNo,{ profilPictureUrl : toModify[element]});
}
else if(element == "address" && (toModify[element] !== null)){
await alterSelf(user.value.regNo,{address : toModify[element]});
}
else if(element == "password" && (toModify[element] !== null)){
await alterSelf(user.value.regNo,{password : toModify[element]});
}
}
toModify= Object.assign({}, pattern);
toModify= Object.assign({},pattern);
user.value = await getSelf()
}
function setModify(item){
toModify.address = item.address;
toModify.profilPictureUrl = item.profilPictureUrl;
toModify.email= item.email;
toModify.password= item.password;
}
async function unRegister(){
disconnect();
deleteUser(user.value.regNo);
disconnect()
setTimeout(() => {
window.location.href="#/home";
}, "500");
@ -64,7 +81,7 @@
}
function getPP(){
if(user.profilePictureUrl === null){
if(user.value.profilePictureUrl === null){
return "/Clyde.png"
}
return user.profilePictureUrl
@ -93,7 +110,7 @@
Role: {{i18n((user.role))}}
</div>
<div>
<button @click="modif=!modif"> {{i18n("profile.modify.data")}} </button>
<button @click="modif=!modif; setModify(user)"> {{i18n("profile.modify.data")}} </button>
</div>
<div v-if="(user.role==='Student')">
<button @click="reg=!reg">{{i18n("profile.reRegister")}}</button>
@ -110,23 +127,23 @@
</div>
<div>
E-mail:
<input type="mail" v-model="personnalInfos.email" />
<input type="mail" v-model="toModify.email" />
</div>
<div>
{{i18n("profile.address")}}:
<input type="text" v-model="personnalInfos.id">
<input type="text" v-model="toModify.id">
</div>
<div>
{{i18n("login.password")}}:
<input type="password" v-model="personnalInfos.password">
<input type="password" v-model="toModify.password">
</div>
<div>
{{i18n("login.cPassword")}}:
<input type="password" v-model="personnalInfos.passwordConfirm">
<input type="password" v-model="toModify.passwordConfirm">
</div>
<div>
<button @click=" modif=!modif; ChangeInfos();">{{i18n("courses.confirm")}}</button>
<button @click="modif=!modif; resetInputs(toModify,pattern);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button>
<button @click="modif=!modif; resetInputs(toModify,pattern);" style="float:right;">{{i18n("courses.back")}}</button>
</div>
</div>
<div v-else-if="curric" class="infosContainer">
@ -162,7 +179,7 @@
<div>
<button @click=" reg=!reg;">{{i18n("courses.confirm")}}</button>
<button @click=" reg=!reg; resetInputs(personnalInfos,patternInfos);console.log(pattern)" style="float:right;">{{i18n("courses.back")}}</button>
<button @click=" reg=!reg; resetInputs(personnalInfos,patternInfos);" style="float:right;">{{i18n("courses.back")}}</button>
</div>
</div>

View File

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

View File

@ -6,7 +6,6 @@
const users = await getAllUsers();
console.log(users);
</script>
<template>
<div v-for="item in users">

View File

@ -140,8 +140,9 @@ export async function getSelf(){
* - Adress
* - Password
*/
export async function alterSelf(data){
return restPatch("/user", data);
export async function alterSelf(id,data){
console.log(data)
return restPatch("/user/"+id, data);
}