diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java index 1f25dfe..aca1f0a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java @@ -81,6 +81,7 @@ public class ProtectionService { toReturn.put("lessonEnd", lesson.getLessonEnd()); toReturn.put("course",courseWithoutPassword(lesson.getCourse())); toReturn.put("local",lesson.getLocal()); + toReturn.put("color", lesson.getColor()); return toReturn; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java index 53e15ba..328dcb6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java @@ -44,6 +44,7 @@ public class ScheduleLessonService { } toReturn.put("lessons",lessons); toReturn.put("scheduleId" , scheduleLessonRepo.findScheduleByCurriculum(curriculum).getScheduleID()); + toReturn.put("curriculum", curriculum); return toReturn; } @@ -60,6 +61,7 @@ public class ScheduleLessonService { } toReturn.put("lessons",lessons); toReturn.put("scheduleId" , schedule.getScheduleID()); + toReturn.put("curriculum", schedule.getCurriculum()); return toReturn; } diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue index 0722d91..8168320 100644 --- a/frontend/src/Apps/Schedule.vue +++ b/frontend/src/Apps/Schedule.vue @@ -3,69 +3,17 @@ import {getDifferenceTime,lastDateOfMonth,formatDate,getFirstDay,sortByDate,matrixFromList,sundayToTheEnd,getMarginTop,getHoursMinutes, monthFromList} from '../scheduleFunctions.js' import {getAllSchedule} from "@/rest/scheduleRest.js"; - const test = await getAllSchedule(); + const allSchedule = await getAllSchedule(); - console.log(test); + + const schedule = ref(allSchedule[0].lessons) - const schedule = [ - { - course:{ - id:14, - name:"Math Pour L'info", - faculty:"Science", - teacher:"Doofenschmirtz", - assistants:[14,25,13],}, - - start:"Mon Apr 01 2024 08:15", - - end:"Mon Apr 01 2024 10:15", - color:"rgb(0,50,100)", - local:"A0B2" - }, - {course:{ - id:12, - name:"Calculus", - faculty:"Science", - teacher:"Doofenschmirtz", - assistants:[], - - }, - start:"Wed Mar 27 2024 08:15", - end:"Wed Mar 27 2024 09:15", - color:"rgb(100,50,0)", - local:"A0B2" - }, - {course:{ - id:2, - name:"Physique II", - faculty:"Science", - teacher:3, - assistants:[], - - }, - start:"Sun Mar 24 2024 10:30 ", - end:"Sun Mar 24 2024 12:30 ", - color:"rgb(100,50,100)", - local:"A0B2" - }, - {course:{ - id:14, - name:"Math Pour L'info", - faculty:"Science", - teacher:14, - assistants:[14,25,13], - }, - start:"Sun Mar 24 2024 13:30", - end:"Sun Mar 24 2024 15:30", - color:"rgb(100,0,50)", - local:"A0B2" - }] const display =ref("Month") 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(schedule[1].start))) + const firstDayOfMonth = ref(getFirstDay(new Date())) function getMonday(d) { d = new Date(d); @@ -90,11 +38,11 @@ function durationCourse(element){ - const hour = element.end.substring(3,5) -element.start.substring(3,5); - return (element.end - element.start)%2; + const hour = element.lessonEnd.substring(3,5) -element.lessonStart.substring(3,5); + return (element.lessonEnd - element.lessonStart)%2; } - const scheduleByWeek = ref(sundayToTheEnd(matrixFromList(schedule,mondayOfWeek.value))); - const month = ref(monthFromList(schedule,new Date().getMonth())); + const scheduleByWeek = ref(sundayToTheEnd(matrixFromList(schedule.value,mondayOfWeek.value))); + const month = ref(monthFromList(schedule.value,new Date().getMonth())); const shift = ref(getFirstDay(new Date()).getDay()); let value = 1; const len = ref(lastDateOfMonth(new Date())); @@ -102,13 +50,13 @@ function changeWeek(i){ const temp = getAnyDays(i); mondayOfWeek.value = temp; - scheduleByWeek.value = sundayToTheEnd(matrixFromList(schedule, mondayOfWeek.value)) + 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); - month.value = monthFromList(schedule,currentDate.value.getMonth()) + month.value = monthFromList(schedule.value,currentDate.value.getMonth()) shift.value= getFirstDay(currentDate.value).getDay(); len.value= lastDateOfMonth(currentDate.value); value = 1; @@ -139,7 +87,7 @@ - + @@ -162,18 +110,18 @@
@@ -211,15 +159,15 @@
- {{getHoursMinutes(element.start)}} + {{getHoursMinutes(element.lessonStart)}}
-

{{element.course.name}}

+

{{element.course.title}}

{{element.local}}

-

{{element.course.teacher}}

+

{{element.course.owner.lastName}}

- {{getHoursMinutes(element.end)}} + {{getHoursMinutes(element.lessonEnd)}}
diff --git a/frontend/src/scheduleFunctions.js b/frontend/src/scheduleFunctions.js index 4c80099..02c9539 100644 --- a/frontend/src/scheduleFunctions.js +++ b/frontend/src/scheduleFunctions.js @@ -16,15 +16,15 @@ export function durationCourse(element){ - const hour = element.end.substring(3,5) -element.start.substring(3,5); + const hour = element.lessonEnd.substring(3,5) -element.lessonStart.substring(3,5); - return (element.end - element.start)%2; + return (element.lessonEnd - element.lessonStart)%2; } export function sortByDate(a, b) { - const nameA = a.start; // ignore upper and lowercase - const nameB = b.start; // ignore upper and lowercase + const nameA = a.lessonStart; // ignore upper and lowercase + const nameB = b.lessonStart; // ignore upper and lowercase if (nameA < nameB) { return -1; @@ -51,7 +51,7 @@ } for(let key in list){ const temp = list[key]; - const day = new Date(list[key].start); + 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)); @@ -75,7 +75,7 @@ } for(let key in list){ const temp = list[key]; - const day = new Date(list[key].start); + 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)); @@ -100,11 +100,11 @@ export function getMarginTop(list, index1, index2){ if(index2 < 0){ - const temp = new Date(list[index1].start); + const temp = new Date(list[index1].lessonStart); temp.setHours(8,0,0); - return Math.abs((new Date(list[index1].start).getTime()- temp.getTime())/60000); + return Math.abs((new Date(list[index1].lessonStart).getTime()- temp.getTime())/60000); } - return Math.abs((new Date(list[index1].start).getTime()- new Date(list[index2].end).getTime())/60000)+getMarginTop(list,index2,index2-1); + return Math.abs((new Date(list[index1].lessonStart).getTime()- new Date(list[index2].lessonEnd).getTime())/60000)+getMarginTop(list,index2,index2-1); } export function getHoursMinutes(date){