Compare commits

..

4 Commits

Author SHA1 Message Date
b2d0be014c UserList and Student List part1
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m2s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-17 15:59:12 +01:00
210fda0401 Merge branch 'master' into wal/front/listingUsers 2024-03-17 13:33:47 +01:00
dcec45acf5 Merge pull request 'added /students endpoint' (#135) from Max/Backend/StudentEndPoin into master
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m11s
Build and test backend / Test-backend (push) Successful in 1m19s
deploy to production / deploy-frontend (push) Successful in 24s
deploy to production / deploy-backend (push) Successful in 2m20s
Build and test FrontEnd / Build-frontend (push) Successful in 24s
Reviewed-on: #135
Reviewed-by: Debucquoy Anthony <d.tonitch@gmail.com>
Reviewed-by: Wal <karpinskiwal@gmail.com>
2024-03-17 12:00:57 +01:00
4379794dba added /students endpoint
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m1s
Build and test backend / Test-backend (pull_request) Successful in 1m56s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 23s
2024-03-16 23:05:26 +01:00
8 changed files with 45 additions and 76 deletions

View File

@ -48,9 +48,9 @@ public class UserController {
}
@GetMapping("/users")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllUsers(@RequestHeader("Authorization") String authorization){
if (authServ.isNotSecretaryOrAdmin(authorization))
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllUsers(@RequestHeader("authorization") String authorization){
System.out.println(authorization);
if (authServ.IsNotIn(new Role[]{Role.Admin,Role.Secretary},authorization))
return new UnauthorizedResponse<>(null);
Iterable<User> users = userService.getAll();
@ -90,6 +90,24 @@ public class UserController {
}
@GetMapping("/students")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllStudent(@RequestHeader("Authorization") String token){
if (authServ.getUserFromToken(token) == null)
return new UnauthorizedResponse<>(null);
Iterable<User> teachers = userService.getAllStudents();
ArrayList<HashMap<String, Object>> withoutPassword = new ArrayList<>();
for (User t: teachers){
withoutPassword.add(userWithoutPassword(t));
}
return new ResponseEntity<>(withoutPassword, HttpStatus.OK);
}
/** return user's data except password
* @param user the user to return

View File

@ -19,4 +19,7 @@ public interface UserRepository extends CrudRepository<User, Long> {
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
Iterable<User> findAllTeachers();
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Student")
Iterable<User> findAllStudents();
}

View File

@ -107,4 +107,6 @@ public class UserService {
public Iterable<User> getAllTeachers (){return userRepo.findAllTeachers();}
public Iterable<User> getAllStudents(){return userRepo.findAllStudents();}
}

View File

@ -45,9 +45,9 @@ profile.address=Address
profile.picture=Profile picture
profile.change.curriculum=Change curriculum
name=Name
teacher=Teacher
student=Student
secretary=Secretary
curriculum=curriculum
credits=Credits
Teacher=Teacher
Student=Student
Secretary=Secretary
Curriculum=curriculum
Credits=Credits
faculty=Faculty

View File

@ -45,9 +45,9 @@ profile.address=Adresse
profile.picture=Photo de profil
profile.change.curriculum=Changer cursus
name=Nom
teacher=Enseignant
student=Etudiant
secretary=Secrétaire
curriculum=Cursus
credits=Credits
Teacher=Enseignant
Student=Etudiant
Secretary=Secrétaire
Curriculum=Cursus
Credits=Credits
faculty=Faculté

View File

@ -1,72 +1,17 @@
<script setup>
import i18n from "@/i18n.js"
import { reactive } from 'vue'
import { getStudents } from '../rest/Users.js'
const users =[{
status: "Inscrit",
profilPicture:"/Clyde.png",
lastName:"Ghost",
firstName:"Clyde",
role:"student",
address: "Radiator Springs",
email:"ClydeGhost@gmail.com",
cursus:[
{
"id": 12,
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"teacher": 42,
"Assistants": []},
{
"id": 42,
"name": "Fonctionnement des ordinateurs",
"credits": 11,
"faculty": "science",
"teacher": 42,
"Assistants": []},
],
option:"IT",
degree:"BAC1",
password:"CeciEstUnMotDePasse123",},
{
status: "En attente",
profilPicture:"/Clyde.png",
lastName:"Ghost",
firstName:"Clyde",
role:"student",
address: "Radiator Springs",
email:"ClydeGhost@gmail.com",
cursus:[
{
"id": 12,
"name": "Math pour l'info",
"credits": 11,
"faculty": "science",
"teacher": 42,
"Assistants": []},
{
"id": 42,
"name": "Fonctionnement des ordinateurs",
"credits": 11,
"faculty": "science",
"teacher": 42,
"Assistants": []},
],
option:"IT",
degree:"BAC1",
password:"CeciEstUnMotDePasse123",
}]
const users = await getStudents();
console.log(users)
</script>
<template>
<div v-for="item in users">
<div class="bodu">
<div class="container">
<div class="status"><a style="margin-left:30px">{{item.status}}</a></div>
<div class="option"><a>{{item.option}}</a></div>
<div class="option"><a>{{item.role}}</a></div>
<div class="surname"><a>{{item.lastName}}</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>

View File

@ -5,13 +5,14 @@
import { getAllUsers } from '../rest/Users.js'
const users = await getAllUsers();
console.log(users);
</script>
<template>
<div v-for="item in users">
<div class="bodu">
<div class="container">
<div class="role"><a style="margin-left:30px">{{i18n(item.role).toUpperCase()}}</a></div>
<div class="role"><a style="margin-left:30px">{{i18n(item.role)}}</a></div>
<div class="surname"><a>{{item.lastName}}</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>

View File

@ -112,12 +112,12 @@ export async function getAllUsers(){
* - role
*/
export async function getTeachers(){
return restGet("/users/teacher")
return restGet("/teachers")
}
export async function getStudents(){
return restGet("/users/student")
return restGet("/students")
}
/**
* Get informations about yourself