Compare commits
	
		
			2 Commits
		
	
	
		
			0ffc8077db
			...
			Leo/Inscri
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 67fa630ecf | |||
| ad0e7b3e35 | 
@ -25,6 +25,7 @@ dependencies {
 | 
				
			|||||||
	implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0")
 | 
						implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0")
 | 
				
			||||||
	// implementation("org.springframework.session:spring-session-jdbc")
 | 
						// implementation("org.springframework.session:spring-session-jdbc")
 | 
				
			||||||
	developmentOnly("org.springframework.boot:spring-boot-devtools")
 | 
						developmentOnly("org.springframework.boot:spring-boot-devtools")
 | 
				
			||||||
 | 
						developmentOnly("org.springframework.boot:spring-boot-docker-compose")
 | 
				
			||||||
	runtimeOnly("org.postgresql:postgresql")
 | 
						runtimeOnly("org.postgresql:postgresql")
 | 
				
			||||||
	testImplementation("org.springframework.boot:spring-boot-starter-test")
 | 
						testImplementation("org.springframework.boot:spring-boot-starter-test")
 | 
				
			||||||
	testImplementation("org.springframework.boot:spring-boot-testcontainers")
 | 
						testImplementation("org.springframework.boot:spring-boot-testcontainers")
 | 
				
			||||||
 | 
				
			|||||||
@ -47,7 +47,6 @@ 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)
 | 
				
			||||||
@ -61,8 +60,6 @@ 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);
 | 
				
			||||||
@ -72,9 +69,7 @@ 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);}
 | 
					 | 
				
			||||||
        return authorizedApps;
 | 
					        return authorizedApps;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -74,9 +74,11 @@ 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);
 | 
				
			||||||
        System.out.println(course.getOwner().getRegNo());
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,97 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.EndPoints;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/lessons/owned")
 | 
					 | 
				
			||||||
    public ResponseEntity<Iterable<HashMap<String,Object>>> getOwnedLessons(@RequestHeader("Authorization") String token){
 | 
					 | 
				
			||||||
      System.out.println(authServ);
 | 
					 | 
				
			||||||
        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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,128 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.EndPoints;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        lessonRequestServ.save(lessonRequest);
 | 
					 | 
				
			||||||
        return new ResponseEntity<>(HttpStatus.OK);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -24,16 +24,10 @@ public class MockController {
 | 
				
			|||||||
    public final CourseService courseService;
 | 
					    public final CourseService courseService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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 MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, LessonService lessonService, ScheduleService scheduleService, ScheduleLessonService scheduleLessonService, LessonRequestService lessonRequestService){
 | 
					    public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){
 | 
				
			||||||
        this.tokenRepo = tokenRepo;
 | 
					        this.tokenRepo = tokenRepo;
 | 
				
			||||||
        this.userRepo = userRepo;
 | 
					        this.userRepo = userRepo;
 | 
				
			||||||
        this.tokenService = tokenService;
 | 
					        this.tokenService = tokenService;
 | 
				
			||||||
@ -41,10 +35,6 @@ public class MockController {
 | 
				
			|||||||
        this.curriculumService = curriculumService;
 | 
					        this.curriculumService = curriculumService;
 | 
				
			||||||
        this.courseService = courseService;
 | 
					        this.courseService = courseService;
 | 
				
			||||||
        this.inscriptionService = inscriptionService;
 | 
					        this.inscriptionService = inscriptionService;
 | 
				
			||||||
        this.lessonService = lessonService;
 | 
					 | 
				
			||||||
        this.scheduleService = scheduleService;
 | 
					 | 
				
			||||||
        this.scheduleLessonService = scheduleLessonService;
 | 
					 | 
				
			||||||
        this.lessonRequestService = lessonRequestService;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** Saves an example of each user type by :
 | 
					    /** Saves an example of each user type by :
 | 
				
			||||||
@ -106,49 +96,6 @@ 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);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,107 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.EndPoints;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import ch.qos.logback.core.net.SyslogOutputStream;
 | 
					 | 
				
			||||||
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 UserCurriculumService userCurriculumService;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    private final CurriculumService curriculumServ;
 | 
					 | 
				
			||||||
    private final AuthenticatorService authServ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private final ScheduleLessonService scheduleLessonServ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public ScheduleController(ScheduleService scheduleServ, UserCurriculumService userCurriculumService, AuthenticatorService authServ, ScheduleLessonService scheduleLessonServ, CurriculumService curriculumServ,LessonService lessonServ) {
 | 
					 | 
				
			||||||
        this.scheduleServ = scheduleServ;
 | 
					 | 
				
			||||||
        this.userCurriculumService = userCurriculumService;
 | 
					 | 
				
			||||||
        this.authServ = authServ;
 | 
					 | 
				
			||||||
        this.scheduleLessonServ = scheduleLessonServ;
 | 
					 | 
				
			||||||
        this.curriculumServ = curriculumServ;
 | 
					 | 
				
			||||||
        this.lessonServ  = lessonServ;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/schedule")
 | 
					 | 
				
			||||||
    public ResponseEntity<Map<String, Object>> findSelfSchedule(@RequestHeader("Authorization") String token){
 | 
					 | 
				
			||||||
        if(authServ.getUserFromToken(token) == null)
 | 
					 | 
				
			||||||
            return new UnauthorizedResponse<>(null);
 | 
					 | 
				
			||||||
        Schedule schedule = scheduleLessonServ.getScheduleByCurriculum(userCurriculumService.findByUser(authServ.getUserFromToken(token)));
 | 
					 | 
				
			||||||
        if(schedule == null)
 | 
					 | 
				
			||||||
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
 | 
					 | 
				
			||||||
        return new ResponseEntity<>(scheduleLessonServ.getDepthScheduleBySchedule(schedule),HttpStatus.OK);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @GetMapping("/schedules")
 | 
					 | 
				
			||||||
    public ResponseEntity<Iterable<Map<String , Object>>> findAllSchedule(){
 | 
					 | 
				
			||||||
        return new ResponseEntity<>(scheduleLessonServ.getAllSchedule(),HttpStatus.OK);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    @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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -103,6 +103,9 @@ 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);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,14 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Repositories;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,14 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Repositories;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,34 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Repositories;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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")
 | 
					 | 
				
			||||||
    Iterable<Schedule> findDistinctSchedule();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Query("select distinct sl.schedule from ScheduleLesson sl where sl.schedule.curriculum = ?1")
 | 
					 | 
				
			||||||
    Schedule findScheduleByCurriculum(Curriculum curriculum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Query("select distinct sl.lesson from ScheduleLesson sl where sl.schedule = ?1")
 | 
					 | 
				
			||||||
    Iterable<Lesson> findLessonsBySchedule(Schedule schedule);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Modifying
 | 
					 | 
				
			||||||
    @Transactional
 | 
					 | 
				
			||||||
    @Query("delete from ScheduleLesson sl where sl.lesson =?1")
 | 
					 | 
				
			||||||
    void delete(Lesson lesson);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,16 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Repositories;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -81,7 +81,7 @@ public class InscriptionService {
 | 
				
			|||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            userRepo.save(userFromRequest);
 | 
					            userRepo.save(userFromRequest);
 | 
				
			||||||
            userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId())));
 | 
					            userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        inscrRequest.setState(requestState);
 | 
					        inscrRequest.setState(requestState);
 | 
				
			||||||
        save(inscrRequest);
 | 
					        save(inscrRequest);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,138 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Services;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public Iterable<LessonChangesRequest> findOwnRequests(User user){
 | 
					 | 
				
			||||||
        return lessonChangesRepo.findOwnRequests(user);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public LessonChangesRequest save(LessonChangesRequest lessonRequest){
 | 
					 | 
				
			||||||
        return lessonChangesRepo.save(lessonRequest);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public LessonChangesRequest findById(long id){
 | 
					 | 
				
			||||||
        return lessonChangesRepo.findById(id);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public Iterable<LessonChangesRequest> getAll(){return lessonChangesRepo.findAll();}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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 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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public void modifyDeleteRequest(LessonChangesRequest lessonChangesRequest, RequestState state){
 | 
					 | 
				
			||||||
        if(state == RequestState.Accepted){
 | 
					 | 
				
			||||||
            lessonServ.delete(lessonServ.findById(lessonChangesRequest.getLessonId()));
 | 
					 | 
				
			||||||
            lessonChangesRequest.setState(state);}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,101 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Services;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.springframework.stereotype.Service;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Repositories.LessonRepository;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Course;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Lesson;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Tables.Role;
 | 
					 | 
				
			||||||
import ovh.herisson.Clyde.Tables.User;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.lang.reflect.GenericSignatureFormatError;
 | 
					 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@Service
 | 
					 | 
				
			||||||
public class LessonService {
 | 
					 | 
				
			||||||
    private final LessonRepository lessonRepo;
 | 
					 | 
				
			||||||
    private final CourseRepository courseRepo;
 | 
					 | 
				
			||||||
    public LessonService(LessonRepository lessonRepo, CourseRepository courseRepo){
 | 
					 | 
				
			||||||
        this.lessonRepo = lessonRepo;
 | 
					 | 
				
			||||||
        this.courseRepo = courseRepo;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public Lesson save(Lesson lesson){
 | 
					 | 
				
			||||||
        return lessonRepo.save(lesson);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public Lesson findById(long id){
 | 
					 | 
				
			||||||
        return lessonRepo.findById(id);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public Iterable<Lesson> findAll(){return lessonRepo.findAll();}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public void delete(Lesson lesson){
 | 
					 | 
				
			||||||
        lessonRepo.delete(lesson);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Services;
 | 
					package ovh.herisson.Clyde.Services;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ovh.herisson.Clyde.Tables.*;
 | 
					import ovh.herisson.Clyde.Tables.Course;
 | 
				
			||||||
 | 
					import ovh.herisson.Clyde.Tables.InscriptionRequest;
 | 
				
			||||||
 | 
					import ovh.herisson.Clyde.Tables.User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
@ -67,33 +69,6 @@ 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) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -116,32 +91,6 @@ 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<>();
 | 
				
			||||||
 | 
				
			|||||||
@ -1,99 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Services;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public Map<String , Object> getDepthScheduleByCurriculum(Curriculum curriculum){
 | 
					 | 
				
			||||||
        if(curriculum == null)
 | 
					 | 
				
			||||||
            return null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        HashMap<String , Object> toReturn = new HashMap<>();
 | 
					 | 
				
			||||||
        ArrayList<Map<String, Object>> lessons = new ArrayList<>();
 | 
					 | 
				
			||||||
        Iterable<Lesson> foundLessons = scheduleLessonRepo.findLessonByCurriculum(curriculum);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (Lesson l: foundLessons){
 | 
					 | 
				
			||||||
            lessons.add(ProtectionService.lessonWithoutPassword(l));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        toReturn.put("lessons",lessons);
 | 
					 | 
				
			||||||
        toReturn.put("scheduleId" , scheduleLessonRepo.findScheduleByCurriculum(curriculum).getScheduleID());
 | 
					 | 
				
			||||||
        toReturn.put("curriculum", curriculum);
 | 
					 | 
				
			||||||
        return toReturn;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public Iterable<Map<String,Object>> getAllSchedule(){
 | 
					 | 
				
			||||||
        ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (Schedule schedule: scheduleRepo.findAll()){
 | 
					 | 
				
			||||||
            toReturn.add(getDepthScheduleBySchedule(schedule));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return toReturn;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,24 +0,0 @@
 | 
				
			|||||||
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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -3,7 +3,6 @@ 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,
 | 
				
			||||||
@ -13,18 +12,11 @@ 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
 | 
				
			||||||
    Inscription,
 | 
					    Inscription,
 | 
				
			||||||
    StudentsList
 | 
					    StudentsList
 | 
				
			||||||
 | 
				
			|||||||
@ -8,7 +8,7 @@ import org.hibernate.annotations.OnDeleteAction;
 | 
				
			|||||||
public class Course {
 | 
					public class Course {
 | 
				
			||||||
    @Id
 | 
					    @Id
 | 
				
			||||||
    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
					    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
				
			||||||
    private int courseId;
 | 
					    private int courseID;
 | 
				
			||||||
    private int credits;
 | 
					    private int credits;
 | 
				
			||||||
    private String title;
 | 
					    private String title;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -26,10 +26,7 @@ public class Course {
 | 
				
			|||||||
    public Course() {}
 | 
					    public Course() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public int getCourseID() {
 | 
					    public int getCourseID() {
 | 
				
			||||||
        return courseId;
 | 
					        return courseID;
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    public void setCourseID(int courseId){
 | 
					 | 
				
			||||||
      this.courseId = courseId;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public int getCredits() {
 | 
					    public int getCredits() {
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Entity
 | 
				
			||||||
 | 
					public class ExemptionsRequest {
 | 
				
			||||||
 | 
					    @Id
 | 
				
			||||||
 | 
					    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
				
			||||||
 | 
					    private int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ManyToOne
 | 
				
			||||||
 | 
					    @JoinColumn(name = "Users")
 | 
				
			||||||
 | 
					    private User user;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ManyToOne
 | 
				
			||||||
 | 
					    @JoinColumn(name = "Course")
 | 
				
			||||||
 | 
					    private Course course;
 | 
				
			||||||
 | 
					    private String justifDocument;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private RequestState state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state){
 | 
				
			||||||
 | 
					        this.user = user;
 | 
				
			||||||
 | 
					        this.course = course;
 | 
				
			||||||
 | 
					        this.justifDocument = justifDocument;
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ExemptionsRequest(){}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public User getUser() {
 | 
				
			||||||
 | 
					        return user;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setUser(User user) {
 | 
				
			||||||
 | 
					        this.user = user;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Course getCourse() {
 | 
				
			||||||
 | 
					        return course;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setCourse(Course course) {
 | 
				
			||||||
 | 
					        this.course = course;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getJustifDocument() {
 | 
				
			||||||
 | 
					        return justifDocument;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setJustifDocument(String justifDocument) {
 | 
				
			||||||
 | 
					        this.justifDocument = justifDocument;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RequestState getState() {
 | 
				
			||||||
 | 
					        return state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setState(RequestState state) {
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,92 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,133 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,34 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
package ovh.herisson.Clyde.Tables;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,55 +0,0 @@
 | 
				
			|||||||
package ovh.herisson.Clyde.Tables;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} 
 | 
					 | 
				
			||||||
@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.persistence.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Entity
 | 
				
			||||||
 | 
					public class ScholarshipRequest {
 | 
				
			||||||
 | 
					    @Id
 | 
				
			||||||
 | 
					    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
				
			||||||
 | 
					    private int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @ManyToOne
 | 
				
			||||||
 | 
					    @JoinColumn(name = "Users")
 | 
				
			||||||
 | 
					    private User user;
 | 
				
			||||||
 | 
					    private RequestState state;
 | 
				
			||||||
 | 
					    private String requestForm;
 | 
				
			||||||
 | 
					    private int amount;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){
 | 
				
			||||||
 | 
					        this.user = user;
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					        this.requestForm = requestForm;
 | 
				
			||||||
 | 
					        this.amount = amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ScholarshipRequest(){}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public User getUser() {
 | 
				
			||||||
 | 
					        return user;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setUser(User user) {
 | 
				
			||||||
 | 
					        this.user = user;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RequestState getState() {
 | 
				
			||||||
 | 
					        return state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setState(RequestState state) {
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getRequestForm() {
 | 
				
			||||||
 | 
					        return requestForm;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setRequestForm(String requestForm) {
 | 
				
			||||||
 | 
					        this.requestForm = requestForm;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getAmount() {
 | 
				
			||||||
 | 
					        return amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setAmount(int amount) {
 | 
				
			||||||
 | 
					        this.amount = amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package ovh.herisson.Clyde.Tables;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import jakarta.persistence.Entity;
 | 
				
			||||||
 | 
					import jakarta.persistence.GeneratedValue;
 | 
				
			||||||
 | 
					import jakarta.persistence.GenerationType;
 | 
				
			||||||
 | 
					import jakarta.persistence.Id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Entity
 | 
				
			||||||
 | 
					public class UninscriptionRequest {
 | 
				
			||||||
 | 
					    @Id
 | 
				
			||||||
 | 
					    @GeneratedValue(strategy = GenerationType.AUTO)
 | 
				
			||||||
 | 
					    private int id;
 | 
				
			||||||
 | 
					    private RequestState state;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public UninscriptionRequest(RequestState state){
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public UninscriptionRequest(){}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public RequestState getState() {
 | 
				
			||||||
 | 
					        return state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setState(RequestState state) {
 | 
				
			||||||
 | 
					        this.state = state;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -21,9 +21,12 @@ public class UserCurriculum {
 | 
				
			|||||||
    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
					    @OnDelete(action = OnDeleteAction.CASCADE)
 | 
				
			||||||
    private Curriculum curriculum;
 | 
					    private Curriculum curriculum;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public UserCurriculum(User user, Curriculum curriculum){
 | 
					    private int year;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public UserCurriculum(User user, Curriculum curriculum, int year){
 | 
				
			||||||
        this.user = user;
 | 
					        this.user = user;
 | 
				
			||||||
        this.curriculum = curriculum;
 | 
					        this.curriculum = curriculum;
 | 
				
			||||||
 | 
					        this.year = year;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public UserCurriculum() {}
 | 
					    public UserCurriculum() {}
 | 
				
			||||||
@ -47,4 +50,12 @@ public class UserCurriculum {
 | 
				
			|||||||
    public void setCurriculum(Curriculum curriculum) {
 | 
					    public void setCurriculum(Curriculum curriculum) {
 | 
				
			||||||
        this.curriculum = curriculum;
 | 
					        this.curriculum = curriculum;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getYear() {
 | 
				
			||||||
 | 
					        return year;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setYear(int year) {
 | 
				
			||||||
 | 
					        this.year = year;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,15 +22,12 @@ 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
 | 
					 | 
				
			||||||
request.moreInfos=More Infos
 | 
					request.moreInfos=More Infos
 | 
				
			||||||
request.accept=Accept
 | 
					request.accept=Accept
 | 
				
			||||||
request.refuse=Refuse
 | 
					request.refuse=Refuse
 | 
				
			||||||
 | 
				
			|||||||
@ -22,15 +22,12 @@ 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
 | 
					 | 
				
			||||||
request.moreInfos=Plus d'Infos
 | 
					request.moreInfos=Plus d'Infos
 | 
				
			||||||
request.accept=Accepter
 | 
					request.accept=Accepter
 | 
				
			||||||
request.refuse=Refuser
 | 
					request.refuse=Refuser
 | 
				
			||||||
 | 
				
			|||||||
@ -25,6 +25,7 @@ window.addEventListener('hashchange', () => {
 | 
				
			|||||||
  const login=ref(i18n("app.login"))
 | 
					  const login=ref(i18n("app.login"))
 | 
				
			||||||
  const active=ref(false)
 | 
					  const active=ref(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const apps = ref([])
 | 
						const apps = ref([])
 | 
				
			||||||
	appList().then(e => apps.value = e)
 | 
						appList().then(e => apps.value = e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -85,18 +86,19 @@ window.addEventListener('hashchange', () => {
 | 
				
			|||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class="page">
 | 
					    <div class="page">
 | 
				
			||||||
 | 
					      <div style=" margin:50px;">
 | 
				
			||||||
        <Suspense>
 | 
					        <Suspense>
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
		<component :is="currentView" />
 | 
							<component :is="currentView" />
 | 
				
			||||||
        </Suspense>
 | 
					        </Suspense>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style scoped>
 | 
					<style scoped>
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  .container{
 | 
					  .container{
 | 
				
			||||||
			height: 100%;
 | 
					 | 
				
			||||||
			width: 100%;
 | 
					 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:[firstCol-start]70px[firstCol-end secondCol-start]auto[endCol];
 | 
					    grid-template-columns:[firstCol-start]70px[firstCol-end secondCol-start]auto[endCol];
 | 
				
			||||||
    grid-template-rows:[firstRow-start]61px[firstRow-end secondRow-start] auto [endRow];
 | 
					    grid-template-rows:[firstRow-start]61px[firstRow-end secondRow-start] auto [endRow];
 | 
				
			||||||
@ -109,8 +111,6 @@ window.addEventListener('hashchange', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  .page {
 | 
					  .page {
 | 
				
			||||||
    grid-area:page;
 | 
					    grid-area:page;
 | 
				
			||||||
		height: 100%;
 | 
					 | 
				
			||||||
		width: 100%;
 | 
					 | 
				
			||||||
    place-self:center;
 | 
					    place-self:center;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										82
									
								
								frontend/src/Apps/AboutStudent.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								frontend/src/Apps/AboutStudent.vue
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,82 @@
 | 
				
			|||||||
 | 
					<script setup>
 | 
				
			||||||
 | 
					  import i18n from "@/i18n.js"
 | 
				
			||||||
 | 
					  import {getSelf, getUser} from '../rest/Users.js'
 | 
				
			||||||
 | 
					  import {ref} from "vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const user = await getSelf();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  function getPP(){
 | 
				
			||||||
 | 
					    if(user.value.profilePictureUrl === null){
 | 
				
			||||||
 | 
					      return "/Clyde.png"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return user.profilePictureUrl
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <div class="body">
 | 
				
			||||||
 | 
					    <div class="container">
 | 
				
			||||||
 | 
					      <div class="profilPic">
 | 
				
			||||||
 | 
					        <img class="subContainter" :src=getPP()>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					      <div class = "globalInfos">
 | 
				
			||||||
 | 
					        <div class="infosContainer">
 | 
				
			||||||
 | 
					          <div>
 | 
				
			||||||
 | 
					            {{user.firstName}} {{user.lastName}}
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					          <div>
 | 
				
			||||||
 | 
					            E-mail: {{user.email}}
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					      </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style>
 | 
				
			||||||
 | 
					.container{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  display:grid;
 | 
				
			||||||
 | 
					  grid-template-columns:200px 900px;
 | 
				
			||||||
 | 
					  grid-template-rows:200px auto;
 | 
				
			||||||
 | 
					  column-gap:30px;
 | 
				
			||||||
 | 
					  row-gap:45px;
 | 
				
			||||||
 | 
					  grid-template-areas:
 | 
				
			||||||
 | 
					  "profilPic globalInfos"
 | 
				
			||||||
 | 
					  "minfos minfos";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.profilPic{
 | 
				
			||||||
 | 
					  grid-area:profilPic;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.globalInfos {
 | 
				
			||||||
 | 
					  grid-area:globalInfos;
 | 
				
			||||||
 | 
					  align-self :center;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.body {
 | 
				
			||||||
 | 
					  width:100%;
 | 
				
			||||||
 | 
					  margin-bottom:10px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.subContainter{
 | 
				
			||||||
 | 
					  width:100%;
 | 
				
			||||||
 | 
					  background-color:rgb(50,50,50);
 | 
				
			||||||
 | 
					  border-radius:20px;
 | 
				
			||||||
 | 
					  border:4px solid black;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.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>
 | 
				
			||||||
@ -16,9 +16,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template> 
 | 
					<template> 
 | 
				
			||||||
  <div style='display:flex; justify-content:center; min-width:1140px;' v-for="item of requests">
 | 
					  <div  v-for="item of requests">
 | 
				
			||||||
  <div class="bodu" v-if="item.state === 'Pending'">
 | 
					  <div class="bodu" v-if="item.state === 'Pending'">
 | 
				
			||||||
  <div class="container">
 | 
					  <div class="container">
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
    <div class="id"><a>{{item.id}}</a></div>
 | 
					    <div class="id"><a>{{item.id}}</a></div>
 | 
				
			||||||
    <div class="surname"><a>{{item.lastName}}</a></div>
 | 
					    <div class="surname"><a>{{item.lastName}}</a></div>
 | 
				
			||||||
    <div class="firstname"><a>{{item.firstName}}</a></div>
 | 
					    <div class="firstname"><a>{{item.firstName}}</a></div>
 | 
				
			||||||
@ -36,9 +37,10 @@
 | 
				
			|||||||
    height:100px;
 | 
					    height:100px;
 | 
				
			||||||
    font-size:20px;
 | 
					    font-size:20px;
 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:10% 14.2% 19% 14.2% 14.2% 14.2% 14.2%;
 | 
					    grid-template-columns:[firstCol-start]100px[firstCol-end secondCol-start]150px[secondCol-end thirdCol-start]200px[thirdCol-end fourthCol-start]150px[fourthCol-end]150px[fifthCol-end]150px[sixthCol-end]150px[endCol];
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
    "id type surname firstname infos accept refuse"; 
 | 
					    "id type surname firstname infos accept refuse"; 
 | 
				
			||||||
 | 
					    column-gap:10px;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -98,8 +100,8 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .bodu {
 | 
					  .bodu {
 | 
				
			||||||
    margin-top:2%;
 | 
					    width:100%;
 | 
				
			||||||
    width:66%;
 | 
					    margin-bottom:10px;
 | 
				
			||||||
    border:2px solid black;
 | 
					    border:2px solid black;
 | 
				
			||||||
    border-radius:9px;
 | 
					    border-radius:9px;
 | 
				
			||||||
    background-color:rgb(50,50,50);
 | 
					    background-color:rgb(50,50,50);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,220 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
<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({});
 | 
					 | 
				
			||||||
async function upPage(id,review){
 | 
					 | 
				
			||||||
  await changeRequestState(id, review) ;
 | 
					 | 
				
			||||||
  requests.value = await getAllRequests();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async function AcceptSetup(id,type){
 | 
					 | 
				
			||||||
  if(type !== 2 ){
 | 
					 | 
				
			||||||
    AcceptMod.value = !AcceptMod.value;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  else{
 | 
					 | 
				
			||||||
    await upPage(id,{local: null,state:'Accepted'});
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function editItem(item){
 | 
					 | 
				
			||||||
  editElementID.value = item.id;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async function setMoreInfos(item){
 | 
					 | 
				
			||||||
    moreInfos.value["requestType"] = requestTypes[item.requestType]
 | 
					 | 
				
			||||||
    moreInfos.value["day"] = formatDate(new Date(item.lessonStart))
 | 
					 | 
				
			||||||
    moreInfos.value["start"] = getHoursMinutes(new Date(item.lessonStart));
 | 
					 | 
				
			||||||
    moreInfos.value["end"] = getHoursMinutes(new Date(item.lessonEnd));
 | 
					 | 
				
			||||||
    moreInfos.value["lessonType"] = item.lessonType;
 | 
					 | 
				
			||||||
  [item["course"] == null ?  moreInfos.value["course"] = null: moreInfos.value["course"]=item.course.title]
 | 
					 | 
				
			||||||
  if (item.requestType==1 || item.requestType == 2){
 | 
					 | 
				
			||||||
    let temp = await getLesson(item.lessonId);
 | 
					 | 
				
			||||||
    if(item.requestType == 1){
 | 
					 | 
				
			||||||
    moreInfos.value["course"] = temp.course.title;
 | 
					 | 
				
			||||||
    moreInfos.value["old_day"] =  formatDate(new Date(temp.lessonStart));
 | 
					 | 
				
			||||||
    moreInfos.value["old_start"] = getHoursMinutes(new Date(temp.lessonStart));
 | 
					 | 
				
			||||||
    moreInfos.value["old_end"] = getHoursMinutes(new Date(temp.lessonEnd));
 | 
					 | 
				
			||||||
    moreInfos.value["old_type"] = temp.lessonType;
 | 
					 | 
				
			||||||
  }}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <div  class="body">
 | 
					 | 
				
			||||||
    <div v-for="item of requests" :key="item.id" :style="{width:[moreInfosMod ? 95:70] + '%'}" class="centerer">
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      <div v-if ="item.state === 'Pending'" class="listElement">
 | 
					 | 
				
			||||||
      <div class="containerElement" v-if="editElementID !== item.id">
 | 
					 | 
				
			||||||
          <div class="id">{{requestTypes[item.requestType]}}</div>
 | 
					 | 
				
			||||||
          <div class="surname">{{item.state}}</div>
 | 
					 | 
				
			||||||
          <div class="firstname">{{item.user.lastName}}</div>
 | 
					 | 
				
			||||||
          
 | 
					 | 
				
			||||||
          <div class="infos">
 | 
					 | 
				
			||||||
            <button @click=" editItem(item);moreInfosMod=!moreInfosMod; setMoreInfos(item); console.log(item);" style="background-color:rgb(105,05,105);" >
 | 
					 | 
				
			||||||
              {{i18n("request.moreInfos")}}
 | 
					 | 
				
			||||||
            </button></div>
 | 
					 | 
				
			||||||
          <div class="accept"><button @click="editItem(item); 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">
 | 
					 | 
				
			||||||
            Local:
 | 
					 | 
				
			||||||
            <select v-model="chosenLocal">
 | 
					 | 
				
			||||||
              <option v-for="item in locals">{{item}}</option>
 | 
					 | 
				
			||||||
            </select>
 | 
					 | 
				
			||||||
            <button @click="AcceptMod = !AcceptMod;upPage(item.id,{local: chosenLocal, state:'Accepted'})"></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">
 | 
					 | 
				
			||||||
                {{value}}:
 | 
					 | 
				
			||||||
              {{key}}
 | 
					 | 
				
			||||||
              </div>
 | 
					 | 
				
			||||||
              </div>
 | 
					 | 
				
			||||||
          </template>
 | 
					 | 
				
			||||||
              <button @click = "moreInfosMod = !moreInfosMod; editElementID = ''">back</button>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
</template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<style scoped>
 | 
					 | 
				
			||||||
.centerer{
 | 
					 | 
				
			||||||
  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%;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.buttonGrid{
 | 
					 | 
				
			||||||
  display:grid;
 | 
					 | 
				
			||||||
  grid-template-columns: auto auto;
 | 
					 | 
				
			||||||
  column-gap:50px;
 | 
					 | 
				
			||||||
  grid-template-areas:
 | 
					 | 
				
			||||||
      "create delete";
 | 
					 | 
				
			||||||
}.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>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -56,10 +56,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
    <div class="setup">
 | 
					      <div class='loginBox'>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div v-if="loginPage">
 | 
					        <div v-if="loginPage">
 | 
				
			||||||
      <div class='loginBox' style="margin-top:30%;">
 | 
					          <form @submit.prevent=" login(outputs.email,outputs.password);goBackHome();"class="form">
 | 
				
			||||||
          <form @submit.prevent="login(outputs.email,outputs.password);goBackHome();"class="form">
 | 
					 | 
				
			||||||
            <h1 style="color:rgb(239,60,168); font-family: sans-serif;">
 | 
					            <h1 style="color:rgb(239,60,168); font-family: sans-serif;">
 | 
				
			||||||
              {{i18n("login.guest.signin")}}
 | 
					              {{i18n("login.guest.signin")}}
 | 
				
			||||||
            </h1>
 | 
					            </h1>
 | 
				
			||||||
@ -74,14 +74,13 @@
 | 
				
			|||||||
            <div class="register">
 | 
					            <div class="register">
 | 
				
			||||||
              <a @click="loginPage=!loginPage">{{i18n("login.guest.register")}}</a>
 | 
					              <a @click="loginPage=!loginPage">{{i18n("login.guest.register")}}</a>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
            <div class="inputBox" style="margin-bottom:35px;">
 | 
					            <div class="inputBox">
 | 
				
			||||||
              <input type="submit" v-model="submitValue">
 | 
					              <input type="submit" v-model="submitValue">
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          </form>
 | 
					          </form>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
      </div>
 | 
					
 | 
				
			||||||
        <div v-else>
 | 
					        <div v-else>
 | 
				
			||||||
          <div class='loginBox' style="margin-top:30%; margin-bottom:50%;">
 | 
					 | 
				
			||||||
          <form class="form">
 | 
					          <form class="form">
 | 
				
			||||||
            <h1 style="color:rgb(239,60,168); font-family: sans-serif; text-align:center;">
 | 
					            <h1 style="color:rgb(239,60,168); font-family: sans-serif; text-align:center;">
 | 
				
			||||||
              {{i18n("login.guest.welcome")}}
 | 
					              {{i18n("login.guest.welcome")}}
 | 
				
			||||||
@ -129,12 +128,9 @@
 | 
				
			|||||||
                <p>{{i18n("login.guest.country")}}</p>
 | 
					                <p>{{i18n("login.guest.country")}}</p>
 | 
				
			||||||
                <input type="text" v-model="outputs.country">
 | 
					                <input type="text" v-model="outputs.country">
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
              <form class="inputBox"novalidate enctype="multipart/form-data">
 | 
					              <form novalidate enctype="multipart/form-data" class="inputBox">
 | 
				
			||||||
              	<p>{{i18n("profile.picture").toUpperCase()}}</p> 
 | 
					              	<p>{{i18n("profile.picture").toUpperCase()}}</p> 
 | 
				
			||||||
              <label class="browser">
 | 
					 | 
				
			||||||
                Parcourir . . .
 | 
					 | 
				
			||||||
				<input type="file" :disabled="imageSaved" @change="ppData = uploadProfilePicture($event.target.files); imageSaved = true;" accept="image/*">
 | 
									<input type="file" :disabled="imageSaved" @change="ppData = uploadProfilePicture($event.target.files); imageSaved = true;" accept="image/*">
 | 
				
			||||||
              </label>
 | 
					 | 
				
			||||||
              </form>
 | 
					              </form>
 | 
				
			||||||
              <div class="inputBox">
 | 
					              <div class="inputBox">
 | 
				
			||||||
                <p>{{i18n("Curriculum").toUpperCase()}}</p> 
 | 
					                <p>{{i18n("Curriculum").toUpperCase()}}</p> 
 | 
				
			||||||
@ -158,25 +154,34 @@
 | 
				
			|||||||
          </form>
 | 
					          </form>
 | 
				
			||||||
         </div>
 | 
					         </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<style scoped>
 | 
					<style scoped>
 | 
				
			||||||
 | 
					.Home{
 | 
				
			||||||
.setup {
 | 
					  position:absolute;
 | 
				
			||||||
  margin-left: auto;
 | 
					 	display: flex;
 | 
				
			||||||
  margin-right:auto;
 | 
					  z-index: 100;
 | 
				
			||||||
  min-width:400px;
 | 
						padding: 8px 16px;
 | 
				
			||||||
 | 
						color:rgb(255, 255, 255);
 | 
				
			||||||
  width:25%;
 | 
						text-decoration: none;
 | 
				
			||||||
  height:60%;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.Home:hover{
 | 
				
			||||||
 | 
					  width:40px;
 | 
				
			||||||
 | 
					  background-color: black;
 | 
				
			||||||
 | 
						border-radius:6px;
 | 
				
			||||||
 | 
						color:white;
 | 
				
			||||||
 | 
					  transform: translate(0px ,1px);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.loginBox {
 | 
					.loginBox {
 | 
				
			||||||
  background-color: rgb(24,24,24);
 | 
					  background-color: rgb(24,24,24);
 | 
				
			||||||
 | 
					  width: 400px;
 | 
				
			||||||
  display:flex;
 | 
					  display:flex;
 | 
				
			||||||
  justify-content: center;
 | 
					  justify-content: center;
 | 
				
			||||||
  border-radius: 5%;
 | 
					  padding: 40px;
 | 
				
			||||||
 | 
					  border-radius: 20px;
 | 
				
			||||||
  box-shadow:0 5px 25px #000000;
 | 
					  box-shadow:0 5px 25px #000000;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -185,8 +190,9 @@
 | 
				
			|||||||
  width:100%;
 | 
					  width:100%;
 | 
				
			||||||
  display: flex;
 | 
					  display: flex;
 | 
				
			||||||
  flex-direction: column;
 | 
					  flex-direction: column;
 | 
				
			||||||
 | 
					  justify-content: center;
 | 
				
			||||||
  align-items:center;
 | 
					  align-items:center;
 | 
				
			||||||
  gap: 3%;
 | 
					  gap: 15px;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -194,12 +200,12 @@
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  width:100%;
 | 
					  width:100%;
 | 
				
			||||||
  border: none;
 | 
					  border: none;
 | 
				
			||||||
  margin-right: 12.5%;
 | 
					  margin-right: 50px;
 | 
				
			||||||
  padding-left: 2.5%;
 | 
					  padding-left: 10px;
 | 
				
			||||||
  padding-top:2.5%;
 | 
					  padding-top:10px;
 | 
				
			||||||
  padding-bottom:2.5%;
 | 
					  padding-bottom:10px;
 | 
				
			||||||
  outline:none;
 | 
					  outline:none;
 | 
				
			||||||
  border-radius: 10px;
 | 
					  border-radius: 4px;
 | 
				
			||||||
  font-size:1.35em;
 | 
					  font-size:1.35em;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -214,9 +220,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
.register{
 | 
					.register{
 | 
				
			||||||
  color:rgb(239,60,168);
 | 
					  color:rgb(239,60,168);
 | 
				
			||||||
  width:70%;
 | 
					  width: 100%;
 | 
				
			||||||
  margin-bottom:20px;
 | 
					  display:flex;
 | 
				
			||||||
  margin-top:20px;
 | 
					 | 
				
			||||||
  cursor: pointer;
 | 
					  cursor: pointer;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -245,21 +250,6 @@ input[type=submit],button,select{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
input[type=file]{
 | 
					 | 
				
			||||||
  display:none;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.browser{
 | 
					 | 
				
			||||||
  display:inline-block;
 | 
					 | 
				
			||||||
  cursor:pointer;
 | 
					 | 
				
			||||||
  border-radius:20px;
 | 
					 | 
				
			||||||
  background-color:rgb(239,60,168);
 | 
					 | 
				
			||||||
  padding:5%;
 | 
					 | 
				
			||||||
  font-size:1.35em;
 | 
					 | 
				
			||||||
  font-family:sans-serif;
 | 
					 | 
				
			||||||
  background:#FFFFFF;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
button:active ,.switchpage:active{
 | 
					button:active ,.switchpage:active{
 | 
				
			||||||
  opacity:0.8;
 | 
					  opacity:0.8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
  const editElementID = ref("")
 | 
					  const editElementID = ref("")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function editItem(id){
 | 
					  function editItem(id){
 | 
				
			||||||
    editElementID.value = id;
 | 
					    editElementID = id;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //Juste pour montrer le Create Mode
 | 
					  //Juste pour montrer le Create Mode
 | 
				
			||||||
@ -35,6 +35,7 @@
 | 
				
			|||||||
    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;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@ -63,6 +64,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  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});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -101,8 +105,7 @@
 | 
				
			|||||||
      </button>
 | 
					      </button>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div v-if="createMod">
 | 
					    <div v-if="createMod">
 | 
				
			||||||
      <form class="listElement" style="width:40%;margin-right:auto;margin-left:auto;">
 | 
					      <form class="listElement">
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        <div style="margin-bottom:20px;">
 | 
					        <div style="margin-bottom:20px;">
 | 
				
			||||||
         {{i18n("name")}} : 
 | 
					         {{i18n("name")}} : 
 | 
				
			||||||
        <input v-model="toAdd.title">
 | 
					        <input v-model="toAdd.title">
 | 
				
			||||||
@ -122,7 +125,7 @@
 | 
				
			|||||||
      </form>
 | 
					      </form>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div v-if="deleteMod">
 | 
					    <div v-if="deleteMod">
 | 
				
			||||||
      <form class="listElement" style="width:40%;margin-right:auto;margin-left:auto;">
 | 
					      <form class="listElement">
 | 
				
			||||||
        <div style="margin-bottom:20px;">
 | 
					        <div style="margin-bottom:20px;">
 | 
				
			||||||
          {{i18n("courses.toDelete")}} :
 | 
					          {{i18n("courses.toDelete")}} :
 | 
				
			||||||
         <select style="max-width:200px;" class="teacher" v-model="toRemove">
 | 
					         <select style="max-width:200px;" class="teacher" v-model="toRemove">
 | 
				
			||||||
@ -135,7 +138,7 @@
 | 
				
			|||||||
      </form>
 | 
					      </form>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <div v-if="!createMod && !deleteMod" v-for="item in curriculum" :key="item.title" style="width:50%;margin-left:auto; margin-right:auto;">
 | 
					    <div v-if="!createMod && !deleteMod" v-for="item in curriculum" :key="item.title">
 | 
				
			||||||
      <div  v-if="editElementID !== item.title" style ="padding:15px 15px 15px 15px;">
 | 
					      <div  v-if="editElementID !== item.title" style ="padding:15px 15px 15px 15px;">
 | 
				
			||||||
        <button   @click="editElementID = item.title; setModify(item); ">
 | 
					        <button   @click="editElementID = item.title; setModify(item); ">
 | 
				
			||||||
        {{i18n("courses.modify")}}
 | 
					        {{i18n("courses.modify")}}
 | 
				
			||||||
@ -146,7 +149,6 @@
 | 
				
			|||||||
        <button @click="editElementID= '';"> {{i18n("courses.back")}} </button>
 | 
					        <button @click="editElementID= '';"> {{i18n("courses.back")}} </button>
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
      <div  class="listElement" > 
 | 
					      <div  class="listElement" > 
 | 
				
			||||||
 | 
					 | 
				
			||||||
      <div class="containerElement" v-if="editElementID !== item.title" >
 | 
					      <div class="containerElement" v-if="editElementID !== item.title" >
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div class="name"> {{item.title}} </div>
 | 
					        <div class="name"> {{item.title}} </div>
 | 
				
			||||||
@ -155,11 +157,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>
 | 
				
			||||||
@ -170,16 +172,17 @@
 | 
				
			|||||||
<style scoped>
 | 
					<style scoped>
 | 
				
			||||||
.body {
 | 
					.body {
 | 
				
			||||||
    width:100%;
 | 
					    width:100%;
 | 
				
			||||||
    margin-top:3.5%;
 | 
					    margin-bottom:10px;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
 .containerElement{ 
 | 
					 .containerElement{ 
 | 
				
			||||||
   justify-content:center;
 | 
					   justify-content:center;
 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:38.8% 38.8% 22.4%;
 | 
					    grid-template-columns:350px 350px 200px;
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
    "name teacher credits"; 
 | 
					    "name teacher credits"; 
 | 
				
			||||||
    column-gap:10px;  }
 | 
					    column-gap:10px;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  .name {
 | 
					  .name {
 | 
				
			||||||
    grid-area:name;
 | 
					    grid-area:name;
 | 
				
			||||||
@ -197,7 +200,6 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.listElement{
 | 
					.listElement{
 | 
				
			||||||
 min-width:625px;
 | 
					 | 
				
			||||||
  border:2px solid black;
 | 
					  border:2px solid black;
 | 
				
			||||||
  font-size:25px;
 | 
					  font-size:25px;
 | 
				
			||||||
  color:white;
 | 
					  color:white;
 | 
				
			||||||
@ -205,7 +207,6 @@
 | 
				
			|||||||
  background-color:rgb(50,50,50);
 | 
					  background-color:rgb(50,50,50);
 | 
				
			||||||
  border-radius:20px;
 | 
					  border-radius:20px;
 | 
				
			||||||
  margin-bottom:10px;
 | 
					  margin-bottom:10px;
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.modify{
 | 
					.modify{
 | 
				
			||||||
@ -254,11 +255,10 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .listTitle{
 | 
					  .listTitle{
 | 
				
			||||||
    min-width:380px;
 | 
					 | 
				
			||||||
    display: flex;
 | 
					    display: flex;
 | 
				
			||||||
    justify-content: center;
 | 
					    justify-content: center;
 | 
				
			||||||
    align-items: center;
 | 
					    align-items: center;
 | 
				
			||||||
    width:25%;
 | 
					    width:400px;
 | 
				
			||||||
    margin-left:auto;
 | 
					    margin-left:auto;
 | 
				
			||||||
    margin-right:auto;
 | 
					    margin-right:auto;
 | 
				
			||||||
    border:2px solid black;
 | 
					    border:2px solid black;
 | 
				
			||||||
@ -266,8 +266,7 @@
 | 
				
			|||||||
    color:white;
 | 
					    color:white;
 | 
				
			||||||
    padding:20px;
 | 
					    padding:20px;
 | 
				
			||||||
    background-color:rgb(50,50,50);
 | 
					    background-color:rgb(50,50,50);
 | 
				
			||||||
    border-radius:20px;
 | 
					    border-radius:20px;margin-bottom:10px;
 | 
				
			||||||
    margin-bottom:10px;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    button:hover{
 | 
					    button:hover{
 | 
				
			||||||
      opacity:0.8;
 | 
					      opacity:0.8;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,272 +0,0 @@
 | 
				
			|||||||
<script setup>
 | 
					 | 
				
			||||||
import { ref } from 'vue'
 | 
					 | 
				
			||||||
import i18n from '@/i18n.js'
 | 
					 | 
				
			||||||
import {formatDate,getHoursMinutes} 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());
 | 
					 | 
				
			||||||
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();
 | 
					 | 
				
			||||||
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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
function invertedFormatDate(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 [year, month, day].join('-');
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
function createLessonEvent(date,hour){
 | 
					 | 
				
			||||||
  const str = date.concat(' ',hour);
 | 
					 | 
				
			||||||
  return new Date(str);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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 = {
 | 
					 | 
				
			||||||
  "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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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 = '';
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
async function askChanges(i){
 | 
					 | 
				
			||||||
  requestType.value= i;
 | 
					 | 
				
			||||||
  await createLessonRequest()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<template>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  <div class="body">
 | 
					 | 
				
			||||||
    <button @click="createMod = !createMod">Ask Create Request</button>
 | 
					 | 
				
			||||||
    <div v-if="createMod">
 | 
					 | 
				
			||||||
    <form class="listElement" style="width:40%; margin:0 auto 0 auto;">
 | 
					 | 
				
			||||||
      <div style="margin-bottom:20px;">
 | 
					 | 
				
			||||||
        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;">
 | 
					 | 
				
			||||||
        Lesson :
 | 
					 | 
				
			||||||
        <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;">
 | 
					 | 
				
			||||||
        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="08:00" max="18:00" required />
 | 
					 | 
				
			||||||
      </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>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      <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>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <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);">
 | 
					 | 
				
			||||||
          Ask Changes
 | 
					 | 
				
			||||||
        </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>{{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:
 | 
					 | 
				
			||||||
            {{element.local}}
 | 
					 | 
				
			||||||
            <div  style="float:right;">
 | 
					 | 
				
			||||||
              <button @click="askChanges(2)" class="delete"> ask Deletion </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;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
.delete{
 | 
					 | 
				
			||||||
  grid-area:delete;
 | 
					 | 
				
			||||||
  background-color:rgb(200,0,0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
  button:hover{
 | 
					 | 
				
			||||||
    opacity:0.8;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</style>
 | 
					 | 
				
			||||||
@ -1,465 +0,0 @@
 | 
				
			|||||||
<script setup>
 | 
					 | 
				
			||||||
import { ref } from 'vue'
 | 
					 | 
				
			||||||
import i18n from '@/i18n.js'
 | 
					 | 
				
			||||||
  import {formatDate,getHoursMinutes} from '../scheduleFunctions.js'
 | 
					 | 
				
			||||||
  import {getAllSchedule, deleteLessonFromSchedule ,getSchedule, getCurriculumSchedule,addLessonToSchedule} from "@/rest/scheduleRest.js";
 | 
					 | 
				
			||||||
  import {getLessons , createLesson, alterLesson , deleteLesson} from "@/rest/lessonSchedule.js"
 | 
					 | 
				
			||||||
  import {getTeachers} from "@/rest/Users.js"
 | 
					 | 
				
			||||||
  import { getcurriculum} 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 courses = ref();
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  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()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function invertedFormatDate(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 [year, month, day].join('-');
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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)))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function createLessonEvent(date,hour){
 | 
					 | 
				
			||||||
    const str = date.concat(' ',hour);
 | 
					 | 
				
			||||||
    return new Date(str);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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,
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
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
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  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;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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= '';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</script>
 | 
					 | 
				
			||||||
<template>
 | 
					 | 
				
			||||||
  <div class="body">
 | 
					 | 
				
			||||||
    <div class="listTitle buttonGrid"v-if="!createMod" >
 | 
					 | 
				
			||||||
      <button class="create" @click="createMod = true;">Create</button>
 | 
					 | 
				
			||||||
      <button class="delete" @click="deleteMod = !deleteMod;">{{!deleteMod ? "Delete" : "Remove Delete"}}</button>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div v-if="createMod">
 | 
					 | 
				
			||||||
      <form class="listElement" style="width:40%; margin:0 auto 0 auto;">
 | 
					 | 
				
			||||||
        <div style="margin-bottom:20px;">
 | 
					 | 
				
			||||||
         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;">
 | 
					 | 
				
			||||||
          Lesson : 
 | 
					 | 
				
			||||||
         <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;">
 | 
					 | 
				
			||||||
          Day:
 | 
					 | 
				
			||||||
          <input type="date" :min="minDate" :max="maxDate" v-model="lessonBuffer.day">
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <div style="margin-bottom:20px;">
 | 
					 | 
				
			||||||
          Start: 
 | 
					 | 
				
			||||||
          <input v-model="lessonBuffer.lessonStart" type="time" min="08:00" max="18:00" required />
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <div style="margin-bottom:20px;">
 | 
					 | 
				
			||||||
          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>
 | 
					 | 
				
			||||||
        <div></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="!createMod">
 | 
					 | 
				
			||||||
      <select @change="changeSchedule()" v-model="trueSchedule">
 | 
					 | 
				
			||||||
        <option v-for="item in allSchedules" :value='item'>{{item.curriculum.option}}</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">{{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'>{{item}}</option>
 | 
					 | 
				
			||||||
      </select>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
    <div v-if="!createMod " :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>
 | 
					 | 
				
			||||||
@ -210,11 +210,11 @@
 | 
				
			|||||||
<style scoped>
 | 
					<style scoped>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.container{
 | 
					.container{
 | 
				
			||||||
  min-width:675px;
 | 
					  
 | 
				
			||||||
  display:grid;
 | 
					  display:grid;
 | 
				
			||||||
  grid-template-columns:10vw 50vw;
 | 
					  grid-template-columns:200px 900px;
 | 
				
			||||||
  grid-template-rows:200px auto;
 | 
					  grid-template-rows:200px auto;
 | 
				
			||||||
  column-gap:2.7%;
 | 
					  column-gap:30px;
 | 
				
			||||||
  row-gap:45px;
 | 
					  row-gap:45px;
 | 
				
			||||||
  grid-template-areas:
 | 
					  grid-template-areas:
 | 
				
			||||||
  "profilPic globalInfos"
 | 
					  "profilPic globalInfos"
 | 
				
			||||||
@ -222,7 +222,6 @@
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.profilPic{
 | 
					.profilPic{
 | 
				
			||||||
  width:100%;
 | 
					 | 
				
			||||||
  grid-area:profilPic;
 | 
					  grid-area:profilPic;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -243,17 +242,13 @@
 | 
				
			|||||||
  grid-area:minfos;
 | 
					  grid-area:minfos;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
.body {
 | 
					.body {
 | 
				
			||||||
    min-width:960px;
 | 
					 | 
				
			||||||
    width:100%;
 | 
					    width:100%;
 | 
				
			||||||
    display:flex;
 | 
					    margin-bottom:10px;
 | 
				
			||||||
    align-items:center;
 | 
					 | 
				
			||||||
    justify-content:center;
 | 
					 | 
				
			||||||
    margin-top:5%;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 .containerElement{ 
 | 
					 .containerElement{ 
 | 
				
			||||||
   justify-content:center;
 | 
					   justify-content:center;
 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:38.8% 38.8% 22.4%;
 | 
					    grid-template-columns:350px 350px 200px;
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
    "name teacher credits"; 
 | 
					    "name teacher credits"; 
 | 
				
			||||||
    column-gap:10px;
 | 
					    column-gap:10px;
 | 
				
			||||||
@ -276,11 +271,10 @@
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.listTitle{
 | 
					.listTitle{
 | 
				
			||||||
    min-width:197px;
 | 
					 | 
				
			||||||
    display: flex;
 | 
					    display: flex;
 | 
				
			||||||
    justify-content: center;
 | 
					    justify-content: center;
 | 
				
			||||||
    align-items: center;
 | 
					    align-items: center;
 | 
				
			||||||
    width:8vw;
 | 
					    width:200px;
 | 
				
			||||||
    margin-left:auto;
 | 
					    margin-left:auto;
 | 
				
			||||||
    margin-right:auto;
 | 
					    margin-right:auto;
 | 
				
			||||||
    border:2px solid black;
 | 
					    border:2px solid black;
 | 
				
			||||||
@ -292,7 +286,6 @@
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.listElement{
 | 
					.listElement{
 | 
				
			||||||
  min-width:625px;
 | 
					 | 
				
			||||||
  border:2px solid black;
 | 
					  border:2px solid black;
 | 
				
			||||||
  font-size:25px;
 | 
					  font-size:25px;
 | 
				
			||||||
  color:white;
 | 
					  color:white;
 | 
				
			||||||
@ -303,7 +296,6 @@
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.infosContainer {
 | 
					.infosContainer {
 | 
				
			||||||
min-width:350px;
 | 
					 | 
				
			||||||
padding-bottom:50px;
 | 
					padding-bottom:50px;
 | 
				
			||||||
border:2px solid black;
 | 
					border:2px solid black;
 | 
				
			||||||
font-size:25px;
 | 
					font-size:25px;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,676 +0,0 @@
 | 
				
			|||||||
<script setup>
 | 
					 | 
				
			||||||
  import { ref } from 'vue'
 | 
					 | 
				
			||||||
  import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../scheduleFunctions.js'
 | 
					 | 
				
			||||||
  import {getAllSchedule, getOwnSchedule, getCurriculumSchedule} from "@/rest/scheduleRest.js";
 | 
					 | 
				
			||||||
  import {getLessons, getOwnedLessons } from "@/rest/lessonSchedule.js"
 | 
					 | 
				
			||||||
  import {isLogged, getSelf,getTeachers} from "@/rest/Users.js"
 | 
					 | 
				
			||||||
  import {getAllCurriculums, getcurriculum} from "@/rest/curriculum.js"
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
  const trueSchedule = ref()
 | 
					 | 
				
			||||||
  const log = await isLogged();
 | 
					 | 
				
			||||||
  const schedule = ref();
 | 
					 | 
				
			||||||
  const curriculum = ref();
 | 
					 | 
				
			||||||
  const shift = ref(getFirstDay(new Date()).getDay());
 | 
					 | 
				
			||||||
  let value = 1;
 | 
					 | 
				
			||||||
  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 == "Admin" || user.role == "Secretary" || user.role == "InscriptionService"){
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    else{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if(user.role == "Teacher"){
 | 
					 | 
				
			||||||
         ownSchedule.value  = await getOwnedLessons(); 
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if(user.role == "Student"){
 | 
					 | 
				
			||||||
        trueSchedule.value = await getOwnSchedule();
 | 
					 | 
				
			||||||
        ownSchedule.value = trueSchedule.value.lessons;
 | 
					 | 
				
			||||||
        curriculum.value = trueSchedule.value.curriculum;}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      schedule.value = ownSchedule.value;
 | 
					 | 
				
			||||||
      scheduleByWeek.value = sundayToTheEnd(matrixFromList(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 = ["Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"];
 | 
					 | 
				
			||||||
  const months = ["Janvier","Fevrier","Mars","Avril",'Mai',"Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"]
 | 
					 | 
				
			||||||
  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 isNotCourse(element){
 | 
					 | 
				
			||||||
    return element==null;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  function durationCourse(element){
 | 
					 | 
				
			||||||
    const hour = element.lessonEnd.substring(3,5) -element.lessonStart.substring(3,5);
 | 
					 | 
				
			||||||
    return (element.lessonEnd - element.lessonStart)%2;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  function displayOwnSchedule(){
 | 
					 | 
				
			||||||
    schedule.value = ownSchedule.value;
 | 
					 | 
				
			||||||
    scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
 | 
					 | 
				
			||||||
      month.value = monthFromList(schedule.value,currentDate.value.getMonth());
 | 
					 | 
				
			||||||
      value = 1;
 | 
					 | 
				
			||||||
      counter=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  function lessonFocus(element){
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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(matrixFromList(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(matrixFromList(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(matrixFromList(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){
 | 
					 | 
				
			||||||
      console.log(lessons[element].lessonType)
 | 
					 | 
				
			||||||
      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
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
  async function changeSchedule(){
 | 
					 | 
				
			||||||
      schedule.value =trueSchedule.value.lessons;
 | 
					 | 
				
			||||||
      curriculum.value = trueSchedule.value.curriculum;
 | 
					 | 
				
			||||||
          
 | 
					 | 
				
			||||||
      scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value));
 | 
					 | 
				
			||||||
      month.value = monthFromList(schedule.value,currentDate.value.getMonth());
 | 
					 | 
				
			||||||
      value = 1;
 | 
					 | 
				
			||||||
      counter=0;
 | 
					 | 
				
			||||||
      courses.value = (await getcurriculum(curriculum.value.curriculumId)).courses;
 | 
					 | 
				
			||||||
      filter.value = "null";
 | 
					 | 
				
			||||||
      subFilter.value = "null"
 | 
					 | 
				
			||||||
      focus.value = null;
 | 
					 | 
				
			||||||
      focusLessons.value = null;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  function changeWeek(i){
 | 
					 | 
				
			||||||
    const temp = getAnyDays(i);
 | 
					 | 
				
			||||||
    mondayOfWeek.value = temp;
 | 
					 | 
				
			||||||
    if(scheduleByWeek.value != null)
 | 
					 | 
				
			||||||
      scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek.value))
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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;
 | 
					 | 
				
			||||||
    if(month.value != null){
 | 
					 | 
				
			||||||
      month.value = monthFromList(schedule.value,currentDate.value.getMonth())}
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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){
 | 
					 | 
				
			||||||
      counter++;
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
      if(counter> 35){
 | 
					 | 
				
			||||||
        counter=1;
 | 
					 | 
				
			||||||
        value = 2;
 | 
					 | 
				
			||||||
        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)">Previous</button>
 | 
					 | 
				
			||||||
            <button @click="changeWeek(7)">Next</button>
 | 
					 | 
				
			||||||
            <button @click="mondayOfWeek = getMonday(new Date()); 
 | 
					 | 
				
			||||||
                scheduleByWeek != null ? scheduleByWeek = sundayToTheEnd(matrixFromList(schedule.value, mondayOfWeek)) : null;">Current</button>
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
          </th>
 | 
					 | 
				
			||||||
          <th class="header" v-for='d,index in 7' >
 | 
					 | 
				
			||||||
            <p class="childHeader">
 | 
					 | 
				
			||||||
            {{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">{{element[index].course.title}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{element[index].local}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{element[index].lessonType}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{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>{{months[currentDate.getMonth()]}} {{currentDate.getFullYear()}}</div>            
 | 
					 | 
				
			||||||
            <button style="position:absolute; top:0; left:0;" @click="changeMonth(-1)">previous</button>
 | 
					 | 
				
			||||||
            <button  style="position:absolute; bottom:0; left:0;"@click="changeMonth(1)">next</button>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            </th>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
          </tr>
 | 
					 | 
				
			||||||
          <tr style="background-color:rgb(24,24,24); height:8.33%;" >
 | 
					 | 
				
			||||||
          <th class="header"  v-for='d,index in 7' >
 | 
					 | 
				
			||||||
            {{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 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">{{element.course.title}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{element.local}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{element.lessonType}}</p>
 | 
					 | 
				
			||||||
                <p class="childInfos">{{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(matrixFromList(schedule.value, mondayOfWeek)) : null;">Current</button>
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        <template  v-for="i,index in 7">
 | 
					 | 
				
			||||||
          <div class="body" style="background-color:#181818;">{{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" >{{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 ? days[6] : 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;">Settings</div>
 | 
					 | 
				
			||||||
      <select @change="changeSchedule()" v-model="trueSchedule">
 | 
					 | 
				
			||||||
        <option v-for="item in allSchedules" :value='item'>{{item.curriculum.option}}</option>
 | 
					 | 
				
			||||||
      </select>
 | 
					 | 
				
			||||||
      <button v-if="display=='Week'" @click="display='Month'">Week</button>
 | 
					 | 
				
			||||||
      <button v-if="display=='Month'" @click="display='Week'; value=1;">Month</button>
 | 
					 | 
				
			||||||
      <button v-if="format == 'Grid'" @click="format ='List'">Grid</button>
 | 
					 | 
				
			||||||
      <button v-if="format == 'List'" @click ="format = 'Grid'">List</button>
 | 
					 | 
				
			||||||
      <button v-if="verifUser()" @click="displayOwnSchedule()">OwnSchedule</button>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      <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">{{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'>{{item}}</option>
 | 
					 | 
				
			||||||
      </select>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
      <div v-if="focus != null" class="moreInfos">
 | 
					 | 
				
			||||||
        <div class="body" style="background-color:rgb(50,50,50); height:10%; font-size:2em;" >More infos</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);">Teacher(s)</div>
 | 
					 | 
				
			||||||
        <div class="body" style="background-color:#484848;">
 | 
					 | 
				
			||||||
          <div>{{focus.course.owner.lastName}}</div>
 | 
					 | 
				
			||||||
          <div v-for="element in focus.course.owner.assistants">
 | 
					 | 
				
			||||||
            {{element.lastName}}
 | 
					 | 
				
			||||||
          </div>
 | 
					 | 
				
			||||||
        </div>
 | 
					 | 
				
			||||||
        <div class="body"  style="background-color:rgb(50,50,50);">Lessons</div>
 | 
					 | 
				
			||||||
       <div class="body" style="background-color:#484848;"v-for="lesson in focusLessons">
 | 
					 | 
				
			||||||
          {{ getHoursMinutes(lesson.lessonStart)}}-{{getHoursMinutes(lesson.lessonEnd)}}
 | 
					 | 
				
			||||||
          {{ lesson.local}}
 | 
					 | 
				
			||||||
          {{lesson.lessonType}}
 | 
					 | 
				
			||||||
        </div>  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
  </div>
 | 
					 | 
				
			||||||
</template>
 | 
					 | 
				
			||||||
<style scoped>
 | 
					 | 
				
			||||||
  .grid{
 | 
					 | 
				
			||||||
    display:grid;
 | 
					 | 
				
			||||||
    margin-top:2%;
 | 
					 | 
				
			||||||
    align-items:center;
 | 
					 | 
				
			||||||
    justify-content:center;
 | 
					 | 
				
			||||||
    grid-template-columns:72vw 14.5vw;
 | 
					 | 
				
			||||||
    column-gap:2vw;
 | 
					 | 
				
			||||||
    overflow:hidden;
 | 
					 | 
				
			||||||
    grid-template-areas:"schedule options";
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  .schedule{
 | 
					 | 
				
			||||||
    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;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    grid-template-rows:30% 70%;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  .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>
 | 
					 | 
				
			||||||
@ -5,8 +5,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const users = await getStudents();
 | 
					  const users = await getStudents();
 | 
				
			||||||
</script> 
 | 
					</script> 
 | 
				
			||||||
<template style="margin-top:5%;">
 | 
					<template>
 | 
				
			||||||
  <div style="display:flex; justify-content:center; " v-for="item in users">
 | 
					  <div v-for="item in users">
 | 
				
			||||||
    <div class="bodu">
 | 
					    <div class="bodu">
 | 
				
			||||||
      <div class="container">
 | 
					      <div class="container">
 | 
				
			||||||
        <div class="status"><a style="margin-left:30px">{{item.status}}</a></div>
 | 
					        <div class="status"><a style="margin-left:30px">{{item.status}}</a></div>
 | 
				
			||||||
@ -25,9 +25,10 @@
 | 
				
			|||||||
    height:100px;
 | 
					    height:100px;
 | 
				
			||||||
    font-size:30px;
 | 
					    font-size:30px;
 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:21.7% 21.7% 21.7% 21.7% 13.1%;
 | 
					    grid-template-columns:250px 250px 250px 250px 150px;
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
    "status option surname firstname infos"; 
 | 
					    "status option surname firstname infos"; 
 | 
				
			||||||
 | 
					    column-gap:10px;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@ -41,6 +42,21 @@
 | 
				
			|||||||
    align-self:center;
 | 
					    align-self:center;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .refuse{
 | 
				
			||||||
 | 
					    grid-area:refuse;
 | 
				
			||||||
 | 
					    align-self:center;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .titles {
 | 
				
			||||||
 | 
					    grid-area:titles;
 | 
				
			||||||
 | 
					    background-color:rgb(215,215,215);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  .id{
 | 
				
			||||||
 | 
					    grid-area:id;
 | 
				
			||||||
 | 
					    margin-left:40px;
 | 
				
			||||||
 | 
					    align-self:center;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .status{
 | 
					  .status{
 | 
				
			||||||
    grid-area:status;
 | 
					    grid-area:status;
 | 
				
			||||||
    align-self:center;
 | 
					    align-self:center;
 | 
				
			||||||
@ -65,15 +81,15 @@
 | 
				
			|||||||
  button{
 | 
					  button{
 | 
				
			||||||
    font-size:15px;
 | 
					    font-size:15px;
 | 
				
			||||||
     height:50px;
 | 
					     height:50px;
 | 
				
			||||||
     width:75%;
 | 
					     width:100px;
 | 
				
			||||||
    border:none;
 | 
					    border:none;
 | 
				
			||||||
    border-radius:20px;
 | 
					    border-radius:20px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .bodu {
 | 
					  .bodu {
 | 
				
			||||||
    margin-top:2%;
 | 
					    width:100%;
 | 
				
			||||||
    width:66%;
 | 
					    margin-bottom:10px;
 | 
				
			||||||
    border:2px solid black;
 | 
					    border:2px solid black;
 | 
				
			||||||
    border-radius:9px;
 | 
					    border-radius:9px;
 | 
				
			||||||
    background-color:rgb(50,50,50);
 | 
					    background-color:rgb(50,50,50);
 | 
				
			||||||
 | 
				
			|||||||
@ -7,8 +7,8 @@
 | 
				
			|||||||
  const users = await getAllUsers();
 | 
					  const users = await getAllUsers();
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
</script> 
 | 
					</script> 
 | 
				
			||||||
<template style="margin-top:5%;">
 | 
					<template>
 | 
				
			||||||
  <div style="display:flex; justify-content:center; min-width:1140px;" v-for="item in users">
 | 
					  <div v-for="item in users">
 | 
				
			||||||
    <div class="bodu">
 | 
					    <div class="bodu">
 | 
				
			||||||
      <div class="container">
 | 
					      <div class="container">
 | 
				
			||||||
        <div class="role"><a style="margin-left:30px">{{i18n(item.role)}}</a></div>
 | 
					        <div class="role"><a style="margin-left:30px">{{i18n(item.role)}}</a></div>
 | 
				
			||||||
@ -22,20 +22,23 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<style scoped>
 | 
					<style scoped>
 | 
				
			||||||
  .container{
 | 
					  .container{
 | 
				
			||||||
 | 
					    justify-content:center;
 | 
				
			||||||
 | 
					    align-items:center;
 | 
				
			||||||
    color:white;
 | 
					    color:white;
 | 
				
			||||||
    height:100px;
 | 
					    height:100px;
 | 
				
			||||||
    font-size:30px;
 | 
					    font-size:30px;
 | 
				
			||||||
    display:grid;
 | 
					    display:grid;
 | 
				
			||||||
    grid-template-columns:27.7% 27.7% 27.7% 16.9%;
 | 
					    grid-template-columns:250px 250px 250px 150px;
 | 
				
			||||||
    grid-template-areas:
 | 
					    grid-template-areas:
 | 
				
			||||||
    "role surname firstname infos"; 
 | 
					    "role surname firstname infos"; 
 | 
				
			||||||
 | 
					    column-gap:10px;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  .infos {
 | 
					  .infos {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    grid-area:infos;
 | 
					    grid-area:infos;
 | 
				
			||||||
    align-self:center;
 | 
					    align-items:center;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .role {
 | 
					  .role {
 | 
				
			||||||
@ -64,18 +67,20 @@
 | 
				
			|||||||
  button{
 | 
					  button{
 | 
				
			||||||
    font-size:15px;
 | 
					    font-size:15px;
 | 
				
			||||||
     height:50px;
 | 
					     height:50px;
 | 
				
			||||||
     width:75%;
 | 
					     width:100px;
 | 
				
			||||||
    border:none;
 | 
					    border:none;
 | 
				
			||||||
    border-radius:20px;
 | 
					    border-radius:20px;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  .bodu {
 | 
					  .bodu {
 | 
				
			||||||
    margin-top:2%;
 | 
					    width:100%;
 | 
				
			||||||
    width:66%;
 | 
					    margin-bottom:10px;
 | 
				
			||||||
    border:2px solid black;
 | 
					    border:2px solid black;
 | 
				
			||||||
    border-radius:9px;
 | 
					    border-radius:9px;
 | 
				
			||||||
    background-color:rgb(50,50,50);
 | 
					    background-color:rgb(50,50,50);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</style>
 | 
					</style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,11 +1,4 @@
 | 
				
			|||||||
body {
 | 
					body {
 | 
				
			||||||
   background-color: rgb(53, 25, 60);
 | 
					   background-color: rgb(53, 25, 60);
 | 
				
			||||||
   margin:0;
 | 
					   margin:0;
 | 
				
			||||||
   width: 100vw;
 | 
					 | 
				
			||||||
   height: 100vh;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#app {
 | 
					 | 
				
			||||||
   width: 100%;
 | 
					 | 
				
			||||||
   height: 100%;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,25 +0,0 @@
 | 
				
			|||||||
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){
 | 
					 | 
				
			||||||
    console.log(infos)
 | 
					 | 
				
			||||||
    console.log(await getLessonRequest(id))
 | 
					 | 
				
			||||||
    return restPatch("/requests/lessonRequest/" + id, infos);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export async function deleteRequest(id){
 | 
					 | 
				
			||||||
    return restDelete("/requests/lessonRequest/"+id);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -9,22 +9,16 @@ 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 AboutStudent from "@/Apps/AboutStudent.vue";
 | 
				
			||||||
import ManageSchedule from "@/Apps/ManageSchedule.vue"
 | 
					 | 
				
			||||||
import ManageOwnedLessons from "@/Apps/ManageOwnLessons.vue";
 | 
					 | 
				
			||||||
import LessonRequests from "@/Apps/LessonRequests.vue";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const apps = {
 | 
					const apps = {
 | 
				
			||||||
		'/schedule': Schedule,
 | 
					 | 
				
			||||||
		'/manage-schedule': ManageSchedule,
 | 
					 | 
				
			||||||
		'/login': LoginPage,
 | 
							'/login': LoginPage,
 | 
				
			||||||
		'/inscription': Inscription,
 | 
							'/inscription': Inscription,
 | 
				
			||||||
		'/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,
 | 
							'/about-students': AboutStudent
 | 
				
			||||||
		'/manage-schedule-requests' : LessonRequests,
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const appsList = {
 | 
					const appsList = {
 | 
				
			||||||
@ -32,14 +26,11 @@ const appsList = {
 | 
				
			|||||||
		'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") },
 | 
							'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") },
 | 
				
			||||||
		'Forum': { path: '#/forum', icon: 'fa-envelope', text: i18n("app.forum") },
 | 
							'Forum': { path: '#/forum', 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") },
 | 
				
			||||||
		'ManageSchedules': { path: '#/manage-schedule', icon: 'fa-calendar-days', text: i18n("app.manageSchedules")},
 | 
					 | 
				
			||||||
		'Inscription': { path: '#/inscription', icon: 'fa-users', text: i18n("app.inscription.requests") },
 | 
							'Inscription': { path: '#/inscription', icon: 'fa-users', text: i18n("app.inscription.requests") },
 | 
				
			||||||
		'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")},
 | 
							'AboutStudent':{ path: '#/about-users', icon: 'fa-users', text:i18n("app.aboutStudent")}
 | 
				
			||||||
		'LessonRequests':{path: '#/manage-schedule-requests', icon:'fa-book', text: i18n("app.lessonRequests")},
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const currentPath = ref(window.location.hash)
 | 
					const currentPath = ref(window.location.hash)
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,8 @@ import { restGet, restPost, restDelete, restPatch } from './restConsumer.js'
 | 
				
			|||||||
 * Create a new course
 | 
					 * Create a new course
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export async function createCourse(name, credits, owner){
 | 
					export async function createCourse(name, credits, owner){
 | 
				
			||||||
 | 
					  console.log(owner);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
	return restPost("/course", {title: name, credits: credits, owner} )
 | 
						return restPost("/course", {title: name, credits: credits, owner} )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,66 +0,0 @@
 | 
				
			|||||||
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")
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * 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);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -20,10 +20,6 @@ export async function restDelete(endPoint) {
 | 
				
			|||||||
	return await _rest(endPoint, {method: "DELETE"});
 | 
						return await _rest(endPoint, {method: "DELETE"});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function restDeleteItem(endPoint, data){
 | 
					 | 
				
			||||||
	return await _rest(endPoint, {method: "DELETE", credentials: 'include', body: JSON.stringify(data)});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export async function restPatch(endPoint, data) {
 | 
					export async function restPatch(endPoint, data) {
 | 
				
			||||||
	return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
 | 
						return await _rest(endPoint, {method: "PATCH", credentials: 'include', body: JSON.stringify(data)});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -45,7 +41,6 @@ async function _rest(endPoint, config){
 | 
				
			|||||||
		'Content-Type': 'application/json',
 | 
							'Content-Type': 'application/json',
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	config['headers'] = config['headers'] == null ? headers : config['headers'];
 | 
						config['headers'] = config['headers'] == null ? headers : config['headers'];
 | 
				
			||||||
  console.log(config)
 | 
					 | 
				
			||||||
	return toast.promise(fetch(restURL + endPoint, config),
 | 
						return toast.promise(fetch(restURL + endPoint, config),
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			pending: config['pending'] != null ? config['pending'] : 'pending',
 | 
								pending: config['pending'] != null ? config['pending'] : 'pending',
 | 
				
			||||||
 | 
				
			|||||||
@ -1,30 +0,0 @@
 | 
				
			|||||||
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)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,115 +0,0 @@
 | 
				
			|||||||
  import {ref} from 'vue'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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('-');
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function durationCourse(element){
 | 
					 | 
				
			||||||
    const hour = element.lessonEnd.substring(3,5) -element.lessonStart.substring(3,5);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    return (element.lessonEnd - element.lessonStart)%2;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function sortByDate(a, b) {
 | 
					 | 
				
			||||||
    const nameA = a.lessonStart; // ignore upper and lowercase
 | 
					 | 
				
			||||||
    const nameB = b.lessonStart; // ignore upper and lowercase
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    if (nameA < nameB) {
 | 
					 | 
				
			||||||
      return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (nameA > nameB) {
 | 
					 | 
				
			||||||
      return 1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return 0; 
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function getFirstDay(d){
 | 
					 | 
				
			||||||
    var date = new Date(d);
 | 
					 | 
				
			||||||
    return new Date(date.getFullYear(), date.getMonth(), 1);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function matrixFromList(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;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function lastDateOfMonth(d){
 | 
					 | 
				
			||||||
    const date = new Date(d);
 | 
					 | 
				
			||||||
    const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
 | 
					 | 
				
			||||||
    return temp.getDate();
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  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;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function sundayToTheEnd(list){
 | 
					 | 
				
			||||||
    const newlist = list;
 | 
					 | 
				
			||||||
    const sunday = newlist.shift();
 | 
					 | 
				
			||||||
    newlist.push(sunday);
 | 
					 | 
				
			||||||
    return newlist;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  export function getDifferenceTime(date1,date2){
 | 
					 | 
				
			||||||
    return Math.abs((new Date(date2).getTime() - new Date(date1).getTime())/60000);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  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);
 | 
					 | 
				
			||||||
    }   
 | 
					 | 
				
			||||||
    return Math.abs((new Date(list[index1].lessonStart).getTime()- new Date(list[index2].lessonEnd).getTime())/60000)+getMarginTop(list,index2,index2-1);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  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();  
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user