1
0
forked from PGL/Clyde

Ajoute le détail des étudiants (big update)

This commit is contained in:
LeoMoulin 2024-03-25 09:57:35 +01:00
parent 67fa630ecf
commit eafff6ec2d
10 changed files with 188 additions and 23 deletions

View File

@ -8,7 +8,9 @@ import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Services.*;
import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.Curriculum;
import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.User;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
@RestController @RestController
@ -22,11 +24,14 @@ public class CurriculumController {
private final UserCurriculumService userCurriculumServ; private final UserCurriculumService userCurriculumServ;
private final CurriculumCourseService curriculumCourseServ; private final CurriculumCourseService curriculumCourseServ;
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){ private final UserService userServ;
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, UserService userServ){
this.curriculumServ = curriculumServ; this.curriculumServ = curriculumServ;
this.authServ = authServ; this.authServ = authServ;
this.userCurriculumServ = userCurriculumServ; this.userCurriculumServ = userCurriculumServ;
this.curriculumCourseServ = curriculumCourseServ; this.curriculumCourseServ = curriculumCourseServ;
this.userServ = userServ;
} }
@GetMapping("/curriculum/{id}") @GetMapping("/curriculum/{id}")
@ -52,6 +57,22 @@ public class CurriculumController {
return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK); return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK);
} }
//Return the list of all curicullums of an user
@GetMapping("/onescurriculum/{userId}")
public ResponseEntity<Map<String ,Object>> findOnesCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){
if (authServ.getUserFromToken(token) == null)
return new UnauthorizedResponse<>(null);
User u = userServ.getUserById(Long.parseLong(userId));
HashMap<String,Object> toReturn = userCurriculumServ.findAllCurriculumByStudent(u);
if (toReturn == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(toReturn,HttpStatus.OK);
}
@GetMapping("/curriculums") @GetMapping("/curriculums")
public ResponseEntity<Iterable<Map<String, Object>>> findAllIndDepth(){ public ResponseEntity<Iterable<Map<String, Object>>> findAllIndDepth(){
return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK); return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),HttpStatus.OK);

View File

@ -3,6 +3,7 @@ package ovh.herisson.Clyde.EndPoints;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Repositories.TokenRepository; import ovh.herisson.Clyde.Repositories.TokenRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Repositories.UserRepository;
import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Services.*;
import ovh.herisson.Clyde.Tables.*; import ovh.herisson.Clyde.Tables.*;
@ -26,8 +27,9 @@ public class MockController {
public final InscriptionService inscriptionService; public final InscriptionService inscriptionService;
ArrayList<User> mockUsers; ArrayList<User> mockUsers;
public final UserCurriculumRepository ucr;
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){ public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, UserCurriculumRepository ucr){
this.tokenRepo = tokenRepo; this.tokenRepo = tokenRepo;
this.userRepo = userRepo; this.userRepo = userRepo;
this.tokenService = tokenService; this.tokenService = tokenService;
@ -35,6 +37,7 @@ public class MockController {
this.curriculumService = curriculumService; this.curriculumService = curriculumService;
this.courseService = courseService; this.courseService = courseService;
this.inscriptionService = inscriptionService; this.inscriptionService = inscriptionService;
this.ucr = ucr;
} }
/** Saves an example of each user type by : /** Saves an example of each user type by :
@ -47,15 +50,14 @@ public class MockController {
public void postMock(){ public void postMock(){
// user part // user part
User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin")); User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin"));
User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User jojo = new User("Bridoux","Justin","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")); 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,jojo)); User popo = new User("Smith", "Paul", "paulsmith@gmail.com", "306 rue du poulet", "belgique", new Date(0), null, Role.Student, passwordEncoder.encode("jesuispaulleroi"));
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo, popo));
userRepo.saveAll(mockUsers); userRepo.saveAll(mockUsers);
@ -64,11 +66,18 @@ public class MockController {
Curriculum infoBab1 = new Curriculum(1,"info"); Curriculum infoBab1 = new Curriculum(1,"info");
Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); Curriculum chemistryBab1 = new Curriculum(1,"chemistry");
Curriculum psychologyBab1 = new Curriculum(1,"psychology"); Curriculum psychologyBab1 = new Curriculum(1,"psychology");
Curriculum infoBab2 = new Curriculum(2,"info");
curriculumService.save(infoBab1); curriculumService.save(infoBab1);
curriculumService.save(chemistryBab1); curriculumService.save(chemistryBab1);
curriculumService.save(psychologyBab1); curriculumService.save(psychologyBab1);
curriculumService.save(infoBab2);
ucr.save(new UserCurriculum(joe, infoBab1, 2022));
ucr.save(new UserCurriculum(joe, chemistryBab1, 2023));
ucr.save(new UserCurriculum(joe, psychologyBab1, 2020));
ucr.save(new UserCurriculum(popo, infoBab1, 2022));
ucr.save(new UserCurriculum(popo, infoBab2, 2023));
Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke);
Course chemistry1 = new Course(12, "Thermochimie",joke); Course chemistry1 = new Course(12, "Thermochimie",joke);

View File

@ -6,8 +6,12 @@ import ovh.herisson.Clyde.Tables.Curriculum;
import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.User;
import ovh.herisson.Clyde.Tables.UserCurriculum; import ovh.herisson.Clyde.Tables.UserCurriculum;
import java.util.ArrayList;
public interface UserCurriculumRepository extends CrudRepository<UserCurriculum, Long> { public interface UserCurriculumRepository extends CrudRepository<UserCurriculum, Long> {
@Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1") @Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1")
Curriculum findByUser(User student); Curriculum findByUser(User student);
ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student);
} }

View File

@ -18,7 +18,6 @@ public class CurriculumService {
public Curriculum findById(long id){ public Curriculum findById(long id){
return curriculumRepo.findById(id); return curriculumRepo.findById(id);
} }
public void delete(Curriculum curriculum) { public void delete(Curriculum curriculum) {
curriculumRepo.delete(curriculum); curriculumRepo.delete(curriculum);
} }

View File

@ -1,20 +1,50 @@
package ovh.herisson.Clyde.Services; package ovh.herisson.Clyde.Services;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.Curriculum;
import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.User;
import ovh.herisson.Clyde.Tables.UserCurriculum;
import java.util.ArrayList;
import java.util.HashMap;
@Service @Service
public class UserCurriculumService { public class UserCurriculumService {
private final UserCurriculumRepository userCurriculumRepository; private final UserCurriculumRepository userCurriculumRepository;
private final CurriculumRepository curriculumRepo;
public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) { public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo) {
this.userCurriculumRepository = userCurriculumRepository; this.userCurriculumRepository = userCurriculumRepository;
this.curriculumRepo = curriculumRepo;
} }
public Curriculum findByUser(User student){ public Curriculum findByUser(User student){
return userCurriculumRepository.findByUser(student); return userCurriculumRepository.findByUser(student);
} }
public HashMap<String,Object> findAllCurriculumByStudent(User student) {
ArrayList<UserCurriculum> list = userCurriculumRepository.findByUserOrderByCurriculum(student);
ArrayList<HashMap<String, Object>> curriculumlist = new ArrayList<HashMap<String, Object>>();
for (int i = 0; i < list.size(); i++) {
HashMap<String, Object> element = new HashMap<>();
Curriculum c = list.get(i).getCurriculum();
element.put("curriculumId", c.getCurriculumId());
element.put("year", c.getYear());
element.put("option", c.getOption());
element.put("dateyear", list.get(i).getYear());
curriculumlist.add(element);
}
HashMap<String, Object> toReturn = new HashMap<String, Object>();
toReturn.put("curriculumList", curriculumlist);
return toReturn;
}
} }

View File

@ -1,16 +1,29 @@
<script setup> <script setup>
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import {getSelf, getUser} from '../rest/Users.js' import {getUser} from '../rest/Users.js'
import {ref} from "vue"; import {getSomeonesCurriculumList} from "@/rest/curriculum.js";
const user = await getSelf(); const props = defineProps(['target']);
let user = await getUser(props.target);
let UserCurriculum = await getSomeonesCurriculumList(props.target);
function getPP(){ function getPP(){
if(user.value.profilePictureUrl === null){ if(user.profilePictureUrl === null){
return "/Clyde.png" return "/Clyde.png"
} }
return user.profilePictureUrl return user.profilePictureUrl
} }
//Cette function renvoie l'année académique concernée si on est dans l'année 2023-2024 elle renvoie 2023
//car dans la db l'année scolaire 2023-2024 est representée juste par 2023 (le même système s'applique pour chaque années on prend la borne inférieure
function getYear(){
let date = new Date();
if (date.getMonth() <= 6){
return date.getFullYear()-1
}
return date.getFullYear()
}
</script> </script>
<template> <template>
@ -22,11 +35,46 @@
<div class = "globalInfos"> <div class = "globalInfos">
<div class="infosContainer"> <div class="infosContainer">
<div> <div>
{{user.firstName}} {{user.lastName}} FirstName/Name : {{user.firstName}} {{user.lastName}}
</div> </div>
<div> <div>
E-mail: {{user.email}} E-mail: {{user.email}}
</div> </div>
<div>
Adresse : {{user.address}}
</div>
<div>
Pays : {{user.country}}
</div>
<div>
Date de naissance : {{user.birthDate}}
</div>
</div>
</div>
<div class="moreInfos">
<div class = "oldcursus">
<div class="listTitle">
Anciens Cursus
</div>
<div class="listElement">
<div class=" containerElement" v-for="item in UserCurriculum.curriculumList">
<div class="year" v-if="parseInt(item.dateyear) !== getYear()">Bac {{item.year}}</div>
<div class="option" v-if="parseInt(item.dateyear) !== getYear()">{{item.option}}</div>
<div class="dateyear" v-if="parseInt(item.dateyear) !== getYear()">Année {{item.dateyear}}-{{item.dateyear+1}}</div>
</div>
</div>
</div>
<div class="newcursus" >
<div class="listTitle">
Cursus Actuel
</div>
<div class="listElement">
<div class=" containerElement" v-for="item in UserCurriculum.curriculumList" >
<div class="year" v-if="parseInt(item.dateyear) === getYear()">Bac {{item.year}}</div>
<div class="option" v-if="parseInt(item.dateyear) === getYear()">{{item.option}}</div>
<div class="dateyear" v-if="parseInt(item.dateyear) === getYear()">Année {{item.dateyear}}-{{item.dateyear+1}}</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -35,9 +83,8 @@
</template> </template>
<style> <style scoped>
.container{ .container{
display:grid; display:grid;
grid-template-columns:200px 900px; grid-template-columns:200px 900px;
grid-template-rows:200px auto; grid-template-rows:200px auto;
@ -79,4 +126,49 @@
background-color:rgb(50,50,50); background-color:rgb(50,50,50);
border-radius:20px; border-radius:20px;
} }
.moreInfos {
display:grid;
grid-template-rows:200px auto;
column-gap:50px;
row-gap:45px;
grid-template-areas:
"minfos minfos";
grid-template-columns:600px 600px;
}
.listTitle{
display: flex;
justify-content: center;
align-items: center;
width:250px;
margin-left:auto;
margin-right:auto;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;margin-bottom:10px;
}
.listElement{
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
margin-bottom:10px;
}
.containerElement{
justify-content:center;
display:grid;
grid-template-columns:100px 100px 300px;
grid-template-areas:
"year option dateyear";
column-gap:40px;
padding-left: 25px;
}
</style> </style>

View File

@ -210,7 +210,6 @@
<style scoped> <style scoped>
.container{ .container{
display:grid; display:grid;
grid-template-columns:200px 900px; grid-template-columns:200px 900px;
grid-template-rows:200px auto; grid-template-rows:200px auto;

View File

@ -1,19 +1,29 @@
<script setup> <script setup>
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import { reactive } from 'vue' import {provide, reactive, ref} from 'vue'
import { getStudents } from '../rest/Users.js' import { getStudents } from '../rest/Users.js'
import AboutStudent from "@/Apps/AboutStudent.vue";
const users = await getStudents(); const users = await getStudents();
</script>
let targetRegNo = "";
let list = ref(true);
</script>
<template> <template>
<div v-for="item in users"> <div v-if="list === false">
<AboutStudent :target=targetRegNo />
<button style="background-color:rgb(105,05,105);" @click="list = true;">Back</button>
</div>
<div v-for="item in users" v-if="list === true">
<div class="bodu"> <div class="bodu">
<div class="container"> <div class="container">
<div class="status"><a style="margin-left:30px">{{item.status}}</a></div> <div class="status"><a style="margin-left:30px">{{item.status}}</a></div>
<div class="option"><a>{{item.role}}</a></div> <div class="option"><a>{{item.role}}</a></div>
<div class="surname"><a>{{item.lastName}}</a></div> <div class="surname"><a>{{item.lastName}}</a></div>
<div class="firstname"><a>{{item.firstName}}</a></div> <div class="firstname"><a>{{item.firstName}}</a></div>
<div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}} </button></div> <div class="infos">
<button style="background-color:rgb(105,05,105);" @click="list = false; targetRegNo = item.regNo;">{{i18n("request.moreInfos")}} </button>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -29,7 +39,6 @@
grid-template-areas: grid-template-areas:
"status option surname firstname infos"; "status option surname firstname infos";
column-gap:10px; column-gap:10px;
} }
.infos { .infos {

View File

@ -18,7 +18,6 @@ const apps = {
'/manage-courses' : Courses, '/manage-courses' : Courses,
'/users-list' : Users, '/users-list' : Users,
'/students-list' : Students, '/students-list' : Students,
'/about-students': AboutStudent
} }
const appsList = { const appsList = {
@ -30,7 +29,6 @@ const appsList = {
'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") },
'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")}, 'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")},
'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")}, 'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")},
'AboutStudent':{ path: '#/about-users', icon: 'fa-users', text:i18n("app.aboutStudent")}
} }
const currentPath = ref(window.location.hash) const currentPath = ref(window.location.hash)

View File

@ -48,3 +48,7 @@ export async function altercurriculum(id, courses){
export async function getSelfCurriculum(){ export async function getSelfCurriculum(){
return restGet("/curriculum"); return restGet("/curriculum");
} }
export async function getSomeonesCurriculumList(user){
return restGet("/onescurriculum/"+user)
}