1
0
forked from PGL/Clyde

Merge remote-tracking branch 'origin/master' into tonitch/feat/notifications

This commit is contained in:
Debucquoy Anthony 2024-04-21 20:19:17 +02:00
commit 43883caef0
Signed by untrusted user: tonitch
GPG Key ID: A78D6421F083D42E
53 changed files with 3802 additions and 215 deletions

View File

@ -47,6 +47,7 @@ public class ApplicationsController {
//if unAuthed //if unAuthed
authorizedApps.add(Applications.Login); authorizedApps.add(Applications.Login);
authorizedApps.add(Applications.Schedule);
User user = authServ.getUserFromToken(token); User user = authServ.getUserFromToken(token);
if(user == null) if(user == null)
@ -60,6 +61,8 @@ public class ApplicationsController {
authorizedApps.add(Applications.Rdv); authorizedApps.add(Applications.Rdv);
} }
if(!authServ.isNotIn(new Role[]{Role.Teacher,Role.Admin},token))
authorizedApps.add(Applications.ManageOwnedLessons);
//if Teacher or Secretary or Admin add ManageCourses App //if Teacher or Secretary or Admin add ManageCourses App
if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token)) if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token))
authorizedApps.add(Applications.ManageCourses); authorizedApps.add(Applications.ManageCourses);
@ -69,7 +72,9 @@ public class ApplicationsController {
authorizedApps.add(Applications.StudentsList);} authorizedApps.add(Applications.StudentsList);}
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){ if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
authorizedApps.add(Applications.UsersList);} authorizedApps.add(Applications.UsersList);
authorizedApps.add(Applications.ManageSchedules);
authorizedApps.add(Applications.LessonRequests);}
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.InscriptionService},token)){ if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.InscriptionService},token)){
authorizedApps.add(Applications.Payments);} authorizedApps.add(Applications.Payments);}

View File

@ -86,11 +86,8 @@ public class CourseController {
public ResponseEntity<Map<String ,Object>> postCourse(@RequestHeader("Authorization") String token, public ResponseEntity<Map<String ,Object>> postCourse(@RequestHeader("Authorization") String token,
@RequestBody Course course) @RequestBody Course course)
{ {
System.out.println(course);
System.out.println(token);
if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)) if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
return new UnauthorizedResponse<>(null); return new UnauthorizedResponse<>(null);
Course createdCourse = courseServ.save(course); Course createdCourse = courseServ.save(course);
if (createdCourse == null) if (createdCourse == null)
return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST); return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);

View File

@ -39,7 +39,7 @@ public class ExternalCurriculumController {
user = userRepository.findById((Integer) externalCurrInfos.get("userRegNo")); user = userRepository.findById((Integer) externalCurrInfos.get("userRegNo"));
} }
ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifDocUrl"), user); ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifdocUrl"), user);
return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK); return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK);
} }

View File

@ -3,10 +3,12 @@ package ovh.herisson.Clyde.EndPoints.Inscription;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.AuthenticatorService; import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.Inscription.InscriptionService; import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
import ovh.herisson.Clyde.Services.ProtectionService; import ovh.herisson.Clyde.Services.ProtectionService;
import ovh.herisson.Clyde.Tables.Curriculum;
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.RequestState;
import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Role;
@ -19,10 +21,11 @@ public class InscriptionController {
private final InscriptionService inscriptionServ; private final InscriptionService inscriptionServ;
private final AuthenticatorService authServ; private final AuthenticatorService authServ;
private final CurriculumRepository curriculumRepository;
public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ){ public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ, CurriculumRepository curriculumRepository){
this.inscriptionServ = inscriptionServ; this.inscriptionServ = inscriptionServ;
this.authServ = authServ; this.authServ = authServ;
this.curriculumRepository = curriculumRepository;
} }
@ -103,4 +106,31 @@ public class InscriptionController {
} }
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@PatchMapping("/request/registerequivimpose/{id}/{cursusid}")
public ResponseEntity<Object> editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable long cursusid){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token))
return new UnauthorizedResponse<>(null);
InscriptionRequest toEdit = inscriptionServ.getById(id);
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
if (toEdit.getEquivalenceState() == RequestState.Accepted){
return new ResponseEntity<>(HttpStatus.OK);
}
//We impose a curriculum
Curriculum curriculum = curriculumRepository.findById(cursusid);
toEdit.setCurriculumId(curriculum.getCurriculumId());
toEdit.setEquivalenceState(RequestState.Accepted);
inscriptionServ.save(toEdit);
if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired))
{
inscriptionServ.createUser(toEdit);
}
return new ResponseEntity<>(HttpStatus.OK);
}
} }

View File

@ -5,10 +5,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Repositories.CourseRepository; import ovh.herisson.Clyde.Repositories.CourseRepository;
import ovh.herisson.Clyde.Repositories.CurriculumRepository; import ovh.herisson.Clyde.Repositories.CurriculumRepository;
import ovh.herisson.Clyde.Repositories.Inscription.ChangeCurriculumRequestRepository; import ovh.herisson.Clyde.Repositories.Inscription.*;
import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository;
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Repositories.UserRepository;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
@ -17,6 +14,7 @@ import ovh.herisson.Clyde.Services.TokenService;
import ovh.herisson.Clyde.Services.UserService; import ovh.herisson.Clyde.Services.UserService;
import ovh.herisson.Clyde.Tables.*; import ovh.herisson.Clyde.Tables.*;
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
import ovh.herisson.Clyde.Tables.Inscription.Minerval;
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest; import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
@ -39,10 +37,10 @@ public class RequestsController {
public final UserService userService; public final UserService userService;
public final UserCurriculumRepository userCurriculumRepository; public final UserCurriculumRepository userCurriculumRepository;
public final CurriculumRepository curriculumRepository; public final CurriculumRepository curriculumRepository;
public final MinervalRepository minervalRepository;
public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository; public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository;
public RequestsController(TokenService tokenService, ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) { public RequestsController(TokenService tokenService, ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, MinervalRepository minervalRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) {
this.tokenService = tokenService; this.tokenService = tokenService;
this.err = err; this.err = err;
this.srr = srr; this.srr = srr;
@ -53,6 +51,7 @@ public class RequestsController {
this.userService = userService; this.userService = userService;
this.userCurriculumRepository = userCurriculumRepository; this.userCurriculumRepository = userCurriculumRepository;
this.curriculumRepository = curriculumRepository; this.curriculumRepository = curriculumRepository;
this.minervalRepository = minervalRepository;
this.changeCurriculumRequestRepository = changeCurriculumRequestRepository; this.changeCurriculumRequestRepository = changeCurriculumRequestRepository;
} }
@ -154,6 +153,8 @@ public class RequestsController {
ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id")); ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id"));
User u = scholarshipRequest.getUser();
//If the request is already accepted we just return ok (otherwise we would duplicate the procedure below) //If the request is already accepted we just return ok (otherwise we would duplicate the procedure below)
if (scholarshipRequest.getState() == RequestState.Accepted){ if (scholarshipRequest.getState() == RequestState.Accepted){
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
@ -162,6 +163,12 @@ public class RequestsController {
if (infos.get("state").equals("Accepted")){ if (infos.get("state").equals("Accepted")){
scholarshipRequest.setState(RequestState.Accepted); scholarshipRequest.setState(RequestState.Accepted);
scholarshipRequest.setAmount((int) infos.get("amount")); scholarshipRequest.setAmount((int) infos.get("amount"));
//We then deduce then amount from the minerval
ArrayList<Minerval> minerval = minervalRepository.getMinervalsByStudentRegNoOrderByYearDesc(u.getRegNo());
minerval.get(0).setPaidAmount(minerval.get(0).getPaidAmount() + scholarshipRequest.getAmount());
minerval.get(0).setToPay(minerval.get(0).getToPay() - scholarshipRequest.getAmount());
minervalRepository.save(minerval.get(0));
}else{ }else{
scholarshipRequest.setState(RequestState.Refused); scholarshipRequest.setState(RequestState.Refused);
} }

View File

@ -0,0 +1,129 @@
package ovh.herisson.Clyde.EndPoints;
/******************************************************
* @file LessonController.java
* @author William Karpinski
* @scope Extension Horaire
*
* Controller of Lessons API
******************************************************/
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.LessonService;
import ovh.herisson.Clyde.Services.ProtectionService;
import ovh.herisson.Clyde.Services.ScheduleLessonService;
import ovh.herisson.Clyde.Tables.Lesson;
import ovh.herisson.Clyde.Tables.Role;
import java.util.HashMap;
import java.util.Map;
@RestController
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
public class LessonController {
private final LessonService lessonServ;
private final ScheduleLessonService scheduleLessonServ;
private final AuthenticatorService authServ;
public LessonController(LessonService lessonServ, ScheduleLessonService scheduleLessonService, AuthenticatorService authServ) {
this.lessonServ = lessonServ;
this.scheduleLessonServ = scheduleLessonService;
this.authServ = authServ;
}
/**
* Return a lesson via its id
*/
@GetMapping("/lesson/{id}")
public ResponseEntity<HashMap<String,Object>> getLesson(@PathVariable long id){
Lesson lesson = lessonServ.findById(id);
if(lesson == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(ProtectionService.lessonWithoutPassword(lesson),HttpStatus.OK);
}
/**
* Return all the lessons
*/
@GetMapping("/lessons")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllLessons(@RequestHeader("Authorization") String token){
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findAll()),HttpStatus.OK);
}
/**
* Return all the lessons of a teacher's courses
*/
@GetMapping("/lessons/owned")
public ResponseEntity<Iterable<HashMap<String,Object>>> getOwnedLessons(@RequestHeader("Authorization") String token){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token)){
return new UnauthorizedResponse<>(null);}
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findAllOwnedLesson(authServ.getUserFromToken(token))),HttpStatus.OK);
}
/**
* Return all the lessons of a student
*/
@GetMapping("/lessons/OwnCurriculum")
public ResponseEntity<Iterable<HashMap<String,Object>>> getOnesLessons(@RequestHeader("Authorization") String token){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Student},token)){
return new UnauthorizedResponse<>(null);}
return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findOnesLessons(authServ.getUserFromToken(token))),HttpStatus.OK);
}
/**
* Post a new lesson
*/
@PostMapping("/lesson")
public ResponseEntity<HashMap<String, Object>> postLesson(@RequestHeader("Authorization") String token,
@RequestBody Map<String, Object> lessonInfos){
if(authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
return new UnauthorizedResponse<>(null);
Lesson lesson = lessonServ.createLesson(lessonInfos);
Lesson createdLesson = lessonServ.save(lesson);
scheduleLessonServ.saveToAllSchedule(lesson);
if(createdLesson==null)
return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(ProtectionService.lessonWithoutPassword(createdLesson), HttpStatus.OK);
}
/**
* Modify a lesson
*/
@PatchMapping("/lesson/{id}")
public ResponseEntity<Lesson> patchLesson(@RequestHeader("Authorization") String token,
@RequestBody Map<String, Object> updates,
@PathVariable long id){
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
if(!lessonServ.modifyData(id, updates)){
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* Delete a lesson
*/
@DeleteMapping("lesson/{id}")
public ResponseEntity<String> deleteLesson(@RequestHeader("Authorization") String token,
@PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
Lesson toDelete = lessonServ.findById(id);
if(toDelete == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
lessonServ.delete(toDelete);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -0,0 +1,150 @@
package ovh.herisson.Clyde.EndPoints;
/******************************************************
* @file LessonRequestsController.java
* @author William Karpinski
* @scope Extension Horaire
*
* Controller of lesson requests API
******************************************************/
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.LessonRequestService;
import ovh.herisson.Clyde.Services.LessonService;
import ovh.herisson.Clyde.Services.ProtectionService;
import ovh.herisson.Clyde.Tables.LessonChangesRequest;
import ovh.herisson.Clyde.Tables.RequestState;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.User;
import java.util.Map;
@RestController
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
public class LessonRequestsController {
private final LessonRequestService lessonRequestServ;
private final AuthenticatorService authServ;
private final LessonService lessonServ;
public LessonRequestsController(LessonRequestService lessonRequestServer, AuthenticatorService authServ, LessonService lessonServ) {
this.lessonRequestServ = lessonRequestServer;
this.authServ = authServ;
this.lessonServ = lessonServ;
}
/**
* Return a lesson request via its id
*/
@GetMapping("/requests/lessonRequest/{id}")
public ResponseEntity<Map<String,Object>> getById(@RequestHeader("Authorization") String token, @PathVariable long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
LessonChangesRequest lessonRequest= lessonRequestServ.findById(id);
return new ResponseEntity<>(ProtectionService.lessonRequestWithoutPassword(lessonRequest), HttpStatus.OK);
}
/**
* return all the requests made by a user
*/
@GetMapping("/requests/lessonRequests/owned")
public ResponseEntity<Iterable<Map<String, Object>>> getOwnedRequests(@RequestHeader("Authorization") String token){
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
return new UnauthorizedResponse<>(null);
User user = authServ.getUserFromToken(token);
Iterable<LessonChangesRequest> lessonChangesRequests = lessonRequestServ.findOwnRequests(user);
return new ResponseEntity<>(ProtectionService.lessonRequestsWithoutPassword(lessonChangesRequests),HttpStatus.OK);
}
/**
* Return all the lesson requests
*/
@GetMapping("/requests/lessonRequests")
public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
Iterable<LessonChangesRequest> lessonRequests= lessonRequestServ.getAll();
return new ResponseEntity<>(ProtectionService.lessonRequestsWithoutPassword(lessonRequests), HttpStatus.OK);
}
/**
* Post a lesson request
*/
@PostMapping("/requests/lessonRequest")
public ResponseEntity<Map<String, Object>> makeRequest(@RequestHeader("Authorization") String token, @RequestBody Map<String,Object> lessonRequestInfos){
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token))
return new UnauthorizedResponse<>(null);
LessonChangesRequest lessonChangesRequest = lessonRequestServ.createLessonRequest(lessonRequestInfos);
LessonChangesRequest createdRequest = lessonRequestServ.save(lessonChangesRequest);
if(createdRequest == null)
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(ProtectionService.lessonRequestWithoutPassword(lessonChangesRequest),HttpStatus.OK);
}
/**
* Modify a lesson Request
*/
@PatchMapping("/requests/lessonRequest/{id}")
public ResponseEntity<LessonChangesRequest> changeRequestState(@PathVariable long id,
@RequestHeader("Authorization") String token,
@RequestBody Map<String , Object> infos){
if(authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token))
return new UnauthorizedResponse<>(null);
LessonChangesRequest lessonRequest = lessonRequestServ.findById(id);
String local = "";
RequestState state = null;
for (Map.Entry<String, Object> entry : infos.entrySet()) {
switch (entry.getKey()) {
case "local":
local = (String) entry.getValue();
break;
case "state":
state = RequestState.valueOf((String)entry.getValue());
}
}
if (state == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
if(lessonRequest.getRequestType() == 0 ) {
if (!lessonRequestServ.modifyCreateRequestState(lessonRequest, state, local))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
else if(lessonRequest.getRequestType() == 1){
infos.put("lessonStart", lessonRequest.getLessonStart());
infos.put("lessonEnd", lessonRequest.getLessonEnd());
infos.put("lessonType",lessonRequest.getLessonType());
if(!lessonRequestServ.modifyChangeRequestState(infos,lessonRequest.getLessonId(),state))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
lessonRequest.setState(state);
}
else{
lessonRequestServ.modifyDeleteRequest(lessonRequest, state);
lessonRequest.setState(state);
}
lessonRequestServ.save(lessonRequest);
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* Delete a lesson request
*/
@DeleteMapping("/requests/lessonRequest/{id}")
public ResponseEntity<String> deleteRequest(@RequestHeader("Authorization") String token, @PathVariable long id){
if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.Teacher},token))
return new UnauthorizedResponse<>(null);
LessonChangesRequest lessonChangesRequest = lessonRequestServ.findById(id);
if (lessonChangesRequest == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
lessonRequestServ.delete(lessonChangesRequest);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -30,6 +30,12 @@ public class MockController {
public final CourseService courseService; public final CourseService courseService;
public final ExternalCurriculumRepository externalCurriculumRepository; public final ExternalCurriculumRepository externalCurriculumRepository;
public final InscriptionService inscriptionService; public final InscriptionService inscriptionService;
public final LessonService lessonService;
public final ScheduleService scheduleService;
public final ScheduleLessonService scheduleLessonService;
public final LessonRequestService lessonRequestService;
ArrayList<User> mockUsers; ArrayList<User> mockUsers;
public final UserCurriculumRepository ucr; public final UserCurriculumRepository ucr;
@ -39,7 +45,7 @@ public class MockController {
public final ScholarshipRequestRepository scholarshipRequestRepository; public final ScholarshipRequestRepository scholarshipRequestRepository;
public final UnregisterRequestRepository uninscriptionRequestRepository; public final UnregisterRequestRepository uninscriptionRequestRepository;
public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository){ public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository, LessonService lessonService, ScheduleService scheduleService, ScheduleLessonService scheduleLessonService, LessonRequestService lessonRequestService){
this.userService = userService; this.userService = userService;
this.tokenRepo = tokenRepo; this.tokenRepo = tokenRepo;
this.userRepo = userRepo; this.userRepo = userRepo;
@ -49,6 +55,10 @@ public class MockController {
this.courseService = courseService; this.courseService = courseService;
this.externalCurriculumRepository = externalCurriculumRepository; this.externalCurriculumRepository = externalCurriculumRepository;
this.inscriptionService = inscriptionService; this.inscriptionService = inscriptionService;
this.lessonService = lessonService;
this.scheduleService = scheduleService;
this.scheduleLessonService = scheduleLessonService;
this.lessonRequestService = lessonRequestService;
this.ucr = ucr; this.ucr = ucr;
this.minervalRepository = minervalRepository; this.minervalRepository = minervalRepository;
this.scholarshipRequestRepository = scholarshipRequestRepository; this.scholarshipRequestRepository = scholarshipRequestRepository;
@ -135,6 +145,50 @@ public class MockController {
inscriptionService.save(inscriptionRequest); inscriptionService.save(inscriptionRequest);
//Schedule part
Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 22 2024 08:15", "Mon Apr 22 2024 10:15","rgb(0,50,100)","A0B2","Course");
Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2","TP");
Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2","TD");
Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2","TP");
Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2","Course");
LessonChangesRequest request1 = new LessonChangesRequest(joke,RequestState.Pending,null,null,null,null,2,null,1);
LessonChangesRequest request2 = new LessonChangesRequest(joke,RequestState.Pending,"Fri Apr 19 2024 10:30 ","Fri Apr 19 2024 12:30 ",null,null,1,null,2);
LessonChangesRequest request3 = new LessonChangesRequest(joke,RequestState.Pending,"Fri Apr 19 2024 13:30 ","Fri Apr 19 2024 15:30 ","Course",progra1,0,"rgb(27,49,100)",4);
Schedule infoBab1Schedule = new Schedule(infoBab1);
Schedule chemistryBab1Schedule = new Schedule(chemistryBab1);
Schedule psychoBab1Schedule = new Schedule(psychologyBab1);
scheduleService.save(infoBab1Schedule);
scheduleService.save(chemistryBab1Schedule);
scheduleService.save(psychoBab1Schedule);
lessonService.save(lesson_0_progra1);
lessonService.save(lesson_0_chemistry1);
lessonService.save(lesson_0_commun);
lessonService.save(lesson_0_psycho1);
lessonService.save(lesson_1_progra1);
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_0_progra1));
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_1_progra1));
scheduleLessonService.save(new ScheduleLesson(infoBab1Schedule,lesson_0_commun));
scheduleLessonService.save(new ScheduleLesson(chemistryBab1Schedule,lesson_0_chemistry1));
scheduleLessonService.save(new ScheduleLesson(chemistryBab1Schedule,lesson_0_commun));
scheduleLessonService.save(new ScheduleLesson(psychoBab1Schedule,lesson_0_psycho1));
scheduleLessonService.save(new ScheduleLesson(psychoBab1Schedule,lesson_0_commun));
lessonRequestService.save(request1);
lessonRequestService.save(request2);
lessonRequestService.save(request3);
UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail(), null); UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail(), null);
uninscriptionRequestRepository.save(unregisterRequest); uninscriptionRequestRepository.save(unregisterRequest);

View File

@ -0,0 +1,116 @@
package ovh.herisson.Clyde.EndPoints;
/******************************************************
* @file ScheduleController.java
* @author William Karpinski
* @scope Extension Horaire
*
* Controller of Schedule API
******************************************************/
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.ScheduleLessonService;
import ovh.herisson.Clyde.Services.ScheduleService;
import ovh.herisson.Clyde.Services.UserCurriculumService;
import ovh.herisson.Clyde.Services.CurriculumService;
import ovh.herisson.Clyde.Tables.*;
import ovh.herisson.Clyde.Services.LessonService;
import java.util.Map;
@RestController
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
public class ScheduleController {
private final ScheduleService scheduleServ;
private final LessonService lessonServ;
private final CurriculumService curriculumServ;
private final AuthenticatorService authServ;
private final ScheduleLessonService scheduleLessonServ;
public ScheduleController(ScheduleService scheduleServ, AuthenticatorService authServ, ScheduleLessonService scheduleLessonServ, CurriculumService curriculumServ,LessonService lessonServ) {
this.scheduleServ = scheduleServ;
this.authServ = authServ;
this.scheduleLessonServ = scheduleLessonServ;
this.curriculumServ = curriculumServ;
this.lessonServ = lessonServ;
}
/**
* Return schedule via its id
*/
@GetMapping("/schedule/{id}")
public ResponseEntity<Map<String,Object>> findById(@PathVariable long id){
Schedule schedule = scheduleServ.findById(id);
if(schedule == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(scheduleLessonServ.getDepthScheduleBySchedule(schedule),HttpStatus.OK);
}
/**
* Return a schedule via its curriculum id
*/
@GetMapping("/schedule/curriculum/{id}")
public ResponseEntity<Map<String, Object>> findCurriculumSchedule(@PathVariable Long id){
Schedule schedule = scheduleLessonServ.getScheduleByCurriculum(curriculumServ.findById(id));
if(schedule == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(scheduleLessonServ.getDepthScheduleBySchedule(schedule),HttpStatus.OK);
}
/**
* Return all schedules
*/
@GetMapping("/schedules")
public ResponseEntity<Iterable<Map<String , Object>>> findAllSchedule(){
return new ResponseEntity<>(scheduleLessonServ.getAllSchedule(),HttpStatus.OK);
}
/**
* Post a new schedule
*/
@PostMapping("/schedule")
public ResponseEntity<Schedule> postSchedule(@RequestHeader("Authorization") String token,
@RequestBody Schedule schedule){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(scheduleServ.save(schedule),HttpStatus.OK);
}
/**
* Post a lesson to a schedule
*/
@PostMapping("/schedule/{id}")
public ResponseEntity<String> postLessonToSchedule(@RequestHeader("Authorization") String token,
@RequestBody Long lessonId,
@PathVariable long id)
{
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
if (!scheduleLessonServ.save(new ScheduleLesson( scheduleServ.findById(id), lessonServ.findById(lessonId))))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* Delete a lesson from a schedule
*/
@DeleteMapping("/schedule/lesson/{id}")
public ResponseEntity<String> deleteLessonFromSchedule(@RequestHeader("Authorization") String token,
@RequestBody Long lessonId,
@PathVariable Long id)
{
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token))
return new UnauthorizedResponse<>(null);
if (!scheduleLessonServ.delete(lessonId))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -103,9 +103,6 @@ public class UserController {
@GetMapping("/teachers") @GetMapping("/teachers")
public ResponseEntity<Iterable<HashMap<String,Object>>> getAllTeachers(@RequestHeader("Authorization") String token){ public ResponseEntity<Iterable<HashMap<String,Object>>> getAllTeachers(@RequestHeader("Authorization") String token){
if (authServ.getUserFromToken(token) == null)
return new UnauthorizedResponse<>(null);
Iterable<User> teachers = userService.getAllTeachers(); Iterable<User> teachers = userService.getAllTeachers();
return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(teachers), HttpStatus.OK); return new ResponseEntity<>(ProtectionService.usersWithoutPasswords(teachers), HttpStatus.OK);

View File

@ -0,0 +1,23 @@
package ovh.herisson.Clyde.Repositories;
/******************************************************
* @file LessonChangesRequestRepository.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.LessonChangesRequest;
import ovh.herisson.Clyde.Tables.User;
public interface LessonChangesRequestRepository extends CrudRepository<LessonChangesRequest, Long> {
LessonChangesRequest findById(long id);
@Query("select lr from LessonChangesRequest lr where lr.user = ?1")
Iterable<LessonChangesRequest> findOwnRequests(User user);
@Query("select lr from LessonChangesRequest lr where lr.lessonId = ?1")
Iterable<LessonChangesRequest> findRequestByLessonId(long id);
}

View File

@ -0,0 +1,20 @@
package ovh.herisson.Clyde.Repositories;
/******************************************************
* @file LessonRepository.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.Course;
import ovh.herisson.Clyde.Tables.Lesson;
public interface LessonRepository extends CrudRepository<Lesson, Long> {
Lesson findById(long id);
@Query("select l from Lesson l where l.course = ?1")
Iterable<Lesson> findLessonByCourse(Course course);
}

View File

@ -0,0 +1,30 @@
package ovh.herisson.Clyde.Repositories;
/******************************************************
* @file ScheduleLessonRepository.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.Curriculum;
import ovh.herisson.Clyde.Tables.Lesson;
import ovh.herisson.Clyde.Tables.Schedule;
import ovh.herisson.Clyde.Tables.ScheduleLesson;
public interface ScheduleLessonRepository extends CrudRepository<ScheduleLesson,Long> {
@Query("select distinct sl.lesson from ScheduleLesson sl where sl.schedule.curriculum = ?1")
Iterable<Lesson> findLessonByCurriculum(Curriculum curriculum);
@Query("select distinct sl.schedule from ScheduleLesson sl where sl.schedule.curriculum = ?1")
Schedule findScheduleByCurriculum(Curriculum curriculum);
@Modifying
@Transactional
@Query("delete from ScheduleLesson sl where sl.lesson =?1")
void delete(Lesson lesson);
}

View File

@ -0,0 +1,22 @@
package ovh.herisson.Clyde.Repositories;
/******************************************************
* @file ScheduleRepository.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.Course;
import ovh.herisson.Clyde.Tables.Lesson;
import ovh.herisson.Clyde.Tables.Schedule;
public interface ScheduleRepository extends CrudRepository<Schedule,Long> {
Schedule getById(long id);
@Query("select distinct sl from Schedule sl where EXISTS (select c.curriculum from CurriculumCourse c where (sl.curriculum = c.curriculum) AND (c.course = ?1))")
Iterable<Schedule> findAllLessonSchedule(Course course);
}

View File

@ -89,7 +89,8 @@ public class InscriptionService {
inscrRequest.getCountry(), inscrRequest.getCountry(),
inscrRequest.getBirthDate(), inscrRequest.getBirthDate(),
inscrRequest.getProfilePicture(), inscrRequest.getProfilePicture(),
inscrRequest.getPassword() inscrRequest.getPassword(),
inscrRequest.getIdentityCard()
); );
userService.save(userFromRequest); userService.save(userFromRequest);

View File

@ -0,0 +1,177 @@
package ovh.herisson.Clyde.Services;
/******************************************************
* @file LeessonRequestService.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.*;
import ovh.herisson.Clyde.Tables.*;
import java.util.Map;
@Service
public class LessonRequestService {
private final LessonChangesRequestRepository lessonChangesRepo;
private final UserRepository userRepo;
private final LessonRepository lessonRepo;
private final LessonService lessonServ;
private final ScheduleLessonRepository scheduleLessonRepo;
private final ScheduleRepository scheduleRepository;
private final ScheduleLessonService scheduleLessonService;
private final UserService userServ;
private final CourseRepository courseRepository;
public LessonRequestService(LessonChangesRequestRepository lessonChangesRepo,
UserRepository userRepo, LessonRepository lessonRepo,
LessonService lessonServ, ScheduleLessonRepository scheduleLessonRepo,
ScheduleRepository scheduleRepository, ScheduleLessonService scheduleLessonService,
UserService userServ, CourseRepository courseRepository) {
this.lessonChangesRepo = lessonChangesRepo;
this.userRepo = userRepo;
this.lessonRepo = lessonRepo;
this.lessonServ = lessonServ;
this.scheduleLessonRepo = scheduleLessonRepo;
this.scheduleRepository = scheduleRepository;
this.scheduleLessonService = scheduleLessonService;
this.userServ = userServ;
this.courseRepository = courseRepository;
}
/**
* Create a new lesson request
*/
public LessonChangesRequest save(LessonChangesRequest lessonRequest){
return lessonChangesRepo.save(lessonRequest);
}
/**
* Find all the requests made by a user
*/
public Iterable<LessonChangesRequest> findOwnRequests(User user){
return lessonChangesRepo.findOwnRequests(user);
}
public LessonChangesRequest findById(long id){
return lessonChangesRepo.findById(id);
}
/**
* Return all the requests
*/
public Iterable<LessonChangesRequest> getAll(){return lessonChangesRepo.findAll();}
/**
* Create a lesson if a request is accepted
*/
public boolean modifyCreateRequestState(LessonChangesRequest lessonRequest, RequestState state, String local ){
if(lessonRequest == null || state == lessonRequest.getState() || state == null){
return false;}
if (state == RequestState.Accepted){
Course course = courseRepository.findById(lessonRequest.getCourse().getCourseID());
if(courseRepository.findById(lessonRequest.getCourse().getCourseID())==null|| local == null){
return false;}
Lesson lesson = new Lesson();
lesson.setCourse(course);
lesson.setLessonStart(lessonRequest.getLessonStart());
lesson.setLessonEnd(lessonRequest.getLessonEnd());
lesson.setColor(lessonRequest.getColor());
lesson.setLocal(local);
lesson.setLessonType(lessonRequest.getLessonType());
lesson = lessonRepo.save(lesson);
scheduleLessonService.saveToAllSchedule(lesson);
}
lessonRequest.setState(state);
save(lessonRequest);
return true;
}
public Iterable<LessonChangesRequest> findRequestByLessonId(long id){
return lessonChangesRepo.findRequestByLessonId(id);
}
/**
* Refuse all the lesson request that depends on a certain lesson
* Used after the deletion of the lesson
*/
public void refuseAllByLessonId(long id){
Iterable<LessonChangesRequest> toRefuse = findRequestByLessonId(id);
for(LessonChangesRequest element : toRefuse)
element.setState(RequestState.Refused);
}
/**
* Modify a lesson if a request is accepted
*/
public boolean modifyChangeRequestState(Map<String, Object> updates, long lessonId,RequestState state){
if(state == RequestState.Accepted){
Lesson lesson = lessonServ.findById(lessonId);
return lessonServ.modifyData(lesson.getLessonID(),updates);
}
return true;
}
/**
* Delete a lesson if a request is accepted
*/
public void modifyDeleteRequest(LessonChangesRequest lessonChangesRequest, RequestState state){
if(state == RequestState.Accepted){
lessonServ.delete(lessonServ.findById(lessonChangesRequest.getLessonId()));
refuseAllByLessonId(lessonChangesRequest.getLessonId());
}
}
/**
* Construct a lesson request
*/
public LessonChangesRequest createLessonRequest(Map<String,Object> lessonInfos) {
LessonChangesRequest target = new LessonChangesRequest();
for (Map.Entry<String, Object> entry : lessonInfos.entrySet()) {
System.out.println(entry.toString());
if(entry.getValue() != null){
switch (entry.getKey()) {
case "requestType":
target.setRequestType((int) entry.getValue());
break;
case "lessonStart":
target.setLessonStart((String) entry.getValue());
break;
case "lessonEnd":
target.setLessonEnd((String) entry.getValue());
break;
case "color":
target.setColor((String) entry.getValue());
break;
case "user":
target.setUser(userServ.getUserById((int) entry.getValue()));
break;
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
case "course":
target.setCourse(courseRepository.findById((int) entry.getValue()));
break;
case "lessonId":
target.setLessonId((int) entry.getValue());
break;
}
}
}
target.setState(RequestState.Pending);
return target;
}
public void delete (LessonChangesRequest toDelete) {
lessonChangesRepo.delete(toDelete);
}
}

View File

@ -0,0 +1,150 @@
package ovh.herisson.Clyde.Services;
/******************************************************
* @file LessonService.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.CourseRepository;
import ovh.herisson.Clyde.Repositories.CurriculumCourseRepository;
import ovh.herisson.Clyde.Repositories.LessonRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Tables.*;
import java.util.ArrayList;
import java.util.Map;
@Service
public class LessonService {
private final LessonRepository lessonRepo;
private final UserCurriculumRepository userCurriculumRepo;
private final CourseRepository courseRepo;
private final CurriculumCourseRepository curriculumCourseRepo;
public LessonService(LessonRepository lessonRepo, UserCurriculumRepository userCurriculumRepo, CourseRepository courseRepo, CurriculumCourseRepository curriculumCourseRepo){
this.lessonRepo = lessonRepo;
this.userCurriculumRepo = userCurriculumRepo;
this.courseRepo = courseRepo;
this.curriculumCourseRepo = curriculumCourseRepo;
}
/**
* Create a lesson
*/
public Lesson save(Lesson lesson){
return lessonRepo.save(lesson);
}
/**
* Find a lesson by its id
*/
public Lesson findById(long id){
return lessonRepo.findById(id);
}
/**
* Return all the lessons
*/
public Iterable<Lesson> findAll(){return lessonRepo.findAll();}
/**
* Return all a teacher's lessons
*/
public Iterable<Lesson> findAllOwnedLesson(User teacher){
ArrayList<Lesson> toReturn = new ArrayList<>();
ArrayList<Course> coursesOwned = (ArrayList<Course>) courseRepo.findAllOwnedCoures(teacher);
for (Course element : coursesOwned) {
for(Lesson lesson : lessonRepo.findLessonByCourse(element))
toReturn.add(lesson);
}
return toReturn;
}
/**
* Return all a student's lessons
*/
public Iterable<Lesson> findOnesLessons(User student){
ArrayList<Lesson> toReturn = new ArrayList<>();
ArrayList<Course> courses = new ArrayList<>();
ArrayList<UserCurriculum> userCurricula = userCurriculumRepo.findByUserAndActual(student, true);
for (UserCurriculum userCurriculum : userCurricula) {
curriculumCourseRepo.findCoursesByCurriculum(userCurriculum.getCurriculum()).forEach((item) -> {
//We need this to eliminate clones because a course can belong to several curriculums
if (!courses.contains(item)) {
System.out.println(item.getTitle());
courses.add(item);
}
});
}
for (Course element : courses) {
for(Lesson lesson : lessonRepo.findLessonByCourse(element))
toReturn.add(lesson);
}
return toReturn;
}
/**
* Construct a new lesson
*/
public Lesson createLesson(Map<String,Object> lessonInfos) {
Lesson target = new Lesson();
for (Map.Entry<String, Object> entry : lessonInfos.entrySet()) {
switch (entry.getKey()) {
case "lessonStart":
target.setLessonStart((String) entry.getValue());
break;
case "lessonEnd":
target.setLessonEnd((String) entry.getValue());
case "color":
target.setColor((String) entry.getValue());
break;
case "local":
target.setLocal((String) entry.getValue());
break;
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
case "courseID":
target.setCourse(courseRepo.findById((int) entry.getValue()));
break;
}
}
return target;
}
/**
* Modify a lesson
*/
public boolean modifyData(long id, Map<String ,Object> updates){
Lesson target = lessonRepo.findById(id);
if(target == null)
return false;
for (Map.Entry<String , Object> entry: updates.entrySet()){
switch (entry.getKey()){
case "lessonStart":
target.setLessonStart((String) entry.getValue());
break;
case "lessonEnd":
target.setLessonEnd((String) entry.getValue());
break;
case "local":
target.setLocal((String) entry.getValue());
break;
case "lessonType":
target.setLessonType((String) entry.getValue());
break;
}
}
lessonRepo.save(target);
return true;
}
/**
* Delete a lesson
*/
public void delete(Lesson lesson){
lessonRepo.delete(lesson);
}
}

View File

@ -1,8 +1,7 @@
package ovh.herisson.Clyde.Services; package ovh.herisson.Clyde.Services;
import ovh.herisson.Clyde.Tables.Course; import ovh.herisson.Clyde.Tables.*;
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
import ovh.herisson.Clyde.Tables.User;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -30,6 +29,7 @@ public class ProtectionService {
toReturn.put("country",user.getCountry()); toReturn.put("country",user.getCountry());
toReturn.put("profilePictureUrl",user.getProfilePictureUrl()); toReturn.put("profilePictureUrl",user.getProfilePictureUrl());
toReturn.put("role",user.getRole()); toReturn.put("role",user.getRole());
toReturn.put("identityCard", user.getIdentityCardUrl());
return toReturn; return toReturn;
} }
@ -69,6 +69,33 @@ public class ProtectionService {
} }
public static HashMap<String , Object> lessonWithoutPassword(Lesson lesson){
if(lesson == null)
return null;
HashMap<String, Object> toReturn = new HashMap<>();
toReturn.put("lessonID", lesson.getLessonID());
toReturn.put("lessonStart", lesson.getLessonStart());
toReturn.put("lessonEnd", lesson.getLessonEnd());
toReturn.put("course",courseWithoutPassword(lesson.getCourse()));
toReturn.put("local",lesson.getLocal());
toReturn.put("color", lesson.getColor());
toReturn.put("lessonType",lesson.getLessonType());
return toReturn;
}
public static Iterable<HashMap<String ,Object>> lessonsWithoutPassword(Iterable<Lesson> lessons){
ArrayList<HashMap<String,Object>> toReturn = new ArrayList<>();
for (Lesson l: lessons){
toReturn.add(ProtectionService.lessonWithoutPassword(l));
}
return toReturn;
}
public static Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) { public static Map<String, Object> requestWithoutPassword(InscriptionRequest inscriptionRequest) {
@ -93,6 +120,32 @@ public class ProtectionService {
return toReturn; return toReturn;
} }
public static Map<String, Object> lessonRequestWithoutPassword(LessonChangesRequest lessonRequest){
if (lessonRequest == null)
return null;
Map<String, Object> toReturn = new HashMap<>();
toReturn.put("id", lessonRequest.getId());
toReturn.put("lessonStart", lessonRequest.getLessonStart());
toReturn.put("lessonEnd", lessonRequest.getLessonEnd());
toReturn.put("lessonType",lessonRequest.getLessonType());
toReturn.put("course", courseWithoutPassword(lessonRequest.getCourse()));
toReturn.put("user", userWithoutPassword(lessonRequest.getUser()));
toReturn.put("requestType", lessonRequest.getRequestType());
toReturn.put("state", lessonRequest.getState());
toReturn.put("lessonId",lessonRequest.getLessonId());
return toReturn;
}
public static Iterable<Map<String, Object>> lessonRequestsWithoutPassword(Iterable<LessonChangesRequest> lessonChangesRequests){
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
for(LessonChangesRequest lessonChangeRequest: lessonChangesRequests){
toReturn.add(lessonRequestWithoutPassword(lessonChangeRequest));
}
return toReturn;
}
public static Iterable<Map<String ,Object>> requestsWithoutPasswords(Iterable<InscriptionRequest> inscriptionRequests){ public static Iterable<Map<String ,Object>> requestsWithoutPasswords(Iterable<InscriptionRequest> inscriptionRequests){
ArrayList<Map<String,Object>> toReturn = new ArrayList<>(); ArrayList<Map<String,Object>> toReturn = new ArrayList<>();

View File

@ -0,0 +1,93 @@
package ovh.herisson.Clyde.Services;
/******************************************************
* @file ScheduleLessonService.java
* @author William Karpinski
* @scope Extension Horaire
******************************************************/
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.LessonRepository;
import ovh.herisson.Clyde.Repositories.ScheduleLessonRepository;
import ovh.herisson.Clyde.Repositories.ScheduleRepository;
import ovh.herisson.Clyde.Tables.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Service
public class ScheduleLessonService {
private final ScheduleLessonRepository scheduleLessonRepo;
private final LessonRepository lessonRepo;
private final ScheduleRepository scheduleRepo;
public ScheduleLessonService(ScheduleLessonRepository scheduleLessonRepo, LessonRepository lessonRepo, ScheduleRepository scheduleRepo) {
this.scheduleLessonRepo = scheduleLessonRepo;
this.lessonRepo = lessonRepo;
this.scheduleRepo = scheduleRepo;
}
public boolean save(ScheduleLesson scheduleLesson){
if(scheduleLesson == null)
return false;
scheduleLessonRepo.save(scheduleLesson);
return true;
}
/**
* Save a lesson to all the schedule it is linked
*/
public boolean saveToAllSchedule(Lesson lesson){
Iterable<Schedule> schedules = scheduleRepo.findAllLessonSchedule(lesson.getCourse());
if(schedules == null)
return false;
for (Schedule schedule : schedules){
save(new ScheduleLesson(schedule, lesson));
}
return true;
}
/**
* Delete a scheduleLesson via its lesson
*/
public boolean delete(long lessonId){
if(lessonId == 0)
return false;
scheduleLessonRepo.delete(lessonRepo.findById(lessonId));
return true;
}
public Schedule getScheduleByCurriculum(Curriculum curriculum){
return scheduleLessonRepo.findScheduleByCurriculum(curriculum);
}
/**
* Return a schedule and the list of lessons that corresponds
*/
public Map<String , Object> getDepthScheduleBySchedule(Schedule schedule){
if(schedule == null)
return null;
HashMap<String , Object> toReturn = new HashMap<>();
ArrayList<Map<String, Object>> lessons = new ArrayList<>();
Iterable<Lesson> foundLessons = scheduleLessonRepo.findLessonByCurriculum(schedule.getCurriculum());
for (Lesson l: foundLessons){
lessons.add(ProtectionService.lessonWithoutPassword(l));
}
toReturn.put("lessons",lessons);
toReturn.put("scheduleId" , schedule.getScheduleID());
toReturn.put("curriculum", schedule.getCurriculum());
return toReturn;
}
/**
* Return all the schedules
*/
public Iterable<Map<String,Object>> getAllSchedule(){
ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
for (Schedule schedule: scheduleRepo.findAll()){
toReturn.add(getDepthScheduleBySchedule(schedule));
}
return toReturn;
}
}

View File

@ -0,0 +1,24 @@
package ovh.herisson.Clyde.Services;
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.ScheduleRepository;
import ovh.herisson.Clyde.Tables.Schedule;
@Service
public class ScheduleService {
private final ScheduleRepository scheduleRepo;
public ScheduleService(ScheduleRepository scheduleRepo) {
this.scheduleRepo = scheduleRepo;
}
public Schedule save(Schedule schedule){
return scheduleRepo.save(schedule);
}
public Schedule findById(long id){
return scheduleRepo.getById(id);
}
public void delete(Schedule schedule){
scheduleRepo.delete(schedule);
}
}

View File

@ -3,6 +3,7 @@ package ovh.herisson.Clyde.Tables;
public enum Applications { public enum Applications {
// without any token // without any token
Login, Login,
Schedule,
// with any token // with any token
Profile, Profile,
@ -12,11 +13,18 @@ public enum Applications {
Msg, Msg,
Forum, Forum,
Rdv, Rdv,
// teachers authorization
ManageOwnedLessons,
// teachers and Secretary authorization // teachers and Secretary authorization
ManageCourses, ManageCourses,
UsersList, UsersList,
//Secretary authorization
ManageSchedules,
LessonRequests,
// InscriptionService authorization // InscriptionService authorization
Requests, Requests,
StudentsList, StudentsList,

View File

@ -0,0 +1,101 @@
package ovh.herisson.Clyde.Tables;
/******************************************************
* @file Lesson.java
* @author William Karpinski
* @scope Extension Horaire
*
* Represent a course in a schedule
******************************************************/
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Entity
public class Lesson {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int lessonID;
@ManyToOne(fetch = FetchType.EAGER)
@OnDelete(action = OnDeleteAction.SET_NULL)
@JoinColumn(name = "Course")
private Course course;
private String lessonStart;
private String lessonEnd;
private String color;
private String lessonType;
private String local;
public Lesson(Course course,String start, String end ,String color,String local,String lessonType){
this.lessonEnd = end;
this.course = course;
this.lessonStart = start;
this.color = color;
this.local = local;
this.lessonType = lessonType;
}
public Lesson() {
}
public int getLessonID(){
return lessonID;
}
public void setCourse(Course course) {
this.course = course;
}
public Course getCourse(){
return course;
}
public String getLessonStart(){
return lessonStart;
}
public String getLessonEnd() {
return lessonEnd;
}
public String getColor(){
return color;
}
public String getLocal() {
return local;
}
public String getLessonType(){
return lessonType;
}
public void setLessonStart(String start){
this.lessonStart = start;
}
public void setLessonEnd(String lessonEnd) {
this.lessonEnd = lessonEnd;
}
public void setColor(String color){
this.color = color;
}
public void setLocal(String local){
this.local = local;
}
public void setLessonType(String lessonType){
this.lessonType = lessonType;
}
}

View File

@ -0,0 +1,148 @@
package ovh.herisson.Clyde.Tables;
/******************************************************
* @file LessonChangesRequest.java
* @author William Karpinski
* @scope Extension Horaire
*
* Represent a request about changes on schedules and lessons
******************************************************/
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Entity
public class LessonChangesRequest {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@ManyToOne
@JoinColumn(name = "Users")
@OnDelete(action = OnDeleteAction.CASCADE)
private User user;
private long lessonId;
private RequestState state;
private String lessonStart;
private String lessonEnd;
private String color;
@ManyToOne
@JoinColumn(name ="Course")
private Course course;
private String lessonType;
/**
* Can take 3 values:
* 0 : Request to CREATE a lesson
* 1 : Request to MODIFY an existing lesson
* 2 : Request to DELETE a lesson
*/
private int requestType;
public LessonChangesRequest(User user, RequestState state, String lessonStart,
String lessonEnd, String lessonType, Course course,
int requestType, String color,long lessonId){
this.user = user;
this.state = state;
this.requestType = requestType;
this.lessonType = lessonType;
this.lessonStart = lessonStart;
this.lessonEnd= lessonEnd;
this.color = color;
this.course = course;
this.lessonId = lessonId;
}
public LessonChangesRequest() {
}
public int getId() {
return id;
}
public RequestState getState() {
return state;
}
public User getUser() {
return user;
}
public long getLessonId(){
return lessonId;
}
public String getLessonStart() {
return lessonStart;
}
public String getLessonEnd() {
return lessonEnd;
}
public int getRequestType() {
return requestType;
}
public String getLessonType() {
return lessonType;
}
public String getColor() {
return color;
}
public Course getCourse() {
return course;
}
public void setState(RequestState state) {
this.state = state;
}
public void setUser(User user) {
this.user = user;
}
public void setLessonStart(String lessonStart) {
this.lessonStart = lessonStart;
}
public void setLessonType(String lessonType) {
this.lessonType = lessonType;
}
public void setLessonEnd(String lessonEnd) {
this.lessonEnd = lessonEnd;
}
public void setColor(String color) {
this.color = color;
}
public void setRequestType(int requestType) {
this.requestType = requestType;
}
public void setLessonId(long lessonId) {
this.lessonId = lessonId;
}
public void setCourse(Course course){
this.course = course;
}
}

View File

@ -0,0 +1,42 @@
package ovh.herisson.Clyde.Tables;
/******************************************************
* @file Schedule.java
* @author William Karpinski
* @scope Extension Horaire
*
* Represent a schedule linked to a curriculum
******************************************************/
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Entity
public class Schedule {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int scheduleID;
@OneToOne
@JoinColumn(name = "Curriculum")
@OnDelete(action = OnDeleteAction.SET_NULL)
private Curriculum curriculum;
public Schedule(Curriculum curriculum){
this.curriculum = curriculum;
}
public Schedule() {}
public int getScheduleID(){
return scheduleID;
}
public Curriculum getCurriculum(){
return curriculum;
}
}

View File

@ -0,0 +1,63 @@
package ovh.herisson.Clyde.Tables;
/******************************************************
* @file ScheduleLesson.java
* @author William Karpinski
* @scope Extension Horaire
*
* Used to link schedules and lessons to each others
******************************************************/
import jakarta.persistence.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
@Entity
public class ScheduleLesson{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "Schedule")
@OnDelete(action = OnDeleteAction.SET_NULL)
private Schedule schedule;
@ManyToOne(fetch = FetchType.EAGER)
@OnDelete(action = OnDeleteAction.SET_NULL)
@JoinColumn(name = "Lesson")
private Lesson lesson;
public ScheduleLesson(Schedule schedule,Lesson lesson){
this.schedule = schedule;
this.lesson = lesson;
}
public ScheduleLesson() {
}
public int getID(){
return id;
}
public Lesson getLesson(){
return lesson;
}
public Schedule getSchedule(){
return schedule;
}
public void setLesson(Lesson lesson){
this.lesson = lesson;
}
public void setSchedule(Schedule schedule){
this.schedule = schedule;
}
}

View File

@ -34,6 +34,7 @@ public class User {
private Date birthDate; private Date birthDate;
private String profilePictureUrl; private String profilePictureUrl;
private Role role; private Role role;
private String identityCardUrl;
@JsonIgnore @JsonIgnore
private String password; private String password;
@ -65,8 +66,10 @@ public class User {
this.password = password; this.password = password;
} }
//This constructor is used to add a student
public User(String lastName, String firstName, String email, String address, public User(String lastName, String firstName, String email, String address,
String country, Date birthDate, String profilePictureUrl, String password) String country, Date birthDate, String profilePictureUrl, String password,String identityCardUrl)
{ {
this.lastName = lastName; this.lastName = lastName;
this.firstName = firstName; this.firstName = firstName;
@ -77,5 +80,6 @@ public class User {
this.profilePictureUrl = profilePictureUrl; this.profilePictureUrl = profilePictureUrl;
this.password = password; this.password = password;
this.role = Role.Student; this.role = Role.Student;
this.identityCardUrl = identityCardUrl;
} }
} }

View File

@ -29,16 +29,76 @@ app.settings=Settings
app.messages=Messages app.messages=Messages
app.forum=Forum app.forum=Forum
app.schedules=Schedules app.schedules=Schedules
app.manageSchedules=Manage Schedules
app.inscription.requests=Inscription Requests app.inscription.requests=Inscription Requests
app.manage.courses=Manage Courses app.manage.courses=Manage Courses
app.language=Language app.language=Language
app.manage.profile=Manage profile app.manage.profile=Manage profile
app.studentList=Students List app.studentList=Students List
app.users=Users app.users=Users
app.manageOwnLessons=Manage Owned Courses Schedule
app.lessonRequests=Schedule Requests
app.payments=Payments app.payments=Payments
request.moreInfos=More Infos request.moreInfos=More Infos
request.accept=Accept request.accept=Accept
request.refuse=Refuse request.refuse=Refuse
Pending=Pending
Delete=Delete
Modify=Modify
Create=Créer
requestType=Request Type
day=Day
start=Start
end=End
monday=Monday
tuesday=Tuesday
wednesday=Wednesday
thursday=Thursday
friday=Friday
saturday=Saturday
sunday=Sunday
january=January
february=February
march=March
april=April
may=May
june=June
july=July
august=August
september=September
october=October
november=November
december=December
Grid=Grid
Week=Week
Month=Month
List=List
Type=Type
Teacher=Teacher
Course=Course
TP=TP
TD=TD
Exam=Exam
OwnSchedule=Own Schedule
SwitchToJSON=Switch to JSON FILE
schedule.previous=Previous
schedule.next=Next
schedule.current=Current
schedule.settings=Settings
schedule.courses=Courses
schedule.teachers=Teacher(s)
schedule.askChanges=Ask Changes
schedule.askCreate=Ask to create course
schedule.askDeletion=Ask Deletion
schedule.createSchedule=Create Schedule
schedule.createLesson=Create course
schedule.deleteMod=Unable deletion
schedule.noDeleteMod=Disable deletion
schedule=Schedule
old_day=Precedent day
old_start=Precedent start
old_end=Precedent end
old_type=Precedent type
courses.createCourse=Create course courses.createCourse=Create course
courses.deleteCourse=Delete course courses.deleteCourse=Delete course
courses.modify=Modify courses.modify=Modify
@ -145,3 +205,6 @@ chcur=Change from a cursus to another
iwouldlike=I would like to : iwouldlike=I would like to :
newcurr=New curriculum newcurr=New curriculum
cursusprereq=The cursus you selected has some prerequisites ensure that your external curriculum data is updated in your profile cursusprereq=The cursus you selected has some prerequisites ensure that your external curriculum data is updated in your profile
imposecurriculum=Impose a curriculum
impose=Impose
gotimposed=The selected curriculum has been imposed

View File

@ -29,16 +29,76 @@ app.settings=Options
app.messages=Messages app.messages=Messages
app.forum=Forum app.forum=Forum
app.schedules=Horaires app.schedules=Horaires
app.manageSchedules=Gérer les horaires
app.inscription.requests=Demandes d'Inscription app.inscription.requests=Demandes d'Inscription
app.manage.courses=Gérer les cours app.manage.courses=Gérer les cours
app.language=Langue app.language=Langue
app.manage.profile=Gérer le profil app.manage.profile=Gérer le profil
app.studentList=Liste des étudiants app.studentList=Liste des étudiants
app.users=Utilisateurs app.users=Utilisateurs
app.manageOwnLessons=Gérer ses horaires de cours
app.lessonRequests=Requêtes d'horaire
app.payments=Payements app.payments=Payements
request.moreInfos=Plus d'Infos request.moreInfos=Plus d'Infos
request.accept=Accepter request.accept=Accepter
request.refuse=Refuser request.refuse=Refuser
Pending=En attente
Delete=Supprimer
Modify=Modifier
Create=Créer
requestType=Type de Requête
day=Jour
start=Début
end=Fin
monday=Lundi
tuesday=Mardi
wednesday=Mercredi
thursday=Jeudi
friday=Vendredi
saturday=Samedi
sunday=Dimanche
january=Janvier
february=Février
march=Mars
april=Avril
may=Mai
june=Juin
july=Juillet
august=Août
september=Septembre
october=Octobre
november=Novembre
december=Decembre
Grid=Grille
Week=Semaine
Month=Mois
List=Liste
Type=Type
Teacher=Professeur
Course=Cours
TP=TP
TD=TD
Exam=Exam
OwnSchedule=Mon Horaire
SwitchToJSON=Afficher le JSON
schedule.previous=Précédent
schedule.next=Prochain
schedule.current=Actuel
schedule.settings=Options
schedule.courses=Cours
schedule.teachers=Professeurs(s)
schedule.askChanges=Demander Changement
schedule.askCreate=Demander de créer un cours
schedule.askDeletion=Demander suppression
schedule.createSchedule=Créer Horaire
schedule.createLesson=Créer cours
schedule.deleteMod=Activer suppression
schedule.noDeleteMod=Désactiver suppression
schedule=Horaire
old_day=Ancien Jour
old_start=Ancien Début
old_end=Ancienne Fin
old_type=Ancien Type
courses.createCourse=Créer un cours courses.createCourse=Créer un cours
courses.deleteCourse=Supprimer un cours courses.deleteCourse=Supprimer un cours
courses.modify=Modifier courses.modify=Modifier
@ -145,3 +205,6 @@ chcur=Changer d'un cursus vers un autre
iwouldlike=Je voudrais : iwouldlike=Je voudrais :
newcurr=Nouveau cursus newcurr=Nouveau cursus
cursusprereq=Le cursus que vous avez selectionné a des prérequis assurez vous que votre dossier de parcours est a jour dans votre profil cursusprereq=Le cursus que vous avez selectionné a des prérequis assurez vous que votre dossier de parcours est a jour dans votre profil
imposecurriculum=Imposer un cursusgotimposed
impose=Imposer
gotimposed=Le cursus selectionné a été imposé

View File

@ -237,6 +237,7 @@ window.addEventListener('hashchange', () => {
.text { .text {
right: 0%; right: 0%;
width: 0%; width: 0%;
visibility: collapse;
opacity: 0; opacity: 0;
color: white; color: white;
font-size: 1.2em; font-size: 1.2em;
@ -246,6 +247,7 @@ window.addEventListener('hashchange', () => {
ul.vertical:hover .text { ul.vertical:hover .text {
opacity:1; opacity:1;
visibility:visible;
width: 60%; width: 60%;
transition-duration: .3s; transition-duration: .3s;
padding-left: 15px; padding-left: 15px;

View File

@ -1,15 +1,12 @@
<script setup> <script setup>
import { import {
addUninscReq, editChangeCurrReq, editChangeCurrReqTeacherState, editChangeCurrReq, editChangeCurrReqTeacherState,
editScholarshipReq, getChangeCurrReqById,
editUnregReq, getChangeCurrReqById,
getScholarshipReqById,
getUnregisterbyId
} from "@/rest/requests.js"; } from "@/rest/requests.js";
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {getSelf, getUser} from "@/rest/Users.js"; import {getSelf} from "@/rest/Users.js";
import {reactive, ref} from "vue"; import {ref} from "vue";
import AboutStudent from "@/Apps/Inscription/AboutStudent.vue"; import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
const props = defineProps(["reqId"]) const props = defineProps(["reqId"])
@ -88,11 +85,6 @@ async function editChangeCurrReqTeacherApproval(state){
"minfos minfos"; "minfos minfos";
} }
.profilPic{
width:100%;
grid-area:profilPic;
}
.globalInfos { .globalInfos {
grid-area:globalInfos; grid-area:globalInfos;
align-self :center; align-self :center;
@ -108,13 +100,6 @@ async function editChangeCurrReqTeacherApproval(state){
margin-top:7%; margin-top:7%;
} }
.subContainter{
width:100%;
background-color:rgb(50,50,50);
border-radius:20px;
border:4px solid black;
}
.infosContainer { .infosContainer {
min-width:350px; min-width:350px;
padding-bottom:50px; padding-bottom:50px;

View File

@ -1,15 +1,11 @@
<script setup> <script setup>
import { import {
addUninscReq,
editExempReqState, editExempReqState,
editScholarshipReq,
getExempReq, getExempReq,
getScholarshipReqById
} from "@/rest/requests.js"; } from "@/rest/requests.js";
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {getUser} from "@/rest/Users.js"; import {ref} from "vue";
import {reactive, ref} from "vue";
import AboutStudent from "@/Apps/Inscription/AboutStudent.vue"; import AboutStudent from "@/Apps/Inscription/AboutStudent.vue";
const props = defineProps(["reqId"]) const props = defineProps(["reqId"])
@ -44,7 +40,7 @@ async function editExemp(newstate){
<button @click="profile = !profile">{{ i18n("seeprofile") }}</button> <button @click="profile = !profile">{{ i18n("seeprofile") }}</button>
</div> </div>
<div> <div>
<button>{{ i18n("dljustifdoc") }}</button> <button><a :href="req.justifDocument">{{ i18n("dljustifdoc") }}</a></button>
</div> </div>
<div> <div>
<button v-if="req.state === 'Pending'" @click="req.state='Accepted';editExemp('Accepted')">{{ i18n("request.accept") }}</button> <button v-if="req.state === 'Pending'" @click="req.state='Accepted';editExemp('Accepted')">{{ i18n("request.accept") }}</button>
@ -76,11 +72,6 @@ async function editExemp(newstate){
"minfos minfos"; "minfos minfos";
} }
.profilPic{
width:100%;
grid-area:profilPic;
}
.globalInfos { .globalInfos {
grid-area:globalInfos; grid-area:globalInfos;
align-self :center; align-self :center;
@ -96,13 +87,6 @@ async function editExemp(newstate){
margin-top:7%; margin-top:7%;
} }
.subContainter{
width:100%;
background-color:rgb(50,50,50);
border-radius:20px;
border:4px solid black;
}
.infosContainer { .infosContainer {
min-width:350px; min-width:350px;
padding-bottom:50px; padding-bottom:50px;

View File

@ -1,20 +1,23 @@
<script setup> <script setup>
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import {getSelf, getUser} from '../../rest/Users.js' import {getSelf} from '../../rest/Users.js'
import {getcurriculum} from "@/rest/curriculum.js"; import {getAllCurriculums, getcurriculum} from "@/rest/curriculum.js";
import {getRegisters} from "@/rest/ServiceInscription.js"; import {getRegisters} from "@/rest/ServiceInscription.js";
import {get} from "jsdom/lib/jsdom/named-properties-tracker.js";
import {getExternalCurriculumByInscrReq} from "@/rest/externalCurriculum.js"; import {getExternalCurriculumByInscrReq} from "@/rest/externalCurriculum.js";
import {ref} from "vue"; import {ref} from "vue";
import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue"; import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue";
import {editEquivalenceState} from "@/rest/requests.js"; import {editEquivalenceState, imposeCurriculum} from "@/rest/requests.js";
const curriculums = await getAllCurriculums()
const props = defineProps(['target']); const props = defineProps(['target']);
const request = await getRegisters(props.target); const request = await getRegisters(props.target);
const cursus = await getcurriculum(request.curriculum); const cursus = await getcurriculum(request.curriculum);
const user = await getSelf(); const user = await getSelf();
const list = ref(false); const list = ref(false);
const externalCurriculum = await getExternalCurriculumByInscrReq(request.id) const externalCurriculum = await getExternalCurriculumByInscrReq(request.id)
const impose = ref(false)
const imposeCurr = ref(0)
const imposed = ref(false)
//Get the parent page windowState to display the correct button //Get the parent page windowState to display the correct button
const windowState = defineModel("windowState") const windowState = defineModel("windowState")
@ -28,6 +31,10 @@ function getPP(){
async function editEquivalence(id, newstate){ async function editEquivalence(id, newstate){
await editEquivalenceState(id, newstate) await editEquivalenceState(id, newstate)
} }
async function refreshCursus(){
cursus.value = await getcurriculum(request.curriculum)
}
</script> </script>
<template> <template>
@ -57,10 +64,10 @@ async function editEquivalence(id, newstate){
{{ i18n("WantedCursus") }} : BAB {{cursus.year}} {{cursus.option}} {{ i18n("WantedCursus") }} : BAB {{cursus.year}} {{cursus.option}}
</div> </div>
<div style="margin-top: 3%"> <div style="margin-top: 3%">
<a :href="request.identityCard">{{ i18n("dlidentitycard") }}</a> <button><a :href="request.identityCard">{{ i18n("dlidentitycard") }}</a></button>
<button v-if="request.admissionDocUrl != null">{{ i18n("dladmissiondoc") }}</button> <button v-if="request.admissionDocUrl != null"><a :href="request.admissionDocUrl">{{ i18n("dladmissiondoc") }}</a></button>
</div> </div>
<div v-if="cursus.year > 1"> <div v-if="externalCurriculum.length !== 0">
<button style="background-color:rgb(105,05,105);margin-top: 3%" @click="list=!list" v-if="(user.role == 'Teacher' || user.role == 'Admin')">{{ i18n("seeextcur") }}</button> <button style="background-color:rgb(105,05,105);margin-top: 3%" @click="list=!list" v-if="(user.role == 'Teacher' || user.role == 'Admin')">{{ i18n("seeextcur") }}</button>
</div> </div>
</div> </div>
@ -73,9 +80,20 @@ async function editEquivalence(id, newstate){
<div v-if="list==true"> <div v-if="list==true">
<ExternalCurriculumList :ext-curr-list="externalCurriculum" :mode="0"></ExternalCurriculumList> <ExternalCurriculumList :ext-curr-list="externalCurriculum" :mode="0"></ExternalCurriculumList>
<div style="margin-left: 15%;margin-top: 5%;"> <div style="margin-left: 15%;margin-top: 5%;">
<button style="margin-left: 2%" v-if="request.equivalenceState === 'Pending'" @click="list = false;editEquivalence(request.id, 'Accepted'); request.equivalenceState='Accepted'">{{i18n("acceptequiv")}}</button> <button style="margin-left: 2%" v-if="request.equivalenceState === 'Pending' && !impose" @click="list = false;editEquivalence(request.id, 'Accepted'); request.equivalenceState='Accepted'">{{i18n("acceptequiv")}}</button>
<button style="margin-left: 2%" v-if="request.equivalenceState === 'Pending'" @click="list = false;editEquivalence(request.id, 'Refused'); request.equivalenceState='Refused'">{{i18n("refuseequiv")}}</button> <button style="margin-left: 2%;margin-right: 3%" v-if="request.equivalenceState === 'Pending' && !impose" @click="list = false;editEquivalence(request.id, 'Refused'); request.equivalenceState='Refused'">{{i18n("refuseequiv")}}</button>
<button style="margin-left: 2%" @click="list=false">Back</button> <div v-if="!imposed && request.equivalenceState !== 'Accepted'" style="margin-top: 3%;margin-left: 1%">
{{i18n("imposecurriculum")}}
<input type="checkbox" v-model="impose" v-if="!imposed">
<select v-if="impose" v-model="imposeCurr">
<option v-for="item in curriculums" :value="item.curriculumId">Bac {{item.year}} {{item.option}}</option>
</select>
</div>
<button v-if="impose && !imposed" style="margin-left: 2%" @click="imposeCurriculum(request.id, imposeCurr);request.equivalenceState='Accepted';imposed=true;">{{ i18n("impose") }}</button>
<div v-if="imposed">
{{ i18n("gotimposed") }}
</div>
<button style="margin-left: 2%" @click="list=false;refreshCursus()">{{ i18n("courses.back") }}</button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,8 +1,7 @@
<script setup> <script setup>
import {addUninscReq, editScholarshipReq, getScholarshipReqById} from "@/rest/requests.js"; import {editScholarshipReq, getScholarshipReqById} from "@/rest/requests.js";
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {getUser} from "@/rest/Users.js";
import {reactive, ref} from "vue"; import {reactive, ref} from "vue";
const props = defineProps(["reqId"]) const props = defineProps(["reqId"])
@ -54,8 +53,8 @@ async function uploadandrefreshScholarshipRequest(){
{{ i18n("login.guest.birthday") }} : {{user.birthDate.slice(0,10)}} {{ i18n("login.guest.birthday") }} : {{user.birthDate.slice(0,10)}}
</div> </div>
<div> <div>
<button @click="">{{ i18n("dltaxdoc") }}</button> <button><a :href="req.taxDocUrl">{{ i18n("dltaxdoc") }}</a></button>
<button style="margin-left: 2%">{{ i18n("dlresidency") }}</button> <button style="margin-left: 2%"><a :href="req.residencyDocUrl">{{ i18n("dlresidency") }}</a></button>
</div> </div>
<div v-if="req.state == 'Pending'" style="margin-top: 2%; margin-bottom: 2%;"> <div v-if="req.state == 'Pending'" style="margin-top: 2%; margin-bottom: 2%;">
{{i18n("enteramount")}} {{i18n("enteramount")}}

View File

@ -5,7 +5,6 @@
import {ref} from "vue"; import {ref} from "vue";
import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue"; import ExternalCurriculumList from "@/Apps/Inscription/ExternalCurriculumList.vue";
import {getExternalCurriculumByUser} from "@/rest/externalCurriculum.js"; import {getExternalCurriculumByUser} from "@/rest/externalCurriculum.js";
import {getUserActualCourses} from "@/rest/courses.js";
const props = defineProps(['target']) const props = defineProps(['target'])
const user = await getUser(props.target) const user = await getUser(props.target)
@ -13,9 +12,6 @@
const externalcurrlist = await getExternalCurriculumByUser(user.regNo) const externalcurrlist = await getExternalCurriculumByUser(user.regNo)
const extercurrlist = ref(false) const extercurrlist = ref(false)
const courselist = await getUserActualCourses(user.regNo)
console.log(courselist)
const watchingUser = await getSelf() const watchingUser = await getSelf()
function getPP(){ function getPP(){
if(user.profilePictureUrl === null){ if(user.profilePictureUrl === null){
@ -23,17 +19,6 @@
} }
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>
@ -60,7 +45,7 @@
{{ i18n("login.guest.birthday") }} : {{user.birthDate}} {{ i18n("login.guest.birthday") }} : {{user.birthDate}}
</div> </div>
<div> <div>
<button v-if="watchingUser.role === 'Admin' || watchingUser.role === 'InscriptionService' || watchingUser.role === 'Secretary' || watchingUser.regNo === user.regNo">{{i18n("dlidentitycard")}}</button> <button v-if="watchingUser.role === 'Admin' || watchingUser.role === 'InscriptionService' || watchingUser.role === 'Secretary' || watchingUser.regNo === user.regNo"><a :href="user.identityCard">{{i18n("dlidentitycard")}}</a></button>
</div> </div>
<div> <div>
<button @click="extercurrlist=!extercurrlist">{{i18n("seeextcur")}}</button> <button @click="extercurrlist=!extercurrlist">{{i18n("seeextcur")}}</button>

View File

@ -1,26 +1,15 @@
<script setup> <script setup>
import { import {
addUninscReq,
editScholarshipReq,
editUnregReq, editUnregReq,
getScholarshipReqById,
getUnregisterbyId getUnregisterbyId
} from "@/rest/requests.js"; } from "@/rest/requests.js";
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {getUser} from "@/rest/Users.js"; import {ref} from "vue";
import {reactive, ref} from "vue";
const props = defineProps(["reqId"]) const props = defineProps(["reqId"])
const req = ref(await getUnregisterbyId(props.reqId)) const req = ref(await getUnregisterbyId(props.reqId))
function getPP(){
if(user.profilePictureUrl === null){
return "/Clyde.png"
}
return user.profilePictureUrl
}
async function uploadandrefreshUnregRequest(state){ async function uploadandrefreshUnregRequest(state){
await editUnregReq(req.value.id, state) await editUnregReq(req.value.id, state)
req.value.state = state req.value.state = state
@ -69,15 +58,9 @@ async function uploadandrefreshUnregRequest(state){
"minfos minfos"; "minfos minfos";
} }
.profilPic{
width:100%;
grid-area:profilPic;
}
.globalInfos { .globalInfos {
grid-area:globalInfos; grid-area:globalInfos;
align-self :center; align-self :center;
} }
.body { .body {
@ -89,13 +72,6 @@ async function uploadandrefreshUnregRequest(state){
margin-top:7%; margin-top:7%;
} }
.subContainter{
width:100%;
background-color:rgb(50,50,50);
border-radius:20px;
border:4px solid black;
}
.infosContainer { .infosContainer {
min-width:350px; min-width:350px;
padding-bottom:50px; padding-bottom:50px;

View File

@ -2,9 +2,8 @@
import {reactive, ref} from "vue"; import {reactive, ref} from "vue";
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {getCourse} from "@/rest/courses.js";
import {getcurriculum} from "@/rest/curriculum.js"; import {getcurriculum} from "@/rest/curriculum.js";
import {uploadFile, uploadProfilePicture} from "@/rest/uploads.js"; import {uploadFile} from "@/rest/uploads.js";
import {createExemptionsRequest, getExempByUser} from "@/rest/requests.js"; import {createExemptionsRequest, getExempByUser} from "@/rest/requests.js";
import {getSelf} from "@/rest/Users.js"; import {getSelf} from "@/rest/Users.js";
@ -14,7 +13,7 @@ const user = await getSelf()
const windowState = defineModel("windowState") const windowState = defineModel("windowState")
const exempList = await getExempByUser(user.regNo) const exempList = await getExempByUser(user.regNo)
const submitted = ref(false)
const courseslist = ref(await getcurriculum(selectedCurriculum.value.curriculumId)) const courseslist = ref(await getcurriculum(selectedCurriculum.value.curriculumId))
const list = ref(true) const list = ref(true)
@ -57,7 +56,7 @@ function isExempted(course){
<div class="firstname">{{item.owner.firstName}}</div> <div class="firstname">{{item.owner.firstName}}</div>
<div class="lastname">{{item.owner.lastName}}</div> <div class="lastname">{{item.owner.lastName}}</div>
<div class="credits">credits : {{item.credits}}</div> <div class="credits">credits : {{item.credits}}</div>
<div class="askexemption" v-if="!isExempted(item)"><button style="background-color:rgb(105,0,0);" @click="list= !list;exemptReq.courseId=item.courseId">{{i18n("askexemp")}}</button></div> <div class="askexemption" v-if="!isExempted(item)"><button style="background-color:rgb(105,0,0);" @click="list= !list;exemptReq.courseId=item.courseID;">{{i18n("askexemp")}}</button></div>
<div v-else class="askexemption" style="font-size: 50%">{{ i18n("exemp") }}</div> <div v-else class="askexemption" style="font-size: 50%">{{ i18n("exemp") }}</div>
</div> </div>
</div> </div>
@ -67,18 +66,21 @@ function isExempted(course){
</div> </div>
</div> </div>
<div v-if="list === false" class="infosContainer"> <div v-if="list === false" class="infosContainer">
<p>{{ i18n("uploadjustifdoc") }} </p> <p v-if="!submitted">{{ i18n("uploadjustifdoc") }} </p>
<div> <div>
<label class="browser"> <label class="browser" v-if="!submitted">
<input type="file" @change="ppData.value = $event.target.files" accept="image/*" ref="filepath"> <input type="file" @change="ppData.value = $event.target.files" ref="filepath">
</label> </label>
</div> </div>
<button style="margin-top: 3%" @click="postExemptionRequest(ppData.value, 'JustificationDocument');"> <button style="margin-top: 3%" v-if="!submitted" @click="postExemptionRequest(ppData.value, 'JustificationDocument');submitted=!submitted">
{{ i18n("subexemreq") }} {{ i18n("subexemreq") }}
</button> </button>
<div v-if="submitted">
{{i18n("reqsent")}}
</div>
</div> </div>
<div v-if="list === false"> <div v-if="list === false">
<button @click="list=!list">{{ i18n("courses.back") }}</button> <button @click="list=!list;submitted=!submitted">{{ i18n("courses.back") }}</button>
</div> </div>
</template> </template>

View File

@ -31,7 +31,7 @@
completion : "completed", completion : "completed",
startYear : 0, startYear : 0,
endYear: 0, endYear: 0,
justifdocUrl : null, justifdocUrl : "",
userRegNo : null userRegNo : null
}) })
@ -43,7 +43,6 @@
if(props.mode !== 2){ if(props.mode !== 2){
extCurrList.value = props.extCurrList extCurrList.value = props.extCurrList
console.log("oe")
} }
function deleteExtCursus(extcursus){ function deleteExtCursus(extcursus){
@ -86,7 +85,7 @@
<div class="school"><a>{{item.school}}</a></div> <div class="school"><a>{{item.school}}</a></div>
<div class="formation"><a>{{item.formation}}</a></div> <div class="formation"><a>{{item.formation}}</a></div>
<div class="completion"><a>{{item.completion}}</a></div> <div class="completion"><a>{{item.completion}}</a></div>
<div class="download"><button>{{ i18n("dldoc") }}</button></div> <div class="download" v-if="props.mode!==2"><button><a :href="item.justifdocUrl">{{ i18n("dldoc") }}</a></button></div>
<div class="edit" v-if="props.mode === 2"><button @click="list=!list;externalCurr.justifdocUrl=item.justifDocUrl; externalCurr.endYear = item.endYear; externalCurr.startYear = item.startYear; externalCurr.school = item.school;externalCurr.completion = item.completion;externalCurr.formation=item.formation;editmode=!editmode;extNum=index">{{i18n("edit")}}</button></div> <div class="edit" v-if="props.mode === 2"><button @click="list=!list;externalCurr.justifdocUrl=item.justifDocUrl; externalCurr.endYear = item.endYear; externalCurr.startYear = item.startYear; externalCurr.school = item.school;externalCurr.completion = item.completion;externalCurr.formation=item.formation;editmode=!editmode;extNum=index">{{i18n("edit")}}</button></div>
<div class="delete" v-if="props.mode === 2"><button @click="deleteExtCursus(item)">{{ i18n("delete") }}</button></div> <div class="delete" v-if="props.mode === 2"><button @click="deleteExtCursus(item)">{{ i18n("delete") }}</button></div>
</div> </div>

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import {ref, vModelSelect, watch} from 'vue' import {ref, watch} from 'vue'
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
import AboutRequest from "@/Apps/Inscription/AboutRequest.vue"; import AboutRequest from "@/Apps/Inscription/AboutRequest.vue";
import { import {
@ -18,7 +18,7 @@
const requests = ref(await getAllRegisters()); const requests = ref(await getAllRegisters());
let targetId = ""; let targetId = "";
const user = await getSelf() const user = await getSelf()
const requestType = ref("inscription"); const requestType = ref(i18n("inscription"));
const filterType = ref("None"); const filterType = ref("None");
//0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister, 5 = manage curriculum change, 6 = manage exemptions //0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister, 5 = manage curriculum change, 6 = manage exemptions
@ -91,8 +91,8 @@
<div class="equivalencestate" style="font-size: 80%">{{ i18n("teacherapproval") }} {{item.equivalenceState}}</div> <div class="equivalencestate" style="font-size: 80%">{{ i18n("teacherapproval") }} {{item.equivalenceState}}</div>
<div class="surname">{{item.lastName}}</div> <div class="surname">{{item.lastName}}</div>
<div class="firstname">{{item.firstName}}</div> <div class="firstname">{{item.firstName}}</div>
<div class="accept" v-if="item.state === 'Pending'"><button @click="windowsState=2;targetId=item.id;" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div> <div class="accept" v-if="item.state === 'Pending' && (user.role === 'Admin' || user.role === 'InscriptionService')"><button @click="windowsState=2;targetId=item.id;" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
<div class="refuse" v-if="item.state === 'Pending'"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div> <div class="refuse" v-if="item.state === 'Pending' && (user.role === 'Admin' || user.role === 'InscriptionService')"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
<div class="infos"><button style="background-color:rgb(105,05,105);" @click="targetId=item.id;windowsState=1;">{{i18n("request.moreInfos")}}</button></div> <div class="infos"><button style="background-color:rgb(105,05,105);" @click="targetId=item.id;windowsState=1;">{{i18n("request.moreInfos")}}</button></div>
</div> </div>
<div class="container" style="grid-template-columns:25% 15% 15% 25% 14.2%;grid-template-areas:'date reqState studentfirstname studentlastname infos';" v-if="requestType === i18n('scholarship')"> <div class="container" style="grid-template-columns:25% 15% 15% 25% 14.2%;grid-template-areas:'date reqState studentfirstname studentlastname infos';" v-if="requestType === i18n('scholarship')">
@ -131,11 +131,13 @@
</div> </div>
</div> </div>
</div> </div>
<div style='display:flex; justify-content:center; min-width:1140px;margin-top: 10%' v-if="windowsState === 2"> <div class="infosContainer" style='margin-left:15%;display:flex; justify-content:center; width: 70%;margin-top: 10%' v-if="windowsState === 2">
<p>{{ i18n("surreq") }}</p> <p>{{ i18n("surreq") }}</p>
<button style="background-color:rgb(105,05,105);" @click="upPage(targetId,'Accepted');windowsState=0;">{{ i18n("validate") }}</button> <div style="margin-left: 10%; margin-top: 1.5%; width: 30%">
<button style="background-color:rgb(105,05,105);margin-right: 2%" @click="upPage(targetId,'Accepted');windowsState=0;">{{ i18n("validate") }}</button>
<button style="background-color:rgb(105,05,105);" @click="windowsState=0;">{{ i18n("courses.back")}}</button> <button style="background-color:rgb(105,05,105);" @click="windowsState=0;">{{ i18n("courses.back")}}</button>
</div> </div>
</div>
<div v-if="windowsState === 3"> <div v-if="windowsState === 3">
<AboutScholarship :req-id="targetId"></AboutScholarship> <AboutScholarship :req-id="targetId"></AboutScholarship>
<div> <div>
@ -253,7 +255,15 @@
background-color:rgb(50,50,50); background-color:rgb(50,50,50);
} }
.infosContainer {
padding-bottom:50px;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
}
</style> </style>

View File

@ -1,6 +1,5 @@
<script setup> <script setup>
import i18n from "@/i18n.js"; import i18n from "@/i18n.js";
import {ref} from "vue";
import {getAllPayments} from "@/rest/requests.js"; import {getAllPayments} from "@/rest/requests.js";
const paymentsList = await getAllPayments() const paymentsList = await getAllPayments()

View File

@ -0,0 +1,218 @@
<!----------------------------------------------------
File: LessonRequests.vue
Author: William Karpinski
Scope: Extension Horaire
Description: Lesson Requests Management Page
----------------------------------------------------->
<script setup>
import i18n from "@/i18n.js"
import {ref} from 'vue'
import {changeRequestState, getAllRequests} from "@/rest/LessonRequests.js";
import {getLesson} from "@/rest/lessonSchedule.js";
import {formatDate, getHoursMinutes} from "@/scheduleFunctions.js";
const requests = ref(await getAllRequests());
const AcceptMod = ref(false);
const moreInfosMod = ref(false);
const requestTypes = ["Create", "Modify", "Delete"]
const editElementID = ref('');
const chosenLocal = ref("");
const locals = ["A0B1","A1B1","A2B1","A0B2"];
const moreInfos = ref({});
/*
* Change a request's state and refreshes the requests '
*/
async function upPage(id,review){
await changeRequestState(id, review) ;
requests.value = await getAllRequests();
}
/*
* Set correctly the variables after clicking on the ACCEPT button
*/
async function AcceptSetup(id,type){
if(type !== 2 ){
editElementID.value = id
AcceptMod.value = true;
}
else{
await upPage(id,{local: null,state:'Accepted'});
}
}
/*
* Set the infos to show when clicking MORE INFOS
*/
async function setMoreInfos(item){
moreInfos.value = Object.assign({},{})
moreInfos.value["requestType"] = requestTypes[item.requestType]
if(item.requestType == 0 || item.requestType == 1){
moreInfos.value["day"] = item.lessonStart == null ? null : formatDate(new Date(item.lessonStart))
moreInfos.value["start"] = item.lessonStart == null ? null : getHoursMinutes(new Date(item.lessonStart))
moreInfos.value["end"] = item.lessonEnd == null ? null : getHoursMinutes(new Date(item.lessonEnd))
moreInfos.value["lessonType"] = item.lessonType;
moreInfos.value["course"] = item["course"] == null ? null:item.course.title}
if (item.requestType==1 || item.requestType == 2){
let temp = await getLesson(item.lessonId);
if(item.requestType == 1 || item.requestType == 2){
moreInfos.value["course"] = temp.course.title;
moreInfos.value[item.requestType == 2 ? "day" : "old_day"] = formatDate(new Date(temp.lessonStart));
moreInfos.value[item.requestType == 2 ? "start" : "old_start"] = getHoursMinutes(new Date(temp.lessonStart));
moreInfos.value[item.requestType == 2 ? "end":"old_end"] = getHoursMinutes(new Date(temp.lessonEnd));
moreInfos.value[item.requestType == 2 ? "lessonType":"old_type"] = temp.lessonType;
}}
editElementID.value = item.id ;
moreInfosMod.value =true;
}
</script>
<template>
<div class="body">
<div v-for="item of requests" :key="item.id" :style="{width:[moreInfosMod ? 95:70] + '%'}" class="center">
<button v-if="moreInfosMod && editElementID == item.id" @click="moreInfosMod = false; editElementID = ''; moreInfos='';">{{i18n("courses.back")}}</button>
<div v-if ="item.state === 'Pending'" class="listElement">
<div class="containerElement" v-if="editElementID !== item.id">
<div class="id">{{i18n(requestTypes[item.requestType].toString())}}</div>
<div class="surname">{{i18n(item.state.toString())}}</div>
<div class="firstname">{{item.user.lastName}}</div>
<div class="infos">
<button @click=" setMoreInfos(item);" style="background-color:rgb(105,05,105);" >
{{i18n("request.moreInfos")}}
</button></div>
<div class="accept"><button @click="AcceptSetup(item.id,item.requestType);" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
<div class="refuse"><button @click="upPage(item.id,{local: null,state:'Refused'})" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
</div>
<div v-else class="containerElement" style="width:auto; height:auto;">
<div v-if="AcceptMod" style="margin-left:20%;">
Local:
<select v-model="chosenLocal">
<option v-for="item in locals">{{item}}</option>
</select>
<button @click="AcceptMod = false;upPage(item.id,{local: chosenLocal, state:'Accepted'})">{{i18n("request.accept")}}</button>
</div>
<template v-if="moreInfosMod" v-for="(key,value) in moreInfos">
<div class="container" v-if="key != null" style="align-self:center;">
<div style="margin:0 auto 0 auto">
{{i18n(value.toString())}}:
{{key}}
</div>
</div>
</template>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.center{
margin:0 auto 0 auto;
}
.containerElement{
justify-content:center;
display:grid;
grid-template-columns:10% 14.2% 19% 14.2% 14.2% 14.2% 14.2%;
grid-template-areas:
"id type surname firstname infos accept refuse";
column-gap:10px; }
.container{
padding-left:50px;
font-size:.8em;
justify-content:center;
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(auto-fill, 120px);
grid-row-gap: 1em;
grid-column-gap: 0.2em;
}
.listElement{
min-width:625px;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
margin-bottom:10px;
}
.infos {
grid-area:infos;
align-self:center;
}
.accept{
grid-area:accept;
align-self:center;
}
.refuse{
grid-area:refuse;
align-self:center;
}
.id{
grid-area:id;
margin-left:40px;
align-self:center;
}
.surname{
grid-area:surname;
align-self:center;
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
.firstname{
grid-area:firstname;
align-self:center;
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
button{
font-size:15px;
height:50px;
width:100px;
border:none;
border-radius:20px;
}
.body {
width:100%;
margin-top:3.5%;
}
button:hover{
opacity:0.8;
}
</style>

View File

@ -2,7 +2,7 @@
import {reactive, ref } from 'vue' import {reactive, ref } from 'vue'
import i18n from '@/i18n.js' import i18n from '@/i18n.js'
import {login, register, disconnect, isLogged} from '@/rest/Users.js' import {login, register, disconnect, isLogged} from '@/rest/Users.js'
import {getAllCurriculums, getcurriculum} from '@/rest/curriculum.js' import {getAllCurriculums} from '@/rest/curriculum.js'
import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js' import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js'
import {toast} from 'vue3-toastify' import {toast} from 'vue3-toastify'
import 'vue3-toastify/dist/index.css'; import 'vue3-toastify/dist/index.css';
@ -31,8 +31,9 @@
const passwordConfirm=ref("") const passwordConfirm=ref("")
const imageSaved = ref(false) const imageSaved = ref(false)
let ppData = ""
const ppData = ref({})
const idcardfile = ref({}) const idcardfile = ref({})
const justifcardfile = ref({}) const justifcardfile = ref({})
@ -58,11 +59,6 @@
disconnect(); disconnect();
window.location.reload();} window.location.reload();}
async function uploadPP(arg){
const data = await uploadProfilePicture(arg);
ppData = data.url;
}
//This functions makes the distinction between a master cursus (year 4 or more) and a bachelor cursus (year 3 or less) //This functions makes the distinction between a master cursus (year 4 or more) and a bachelor cursus (year 3 or less)
function getCursusDisplay(cursus){ function getCursusDisplay(cursus){
if (cursus.year <= 3){ if (cursus.year <= 3){
@ -77,6 +73,7 @@
//We upload the two files and we get their paths on the server //We upload the two files and we get their paths on the server
const identityCardFile = await uploadFile(idcardfile.value, "IdentityCard") const identityCardFile = await uploadFile(idcardfile.value, "IdentityCard")
const justifFile = ref(null) const justifFile = ref(null)
const profilepic = await uploadProfilePicture(ppData.value)
if (curricula[outputs.curriculum-1].requireCertificate){ if (curricula[outputs.curriculum-1].requireCertificate){
justifFile.value = await uploadFile(justifcardfile.value, "JustificationDocument") justifFile.value = await uploadFile(justifcardfile.value, "JustificationDocument")
@ -89,7 +86,7 @@
justif = null justif = null
} }
const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, identityCardFile.url, new Date(), outputs.equivalenceState, justif); const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, profilepic.url, identityCardFile.url, new Date(), outputs.equivalenceState, justif);
for (let item in externalCurrTab.value){ for (let item in externalCurrTab.value){
const temp = await uploadFile(externalCurrTab.value[item].justifdocUrl, "JustificationDocument") const temp = await uploadFile(externalCurrTab.value[item].justifdocUrl, "JustificationDocument")
@ -178,10 +175,10 @@
</form> </form>
<label class="browser"> <label class="browser">
{{i18n("login.guest.browse")}} {{i18n("login.guest.browse")}}
<input type="file" :disabled="imageSaved" @change="ppData = uploadProfilePicture($event.target.files); imageSaved = true;" accept="image/*"> <input type="file" :disabled="imageSaved" @change="ppData = $event.target.files; imageSaved = true;" accept="image/*">
</label> </label>
<form novalidate enctype="multipart/form-data" class="inputBox"> <form novalidate enctype="multipart/form-data" class="inputBox">
<input type="file" @change="uploadPP($event.target.files); imageSaved = true;" accept="image/*"> <input type="file" @change="imageSaved = true;" accept="image/*">
</form> </form>
<div class="inputBox"> <div class="inputBox">
<p>{{i18n("Curriculum").toUpperCase()}}</p> <p>{{i18n("Curriculum").toUpperCase()}}</p>
@ -221,14 +218,16 @@
</div> </div>
</div> </div>
<button @click="page++;" style="margin-top: 10%">{{i18n("login.guest.nextpage")}}</button> <button @click="page++;" style="margin-top: 10%">{{i18n("login.guest.nextpage")}}</button>
</div> </div>
<div v-if="page === 3"> <div v-if="page === 3">
<p style="color:rgb(239,60,168);margin-bottom: 5%"> <p style="color:rgb(239,60,168);margin-bottom: 5%">
{{i18n("login.guest.formationdisclaimer")}} {{i18n("login.guest.formationdisclaimer")}}
</p> </p>
<button @click="page++">{{i18n("login.guest.managecareer")}}</button> <button @click="page++">{{i18n("login.guest.managecareer")}}</button>
<button @click="postRegisterReq();">{{ i18n("login.guest.sendRegReq") }}</button> <button @click="postRegisterReq();page+=2">{{ i18n("login.guest.sendRegReq") }}</button>
</div>
<div v-if="page===5" style="margin-left: 7%">
<p style="color: rgb(239,60,168);">{{i18n("reqsent")}}</p>
</div> </div>
</form> </form>
</div> </div>
@ -297,13 +296,7 @@
cursor: pointer; cursor: pointer;
} }
.bodu {
margin-top:2%;
width:50%;
border:2px solid black;
border-radius:9px;
background-color:rgb(50,50,50);
}
.switchpage{ .switchpage{
width:100px; width:100px;
@ -342,22 +335,8 @@ input[type=file]{
background:#FFFFFF; background:#FFFFFF;
} }
.container{
margin-top: 2%;
color:white;
height:60px;
font-size:30px;
display:grid;
grid-template-columns:30% 30% 20% 20%;
grid-template-areas:
"school formation completion edit remove";
column-gap:10px;
}
button:active ,.switchpage:active{ button:active ,.switchpage:active{
opacity:0.8; opacity:0.8;
} }
</style> </style>

View File

@ -35,7 +35,6 @@
let isnull= false; let isnull= false;
for(const [key, value] of Object.entries(toAdd)){ for(const [key, value] of Object.entries(toAdd)){
console.log(toAdd.owner);
if(value === null){ if(value === null){
isnull=true; isnull=true;
} }
@ -64,17 +63,14 @@
async function patchCourse(course){ async function patchCourse(course){
for (let element in toModify){ for (let element in toModify){
console.log(toModify,1)
console.log(toModify[element],2)
if (element =="owner" && (toModify[element].regNo != course.owner.regNo)){ if (element =="owner" && (toModify[element].regNo != course.owner.regNo)){
await alterCourse(course.courseId,{owner:toModify[element].regNo}); await alterCourse(course.courseID,{owner:toModify[element].regNo});
} }
else if(element == "title" && (toModify[element] != course.title)){ else if(element == "title" && (toModify[element] != course.title)){
await alterCourse(course.courseId,{title:toModify[element]}); await alterCourse(course.courseID,{title:toModify[element]});
} }
else if(element == "credits" && (parseInt(toModify[element]) != course.credits)){ else if(element == "credits" && (parseInt(toModify[element]) != course.credits)){
await alterCourse(course.courseId,{credits:parseInt(toModify[element])}); await alterCourse(course.courseID,{credits:parseInt(toModify[element])});
} }
} }
toModify= Object.assign({},pattern); toModify= Object.assign({},pattern);
@ -159,11 +155,11 @@
</div> </div>
<div class="containerElement"v-else> <div class="containerElement"v-else>
<input style="max-width:200px;" class="name" v-model="toModify.title"> <input style="max-width:200px;" class="name" v-model="toModify.title">
<select v-if="self.role === 'Secretary'" style="max-width:200px;" class="teacher" v-model="toModify.owner"> <select v-if="self.role != 'Secretary'" style="max-width:200px;" class="teacher" v-model="toModify.owner">
<option v-for="(item,index) in profList" :value='item'>{{item.lastName}}</option> <option v-for="(item,index) in profList" :value='item'>{{item.lastName}}</option>
</select> </select>
<div v-else class="teacher">{{item.owner.lastName}}</div> <div v-else class="teacher">{{item.owner.lastName}}</div>
<input v-if="self.role==='Secretary'"style="max-width:100px;"class="credits" v-model="toModify.credits"> <input v-if="self.role !='Secretary'"style="max-width:100px;"class="credits" v-model="toModify.credits">
<div v-else class="credits">{{i18n("Credits")}}:{{item.credits}}</div> <div v-else class="credits">{{i18n("Credits")}}:{{item.credits}}</div>
</div> </div>
</div> </div>
@ -177,17 +173,6 @@
margin-top:3.5%; margin-top:3.5%;
} }
.infosContainer {
min-width:350px;
padding-bottom:50px;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
}
.containerElement{ .containerElement{
justify-content:center; justify-content:center;
display:grid; display:grid;

View File

@ -0,0 +1,277 @@
<!----------------------------------------------------
File: LessonRequests.vue
Author: William Karpinski
Scope: Extension Horaire
Description: Lessons Management Page for the teachers
----------------------------------------------------->
<script setup>
import { ref } from 'vue'
import i18n from '@/i18n.js'
import {formatDate,invertedFormatDate,getHoursMinutes,sortByDate, createLessonEvent} from '../scheduleFunctions.js'
import {getOwnedLessons} from "@/rest/lessonSchedule.js";
import {getSelf} from "@/rest/Users.js";
import {createRequest} from "@/rest/LessonRequests.js"
import {getcurriculum} from "@/rest/curriculum.js";
import {getAllSchedule} from "@/rest/scheduleRest.js";
const curriculum = ref();
const allSchedules = ref(await getAllSchedule());
const schedule = ref(await getOwnedLessons());
schedule.value.sort((a,b) => sortByDate(b,a))
const createMod = ref(false);
const user = await getSelf();
const editElementID = ref();
const requestType = ref(0);
const currentDate = new Date();
const types = ["TP","TD","Course","Exam"];
const colors = {"TP":"rgb(36,175,255)","TD":"rgb(255,36,175)","Exam":"rgb(175,255,36)","Course":"rgb(255,36,175)"}
const courses = ref();
const maxDate = ref(invertedFormatDate(new Date([currentDate.getMonth()<7 ? currentDate.getFullYear() : (currentDate.getFullYear())+1],7,31)));
const minDate = ref(invertedFormatDate((new Date()).setDate(currentDate.getDate()+1)))
/*
* Checks if a lesson is in the future or not
*/
function inFuture(lesson){
let toCompare = new Date(lesson.lessonStart);
let current = new Date();
return (current < toCompare)
}
async function setCourses(){
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses
}
const pattern = {
"lessonId":null,
"course": null,
"day":null,
"lessonStart": null,
"lessonEnd": null,
"lessonType": null,
}
const patternRequest ={
"user": user.regNo,
"state": "Pending",
"requestType": 0,
"lessonId":null,
"lessonType":null,
"lessonStart":null,
"lessonEnd":null,
"color":null,
"course":0,}
const toModify = ref(Object.assign({}, pattern));
const requestBuffer = ref(Object.assign({},patternRequest));
function setModify(lesson){
toModify.value.lessonId = editElementID.value;
toModify.value.day = invertedFormatDate(new Date(lesson.lessonStart));
toModify.value.lessonStart = getHoursMinutes(lesson.lessonStart);
toModify.value.lessonEnd = getHoursMinutes(lesson.lessonEnd);
toModify.value.lessonType = lesson.lessonType
}
function setCreate(){
toModify.value = ref(Object.assign({},pattern));
createMod.value = !createMod.value;
}
/*
* Constructs a request and posts it
*/
async function createLessonRequest(){
if(requestType.value === 0 || requestType.value === 1){
//modify
requestBuffer.value.color = colors[toModify.value.lessonType] ;
requestBuffer.value.requestType = requestType.value;
requestBuffer.value.course = toModify.value.course;
let start = createLessonEvent(toModify.value.day,toModify.value.lessonStart)
let end = createLessonEvent(toModify.value.day,toModify.value.lessonEnd)
for (let element in toModify.value){
if(element !== "day" && element !== "lessonStart" && element !== "lessonEnd"){
requestBuffer.value[element] = toModify.value[element];
}
if(element === "lessonStart"){
requestBuffer.value.lessonStart = start;
}
if(element === "lessonEnd"){
requestBuffer.value.lessonEnd = end;
}
}
}
else if(requestType.value === 2 || requestType.value === 1) {
//delete
requestBuffer.value.lessonId = editElementID;
requestBuffer.value.requestType = requestType.value;
}
await createRequest(requestBuffer.value);
editElementID.value = '';
}
/*
* Creates a request of a certain type
* 0 = CREATE REQUEST
* 1 = MODIFY REQUEST
* 2 = DELETE REQUEST
*/
async function askChanges(i){
requestType.value= i;
await createLessonRequest()
}
</script>
<template>
<div class="body">
<div v-if="createMod">
<form class="listElement" style="width:40%; margin:0 auto 0 auto;">
<div style="margin-bottom:20px;">
{{i18n("schedule")}} :
<select @change="setCourses()"v-model="curriculum">
<option v-for="item in allSchedules" :value='item.curriculum'>{{item.curriculum.option}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
{{i18n("course")}}:
<select v-if="curriculum != null" v-model="toModify.course">
<option v-for="item in courses" :value='item.courseID'>{{item.title}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
{{i18n("day")}}:
<input type="date" :min="minDate" :max="maxDate" v-model="toModify.day">
</div>
<div style="margin-bottom:20px;">
{{i18n("start")}}:
<input v-model="toModify.lessonStart" type="time" min="08:00" max="18:00" required />
</div>
<div style="margin-bottom:20px;">
{{i18n("end")}}:
<input v-model="toModify.lessonEnd" type="time" min="10:00" max="20:00" required />
</div>
<div style="margin-bottom:20px;">
Type:
<select v-model="toModify.lessonType">
<option v-for="item in types" :value='item'>{{i18n(item)}}</option>
</select>
</div>
<button class="create" @click="createMod=!createMod; askChanges(0);"> {{i18n("courses.confirm")}} </button>
<button style="float:right;" @click="createMod=!createMod">{{i18n("courses.back")}}</button>
</form>
</div>
<button v-if="!createMod" @click="setCreate()" style="display:flex; margin:0 auto 0 auto;">{{i18n("schedule.askCreate")}}</button>
<div v-if="!createMod"v-for="element in schedule" style="width:50%;margin-left:auto; margin-right:auto;" >
<div v-if="editElementID !== element.lessonID" style ="padding:15px 15px 15px 15px;">
<button v-if="inFuture(element)" @click="editElementID = element.lessonID;setModify(element);">
{{i18n("schedule.askChanges")}}
</button>
</div>
<div v-else>
<button @click="askChanges(1);"> {{i18n("courses.confirm")}} </button>
<button @click="editElementID= '';"> {{i18n("courses.back")}} </button>
</div>
<div class="listElement">
<div v-if="editElementID !== element.lessonID">
<div>
{{element.course.title}}
</div>
<div>{{formatDate(element.lessonStart)}}</div>
<div>{{getHoursMinutes(element.lessonStart)}}-{{getHoursMinutes(element.lessonEnd)}}
</div>
<div>{{element.local}}</div>
<div>{{i18n(element.lessonType)}}</div>
</div>
<div v-else>
<div>{{element.course.title}}</div>
<div style="margin-bottom:20px;">
{{i18n("day")}}:
<input type="date" :min="minDate" :max="maxDate" v-model="toModify.day">
</div>
<div style="margin-bottom:20px;">
{{i18n("start")}}:
<input v-model="toModify.lessonStart" type="time" min="8:00" max="20:00"/>
</div>
<div style="margin-bottom:20px;">
{{i18n("end")}}:
<input v-model="toModify.lessonEnd" type="time" min="10:00" max="20:00" required />
</div>
<div style="margin-bottom:20px;">
{{i18n("Type")}}:
<select v-model="toModify.lessonType">
<option v-for="item in types" :value='item'>{{i18n(item)}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
Local:
{{element.local}}
<div style="float:right;">
<button @click="askChanges(2)" class="delete"> {{i18n("schedule.askDeletion")}} </button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.body {
width:100%;
margin-top:3.5%;
}
.listElement{
min-width:625px;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
margin-bottom:10px;
}
input, select{
padding:10px 10px 10px 10px;
font-size:25px;
cursor: pointer;
border:none;
border-radius:15px;
}
button{
font-size:15px;
height:auto;
width:100px;
border:none;
border-radius:20px;
}
.delete{
grid-area:delete;
background-color:rgb(200,0,0);
}
button:hover{
opacity:0.8;
}
</style>

View File

@ -0,0 +1,506 @@
<!----------------------------------------------------
File: LessonRequests.vue
Author: William Karpinski
Scope: Extension Horaire
Description: Lessons Management Page for the secretary
----------------------------------------------------->
<script setup>
import { ref } from 'vue'
import i18n from '@/i18n.js'
import {formatDate,getHoursMinutes, invertedFormatDate, createLessonEvent} from '../scheduleFunctions.js'
import {getAllSchedule, deleteLessonFromSchedule ,getSchedule, createSchedule} from "@/rest/scheduleRest.js";
import {getLessons, createLesson, alterLesson, deleteLesson} from "@/rest/lessonSchedule.js"
import {getTeachers} from "@/rest/Users.js"
import {getcurriculum, getAllCurriculums} from "@/rest/curriculum.js"
const trueSchedule = ref()
const schedule = ref();
const lessonFinder = ref();
const curriculum = ref();
const allSchedules = ref(await getAllSchedule());
const filter = ref("null");
const subFilter = ref("null");
const filters = ["Type","Teacher","Course"];
const types = ["TP","TD","Course","Exam"];
const locals = ["A0B1","A1B1","A2B1","A0B2"]
const teachers = await getTeachers() ;
const allCurriculum = ref();
const courses = ref();
const createScheduleMod = ref(false);
const createMod = ref(false);
const deleteMod = ref(false);
const colors = {"TP":"rgb(36,175,255)","TD":"rgb(255,36,175)","Exam":"rgb(175,255,36)","Course":"rgb(255,36,175)"}
const currentDate = new Date();
const editElementID = ref();
const maxDate = ref(invertedFormatDate(new Date([currentDate.getMonth()<7 ? currentDate.getFullYear() : (currentDate.getFullYear())+1],7,31)));
const minDate = ref(invertedFormatDate((new Date()).setDate(currentDate.getDate()+1)))
const pattern = {
"course": null,
"day":null,
"lessonStart": null,
"lessonEnd": null,
"lessonType": null,
"local": null,
"color": null,
}
const lessonCreator = {
"courseID" : null,
"lessonStart":null,
"lessonEnd":null,
"lessonType":null,
"local":null,
"color":null,
}
const patternModify = {
"day": null,
"lessonStart": null,
"lesssonEnd": null,
"local":null,
"lessonType":null,
}
/*
* Sets up allCurriculum to contain only the curriculums that don't have any schedule
*/
async function setCurriculum(){
const temp = await getAllCurriculums();
let isIn = false;
let toReturn =[] ;
for (let element in temp){
for (let item in allSchedules.value){
console.log(allSchedules.value[item])
console.log(temp[element])
if((allSchedules.value[item].curriculum.option == temp[element].option) && (allSchedules.value[item].curriculum.year == temp[element].year)){
isIn = true;
break;
}
}
if(!isIn){
toReturn.push(temp[element])
}
isIn = false;
}
allCurriculum.value = toReturn.slice();
}
const toModify = ref(Object.assign({}, pattern));
const lessonBuffer = ref(Object.assign({}, pattern));
const lessonCreatorBuffer = ref(Object.assign({},lessonCreator));
function setModify(lesson){
toModify.value.day = invertedFormatDate(new Date(lesson.lessonStart));
toModify.value.lessonStart = getHoursMinutes(lesson.lessonStart);
toModify.value.lessonEnd = getHoursMinutes(lesson.lessonEnd);
toModify.value.local = lesson.local;
toModify.value.lessonType = lesson.lessonType;
}
function inFuture(lesson){
let toCompare = new Date(lesson.lessonStart);
let current = new Date();
return (current < toCompare)
}
async function setCourses(){
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses
}
/*
* Sort the lessons via a criteria
*/
function sortSchedule(){
schedule.value =trueSchedule.value.lessons;
if(filter.value =="Teacher"){
schedule.value = sortByTeacher(schedule.value,subFilter.value);
}
else if(filter.value =="Type"){
schedule.value = sortByType(schedule.value,subFilter.value);
}
else if(filter.value =="Course"){
schedule.value = sortByCourse(schedule.value,subFilter.value);
}
}
function sortByType(lessons,type){
if(type == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].lessonType == type){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByCourse(lessons,course){
if(course == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.courseID == course.courseID){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByTeacher(lessons, teacher){
if(teacher == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.owner.regNo == teacher.regNo){
matrix.push(lessons[element])
}
}
return matrix
}
/*
* Change the schedule filter
*/
async function changeSchedule(){
schedule.value =trueSchedule.value.lessons;
curriculum.value = trueSchedule.value.curriculum;
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses;
filter.value = "null";
subFilter.value = "null"
}
async function newLesson(){
let isnull = false;
if (lessonBuffer.value.lessonType != null){
lessonBuffer.value.color = colors[lessonBuffer.value.lessonType];
for(let element in lessonBuffer.value){
if(lessonBuffer.value[element] == null){
isnull=true;
break;
}
}
if(!isnull){
let start = createLessonEvent(lessonBuffer.value.day,lessonBuffer.value.lessonStart)
let end = createLessonEvent(lessonBuffer.value.day,lessonBuffer.value.lessonEnd)
lessonCreatorBuffer.value.lessonStart = start;
lessonCreatorBuffer.value.lessonEnd = end;
lessonCreatorBuffer.value.color = lessonBuffer.value.color;
lessonCreatorBuffer.value.lessonType =lessonBuffer.value.lessonType;
lessonCreatorBuffer.value.local = lessonBuffer.value.local;
lessonCreatorBuffer.value.courseID = lessonBuffer.value.course.courseID;
await createLesson(lessonCreatorBuffer.value);
lessonFinder.value = await getLessons();
}
}
lessonBuffer.value = Object.assign({}, pattern);
lessonFinder.value = null;
lessonCreatorBuffer.value = Object.assign({},lessonCreator)
trueSchedule.value = null;
}
/*
* Modify a lesson
*/
async function patchLesson(lesson){
for (let element in toModify.value){
if (element =="lessonType" && (toModify.value[element] != lesson[element])){
await alterLesson(lesson.lessonID,{lessonType:toModify.value[element]});
}
if (element =="local" && (toModify.value[element] != lesson[element])){
await alterLesson(lesson.lessonID,{local:toModify.value[element]});
}
if (element =="lessonStart" && (toModify.value[element] != lesson[element])){
await alterLesson(lesson.lessonID,{lessonStart:createLessonEvent(toModify.value.day,toModify.value[element])
});
}
if (element =="lessonEnd" && (toModify.value[element] != lesson[element])){
await alterLesson(lesson.lessonID,{lessonEnd:createLessonEvent(toModify.value.day,toModify.value[element])
});
}
if(element == "day" && (toModify.value[element] != invertedFormatDate(new Date(lesson.lessonStart))) ){
if(toModify.value.lessonStart == lesson.lessonStart){
await alterLesson(lesson.lessonID,{lessonStart:createLessonEvent(toModify.value.day,lesson.lessonStart)
});}
if(toModify.value.lessonEnd == lesson.lessonEnd){
await alterLesson(lesson.lessonID,{lessonStart:createLessonEvent(toModify.value.day,lesson.lessonStart)});
}
}
}
toModify.value= Object.assign({},patternModify);
trueSchedule.value = await getSchedule(trueSchedule.value.scheduleId);
schedule.value =trueSchedule.value.lessons;
editElementID.value= '';
}
async function removeLesson() {
await deleteLessonFromSchedule(trueSchedule.value.scheduleId, editElementID.value)
await deleteLesson(editElementID.value);
trueSchedule.value = await getSchedule(trueSchedule.value.scheduleId);
schedule.value =trueSchedule.value.lessons;
editElementID.value= '';
}
/*
* Create a new Schedule
*/
async function newSchedule(){
await createSchedule(curriculum.value);
allSchedules.value = await getAllSchedule();
setCurriculum();
}
</script>
<template>
<div class="body">
<div class="listTitle buttonGrid"v-if="!createMod && !createScheduleMod" >
<button class="create" @click="setCurriculum();createScheduleMod = true"> {{i18n("schedule.createSchedule")}}</button>
<button class="create" @click="createMod = true;">{{i18n("schedule.createLesson")}}</button>
<button class="delete" @click="deleteMod = !deleteMod;">{{!deleteMod ? i18n("schedule.deleteMod") : i18n("schedule.noDeleteMod")}}</button>
</div>
<div v-if="createMod">
<form class="listElement" style="width:40%; margin:0 auto 0 auto;">
<div style="margin-bottom:20px;">
{{i18n("schedule")}} :
<select @change="setCourses()"v-model="curriculum">
<option v-for="item in allSchedules" :value='item.curriculum'>{{item.curriculum.option}} - {{item.curriculum.year}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
{{i18n("Course")}} :
<select v-if="curriculum != null" v-model="lessonBuffer.course">
<option v-for="item in courses" :value='item'>{{item.title}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
{{i18n("day")}}:
<input type="date" :min="minDate" :max="maxDate" v-model="lessonBuffer.day">
</div>
<div style="margin-bottom:20px;">
{{i18n("start")}}:
<input v-model="lessonBuffer.lessonStart" type="time" min="08:00" max="18:00" required />
</div>
<div style="margin-bottom:20px;">
{{i18n("end")}}:
<input v-model="lessonBuffer.lessonEnd" type="time" min="10:00" max="20:00" required />
</div>
<div style="margin-bottom:20px;">
Type:
<select v-model="lessonBuffer.lessonType">
<option v-for="item in types" :value='item'>{{item}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
Local:
<select v-model="lessonBuffer.local">
<option v-for="item in locals" :value='item'>{{item}}</option>
</select>
</div>
<button class="create" @click="createMod=!createMod; newLesson();"> {{i18n("courses.confirm")}} </button>
<button style="float:right;" @click="createMod=!createMod">{{i18n("courses.back")}}</button>
</form>
</div>
<div v-if="createScheduleMod">
<form class="listElement" style="width:40%; margin:0 auto 0 auto;">
<div style="margin-bottom:20px;">
{{i18n("schedule")}} :
<select v-model="curriculum">
<option v-for="item in allCurriculum" :value='item'>{{item.option}} - {{item.year}}</option>
</select>
</div>
<button class="create" @click="createScheduleMod=!createScheduleMod ;newSchedule();"> {{i18n("courses.confirm")}} </button>
<button style="float:right;" @click="createScheduleMod=!createScheduleMod;">{{i18n("courses.back")}}</button>
</form>
</div>
<div v-if="!createMod && !createScheduleMod">
<select @change="changeSchedule()" v-model="trueSchedule">
<option v-for="item in allSchedules" :value='item'>{{item.curriculum.option}} - {{item.curriculum.year}}</option>
</select>
<select v-if="schedule != null" @change="subFilter = 'null'" v-model="filter">
<option :value ="null">No Filter</option>
<option v-for="item in filters" :value="item">{{i18n(item.toString())}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Teacher'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in teachers" :value=item>{{item.lastName}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Course'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in courses" :value=item>{{item.title}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Type'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in types" :value='item'>{{item}}</option>
</select>
</div>
<div v-if="!createMod && !createScheduleMod" :key="element.lessonID" v-for="element in schedule" style="width:50%;margin-left:auto; margin-right:auto;" >
<div v-if="editElementID !== element.lessonID" style ="padding:15px 15px 15px 15px;">
<button v-if="inFuture(element)" @click="editElementID = element.lessonID;setModify(element);">
{{i18n("courses.modify")}}
</button>
</div>
<div v-else>
<button @click="patchLesson(element);"> {{i18n("courses.confirm")}} </button>
<button @click="editElementID= '';"> {{i18n("courses.back")}} </button>
</div>
<div class="listElement">
<div v-if="editElementID != element.lessonID">
<div>
{{element.course.title}}
</div>
<div>{{formatDate(element.lessonStart)}}</div>
<div>{{getHoursMinutes(element.lessonStart)}}-{{getHoursMinutes(element.lessonEnd)}}
</div>
<div>{{element.local}}</div>
<div>{{element.lessonType}}</div>
</div>
<div v-else>
<div>{{element.course.title}}</div>
<div style="margin-bottom:20px;">
Day:
<input type="date" :min="minDate" :max="maxDate" v-model="toModify.day">
</div>
<div style="margin-bottom:20px;">
Start:
<input v-model="toModify.lessonStart" type="time" min="8:00" max="20:00"/>
</div>
<div style="margin-bottom:20px;">
End:
<input v-model="toModify.lessonEnd" type="time" min="10:00" max="20:00" required />
</div>
<div style="margin-bottom:20px;">
Type:
<select v-model="toModify.lessonType">
<option v-for="item in types" :value='item'>{{item}}</option>
</select>
</div>
<div style="margin-bottom:20px;">
Local:
<select v-model="toModify.local">
<option v-for="item in locals" :value='item'>{{item}}</option>
</select>
<div v-if="deleteMod" style="float:right;">
<button class="delete" @click="removeLesson(element);"> {{i18n("courses.deleteCourse")}} </button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.body {
width:100%;
margin-top:3.5%;
}
.listElement{
min-width:625px;
border:2px solid black;
font-size:25px;
color:white;
padding:20px;
background-color:rgb(50,50,50);
border-radius:20px;
margin-bottom:10px;
}
input, select{
padding:10px 10px 10px 10px;
font-size:25px;
cursor: pointer;
border:none;
border-radius:15px;
}
button{
font-size:15px;
height:50px;
width:100px;
border:none;
border-radius:20px;
}
.buttonGrid{
display:grid;
grid-template-columns: auto auto;
column-gap:50px;
grid-template-areas:
"create delete";
}
.create{
grid-area:create;
background-color:rgb(0,200,0);
}
.delete{
grid-area:delete;
background-color:rgb(200,0,0);
}
.listTitle{
min-width:380px;
display: flex;
justify-content: center;
align-items: center;
width:25%;
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;
button:hover{
opacity:0.8;
}
}
</style>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import {reactive, ref } from 'vue' import {reactive, ref } from 'vue'
import {getSelf,alterSelf,disconnect,deleteUser} from '../rest/Users.js' import {getSelf,alterSelf} from '../rest/Users.js'
import {getSelfCurriculum, getAllCurriculums, getSomeonesCurriculumList, getcurriculum} from '../rest/curriculum.js' import {getAllCurriculums, getSomeonesCurriculumList, getcurriculum} from '../rest/curriculum.js'
import {getCourses} from "../rest/courses.js" import {getCourses} from "../rest/courses.js"
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js' import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js'
@ -119,16 +119,6 @@
toModify.password= item.password; toModify.password= item.password;
} }
async function unRegister(){
deleteUser(user.value.regNo);
disconnect()
setTimeout(() => {
window.location.href="#/home";
}, "500");
}
function getPP(){ function getPP(){
if(user.value.profilePictureUrl === null){ if(user.value.profilePictureUrl === null){
return "/Clyde.png" return "/Clyde.png"
@ -136,14 +126,6 @@
return user.profilePictureUrl return user.profilePictureUrl
} }
function getYear(){
let date = new Date();
if (date.getMonth() <= 6){
return date.getFullYear()-1
}
return date.getFullYear()
}
async function refreshExtCurrList(){ async function refreshExtCurrList(){
extcurrlist.value = await getExternalCurriculumByUser(user.value.regNo) extcurrlist.value = await getExternalCurriculumByUser(user.value.regNo)
} }
@ -258,7 +240,7 @@
<button @click="windowState=0">{{i18n("courses.back")}}</button> <button @click="windowState=0">{{i18n("courses.back")}}</button>
</div> </div>
<div v-else-if="windowState === 5" class="infosContainer"> <div v-else-if="windowState === 5" class="infosContainer">
<div v-if="minerv.value.toPay !== 0"> <div v-if="minerv.value.toPay > 0">
{{ i18n("payment") }} : {{minerv.value.toPay}} {{ i18n("lefttopay") }} {{ i18n("payment") }} : {{minerv.value.toPay}} {{ i18n("lefttopay") }}
<div v-if="minerv.value.paidAmount <= 50"> <div v-if="minerv.value.paidAmount <= 50">
<button @click="windowState=6; paymentAmount = 50">{{ i18n("paydeposit") }} (50)</button> <button @click="windowState=6; paymentAmount = 50">{{ i18n("paydeposit") }} (50)</button>
@ -271,7 +253,7 @@
{{ i18n("alreadypaid") }} {{ i18n("alreadypaid") }}
</div> </div>
<div> <div>
<button @click="windowState=7">{{ i18n("askscholarship") }}</button> <button @click="windowState=7" v-if="minerv.value.toPay <= 0">{{ i18n("askscholarship") }}</button>
</div> </div>
</div> </div>
<div v-if="windowState === 5"> <div v-if="windowState === 5">

View File

@ -0,0 +1,802 @@
<!----------------------------------------------------
File: Schedule.vue
Author: William Karpinski
Scope: Extension Horaire
Description: Schedules Page accessed by everyone
----------------------------------------------------->
<script setup>
import { ref } from 'vue'
import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,weekFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList, durationCourse} from '../scheduleFunctions.js'
import {getAllSchedule} from "@/rest/scheduleRest.js";
import {getOnesLessons, getOwnedLessons } from "@/rest/lessonSchedule.js"
import {isLogged, getSelf,getTeachers} from "@/rest/Users.js"
import {getUserActualCourses} from "@/rest/courses.js";
import {getcurriculum} from "@/rest/curriculum.js";
import i18n from "../i18n.js";
const trueSchedule = ref()
const log = await isLogged();
const schedule = ref();
const importedJSON = ref();
const jsonSchedule = ref();
const jsonMod = ref(false);
const curriculum = ref();
const shift = ref(getFirstDay(new Date()).getDay());
let value = 1;
let done = false;
const len = ref(lastDateOfMonth(new Date()));
const scheduleByWeek = ref();
const month = ref();
const mondayOfWeek =ref(getMonday(new Date()))
const currentDate = ref(new Date())
const allSchedules = await getAllSchedule();
let counter = 0;
const ownSchedule = ref();
const filter = ref("null");
const subFilter = ref("null");
const focus = ref();
const focusLessons = ref();
let user;
if(log){
user = await getSelf();
if(user.role == "Teacher" || user.role == "Student"){
if(user.role == "Teacher"){
ownSchedule.value = await getOwnedLessons();
}
if(user.role == "Student"){
let test = await getUserActualCourses();
console.log(test);
ownSchedule.value = await getOnesLessons();}
schedule.value = ownSchedule.value;
schedule.value.sort((a,b) => sortByDate(a,b));
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,new Date().getMonth());
}
}
const display =ref("Week");
const format = ref("Grid");
const filters = ["Type","Teacher","Course"];
const types = ["TP","TD","Course","Exam"];
const teachers = await getTeachers() ;
const courses = ref();
if(curriculum.value != null){
courses.value = curriculum.value.courses;
}
const days = ["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];
const months = ["january","february","march","april",'may',"june","july","august","september","october","november","december"]
const firstDayOfMonth = ref(getFirstDay(new Date()))
const monthDone = ref(false);
function getMonday(d) {
d = new Date(d);
d.setHours(0,0,0);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6 : 1);
return new Date(d.setDate(diff));
}
function getAnyDays(d){
var day = new Date(mondayOfWeek.value);
day.setDate(day.getDate() + d );
return day;
}
function verifUser(){
if(log)
return (user.role == "Student" || user.role == "Teacher");
return false
}
function displayOwnSchedule(){
schedule.value = ownSchedule.value;
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
done = false;
}
/*
* Create a JSON from a schedule
*/
function createJSON(){
const json = {"data":[]};
for(let element in schedule.value){
let item = {};
item["title"] = schedule.value[element].course.title + "\n" + schedule.value[element].course.owner.lastName+ "\n" + schedule.value[element].local
item["start"] = schedule.value[element].lessonStart;
item["end"] = schedule.value[element].lessonEnd;
item["color"] = schedule.value[element].color;
json.data.push(item)
}
return json
}
/*
* Export a JSON
*/
function exportJSON(){
let json = createJSON();
const data = JSON.stringify(json);
const blob = new Blob([data], {type:"application/json"});
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = "Schedule.json";
a.click();
}
/*
* Used to convert a JSON imported to an object
*/
function onFileChange(e) {
let files = e.target.files || e.dataTransfer.files;
if (!files.length) return;
readFile(files[0]);
}
function readFile(file) {
let reader = new FileReader();
reader.onload = e => {
let json = JSON.parse(e.target.result);
importedJSON.value = json
createScheduleFromJSON();
jsonMod.value= true;
};
reader.readAsText(file);
}
function createScheduleFromJSON(){
let jsonBrut = importedJSON.value;
let toEventList = [];
for(let element in jsonBrut["data"]){
let temp = {}
temp["title"] = jsonBrut["data"][element].title;
temp["lessonStart"] = jsonBrut["data"][element].start;
temp["lessonEnd"] = jsonBrut["data"][element].end;
temp["color"] = jsonBrut["data"][element].color;
toEventList.push(temp);
}
jsonSchedule.value = toEventList;
scheduleByWeek.value = sundayToTheEnd(weekFromList(jsonSchedule.value,mondayOfWeek.value));
month.value = monthFromList(jsonSchedule.value,new Date().getMonth());
}
/*
* Display the JSON on the schedule
*/
function switchToJSON(){
jsonMod.value = true;
scheduleByWeek.value = sundayToTheEnd(weekFromList(jsonSchedule.value,mondayOfWeek.value));
month.value = monthFromList(jsonSchedule.value,new Date().getMonth());
}
/*
* used to focus on a lesson when we click on it
*/
function lessonFocus(element){
if(!jsonMod.value){
focus.value = element;
var lessonsList = [];
for (let element in schedule.value){
if (schedule.value[element].course.courseID == focus.value.course.courseID){
lessonsList.push(schedule.value[element]);
}
}
focusLessons.value = lessonsList;}
}
/*
* convert the current date to a DATE object
*/
function dateOfMonth(i){
return new Date(currentDate.value.getFullYear(),currentDate.value.getMonth(),i);
}
function sortSchedule(){
schedule.value =trueSchedule.value.lessons;
if(filter.value =="Teacher"){
schedule.value = sortByTeacher(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
else if(filter.value =="Type"){
schedule.value = sortByType(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
else if(filter.value =="Course"){
schedule.value = sortByCourse(schedule.value,subFilter.value);
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
}
if(focus.value != null){
lessonFocus(focus.value)
}
}
function sortByType(lessons,type){
if(type == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].lessonType == type){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByCourse(lessons,course){
if(course == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.courseID == course.courseID){
matrix.push(lessons[element])
}
}
return matrix
}
function sortByTeacher(lessons, teacher){
if(teacher == null){
return lessons;
}
const matrix = [];
for (let element in lessons){
if(lessons[element].course.owner.regNo == teacher.regNo){
matrix.push(lessons[element])
}
}
return matrix
}
/*
* Change the schedule filter
*/
async function changeSchedule(){
schedule.value =trueSchedule.value.lessons;
curriculum.value = trueSchedule.value.curriculum;
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value,mondayOfWeek.value));
month.value = monthFromList(schedule.value,currentDate.value.getMonth());
value = 1;
counter=0;
done = false;
courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses;
filter.value = "null";
subFilter.value = "null"
focus.value = null;
focusLessons.value = null;
jsonMod.value = false;
}
/*
* change the week to display
*/
function changeWeek(i){
const temp = getAnyDays(i);
mondayOfWeek.value = temp;
if(scheduleByWeek.value != null)
if(jsonMod.value){
scheduleByWeek.value = sundayToTheEnd(weekFromList(jsonSchedule.value, mondayOfWeek.value))}
else{
scheduleByWeek.value = sundayToTheEnd(weekFromList(schedule.value, mondayOfWeek.value))}
}
/*
* change the month to display
*/
function changeMonth(i){
const temp = currentDate.value;
currentDate.value = new Date( ( 0< temp.getMonth()+i < 13 ? temp.getFullYear() : temp.getFullYear()+i), (0< temp.getMonth()+i <13 ? temp.getMonth()+i : 12 ),1);
shift.value= getFirstDay(currentDate.value).getDay();
len.value= lastDateOfMonth(currentDate.value);
value = 1;
counter = 0;
done=false;
if(month.value != null){
if(jsonMod.value){
month.value = monthFromList(jsonSchedule.value,currentDate.value.getMonth())}
}
else{
month.value = monthFromList(schedule.value,currentDate.value.getMonth())}
}
/*
* used to display correctly the dates of a month
*/
function isAValue(){
if(value-shift.value<0 ){
counter++;
value++;
return false;
}
if(value-shift.value<len.value){
value++;
counter++;
return true;}
if(value-shift.value==len.value){
done = true;
counter++;
if(counter> 35){
counter=1;
value = 2;
done = false;
return true; }
return false;
}
}
</script>
<template>
<div class="grid">
<div class="schedule" v-if="format == 'Grid'">
<template v-if="display=='Week'">
<table class="table">
<tr style="background-color:rgb(24,24,24)">
<th>
<button @click="changeWeek(-7)">{{i18n("schedule.previous")}}</button>
<button @click="changeWeek(7)">{{i18n("schedule.next")}}</button>
<button @click="mondayOfWeek = getMonday(new Date());
scheduleByWeek != null ? scheduleByWeek = sundayToTheEnd(weekFromList(schedule.value, mondayOfWeek)) : null;">{{i18n("schedule.current")}}</button>
</th>
<th class="header" v-for='d,index in 7' >
<p class="childHeader">
{{i18n(days[index])}}
</p>
<p class="childHeader">
{{formatDate(getAnyDays(index))}}
</p>
</th>
</tr>
<tr v-for="(n,index) in 12">
<th class="hour">{{8 + index}}:00-{{9+index}}:00</th>
<td v-for="m in 7"></td>
</tr>
</table>
<div v-if="scheduleByWeek != null " class="courseGrid">
<div class="dayCourse" v-for="element in scheduleByWeek">
<template v-for="i,index in element.length">
<div class="course" @click.native="lessonFocus(element[index])" v-bind:style="{background:element[index].color,
height:((getDifferenceTime(element[index].lessonEnd,element[index].lessonStart)/7.2)-0.5)+'%', top:((getMarginTop(element, index, index-1)/7.20))+'%'}">
<div class="hourStart">
{{getHoursMinutes(element[index].lessonStart)}}
</div>
<div class="infos">
<p class="childInfos" >{{jsonMod ? element[index].title : element[index].course.title}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].local}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].lessonType}}</p>
<p class="childInfos"v-if="!jsonMod">{{element[index].course.owner.lastName}}</p>
</div>
<div class="hourEnd">
{{getHoursMinutes(element[index].lessonEnd)}}
</div>
</div>
</template>
</div>
</div>
</template>
<template v-else>
<table class="table">
<tr style="background-color:rgb(24,24,24); height:8.33%;">
<th colspan="7" class="header">
<div>{{i18n(months[currentDate.getMonth()])}} {{currentDate.getFullYear()}}</div>
<button style="position:absolute; top:0; left:0;" @click="changeMonth(-1)">{{i18n("schedule.previous")}}</button>
<button style="position:absolute; bottom:0; left:0;"@click="changeMonth(1)">{{i18n("schedule.next")}}</button>
</th>
</tr>
<tr style="background-color:rgb(24,24,24); height:8.33%;" >
<th class="header" v-for='d,index in 7' >
{{i18n(days[index])}}
</th>
</tr>
<tr v-for="n in 5" style="height:16.67%;">
<td v-for="m,i in 7" style="height:16.67%; position:relative;">
<div v-if="isAValue()" style="top:0; right:2%; border-radius:20%;color:rgb(200,200,200) ; position:absolute;z-index:50;">{{value-shift}}</div>
<div v-if="month != null" style="overflow-y:scroll; height:100%;" >
<template v-for="element in month[value-shift]">
<div v-if="!done"class="course" @click.native="lessonFocus(element)" v-bind:style="{background:element.color, height:100+'%'}">
<div class="hourStart">
{{getHoursMinutes(element.lessonStart)}}
</div>
<div class="infos">
<p class="childInfos" >{{jsonMod ? element.title : element.course.title}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.local}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.lessonType}}</p>
<p class="childInfos"v-if="!jsonMod">{{element.course.owner.lastName}}</p>
</div>
<div class="hourEnd">
{{getHoursMinutes(element.lessonEnd)}}
</div>
</div>
</template>
</div>
</td>
</tr>
</table>
</template>
</div>
<div class="schedule" v-else>
<div v-if="display == 'Week'">
<button @click="changeWeek(-7)">Previous</button>
<button @click="changeWeek(7)">Next</button>
<button @click="mondayOfWeek = getMonday(new Date());
scheduleByWeek != null ? scheduleByWeek = sundayToTheEnd(weekFromList(schedule.value, mondayOfWeek)) : null;">Current</button>
<template v-for="i,index in 7">
<div class="body" style="background-color:#181818;">{{i18n(days[index])}} {{formatDate(getAnyDays(index))}}
</div>
<template v-if="scheduleByWeek != null">
<div class="body" style="background-color:#353535;" >
<div class="containerList"v-for="n,j in scheduleByWeek[index].length" @click.native="lessonFocus(scheduleByWeek[index][j])" >
<div class="colorList" v-bind:style="{background:scheduleByWeek[index][j].color}"></div>
<div class="hoursList">{{ getHoursMinutes(scheduleByWeek[index][j].lessonStart)}}-{{getHoursMinutes(scheduleByWeek[index][j].lessonEnd)}}</div>
<div class="titleList">{{scheduleByWeek[index][j].course.title}}</div>
<div class="teacherList">{{scheduleByWeek[index][j].course.owner.lastName}}</div>
<div class="localList">{{scheduleByWeek[index][j].local}}</div>
<div class="typeList">{{scheduleByWeek[index][j].lessonType}}</div>
</div>
</div>
</template>
</template>
</div>
<div v-if="display == 'Month'">
<button @click="changeMonth(-1)">Previous</button>
<button @click="changeMonth(1)">Next</button>
<div class="body" >{{i18n(months[currentDate.getMonth()])}} {{currentDate.getFullYear()}}</div>
<template v-for="i,index in lastDateOfMonth(currentDate.getMonth())-1">
<div class="body" style="background-color:#181818;">{{ dateOfMonth(i).getDay()-1== -1 ? i18n(days[6]) : i18n(days[dateOfMonth(i).getDay()-1]) }} {{formatDate(dateOfMonth(i))}}
</div>
<template v-if="scheduleByWeek != null">
<div class="body" style="background-color:#353535;" >
<div class="containerList" v-for="n,j in month[i].length" @click.native="lessonFocus( month[i][j])">
<div class="colorList" v-bind:style="{background:month[i][j].color}"></div>
<div class="hoursList">{{ getHoursMinutes(month[i][j].lessonStart)}}-{{getHoursMinutes(month[i][j].lessonEnd)}}</div>
<div class="titleList">{{month[i][j].course.title}}</div>
<div class="teacherList">{{month[i][j].course.owner.lastName}}</div>
<div class="localList">{{month[i][j].local}}</div>
<div class="typeList">{{month[i][j].lessonType}}</div>
</div>
</div>
</template>
</template>
</div>
</div>
<div class="options">
<div class="settings">
<div class="body" style="background-color:rgb(50,50,50);margin:5% 0 5% 0;">{{i18n("schedule.settings")}}</div>
<select @change="changeSchedule()" v-model="trueSchedule">
<option v-for="item in allSchedules" :value='item'>{{item.curriculum.option}}-{{item.curriculum.year}}</option>
</select>
<button v-if="display=='Week'" @click="display='Month'">{{i18n("Week")}}</button>
<button v-if="display=='Month'" @click="display='Week'; value=1;">{{i18("Month")}}</button>
<button v-if="format == 'Grid'" @click="format ='List'">{{i18n("Grid")}}</button>
<button v-if="format == 'List'" @click ="format = 'Grid'">{{i18n("List")}}</button>
<button v-if="verifUser()" @click="jsonMod=false ;displayOwnSchedule();">{{i18n("OwnSchedule")}}</button>
<button v-if="importedJSON != null" @click="switchToJSON()">{{i18n("SwitchToJSON")}}</button>
<select v-if="schedule != null && !jsonMod" @change="subFilter = 'null'" v-model="filter">
<option :value ="null">No Filter</option>
<option v-for="item in filters" :value="item">{{i18n(item)}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Teacher'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in teachers" :value=item>{{item.lastName}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Course'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in courses" :value=item>{{item.title}}</option>
</select>
<select @change="sortSchedule()" v-if="filter == 'Type'" v-model="subFilter">
<option :value ="null">No Filter</option>
<option v-for="item in types" :value='item'>{{i18n(item)}}</option>
</select>
<button @click="exportJSON()" >Export JSON</button>
<div style="color:white;">IMPORT JSON</div>
<input type="file" @change="onFileChange" accept="application/JSON" ></input>
</div>
<div v-if="focus != null && !jsonMod" class="moreInfos">
<div class="body" style="background-color:rgb(50,50,50); height:10%; font-size:2em;" >{{i18n("request.moreInfos")}}</div>
<div class="body" :style="{background:focus.color,height:auto,fontSize:1.2+'em', alignItems:center}">
{{focus.course.title}}</div>
<div class="body" style="background-color:rgb(50,50,50);">{{i18n("schedule.teachers")}}</div>
<div class="body" style="background-color:#484848;">
<div>{{focus.course.owner.lastName}}</div>
<div v-for="element in focus.course.assistants">
{{element.lastName}}
</div>
</div>
<div class="body" style="background-color:rgb(50,50,50);">{{i18n("schedule.courses")}}</div>
<div class="body" style="background-color:#484848;"v-for="lesson in focusLessons">
{{ getHoursMinutes(lesson.lessonStart)}}-{{getHoursMinutes(lesson.lessonEnd)}}
{{ lesson.local}}
{{i18n(lesson.lessonType.toString())}}
</div>
</div>
</div>
</div>
</template>
<style scoped>
.grid{
min-width:1400px;
display:grid;
margin-top:2%;
align-items:center;
justify-content:center;
grid-template-columns:72% 14.5%;
column-gap:2vw;
overflow:hidden;
grid-template-areas:"schedule options";
}
.schedule{
min-width:900px;
position:relative;
overflow-y:scroll;
border-radius:20px;
grid-area:schedule;
width:100%;
height:85vh;
background-color:rgba(255,255,255,0.1);
}
.options{
display:grid;
border-radius:20px;
grid-area:options;
background-color:rgba(255,255,255,0.1);
width:100%;
height:85vh;
min-width:240px;
grid-template-rows:40% 60%;
}
.settings{
display:flex;
flex-direction:column;
width:80%;
margin:0 auto 0 auto;
}
.settings select,.settings button{
margin-top:2%;
width:100%;
}
.moreInfos{
width:90%;
display:flex;
flex-direction:column;
margin:0 auto 0 auto;
overflow-y:scroll;
overflow-x:hidden;
}
.table{
width:100%;
height:100%;
border-spacing:0;
border-collapse:separate;
border-radius: 20px;
border: 2px solid black
}
.hour{
background-color:rgb(72,72,72)
}
.header{
width:12.5%;
color:#FFFFFF;
position:relative;
}
.childHeader{
margin-top:0;
margin-bottom:0;
max-height:14.28%
}
table th:not(:last-child),
table td:not(:last-child) {
border-right: 1px solid black;
}
table tr:not(:last-child)>td,
table tr:not(:last-child)>th
{
border-bottom:1px solid black;
}
.courseGrid{
top:13.75%;
left:12.5%;
position:absolute;
width:87.5%;
height:86.25%;
display:grid;
grid-template-columns:repeat(7,1fr);
}
.course{
position:relative;
border: 1px solid black;
border-radius:10px;
width:90%;
margin-left:auto;
margin-right:auto;
display:grid;
grid-template-rows:1fr 1fr 1fr;
}
.dayCourse{
display:block;
}
.infos{
height:100%;
width:100%;
font-size:0.75em;
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
position:absolute;
}
.childInfos{
text-align:center;
margin-top:0%;
margin-bottom:0%;
overflow:hidden;
}
.hourStart{
background-color:rgb(200,200,200);
border-radius:5px;
position:absolute;
top:2%;
left:2%;
font-size:0.75em;
border: 1px solid black;
}
.hourEnd{
background-color:rgb(200,200,200);
border-radius:3px;
position:absolute;
bottom:2%;
left:2%;
font-size:0.7em;
}
.containerList{
color:white;
height:100px;
font-size:20px;
display:grid;
grid-template-columns:5vw auto auto auto auto auto;
grid-template-areas:
"color hours title teacher local type";
}
.colorList{
grid-area:color;
align-self:center;
width:75%;
height:75%;
border:1px solid black;
border-radius:20%;
}
.hoursList{
grid-area:hours;
align-self:center;
}
.titleList{
grid-area:title;
align-self:center;
}
.teacherList {
grid-area:teacher;
align-self:center;
}
.localList{
grid-area:local;
align-self:center;
}
.typeList{
grid-area:type;
align-self:center;
}
.body {
color:white;
margin-top:2%;
width:98%;
border:2px solid black;
border-radius:9px;
text-align:center;
}
</style>

View File

@ -0,0 +1,23 @@
import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
export async function getLessonRequest(id){
return restGet('/requests/lessonRequest/' + id);
}
export async function getAllRequests(){
return restGet("/requests/lessonRequests");
}
export async function getOwnedRequests(){
return restGet("/requests/lessonRequests/owned");
}
export async function createRequest(request){
return restPost("/requests/lessonRequest", request);
}
export async function changeRequestState(id, infos){
return restPatch("/requests/lessonRequest/" + id, infos);
}
export async function deleteRequest(id){
return restDelete("/requests/lessonRequest/"+id);
}

View File

@ -8,18 +8,26 @@ import Profil from "@/Apps/Profil.vue"
import Courses from "@/Apps/ManageCourses.vue" import Courses from "@/Apps/ManageCourses.vue"
import Users from "@/Apps/UsersList.vue" import Users from "@/Apps/UsersList.vue"
import Students from "@/Apps/StudentsList.vue" import Students from "@/Apps/StudentsList.vue"
import Schedule from "@/Apps/Schedule.vue"
import ManageSchedule from "@/Apps/ManageSchedule.vue"
import ManageOwnedLessons from "@/Apps/ManageOwnLessons.vue";
import LessonRequests from "@/Apps/LessonRequests.vue";
import Msg from "@/Apps/Msg.vue" import Msg from "@/Apps/Msg.vue"
import Forums from '@/Apps/Forums.vue' import Forums from '@/Apps/Forums.vue'
import Payments from "@/Apps/Inscription/PaymentInfo.vue"; import Payments from "@/Apps/Inscription/PaymentInfo.vue";
import ManageRequests from "@/Apps/Inscription/ManageRequests.vue"; import ManageRequests from "@/Apps/Inscription/ManageRequests.vue";
const apps = { const apps = {
'/schedule': Schedule,
'/manage-schedule': ManageSchedule,
'/login': LoginPage, '/login': LoginPage,
'/requests': ManageRequests, '/requests': ManageRequests,
'/profil': Profil, '/profil': Profil,
'/manage-courses' : Courses, '/manage-courses' : Courses,
'/users-list' : Users, '/users-list' : Users,
'/students-list' : Students, '/students-list' : Students,
'/manage-owned-lessons': ManageOwnedLessons,
'/manage-schedule-requests' : LessonRequests,
'/msg' : Msg, '/msg' : Msg,
'/forums': Forums, '/forums': Forums,
'/payments': Payments '/payments': Payments
@ -30,10 +38,13 @@ const appsList = {
'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") }, 'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") },
'Forum': { path: '#/forums', icon: 'fa-envelope', text: i18n("app.forum") }, 'Forum': { path: '#/forums', icon: 'fa-envelope', text: i18n("app.forum") },
'Schedule': { path: '#/schedule', icon: 'fa-calendar-days', text: i18n("app.schedules") }, 'Schedule': { path: '#/schedule', icon: 'fa-calendar-days', text: i18n("app.schedules") },
'Requests': { path: '#/requests', icon: 'fa-users', text: "Requests" }, 'ManageSchedules': { path: '#/manage-schedule', icon: 'fa-calendar-days', text: i18n("app.manageSchedules")},
'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")},
'ManageOwnedLessons':{path: '#/manage-owned-lessons',icon:'fa-calendar-days',text: i18n("app.manageOwnLessons")},
'LessonRequests':{path: '#/manage-schedule-requests', icon:'fa-book', text: i18n("app.lessonRequests")},
'Requests': { path: '#/requests', icon: 'fa-users', text: "Requests" },
'Payments':{path: '#/payments', icon:'fa-users', text:i18n("app.payments")} 'Payments':{path: '#/payments', icon:'fa-users', text:i18n("app.payments")}
} }

View File

@ -0,0 +1,69 @@
import {restGet,restPatch,restPost,restDelete} from "@/rest/restConsumer.js";
/**
* Create a new lesson
*/
export async function createLesson(datas){
return restPost("/lesson", datas )
}
/**
* Delete a lesson
*/
export async function deleteLesson(id){
return restDelete("/lesson/" + id);
}
/**
* Get information on a particular course
*
* @return all attribute of the lesson
* - course
* - start
* - end
* - color
* - local
*/
export async function getLesson(id){
return restGet("/lesson/" + id);
}
/**
* Get the list of courses to display on secretary's option
*
* @return list of courses of the form
* - id
* - name
* - credits
* - facutly
* - teacher
* - Assistants
*/
export async function getLessons(){
return restGet("/lessons")
}
export async function getOwnedLessons(){
return restGet("/lessons/owned")
}
export async function getOnesLessons(){
return restGet("/lessons/OwnCurriculum");
}
/**
* Change the options of a course
*
* @param id the id of the course
* @param changes Object with value to changes
*
* The changes object can contain:
* - name
* - credits
* - faculty
* - teacher
* - assistants: should be a list and will replace all assistants
*/
export async function alterLesson(id, changes){
return restPatch("/lesson/" + id, changes);
}

View File

@ -79,3 +79,7 @@ export async function editExempReqState(id, newstate){
export async function getExempByUser(userId){ export async function getExempByUser(userId){
return restGet("/exemptionreq/"+userId) return restGet("/exemptionreq/"+userId)
} }
export async function imposeCurriculum(id, cursusid){
return restPatch("/request/registerequivimpose/"+id+"/"+cursusid)
}

View File

@ -20,6 +20,9 @@ export function restDelete(endPoint) {
return _rest(endPoint, {method: "DELETE"}); return _rest(endPoint, {method: "DELETE"});
} }
export function restDeleteItem(endPoint, data){
return _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
}
export function restPatch(endPoint, data) { export function restPatch(endPoint, data) {
return _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)}); return _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
} }

View File

@ -0,0 +1,30 @@
import {restGet, restPost, restPatch, restDelete, restDeleteItem} from "@/rest/restConsumer.js";
export async function getAllSchedule(){
return restGet('/schedules');
}
export async function getOwnSchedule(){
return restGet('/schedule')
}
export async function createSchedule(curriculum) {
return restPost('/schedule',{curriculum : curriculum})
}
export async function getCurriculumSchedule(id){
return restGet('/schedule/curriculum/' + id)
}
export async function addLessonToSchedule(id,lessonId){
return restPost('/schedule/' + id, lessonId)
}
export async function getSchedule(id){
return restGet('/schedule/' + id);
}
export async function deleteLessonFromSchedule(id,lessonId){
return restDeleteItem('/schedule/lesson/'+ id, lessonId)
}

View File

@ -0,0 +1,169 @@
/*
* Get a date object in a date format dd-mm-yyyy
*/
export function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [day, month, year].join('-');
}
/*
* Get a date object in a date format yyyy-mm-dd
*/
export function invertedFormatDate(date) {
let d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
/*
* Create a string date via the hour and the date
*/
export function createLessonEvent(date,hour){
const str = date.concat(' ',hour);
return new Date(str);
}
/*
* Get the duration of a lesson
*/
export function durationCourse(element){
const hour = element.lessonEnd.substring(3,5) -element.lessonStart.substring(3,5);
return (element.lessonEnd - element.lessonStart)%2;
}
/*
* Help to sort lessons chronologically
*/
export function sortByDate(a, b) {
const nameA = new Date(a.lessonStart); // ignore upper and lowercase
const nameB = new Date(b.lessonStart); // ignore upper and lowercase
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
}
/*
* Get the first day of the current month
*/
export function getFirstDay(d){
var date = new Date(d);
return new Date(date.getFullYear(), date.getMonth(), 1);
}
/*
* Convert a list of lesson to a schedule in a week
*/
export function weekFromList(list, weekMonday){
const weekStart = new Date(weekMonday);
const matrix = new Array(7);
for (let i = 0; i < matrix.length; i++) {
matrix[i] = [];
}
for(let key in list){
const temp = list[key];
const day = new Date(list[key].lessonStart);
if((((day.getTime()-weekStart.getTime())/60000)<10080) && (((day.getTime()-weekStart.getTime())/60000)>0)){
matrix[day.getDay()].push(temp);
matrix[day.getDay()].sort((a,b) => sortByDate(a,b));
}
}
return matrix;
}
/*
* Return the last date of a month
*/
export function lastDateOfMonth(d){
const date = new Date(d);
const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
return temp.getDate();
}
/*
* Convert a list of lesson to a schedule in a month
*/
export function monthFromList(list,month){
const beginning = getFirstDay(month);
const matrix = new Array(lastDateOfMonth(month))
for (let i = 0; i < matrix.length; i++) {
matrix[i] = [];
}
for(let key in list){
const temp = list[key];
const day = new Date(list[key].lessonStart);
if(day.getMonth()==month){
matrix[day.getDate()].push(temp);
matrix[day.getDay()].sort((a,b) => sortByDate(a,b));
}}
return matrix;
}
/*
* Put the first element of a weekly schedule (corresponds to sunday) to the end of the list
*/
export function sundayToTheEnd(list){
const newlist = list;
const sunday = newlist.shift();
newlist.push(sunday);
return newlist;
}
/*
* Get the difference of time between 2 dates
*/
export function getDifferenceTime(date1,date2){
return Math.abs((new Date(date2).getTime() - new Date(date1).getTime())/60000);
}
/*
* used to shift the lessons correctly
*/
export function getMarginTop(list, index1, index2){
if(index2 < 0){
const temp = new Date(list[index1].lessonStart);
temp.setHours(8,0,0);
return Math.abs((new Date(list[index1].lessonStart).getTime()- temp.getTime())/60000);
}
if(new Date(list[index1].lessonStart).getTime() === new Date(list[index2].lessonEnd).getTime()){
return Math.abs(getMarginTop(list,index2,index2-1));
}
return Math.abs((new Date(list[index1].lessonStart).getTime()- new Date(list[index2].lessonEnd).getTime())/60000)+getMarginTop(list,index2,index2-1);
}
/*
* Get the hour and minutes of a date in the right format
*/
export function getHoursMinutes(date){
const d = new Date(date);
let hours = [d.getHours().toString().length == 1 ? "0" + d.getHours().toString() : d.getHours()];
return hours+ ":" + d.getMinutes();
}