From 972d08a54d234ce6871a9bc56adc597908e7e769 Mon Sep 17 00:00:00 2001 From: Wawilski Date: Sun, 24 Mar 2024 13:37:27 +0100 Subject: [PATCH 01/68] added temporary fix to docker issue --- backend/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index b7cabcd..e0abc58 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -25,7 +25,7 @@ dependencies { implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0") // implementation("org.springframework.session:spring-session-jdbc") developmentOnly("org.springframework.boot:spring-boot-devtools") - developmentOnly("org.springframework.boot:spring-boot-docker-compose") + // developmentOnly("org.springframework.boot:spring-boot-docker-compose") runtimeOnly("org.postgresql:postgresql") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-testcontainers") From 2b9493422d352f2693711714509c47cba4d158c6 Mon Sep 17 00:00:00 2001 From: Wawilski Date: Mon, 1 Apr 2024 16:51:18 +0200 Subject: [PATCH 02/68] setup grid to display courses --- backend/build.gradle.kts | 1 - .../EndPoints/ApplicationsController.java | 1 + .../herisson/Clyde/Tables/Applications.java | 1 + frontend/src/App.vue | 1 - frontend/src/Apps/Schedule.vue | 211 ++++++++++++++++++ frontend/src/rest/apps.js | 2 + 6 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 frontend/src/Apps/Schedule.vue diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index e0abc58..2551f2a 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -25,7 +25,6 @@ dependencies { implementation("com.kohlschutter.junixsocket:junixsocket-core:2.9.0") // implementation("org.springframework.session:spring-session-jdbc") developmentOnly("org.springframework.boot:spring-boot-devtools") - // developmentOnly("org.springframework.boot:spring-boot-docker-compose") runtimeOnly("org.postgresql:postgresql") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-testcontainers") diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index 8d1f1ca..83c5050 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -47,6 +47,7 @@ public class ApplicationsController { //if unAuthed authorizedApps.add(Applications.Login); + authorizedApps.add(Applications.Schedule); User user = authServ.getUserFromToken(token); if(user == null) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 3dadcec..684441a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -3,6 +3,7 @@ package ovh.herisson.Clyde.Tables; public enum Applications { // without any token Login, + Schedule, // with any token Profile, diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6dcad67..83f753b 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -25,7 +25,6 @@ window.addEventListener('hashchange', () => { const login=ref(i18n("app.login")) const active=ref(false) - const apps = ref([]) appList().then(e => apps.value = e) diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue new file mode 100644 index 0000000..490cf9b --- /dev/null +++ b/frontend/src/Apps/Schedule.vue @@ -0,0 +1,211 @@ + + + diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index 99cbc10..2672686 100644 --- a/frontend/src/rest/apps.js +++ b/frontend/src/rest/apps.js @@ -9,8 +9,10 @@ import Profil from "@/Apps/Profil.vue" import Courses from "@/Apps/ManageCourses.vue" import Users from "@/Apps/UsersList.vue" import Students from "@/Apps/StudentsList.vue" +import Schedule from "@/Apps/Schedule.vue" const apps = { + '/schedule': Schedule, '/login': LoginPage, '/inscription': Inscription, '/profil': Profil, From 443cf557849c8a01faecd6374544b1523b4e20be Mon Sep 17 00:00:00 2001 From: Wawilski Date: Tue, 2 Apr 2024 16:52:40 +0200 Subject: [PATCH 03/68] weekly set up, end --- frontend/src/Apps/ManageCourses.vue | 2 +- frontend/src/Apps/Schedule.vue | 77 +++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/frontend/src/Apps/ManageCourses.vue b/frontend/src/Apps/ManageCourses.vue index 7337633..96bd35b 100644 --- a/frontend/src/Apps/ManageCourses.vue +++ b/frontend/src/Apps/ManageCourses.vue @@ -17,7 +17,7 @@ const editElementID = ref("") function editItem(id){ - editElementID = id; + editElementID.value = id; } //Juste pour montrer le Create Mode diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue index 490cf9b..1fab1bc 100644 --- a/frontend/src/Apps/Schedule.vue +++ b/frontend/src/Apps/Schedule.vue @@ -3,23 +3,26 @@ const schedule = [ {course:"Math Pour L'info", - start:"Wed Mar 27 2024 10:15 GMT+0100", - end:"Wed Mar 27 2024 12:15 GMT+0100"}, + start:"Tue Mar 26 2024 08:15 GMT+0100", + end:"Tue Mar 26 2024 10:15 GMT+0100", + color:"rgb(0,50,100)"}, { course:"Calculus", - start:"Wed Mar 27 2024 08:00 GMT+0100", - end:"Wed Mar 27 2024 10:00 GMT+0100" - + start:"Wed Mar 27 2024 08:15 GMT+0100", + end:"Wed Mar 27 2024 09:15 GMT+0100", + color:"rgb(100,50,0)" }, { course:"Physique II", - start:"Tue Mar 26 2024 10:15 GMT+0100", - end:"Tue Mar 26 2024 12:15 GMT+0100" + start:"Tue Mar 26 2024 10:30 GMT+0100", + end:"Tue Mar 26 2024 12:30 GMT+0100", + color:"rgb(100,50,100)" }, { course:"Math Pour L'info", - start:"Thu Mar 28 2024 10:15 GMT+0100", - end:"Thu Mar 28 2024 12:15 GMT+0100" + start:"Tue Mar 26 2024 13:30 GMT+0100", + end:"Tue Mar 26 2024 15:30 GMT+0100", + color:"rgb(100,0,50)" }] function formatDate(date) { var d = new Date(date), @@ -97,10 +100,28 @@ return matrix; } - - const schedule2 = matrixFromList(schedule); - const scheduleByWeek = transpose(schedule2); - + function sundayToTheEnd(list){ + const newlist = list; + const sunday = newlist.shift(); + newlist.push(sunday); + return newlist; + } + + function getDifferenceTime(date1,date2){ + return Math.abs((new Date(date2).getTime() - new Date(date1).getTime())/60000); + } + + function getMarginTop(list, index1, index2){ + if(index2 < 0){ + const temp = new Date(list[index1].start); + temp.setHours(8,0,0); + return Math.abs((new Date(list[index1].start).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); + } + + + const scheduleByWeek = sundayToTheEnd(matrixFromList(schedule)); console.log(scheduleByWeek) @@ -126,8 +147,15 @@
-
- Test +
+
@@ -201,11 +229,20 @@ } - .course{ - width:100%; - height:100%; - background-color:rgb(100,0,100); - } + .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; + } From cb750b8505f956717eb137a06f161eb89210c446 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 2 Apr 2024 21:40:52 +0200 Subject: [PATCH 04/68] Database creation (Tables) --- backend/build.gradle.kts | 2 ++ .../ovh/herisson/Clyde/Tables/Course.java | 9 ++++++ .../herisson/Clyde/Tables/Msg/Answers.java | 32 +++++++++++++++++++ .../ovh/herisson/Clyde/Tables/Msg/Forum.java | 28 ++++++++++++++++ .../ovh/herisson/Clyde/Tables/Msg/Topic.java | 26 +++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Answers.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Forum.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Topic.java diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index b7cabcd..794631f 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -16,6 +16,8 @@ repositories { } dependencies { + compileOnly("org.projectlombok:lombok") + annotationProcessor("org.projectlombok:lombok") implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-mail") diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java index df0421d..8870618 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -1,6 +1,10 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.Msg.Forum; + +import java.util.List; + import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; @@ -17,6 +21,11 @@ public class Course { @JoinColumn(name = "Users") private User owner; + //// Extension Messagerie ///// + @OneToMany + private List forums; + /////////////////////////////// + public Course(int credits, String title, User owner){ this.credits = credits; this.title = title; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Answers.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Answers.java new file mode 100644 index 0000000..2f4d452 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Answers.java @@ -0,0 +1,32 @@ +package ovh.herisson.Clyde.Tables.Msg; + + +import java.util.Date; + +import org.hibernate.annotations.CreationTimestamp; + +import jakarta.persistence.*; +import lombok.Data; +import ovh.herisson.Clyde.Tables.User; + +@Entity +@Data +public class Answers { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @CreationTimestamp + private Date creation; + + @ManyToOne + private Topic topic; + + private String content; + + @OneToOne + private User author; + + private boolean anonymous; + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Forum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Forum.java new file mode 100644 index 0000000..e021c18 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Forum.java @@ -0,0 +1,28 @@ +package ovh.herisson.Clyde.Tables.Msg; + +import java.util.List; + +import jakarta.persistence.*; +import lombok.Data; +import ovh.herisson.Clyde.Tables.Course; +import ovh.herisson.Clyde.Tables.User; + +@Entity +@Data +public class Forum { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne(cascade = CascadeType.ALL) + private Course course; + + private String name; + + @OneToMany + private List writers; // User who are authorized to create a post + + @OneToMany + private List register; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Topic.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Topic.java new file mode 100644 index 0000000..d63b3e1 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Topic.java @@ -0,0 +1,26 @@ +package ovh.herisson.Clyde.Tables.Msg; + +import java.util.List; + +import jakarta.persistence.*; +import lombok.Data; +import ovh.herisson.Clyde.Tables.User; + +@Entity +@Data +public class Topic { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String subject, content; + + @OneToOne + private User author; + + @OneToMany(mappedBy = "topic", cascade = CascadeType.ALL) + private List answers; + + private boolean locked; // true if new messages can be posted +} From a96609d2efd9d9154bdb06347c0ba3ee8e67d3d2 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 3 Apr 2024 14:58:04 +0200 Subject: [PATCH 05/68] Page to right size --- frontend/src/App.vue | 13 ++++++------- frontend/src/assets/main.css | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6dcad67..40fbbc6 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -99,20 +99,19 @@ window.addEventListener('hashchange', () => { height: 100%; width: 100%; display:grid; - 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-columns:[firstCol-start]70px[firstCol-end secondCol-start] auto [endCol]; + grid-template-rows:[firstRow-start] var(--header-size) [firstRow-end secondRow-start] calc(100% - var(--header-size)) [endRow]; grid-template-areas: "topBar topBar" "leftBar page"; - row-gap:0px; - column-gap:0px; + } .page { grid-area:page; height: 100%; width: 100%; - place-self:center; } .topBar{ @@ -155,7 +154,7 @@ window.addEventListener('hashchange', () => { ul.vertical{ list-style-type: none; - margin-top: 61px; + margin-top: var(--header-size); top:0; left:0; padding: 25px 0 0; @@ -203,7 +202,7 @@ window.addEventListener('hashchange', () => { left:0; position: fixed; - height:61px; + height:var(--header-size); width: 100%; background-color: rgb(24, 24, 24); } diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index 54ce8d8..67f454e 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -1,3 +1,7 @@ +:root { + --header-size: 61px; +} + body { background-color: rgb(53, 25, 60); margin:0; From 9937a7db39ac84de5bce4bdfe2c37555d11ad46d Mon Sep 17 00:00:00 2001 From: Wawilski Date: Thu, 4 Apr 2024 14:44:35 +0200 Subject: [PATCH 06/68] Display Week and Month End --- frontend/src/Apps/Schedule.vue | 350 ++++++++++++++++++++++----------- frontend/src/schedule.js | 114 +++++++++++ 2 files changed, 351 insertions(+), 113 deletions(-) create mode 100644 frontend/src/schedule.js diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue index 1fab1bc..0c3f640 100644 --- a/frontend/src/Apps/Schedule.vue +++ b/frontend/src/Apps/Schedule.vue @@ -1,145 +1,152 @@ @@ -167,13 +242,14 @@ margin-top:2%; align-items:center; justify-content:center; - grid-template-columns:15vw 70vw; - column-gap:2.5vw; - - grid-template-areas:"options schedule"; + grid-template-columns:72vw 14.5vw; + column-gap:2vw; + overflow:hidden; + grid-template-areas:"schedule options"; } .schedule{ - position:relative; + position:relative; + overflow-y:scroll; border-radius:20px; grid-area:schedule; width:100%; @@ -181,6 +257,8 @@ background-color:rgba(255,255,255,0.1); } .options{ + display:flex; + flex-direction:column; border-radius:20px; grid-area:options; background-color:rgba(255,255,255,0.1); @@ -203,9 +281,17 @@ } .header{ - align-items:center; 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) { @@ -228,8 +314,7 @@ grid-template-columns:repeat(7,1fr); } - - + .course{ position:relative; border: 1px solid black; @@ -244,5 +329,44 @@ .dayCourse{ display:block; } + + .infos{ + height:100%; + width:100%; + font-size:0.85em; + 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; + } + + diff --git a/frontend/src/schedule.js b/frontend/src/schedule.js new file mode 100644 index 0000000..4c80099 --- /dev/null +++ b/frontend/src/schedule.js @@ -0,0 +1,114 @@ + 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.end.substring(3,5) -element.start.substring(3,5); + + + return (element.end - element.start)%2; + } + + export function sortByDate(a, b) { + const nameA = a.start; // ignore upper and lowercase + const nameB = b.start; // 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].start); + 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].start); + 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].start); + temp.setHours(8,0,0); + return Math.abs((new Date(list[index1].start).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); + } + + export function getHoursMinutes(date){ + const d = new Date(date); + return d.getHours()+ ":" + d.getMinutes(); + } + From 7bd745fd5e4dd1e976a4c086ef3198de0a90b6fd Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Fri, 5 Apr 2024 08:57:19 +0200 Subject: [PATCH 07/68] Adding frontend visual side --- frontend/src/Apps/Forums.vue | 138 +++++++++++++++++++++++++++++++++++ frontend/src/rest/apps.js | 4 +- frontend/src/rest/forum.js | 71 ++++++++++++++++++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 frontend/src/Apps/Forums.vue create mode 100644 frontend/src/rest/forum.js diff --git a/frontend/src/Apps/Forums.vue b/frontend/src/Apps/Forums.vue new file mode 100644 index 0000000..3e777e2 --- /dev/null +++ b/frontend/src/Apps/Forums.vue @@ -0,0 +1,138 @@ + + + + + + + + diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index 99cbc10..344e22a 100644 --- a/frontend/src/rest/apps.js +++ b/frontend/src/rest/apps.js @@ -9,6 +9,7 @@ import Profil from "@/Apps/Profil.vue" import Courses from "@/Apps/ManageCourses.vue" import Users from "@/Apps/UsersList.vue" import Students from "@/Apps/StudentsList.vue" +import Forums from '@/Apps/Forums.vue' const apps = { '/login': LoginPage, @@ -17,12 +18,13 @@ const apps = { '/manage-courses' : Courses, '/users-list' : Users, '/students-list' : Students, + '/forums': Forums, } const appsList = { 'Msg': { path: '#/msg', icon: 'fa-comment', text: i18n("app.messages") }, 'Notification': { path: '#/notifs', icon: 'fa-bell', text: i18n("app.notifications") }, - 'Forum': { path: '#/forum', icon: 'fa-envelope', text: i18n("app.forum") }, + 'Forum': { path: '#/forums', icon: 'fa-envelope', text: i18n("app.forum") }, 'Schedule': { path: '#/schedule', icon: 'fa-calendar-days', text: i18n("app.schedules") }, 'Inscription': { path: '#/inscription', icon: 'fa-users', text: i18n("app.inscription.requests") }, 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, diff --git a/frontend/src/rest/forum.js b/frontend/src/rest/forum.js new file mode 100644 index 0000000..7920a33 --- /dev/null +++ b/frontend/src/rest/forum.js @@ -0,0 +1,71 @@ +import { ref } from 'vue' +import { restGet, restPost, restDelete, restPatch } from './restConsumer.js' + +/** + * List forums of a course + */ +export async function getForumsOfCourse(id){ + ForumsOfCurrentCourse.value = [ + { + id: 1, + name: "forum~1" + }, + { + id: 2, + name: "forum~2" + }, + ] + // ForumsOfCurrentCourse = await restGet("/forums/" + id) +} + +export const ForumsOfCurrentCourse = ref(); + +/** + * List post of a specified forum + */ +export async function getPostsOfForum(id){ + PostsOfCurrentForum.value = [ + { + id: 1, + name: "Post~1" + }, + { + id: 2, + name: "Post~2" + }, + ] + // PostsCurrentForum.value = await restGet("/forum/" + id); +} + +export const PostsOfCurrentForum = ref(); + +/** + * Get a post and its responses + */ +export async function fetchPost(id){ + fetchedPost.value = { + id: 1, + subject: "This is the subject of the post", + content: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", + messages: [ + { + id: 1, + author: "author~1", + content: "J'ai pas copris le message !" + }, + { + id: 2, + author: "author~2", + content: "tu as fait une faute dans ton message..." + }, + { + id: 3, + author: null, + content: "I'm anonymous noww..." + } + ] + } + // fetchedPost.value = await restGet("/forum/post/" + id); +} + +export const fetchedPost = ref(); From aa3e1cb8684716c8413f38c39f8163802a61661d Mon Sep 17 00:00:00 2001 From: Wawilski Date: Sun, 7 Apr 2024 14:33:51 +0200 Subject: [PATCH 08/68] backend Schedule --- .../Clyde/EndPoints/CourseController.java | 2 - .../Clyde/EndPoints/LessonController.java | 75 ++++++++++++++++++ .../Clyde/EndPoints/MockController.java | 45 ++++++++++- .../Clyde/EndPoints/ScheduleController.java | 66 ++++++++++++++++ .../Clyde/Repositories/LessonRepository.java | 14 ++++ .../ScheduleLessonRepository.java | 23 ++++++ .../Repositories/ScheduleRepository.java | 9 +++ .../Clyde/Services/LessonService.java | 59 ++++++++++++++ .../Clyde/Services/ProtectionService.java | 26 +++++++ .../Clyde/Services/ScheduleLessonService.java | 75 ++++++++++++++++++ .../Clyde/Services/ScheduleService.java | 24 ++++++ .../ovh/herisson/Clyde/Tables/Lesson.java | 77 +++++++++++++++++++ .../ovh/herisson/Clyde/Tables/Schedule.java | 33 ++++++++ .../herisson/Clyde/Tables/ScheduleLesson.java | 53 +++++++++++++ frontend/src/Apps/Schedule.vue | 9 ++- frontend/src/rest/courses.js | 2 - frontend/src/rest/lessonSchedule.js | 65 ++++++++++++++++ frontend/src/rest/scheduleRest.js | 13 ++++ .../src/{schedule.js => scheduleFunctions.js} | 0 19 files changed, 662 insertions(+), 8 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/LessonController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScheduleController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/LessonRepository.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleLessonRepository.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleRepository.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Services/LessonService.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleService.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Lesson.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Schedule.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScheduleLesson.java create mode 100644 frontend/src/rest/lessonSchedule.js create mode 100644 frontend/src/rest/scheduleRest.js rename frontend/src/{schedule.js => scheduleFunctions.js} (100%) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java index d5e87a8..40b1e0f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java @@ -74,8 +74,6 @@ public class CourseController { public ResponseEntity> postCourse(@RequestHeader("Authorization") String token, @RequestBody Course course) { - System.out.println(course); - System.out.println(token); if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)) return new UnauthorizedResponse<>(null); diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LessonController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LessonController.java new file mode 100644 index 0000000..bd8bfb5 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LessonController.java @@ -0,0 +1,75 @@ +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.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 AuthenticatorService authServ; + + public LessonController(LessonService lessonServ, AuthenticatorService authServ) { + this.lessonServ = lessonServ; + this.authServ = authServ; + } + + @GetMapping("/lesson/{id}") + public ResponseEntity> 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>> 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>> getOwnedLessons(@RequestHeader("Authorization") String token){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher},token)) + return new UnauthorizedResponse<>(null); + return new ResponseEntity<>(ProtectionService.lessonsWithoutPassword(lessonServ.findAllOwnedLesson(authServ.getUserFromToken(token))),HttpStatus.OK); + } + + + @PostMapping("/lesson") + public ResponseEntity> postLesson(@RequestHeader("Authorization")String token, + @RequestBody Lesson lesson){ + if(authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)) + return new UnauthorizedResponse<>(null); + Lesson createdLesson = lessonServ.save(lesson); + + if(createdLesson==null) + return new ResponseEntity<>(null,HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(ProtectionService.lessonWithoutPassword(createdLesson), HttpStatus.OK); + } + + @PatchMapping("/lesson/{id}") + public ResponseEntity patchLesson(@RequestHeader("Authorization") String token, + @RequestBody Map updates, + @PathVariable long id){ + if(authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary},token)) + return new UnauthorizedResponse<>(null); + if(!lessonServ.modifyData(id, updates, authServ.getUserFromToken(token).getRole())) + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 0b7a1b4..779a1f0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -24,10 +24,15 @@ public class MockController { public final CourseService courseService; public final InscriptionService inscriptionService; + + public final LessonService lessonService; + public final ScheduleService scheduleService; + public final ScheduleLessonService scheduleLessonService; + ArrayList mockUsers; - public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){ + public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, LessonService lessonService, ScheduleService scheduleService, ScheduleLessonService scheduleLessonService){ this.tokenRepo = tokenRepo; this.userRepo = userRepo; this.tokenService = tokenService; @@ -35,6 +40,9 @@ public class MockController { this.curriculumService = curriculumService; this.courseService = courseService; this.inscriptionService = inscriptionService; + this.lessonService = lessonService; + this.scheduleService = scheduleService; + this.scheduleLessonService = scheduleLessonService; } /** Saves an example of each user type by : @@ -95,7 +103,40 @@ public class MockController { InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 1,RequestState.Pending,"yes.png","password"); inscriptionService.save(inscriptionRequest); - + + + //Schedule part + + Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 01 2024 08:15", "Mon Apr 01 2024 10:15","rgb(0,50,100)","A0B2"); + Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2"); + Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2"); + Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2"); + Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2"); + + 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)); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScheduleController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScheduleController.java new file mode 100644 index 0000000..51cbcc1 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ScheduleController.java @@ -0,0 +1,66 @@ +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.ScheduleLessonService; +import ovh.herisson.Clyde.Services.ScheduleService; +import ovh.herisson.Clyde.Services.UserCurriculumService; +import ovh.herisson.Clyde.Tables.Role; +import ovh.herisson.Clyde.Tables.Schedule; + +import java.util.Map; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class ScheduleController { + + private final ScheduleService scheduleServ; + + private final UserCurriculumService userCurriculumService; + private final AuthenticatorService authServ; + + private final ScheduleLessonService scheduleLessonServ; + + public ScheduleController(ScheduleService scheduleServ, UserCurriculumService userCurriculumService, AuthenticatorService authServ, ScheduleLessonService scheduleLessonServ) { + this.scheduleServ = scheduleServ; + this.userCurriculumService = userCurriculumService; + this.authServ = authServ; + this.scheduleLessonServ = scheduleLessonServ; + } + + @GetMapping("/schedule/{id}") + public ResponseEntity> 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> 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("/schedules") + public ResponseEntity>> findAllSchedule(){ + return new ResponseEntity<>(scheduleLessonServ.getAllSchedule(),HttpStatus.OK); + } + + @PostMapping("/schedule") + public ResponseEntity 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); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/LessonRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/LessonRepository.java new file mode 100644 index 0000000..eae64da --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/LessonRepository.java @@ -0,0 +1,14 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Lesson; +import ovh.herisson.Clyde.Tables.User; + +public interface LessonRepository extends CrudRepository { + + Lesson findById(long id); + + @Query("select l from Lesson l where l.course.owner = ?1") + Iterable findAllOwnedLesson(User teacher); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleLessonRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleLessonRepository.java new file mode 100644 index 0000000..81fec17 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleLessonRepository.java @@ -0,0 +1,23 @@ +package ovh.herisson.Clyde.Repositories; + +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 { + + @Query("select distinct sl.lesson from ScheduleLesson sl where sl.schedule.curriculum = ?1") + Iterable findLessonByCurriculum(Curriculum curriculum); + + @Query("select distinct sl.schedule from ScheduleLesson sl") + Iterable 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 findLessonBySchedule(Schedule schedule); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleRepository.java new file mode 100644 index 0000000..192fb05 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ScheduleRepository.java @@ -0,0 +1,9 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.Schedule; + +public interface ScheduleRepository extends CrudRepository { + + Schedule findById(long id); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/LessonService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/LessonService.java new file mode 100644 index 0000000..5b3c13d --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/LessonService.java @@ -0,0 +1,59 @@ +package ovh.herisson.Clyde.Services; + +import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.LessonRepository; +import ovh.herisson.Clyde.Tables.Lesson; +import ovh.herisson.Clyde.Tables.Role; +import ovh.herisson.Clyde.Tables.User; +import java.util.Map; + +@Service +public class LessonService { + private final LessonRepository lessonRepo; + public LessonService(LessonRepository lessonRepo){ + this.lessonRepo = lessonRepo; + } + + public Lesson save(Lesson lesson){ + return lessonRepo.save(lesson); + } + public Lesson findById(long id){ + return lessonRepo.findById(id); + } + public Iterable findAll(){return lessonRepo.findAll();} + + public Iterable findAllOwnedLesson(User teacher){ + return lessonRepo.findAllOwnedLesson(teacher); + } + + public boolean modifyData(long id, Map updates, Role role){ + Lesson target = lessonRepo.findById(id); + + if(target == null || role != Role.Secretary) + return false; + + + for (Map.Entry entry: updates.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()); + } + } + lessonRepo.save(target); + return true; + } + + public void delete(Lesson lesson){ + lessonRepo.delete(lesson); + } + + +} 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 44e53a7..1f25dfe 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java @@ -2,6 +2,7 @@ package ovh.herisson.Clyde.Services; import ovh.herisson.Clyde.Tables.Course; import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Lesson; import ovh.herisson.Clyde.Tables.User; import java.util.ArrayList; @@ -69,6 +70,31 @@ public class ProtectionService { } + public static HashMap lessonWithoutPassword(Lesson lesson){ + if(lesson == null) + return null; + + HashMap 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()); + return toReturn; + } + + public static Iterable> lessonsWithoutPassword(Iterable lessons){ + ArrayList> toReturn = new ArrayList<>(); + + for (Lesson l: lessons){ + toReturn.add(ProtectionService.lessonWithoutPassword(l)); + } + + return toReturn; + + } + public static Map requestWithoutPassword(InscriptionRequest inscriptionRequest) { diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java new file mode 100644 index 0000000..53e15ba --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleLessonService.java @@ -0,0 +1,75 @@ +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; + +@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 void save(ScheduleLesson scheduleLesson){ + scheduleLessonRepo.save(scheduleLesson); + } + + public Schedule getScheduleByCurriculum(Curriculum curriculum){ + return scheduleLessonRepo.findScheduleByCurriculum(curriculum); + } + + public Map getDepthScheduleByCurriculum(Curriculum curriculum){ + if(curriculum == null) + return null; + + HashMap toReturn = new HashMap<>(); + ArrayList> lessons = new ArrayList<>(); + Iterable foundLessons = scheduleLessonRepo.findLessonByCurriculum(curriculum); + + for (Lesson l: foundLessons){ + lessons.add(ProtectionService.lessonWithoutPassword(l)); + } + toReturn.put("lessons",lessons); + toReturn.put("scheduleId" , scheduleLessonRepo.findScheduleByCurriculum(curriculum).getScheduleID()); + return toReturn; + } + + public Map getDepthScheduleBySchedule(Schedule schedule){ + if(schedule == null) + return null; + + HashMap toReturn = new HashMap<>(); + ArrayList> lessons = new ArrayList<>(); + Iterable foundLessons = scheduleLessonRepo.findLessonByCurriculum(schedule.getCurriculum()); + + for (Lesson l: foundLessons){ + lessons.add(ProtectionService.lessonWithoutPassword(l)); + } + toReturn.put("lessons",lessons); + toReturn.put("scheduleId" , schedule.getScheduleID()); + return toReturn; + } + + public Iterable> getAllSchedule(){ + ArrayList> toReturn = new ArrayList<>(); + + for (Schedule schedule: scheduleRepo.findAll()){ + toReturn.add(getDepthScheduleBySchedule(schedule)); + } + return toReturn; + } + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleService.java new file mode 100644 index 0000000..950261c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ScheduleService.java @@ -0,0 +1,24 @@ +package ovh.herisson.Clyde.Services; + +import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.ScheduleRepository; +import ovh.herisson.Clyde.Tables.Schedule; + +@Service +public class ScheduleService { + private final ScheduleRepository scheduleRepo; + public ScheduleService(ScheduleRepository scheduleRepo) { + this.scheduleRepo = scheduleRepo; + } + public Schedule save(Schedule schedule){ + return scheduleRepo.save(schedule); + } + public Schedule findById(long id){ + return scheduleRepo.findById(id); + } + public void delete(Schedule schedule){ + scheduleRepo.delete(schedule); + } + +} + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Lesson.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Lesson.java new file mode 100644 index 0000000..00a693c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Lesson.java @@ -0,0 +1,77 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + + +@Entity +public class Lesson { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int lessonID; + + @ManyToOne + @JoinColumn(name= "Course") + private Course course; + + private String lessonStart; + + private String lessonEnd; + private String color; + + private String local; + + public Lesson(Course course,String start, String end ,String color,String local){ + this.lessonEnd = end; + this.course = course; + this.lessonStart = start; + this.color = color; + this.local = local; + } + + 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 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; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Schedule.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Schedule.java new file mode 100644 index 0000000..993c38c --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Schedule.java @@ -0,0 +1,33 @@ + +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") + private Curriculum curriculum; + + public Schedule(Curriculum curriculum){ + this.curriculum = curriculum; + } + + public Schedule() {} + + + public int getScheduleID(){ + return scheduleID; +} + + public Curriculum getCurriculum(){ + return curriculum; +} + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScheduleLesson.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScheduleLesson.java new file mode 100644 index 0000000..3b7b6a4 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScheduleLesson.java @@ -0,0 +1,53 @@ +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") + private Schedule schedule; + + + @ManyToOne(fetch = FetchType.EAGER) + @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; + } + + +} diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue index 0c3f640..0722d91 100644 --- a/frontend/src/Apps/Schedule.vue +++ b/frontend/src/Apps/Schedule.vue @@ -1,7 +1,12 @@ @@ -28,10 +33,11 @@ const selectedForum = ref(); +
{{ post.name }}
- +
@@ -43,10 +49,41 @@ const selectedForum = ref();
+
+
+ + +
+
From 2e02cd88701a75ebc00d897d1e20b4958ccf4fff Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 13 Apr 2024 15:56:43 +0200 Subject: [PATCH 17/68] Style bits redone --- frontend/src/Apps/Forums.vue | 30 +++++++++++++++++++----------- frontend/src/rest/forum.js | 4 +++- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/frontend/src/Apps/Forums.vue b/frontend/src/Apps/Forums.vue index 50e17f6..0effc5c 100644 --- a/frontend/src/Apps/Forums.vue +++ b/frontend/src/Apps/Forums.vue @@ -18,7 +18,6 @@ const selectedCourse = ref(); const selectedForum = ref(); const Role = (await getSelf()).role; -const addForum = ref(false); const addForumName = ref(""); const addPost = ref(false); const addPostSubject = ref(""); @@ -33,10 +32,10 @@ const addPostContent = ref(""); - + -
{{ post.subject }}
@@ -49,14 +48,14 @@ const addPostContent = ref("");

{{msg.author.firtName}} {{msg.author.lastName}} - {{msg.content}}

- +
-