From 69c3a3b965225b7cc399fe2977814dd34a386e56 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Thu, 29 Feb 2024 20:08:12 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Impl=C3=A9mentation=20des=20diff=C3=A9ren?= =?UTF-8?q?tes=20classes=20repr=C3=A9sentants=20les=20tables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/build.gradle.kts | 1 + .../ovh/herisson/Clyde/Tables/Course.java | 16 +++++++++ .../ovh/herisson/Clyde/Tables/Cursus.java | 16 +++++++++ .../herisson/Clyde/Tables/CursusCourse.java | 16 +++++++++ .../java/ovh/herisson/Clyde/Tables/Role.java | 7 ++++ .../ovh/herisson/Clyde/Tables/Secretary.java | 15 ++++++++ .../Clyde/Tables/TeacherGivenCourse.java | 15 ++++++++ .../Clyde/Tables/TeacherOwnerCourse.java | 16 +++++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 35 +++++++++++++++++++ .../ovh/herisson/Clyde/Tables/UserCursus.java | 13 +++++++ 10 files changed, 150 insertions(+) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/User.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 91c7679..85fae7b 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -19,6 +19,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation("org.springframework.boot:spring-boot-starter-mail") implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-data-jpa") // implementation("org.springframework.session:spring-session-jdbc") developmentOnly("org.springframework.boot:spring-boot-devtools") developmentOnly("org.springframework.boot:spring-boot-docker-compose") diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java new file mode 100644 index 0000000..b5bdf00 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -0,0 +1,16 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Course { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int CourseID; + private int Credits; + private String Title; + private String Faculty; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java new file mode 100644 index 0000000..c909f9e --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java @@ -0,0 +1,16 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Cursus { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int CursusId; + private int Year; + private String Option; + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java new file mode 100644 index 0000000..c8a669f --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java @@ -0,0 +1,16 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class CursusCourse { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private int CursusId; + private int CourseId; + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java new file mode 100644 index 0000000..d9ccb94 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java @@ -0,0 +1,7 @@ +package ovh.herisson.Clyde.Tables; + +public enum Role { + Teacher, + Student; + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java new file mode 100644 index 0000000..8c2220b --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java @@ -0,0 +1,15 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Secretary { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private int RegNo; + private String Faculty; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java new file mode 100644 index 0000000..cf6e39d --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -0,0 +1,15 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class TeacherGivenCourse { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private int RegNo; + private int CourseId; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java new file mode 100644 index 0000000..385f504 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java @@ -0,0 +1,16 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class TeacherOwnerCourse { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private int RegNo; + private int CourseId; +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java new file mode 100644 index 0000000..ca69efe --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -0,0 +1,35 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +import java.util.Date; + +//Classe représentant un utilisateur l'attribut password demande surement un peu de rafinement niveau sécurité +//et l'attribut tokenApi doit encore être ajouté vu qu'il faut en discuter + +@Entity +//Je rajoute un s au nom de la table pour éviter les conflits avec les mots réservés +@Table(name = "Users") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int RegNo; + + private String LastName; + private String FirstName; + private String Email; + private String Adress; + private String Country; + private Date BirthDate; + private ovh.herisson.Clyde.Tables.Role Role; + private String Password; + + public User(String LastName, String FirstName){ + this.LastName = LastName; + this.FirstName = FirstName; + } + + public User() { + + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java new file mode 100644 index 0000000..d638198 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java @@ -0,0 +1,13 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +@Entity +@Table(name = "User_Cursus") +public class UserCursus { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private int RegNo; + private int CursusId; +} From 25019d8b912a8cee6e3c2519371b1b162899985d Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Fri, 1 Mar 2024 01:47:11 +0100 Subject: [PATCH 02/17] =?UTF-8?q?Suppression=20de=20TeacherOwnerCourse.jav?= =?UTF-8?q?a=20et=20ajout=20d'un=20bool=C3=A9en=20Owned=20dans=20TeacherGi?= =?UTF-8?q?venCourse.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clyde/Tables/TeacherGivenCourse.java | 1 + .../Clyde/Tables/TeacherOwnerCourse.java | 16 ---------------- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java index cf6e39d..5dcf1bf 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -12,4 +12,5 @@ public class TeacherGivenCourse { private int id; private int RegNo; private int CourseId; + private boolean Owned; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java deleted file mode 100644 index 385f504..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherOwnerCourse.java +++ /dev/null @@ -1,16 +0,0 @@ -package ovh.herisson.Clyde.Tables; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class TeacherOwnerCourse { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - private int RegNo; - private int CourseId; -} From 3956037ab5e7e293aa729ad0609d2b0efbc9862a Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 2 Mar 2024 23:33:48 +0100 Subject: [PATCH 03/17] example backend api with user table --- .../Clyde/EndPoints/UserController.java | 27 +++++++++ .../Clyde/Repositories/UserRepository.java | 16 ++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 57 ++++++++++++++++++- .../src/main/resources/application.properties | 3 +- 4 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java new file mode 100644 index 0000000..1210831 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -0,0 +1,27 @@ +package ovh.herisson.Clyde.EndPoints; + + +import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.UserRepository; +import ovh.herisson.Clyde.Tables.User; + + +@RestController +@CrossOrigin(origins = "http://localhost:5173") +public class UserController { + + private final UserRepository userRepo; + + public UserController(UserRepository userRepo){ + this.userRepo = userRepo; + } + + @GetMapping("/users") + public Iterable getUsers(){ + return userRepo.findAll(); + } + @PostMapping("/users") + public void postUser(@RequestBody User user ){ + userRepo.save(user); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java new file mode 100644 index 0000000..38f9ae0 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserRepository.java @@ -0,0 +1,16 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.User; + +import java.util.List; + +public interface UserRepository extends CrudRepository { + + User findById(long id); + + /** + @Query(value = "select a.* from Users a ",nativeQuery = true) + Iterable findAllUsers();**/ +} \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index ca69efe..2165681 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -14,7 +14,6 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int RegNo; - private String LastName; private String FirstName; private String Email; @@ -32,4 +31,60 @@ public class User { public User() { } + + public String getLastName() { + return LastName; + } + + public void setLastName(String LastName) { + this.LastName = LastName; + } + + public String getFirstName() { + return FirstName; + } + + public void setFirstName(String firstName) { + FirstName = firstName; + } + + public String getEmail() { + return Email; + } + + public void setEmail(String email) { + Email = email; + } + + public String getAdress() { + return Adress; + } + + public void setAdress(String adress) { + Adress = adress; + } + + public String getCountry() { + return Country; + } + + public void setCountry(String country) { + Country = country; + } + + public Date getBirthDate() { + return BirthDate; + } + + public void setBirthDate(Date birthDate) { + BirthDate = birthDate; + } + + public ovh.herisson.Clyde.Tables.Role getRole() { + return Role; + } + + public void setRole(ovh.herisson.Clyde.Tables.Role role) { + Role = role; + } } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 8b13789..df288a6 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1 +1,2 @@ - +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect From 684c3095eb7b4e9297d29a85f9648abe3e7d8d9b Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sun, 3 Mar 2024 17:42:26 +0100 Subject: [PATCH 04/17] =?UTF-8?q?-=20Changement=20des=20noms=20de=20variab?= =?UTF-8?q?les=20-=20Ajout=20des=20getters/setters=20appropri=C3=A9s=20-?= =?UTF-8?q?=20Ajout=20des=20constructeur=20n=C3=A9cessaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .attach_pid7200 | 0 .../ovh/herisson/Clyde/Tables/Course.java | 44 +++++++++++-- .../ovh/herisson/Clyde/Tables/Cursus.java | 33 +++++++++- .../herisson/Clyde/Tables/CursusCourse.java | 30 ++++++++- .../ovh/herisson/Clyde/Tables/Secretary.java | 31 ++++++++- .../Clyde/Tables/TeacherGivenCourse.java | 44 ++++++++++++- .../java/ovh/herisson/Clyde/Tables/User.java | 64 ++++++++++--------- .../ovh/herisson/Clyde/Tables/UserCursus.java | 31 ++++++++- 8 files changed, 232 insertions(+), 45 deletions(-) create mode 100644 .attach_pid7200 diff --git a/.attach_pid7200 b/.attach_pid7200 new file mode 100644 index 0000000..e69de29 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 b5bdf00..54e167a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -9,8 +9,44 @@ import jakarta.persistence.Id; public class Course { @Id @GeneratedValue(strategy = GenerationType.AUTO) - private int CourseID; - private int Credits; - private String Title; - private String Faculty; + private int courseID; + private int credits; + private String title; + private String faculty; + + public Course(int credits, String title, String faculty){ + this.credits = credits; + this.title = title; + this.faculty = faculty; + } + + public Course() {} + + public int getCourseID() { + return courseID; + } + + public int getCredits() { + return credits; + } + + public void setCredits(int credits){ + this.credits = credits; + } + + public String getFaculty() { + return faculty; + } + + public void setFaculty(String faculty){ + this.faculty = faculty; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title){ + this.title = title; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java index c909f9e..5167197 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Cursus.java @@ -9,8 +9,35 @@ import jakarta.persistence.Id; public class Cursus { @Id @GeneratedValue(strategy = GenerationType.AUTO) - private int CursusId; - private int Year; - private String Option; + private int cursusId; + private int year; + private String option; + + public Cursus(int year, String option){ + this.year = year; + this.option = option; + } + + public Cursus() {} + + public int getCursusId(){ + return this.cursusId; + } + + public int getYear(){ + return this.year; + } + + public void setYear(int year){ + this.year = year; + } + + public String getOption(){ + return this.option; + } + + public void setOption(String option){ + this.option = option; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java index c8a669f..30fed1c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java @@ -10,7 +10,33 @@ public class CursusCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private int CursusId; - private int CourseId; + private int cursusId; + private int courseId; + public CursusCourse(int cursusId, int courseId){ + this.cursusId = cursusId; + this.courseId = courseId; + } + + public CursusCourse() {} + + public int getId() { + return id; + } + + public int getCourseId() { + return courseId; + } + + public void setCourseId(int courseId){ + this.courseId = courseId; + } + + public int getCursusId() { + return cursusId; + } + + public void setCursusId(int cursusId) { + this.cursusId = cursusId; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java index 8c2220b..ec7a86a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java @@ -10,6 +10,33 @@ public class Secretary { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private int RegNo; - private String Faculty; + private int regNo; + private String faculty; + + public Secretary(int regNo, String faculty){ + this.regNo = regNo; + this.faculty = faculty; + } + + public Secretary() {} + + public int getId() { + return id; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public String getFaculty() { + return faculty; + } + + public void setFaculty(String faculty) { + this.faculty = faculty; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java index 5dcf1bf..6e137c5 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -10,7 +10,45 @@ public class TeacherGivenCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private int RegNo; - private int CourseId; - private boolean Owned; + private int regNo; + private int courseId; + + //This flag helps make the difference between an assistant or a Teacher (who owns the course) + private boolean owned; + + public TeacherGivenCourse(int regNo, int courseId, boolean owned){ + this.regNo = regNo; + this.courseId = courseId; + this.owned = owned; + } + + public TeacherGivenCourse() {} + + public int getId() { + return id; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public int getCourseId() { + return courseId; + } + + public void setCourseId(int courseId) { + this.courseId = courseId; + } + + public boolean isOwned() { + return owned; + } + + public void setOwned(boolean owned) { + this.owned = owned; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 2165681..172fd0d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -13,78 +13,84 @@ import java.util.Date; public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) - private int RegNo; - private String LastName; - private String FirstName; - private String Email; - private String Adress; - private String Country; - private Date BirthDate; - private ovh.herisson.Clyde.Tables.Role Role; - private String Password; + private int regNo; + private String lastName; + private String firstName; + private String email; + private String adress; + private String country; + private Date birthDate; + private ovh.herisson.Clyde.Tables.Role role; + private String password; - public User(String LastName, String FirstName){ - this.LastName = LastName; - this.FirstName = FirstName; + public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role){ + this.lastName = lastName; + this.firstName = firstName; + this.email = email; + this.adress = adress; + this.country = country; + this.birthDate = birthDate; + this.role = role; } - public User() { + public User() {} + public int getRegNo(){ + return this.regNo; } - public String getLastName() { - return LastName; + return lastName; } - public void setLastName(String LastName) { - this.LastName = LastName; + public void setLastName(String lastName) { + this.lastName = lastName; } public String getFirstName() { - return FirstName; + return firstName; } public void setFirstName(String firstName) { - FirstName = firstName; + this.firstName = firstName; } public String getEmail() { - return Email; + return email; } public void setEmail(String email) { - Email = email; + this.email = email; } public String getAdress() { - return Adress; + return adress; } public void setAdress(String adress) { - Adress = adress; + this.adress = adress; } public String getCountry() { - return Country; + return country; } public void setCountry(String country) { - Country = country; + this.country = country; } public Date getBirthDate() { - return BirthDate; + return birthDate; } public void setBirthDate(Date birthDate) { - BirthDate = birthDate; + this.birthDate = birthDate; } public ovh.herisson.Clyde.Tables.Role getRole() { - return Role; + return role; } public void setRole(ovh.herisson.Clyde.Tables.Role role) { - Role = role; + this.role = role; } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java index d638198..2222fdb 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java @@ -8,6 +8,33 @@ public class UserCursus { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - private int RegNo; - private int CursusId; + private int regNo; + private int cursusId; + + public UserCursus(int regNo, int cursusId){ + this.regNo = regNo; + this.cursusId = cursusId; + } + + public UserCursus() {} + + public int getId() { + return id; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public int getCursusId() { + return cursusId; + } + + public void setCursusId(int cursusId) { + this.cursusId = cursusId; + } } From 6c688dab599940229d6d9f7d82682db84b92963e Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Mon, 4 Mar 2024 21:25:44 +0100 Subject: [PATCH 05/17] added Admin and Secretary --- backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java index d9ccb94..bb14f3f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java @@ -2,6 +2,7 @@ package ovh.herisson.Clyde.Tables; public enum Role { Teacher, - Student; - + Student, + Admin, + Secretary; } From 45bfe08c9a006039b74c772204d2876de7b45cc6 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Mon, 4 Mar 2024 21:27:22 +0100 Subject: [PATCH 06/17] added .idea/ to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 24a8972..93aac47 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build .project .settings +.idea/ From 36f1ab3203716f7163e412822e8c00c53f02fe39 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Mon, 4 Mar 2024 21:27:22 +0100 Subject: [PATCH 07/17] added .idea/ to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 24a8972..93aac47 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build .project .settings +.idea/ From cc89d7f5b7b2fea4fd28b0cba50bd917f45d6e65 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Mon, 4 Mar 2024 23:35:15 +0100 Subject: [PATCH 08/17] added ResponseEntity and TODOs --- .../Clyde/EndPoints/UserController.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java index 1210831..affb301 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -1,6 +1,9 @@ package ovh.herisson.Clyde.EndPoints; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Tables.User; @@ -16,12 +19,26 @@ public class UserController { this.userRepo = userRepo; } + @GetMapping("/user") + public ResponseEntity getUsers(@RequestHeader("Authorization") String token){ + //TODO + // Get the token thru the data base + // tokenRepo.findToken(token) => User userFromToken + // si role != secretary => return error : ResponseEntity(null, HttpStatus.UNAUTHORIZED) + return new ResponseEntity(/**userRepo.findById(userFromToken.id),**/ HttpStatus.OK); + } + + @PostMapping("/user") + public ResponseEntity postUser(@RequestBody User user){ + userRepo.save(user); + return new ResponseEntity(String.format("Account created with ID:%s",user.getRegNo()),HttpStatus.CREATED); + } + @GetMapping("/users") - public Iterable getUsers(){ + public Iterable getAllUsers(){//TODO ne l'accepter que si c'est le secrétariat return userRepo.findAll(); } - @PostMapping("/users") - public void postUser(@RequestBody User user ){ - userRepo.save(user); - } + + } + From dcd1fad6ac4afa344f13c5e41f7edceaf02180fb Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 5 Mar 2024 10:51:49 +0100 Subject: [PATCH 09/17] solve access to /login Vite won't export not specified page, so I specified it in the config. --- frontend/{login.html => login/index.html} | 0 frontend/vite.config.js | 9 +++++++++ 2 files changed, 9 insertions(+) rename frontend/{login.html => login/index.html} (100%) diff --git a/frontend/login.html b/frontend/login/index.html similarity index 100% rename from frontend/login.html rename to frontend/login/index.html diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 5c45e1d..7ff998b 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -8,6 +8,15 @@ export default defineConfig({ plugins: [ vue(), ], + build: { + rollupOptions:{ + input:{ + main: './index.html', + login: './login/index.html' + } + + } + }, resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) From c27c3ac9fba1dcb8ed4b4adcfdd78ab73cb2604e Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Tue, 5 Mar 2024 14:14:56 +0100 Subject: [PATCH 10/17] - Ajout des champs password et salt dans user - Ajout de la table token - Ajout des foreign keys --- .../herisson/Clyde/Tables/CursusCourse.java | 9 ++-- .../ovh/herisson/Clyde/Tables/Secretary.java | 7 ++-- .../Clyde/Tables/TeacherGivenCourse.java | 9 ++-- .../java/ovh/herisson/Clyde/Tables/Token.java | 41 +++++++++++++++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 21 +++++++++- .../ovh/herisson/Clyde/Tables/UserCursus.java | 3 ++ 6 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java index 30fed1c..e48e6a3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusCourse.java @@ -1,16 +1,17 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class CursusCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "Cursus") private int cursusId; + + @JoinColumn(name = "Course") private int courseId; public CursusCourse(int cursusId, int courseId){ diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java index ec7a86a..6161952 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java @@ -1,15 +1,14 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class Secretary { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "User") private int regNo; private String faculty; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java index 6e137c5..f2c089a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -1,16 +1,17 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class TeacherGivenCourse { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + + @JoinColumn(name = "User") private int regNo; + + @JoinColumn(name = "Course") private int courseId; //This flag helps make the difference between an assistant or a Teacher (who owns the course) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java new file mode 100644 index 0000000..0ed6606 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java @@ -0,0 +1,41 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Token { + @GeneratedValue(strategy = GenerationType.AUTO) + @Id + private int id; + private int regNo; + private String data; + + public Token(int regNo, String data){ + this.regNo = regNo; + this.data = data; + } + + public Token(){} + public int getId() { + return id; + } + + public int getRegNo() { + return regNo; + } + + public void setRegNo(int regNo) { + this.regNo = regNo; + } + + public String getData(){ + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 172fd0d..2755eff 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -22,8 +22,8 @@ public class User { private Date birthDate; private ovh.herisson.Clyde.Tables.Role role; private String password; - - public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role){ + private String salt; + public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role, String password, String salt){ this.lastName = lastName; this.firstName = firstName; this.email = email; @@ -31,6 +31,8 @@ public class User { this.country = country; this.birthDate = birthDate; this.role = role; + this.password = password; + this.salt = salt; } public User() {} @@ -93,4 +95,19 @@ public class User { public void setRole(ovh.herisson.Clyde.Tables.Role role) { this.role = role; } + public String getPassword(){ + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getSalt(){ + return salt; + } + + public void setSalt(String salt) { + this.salt = salt; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java index 2222fdb..9460905 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java @@ -8,7 +8,10 @@ public class UserCursus { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; + @JoinColumn(name = "User") private int regNo; + + @JoinColumn(name = "Cursus") private int cursusId; public UserCursus(int regNo, int cursusId){ From 24a54bdee48a603aa14368cb8c9eb0928a16128d Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 5 Mar 2024 20:28:23 +0100 Subject: [PATCH 11/17] removing useless function & calling reloadLang properly (#52) Reviewed-on: https://git.herisson.ovh/PGL/Clyde/pulls/52 Reviewed-by: Maxime <231026@umons.ac.be> Reviewed-by: Wal Co-authored-by: Anthony Debucquoy Co-committed-by: Anthony Debucquoy --- frontend/src/i18n.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 02fba50..a72ceee 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -22,7 +22,7 @@ let langs; * * @return :string The translated text */ -function i18n(key, options) { +export default function i18n(key, options) { let ret = langs[key]; if(options != null){ for (let key in options) { @@ -32,14 +32,6 @@ function i18n(key, options) { return ret; } -async function reloadLang(){ - langs = await loadLangs(); -} -reloadLang(); - -export default i18n; - - // // Those functions are utility functions use by previous exported functions. // @@ -65,7 +57,7 @@ function getCookie(key){ * @param select the language to load. could be null to fetch the cookies for an answer * if nothing is found. default to EN.txt */ -async function loadLangs(lang){ +export async function loadLangs(lang){ lang = lang != null ? lang : getCookie("lang"); lang = lang != "" ? lang : default_lang; @@ -80,5 +72,6 @@ async function loadLangs(lang){ filteredLines[line.substr(0, split)] = line.substr(split+1, line.length); }; } - return filteredLines; + langs = filteredLines; } +await loadLangs(); From bb0e6783ece6baaa6fbaf24c0d1bbb348f46e80d Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Tue, 5 Mar 2024 23:34:49 +0100 Subject: [PATCH 12/17] correction commit --- .attach_pid7200 | 0 .../ovh/herisson/Clyde/Tables/Secretary.java | 2 +- .../Clyde/Tables/TeacherGivenCourse.java | 2 +- .../java/ovh/herisson/Clyde/Tables/Token.java | 23 +++++++++--------- .../java/ovh/herisson/Clyde/Tables/User.java | 24 ++++++------------- .../ovh/herisson/Clyde/Tables/UserCursus.java | 3 +-- 6 files changed, 21 insertions(+), 33 deletions(-) delete mode 100644 .attach_pid7200 diff --git a/.attach_pid7200 b/.attach_pid7200 deleted file mode 100644 index e69de29..0000000 diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java index 6161952..cf533a0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Secretary.java @@ -8,7 +8,7 @@ public class Secretary { @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @JoinColumn(name = "User") + @JoinColumn(name = "Users") private int regNo; private String faculty; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java index f2c089a..9cb931e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/TeacherGivenCourse.java @@ -8,7 +8,7 @@ public class TeacherGivenCourse { @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @JoinColumn(name = "User") + @JoinColumn(name = "Users") private int regNo; @JoinColumn(name = "Course") diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java index 0ed6606..ec59cbf 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Token.java @@ -1,21 +1,20 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; +import jakarta.persistence.*; @Entity public class Token { @GeneratedValue(strategy = GenerationType.AUTO) @Id private int id; - private int regNo; - private String data; - public Token(int regNo, String data){ + @JoinColumn(name ="Users") + private int regNo; + private String token; + + public Token(int regNo, String token){ this.regNo = regNo; - this.data = data; + this.token = token; } public Token(){} @@ -31,11 +30,11 @@ public class Token { this.regNo = regNo; } - public String getData(){ - return data; + public String getToken(){ + return token; } - public void setData(String data) { - this.data = data; + public void setToken(String data) { + this.token = data; } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 2755eff..746ac3b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -17,22 +17,20 @@ public class User { private String lastName; private String firstName; private String email; - private String adress; + private String address; private String country; private Date birthDate; private ovh.herisson.Clyde.Tables.Role role; private String password; - private String salt; - public User(String lastName, String firstName, String email, String adress, String country, Date birthDate, Role role, String password, String salt){ + public User(String lastName, String firstName, String email, String address, String country, Date birthDate, Role role, String password){ this.lastName = lastName; this.firstName = firstName; this.email = email; - this.adress = adress; + this.address = address; this.country = country; this.birthDate = birthDate; this.role = role; this.password = password; - this.salt = salt; } public User() {} @@ -64,12 +62,12 @@ public class User { this.email = email; } - public String getAdress() { - return adress; + public String getAddress() { + return address; } - public void setAdress(String adress) { - this.adress = adress; + public void setAddress(String adress) { + this.address = adress; } public String getCountry() { @@ -102,12 +100,4 @@ public class User { public void setPassword(String password) { this.password = password; } - - public String getSalt(){ - return salt; - } - - public void setSalt(String salt) { - this.salt = salt; - } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java index 9460905..4de1559 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCursus.java @@ -3,12 +3,11 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; @Entity -@Table(name = "User_Cursus") public class UserCursus { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @JoinColumn(name = "User") + @JoinColumn(name = "Users") private int regNo; @JoinColumn(name = "Cursus") From 212ab638a2c393c7e691696e32c6900a25764390 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 10:01:55 +0100 Subject: [PATCH 13/17] allow unix socket connection for database in prod --- .gitea/workflows/deploy.yaml | 2 +- backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 8239a07..e01bb46 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -53,5 +53,5 @@ jobs: scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/ - name: restarting the backend run: | - ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f" + ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f" - run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api" diff --git a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java index c310d52..a60d41d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java +++ b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java @@ -29,7 +29,7 @@ public class JdbcConfig { public DataSource psqlSourceProd(){ DriverManagerDataSource source = new DriverManagerDataSource(); source.setDriverClassName("org.postgresql.Driver"); - source.setUrl("jdbc:postgresql://localhost:5432/clyde"); + source.setUrl("jdbc:postgresql:clyde"); source.setUsername("clyde"); return source; From 38ed24915010824e975958a58fac91885d8d0210 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 10:52:11 +0100 Subject: [PATCH 14/17] using unix socket --- backend/build.gradle.kts | 1 + .../java/ovh/herisson/Clyde/JdbcConfig.java | 2 +- frontend/package-lock.json | 642 ------------------ 3 files changed, 2 insertions(+), 643 deletions(-) diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index eabd3e3..ae0a6c9 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -21,6 +21,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-mail") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-data-jpa") + 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") diff --git a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java index a60d41d..2fb978c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java +++ b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java @@ -29,7 +29,7 @@ public class JdbcConfig { public DataSource psqlSourceProd(){ DriverManagerDataSource source = new DriverManagerDataSource(); source.setDriverClassName("org.postgresql.Driver"); - source.setUrl("jdbc:postgresql:clyde"); + source.setUrl("jdbc:postgresql:clyde?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432"); source.setUsername("clyde"); return source; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index f1c941f..3165c6e 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -13,7 +13,6 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.3", - "@vue/test-utils": "^2.4.4", "jsdom": "^24.0.0", "vite": "^5.0.11" } @@ -397,44 +396,11 @@ "node": ">=12" } }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, - "node_modules/@one-ini/wasm": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@one-ini/wasm/-/wasm-0.1.1.tgz", - "integrity": "sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==", - "dev": true - }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.12.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.12.0.tgz", @@ -723,34 +689,6 @@ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.19.tgz", "integrity": "sha512-/KliRRHMF6LoiThEy+4c1Z4KB/gbPrGjWwJR+crg2otgrf/egKzRaCPvJ51S5oetgsgXLfc4Rm5ZgrKHZrtMSw==" }, - "node_modules/@vue/test-utils": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/@vue/test-utils/-/test-utils-2.4.4.tgz", - "integrity": "sha512-8jkRxz8pNhClAf4Co4ZrpAoFISdvT3nuSkUlY6Ys6rmTpw3DMWG/X3mw3gQ7QJzgCZO9f+zuE2kW57fi09MW7Q==", - "dev": true, - "dependencies": { - "js-beautify": "^1.14.9", - "vue-component-type-helpers": "^1.8.21" - }, - "peerDependencies": { - "@vue/server-renderer": "^3.0.1", - "vue": "^3.0.1" - }, - "peerDependenciesMeta": { - "@vue/server-renderer": { - "optional": true - } - } - }, - "node_modules/abbrev": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-2.0.0.tgz", - "integrity": "sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==", - "dev": true, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/agent-base": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz", @@ -763,57 +701,12 @@ "node": ">= 14" } }, - "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -826,39 +719,6 @@ "node": ">= 0.8" } }, - "node_modules/commander": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz", - "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==", - "dev": true, - "engines": { - "node": ">=14" - } - }, - "node_modules/config-chain": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", - "integrity": "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==", - "dev": true, - "dependencies": { - "ini": "^1.3.4", - "proto-list": "~1.2.1" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/cssstyle": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.0.1.tgz", @@ -921,36 +781,6 @@ "node": ">=0.4.0" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "node_modules/editorconfig": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-1.0.4.tgz", - "integrity": "sha512-L9Qe08KWTlqYMVvMcTIvMAdl1cDUubzRNYL+WfA4bLDMHe4nemKkpmYzkznE1FwLKu0EEmy6obgQKzMJrg4x9Q==", - "dev": true, - "dependencies": { - "@one-ini/wasm": "0.1.1", - "commander": "^10.0.0", - "minimatch": "9.0.1", - "semver": "^7.5.3" - }, - "bin": { - "editorconfig": "bin/editorconfig" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -1000,22 +830,6 @@ "@esbuild/win32-x64": "0.19.12" } }, - "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -1044,28 +858,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/glob": { - "version": "10.3.10", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", - "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", - "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/html-encoding-sniffer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", @@ -1116,81 +908,12 @@ "node": ">=0.10.0" } }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", "dev": true }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/jackspeak": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", - "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", - "dev": true, - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" - } - }, - "node_modules/js-beautify": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.15.1.tgz", - "integrity": "sha512-ESjNzSlt/sWE8sciZH8kBF8BPlwXPwhR6pWKAw8bw4Bwj+iZcnKW6ONWUutJ7eObuBZQpiIb8S7OYspWrKt7rA==", - "dev": true, - "dependencies": { - "config-chain": "^1.1.13", - "editorconfig": "^1.0.4", - "glob": "^10.3.3", - "js-cookie": "^3.0.5", - "nopt": "^7.2.0" - }, - "bin": { - "css-beautify": "js/bin/css-beautify.js", - "html-beautify": "js/bin/html-beautify.js", - "js-beautify": "js/bin/js-beautify.js" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/js-cookie": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", - "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==", - "dev": true, - "engines": { - "node": ">=14" - } - }, "node_modules/jsdom": { "version": "24.0.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-24.0.0.tgz", @@ -1231,15 +954,6 @@ } } }, - "node_modules/lru-cache": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", - "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", - "dev": true, - "engines": { - "node": "14 || >=16.14" - } - }, "node_modules/magic-string": { "version": "0.30.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.7.tgz", @@ -1272,30 +986,6 @@ "node": ">= 0.6" } }, - "node_modules/minimatch": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz", - "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minipass": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", - "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -1319,21 +1009,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "node_modules/nopt": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", - "integrity": "sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==", - "dev": true, - "dependencies": { - "abbrev": "^2.0.0" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, "node_modules/nwsapi": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", @@ -1352,31 +1027,6 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-scurry": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", - "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", - "dev": true, - "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -1409,12 +1059,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/proto-list": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", - "integrity": "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==", - "dev": true - }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -1498,66 +1142,6 @@ "node": ">=v12.22.7" } }, - "node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", @@ -1566,102 +1150,6 @@ "node": ">=0.10.0" } }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -1789,12 +1277,6 @@ } } }, - "node_modules/vue-component-type-helpers": { - "version": "1.8.27", - "resolved": "https://registry.npmjs.org/vue-component-type-helpers/-/vue-component-type-helpers-1.8.27.tgz", - "integrity": "sha512-0vOfAtI67UjeO1G6UiX5Kd76CqaQ67wrRZiOe7UAb9Jm6GzlUr/fC7CV90XfwapJRjpCMaZFhv1V0ajWRmE9Dg==", - "dev": true - }, "node_modules/vue3-toastify": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/vue3-toastify/-/vue3-toastify-0.2.1.tgz", @@ -1871,124 +1353,6 @@ "node": ">=18" } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/ws": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", @@ -2024,12 +1388,6 @@ "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true } } } From a253a5152dd16a17ace4c3c2dca506a951903c37 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 11:20:29 +0100 Subject: [PATCH 15/17] My life is a potato --- .gitea/workflows/deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index e01bb46..35ed21a 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -53,5 +53,5 @@ jobs: scp -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:api/ - name: restarting the backend run: | - ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f" + ssh -o "StrictHostKeyChecking=no" -o "LogLevel=ERROR" -i key ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd api/backend && docker build -t clyde/backend . && docker rm clyde_backend_prod -f || true && docker run --rm -d -u $(id -u clyde):$(id -g clyde) -v /var/run/postgresql:/var/run/postgresql --name clyde_backend_prod -p 4000:8080 clyde/backend && docker image prune -f' - run: echo "The backend has been deployed. running at https://clyde.herisson.ovh/api" From 6df81a66f267ca811c1b3b19b5b1c03971af93c2 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 14:41:03 +0100 Subject: [PATCH 16/17] Fixing i18n path --- frontend/src/i18n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index a72ceee..17fdbce 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -61,7 +61,7 @@ export async function loadLangs(lang){ lang = lang != null ? lang : getCookie("lang"); lang = lang != "" ? lang : default_lang; - const filename = "./i18n/" + lang.toUpperCase() + ".txt"; + const filename = "/i18n/" + lang.toUpperCase() + ".txt"; const content = await (await fetch(filename)).text(); const lines = content.split("\n"); From 0e7c18e088216469d00c044aa98eb569b0be2304 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Wed, 6 Mar 2024 21:38:09 +0100 Subject: [PATCH 17/17] Base for rest api utilisation (#53) The restConsumer will be the base, then I will create a js file per "object" (for instance there will be users.js with all endpoints for users using the restConsumer.js) Reviewed-on: https://git.herisson.ovh/PGL/Clyde/pulls/53 Reviewed-by: Wal Reviewed-by: Maxime <231026@umons.ac.be> Co-authored-by: Anthony Debucquoy Co-committed-by: Anthony Debucquoy --- frontend/src/i18n.js | 18 ++----------- frontend/src/login.js | 1 + frontend/src/rest/restConsumer.js | 45 +++++++++++++++++++++++++++++++ frontend/src/utils.js | 17 ++++++++++++ 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 frontend/src/rest/restConsumer.js create mode 100644 frontend/src/utils.js diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 17fdbce..eaf2dac 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -9,6 +9,8 @@ * */ +import { getCookie } from './utils.js'; + const default_lang = "EN"; let langs; @@ -36,22 +38,6 @@ export default function i18n(key, options) { // Those functions are utility functions use by previous exported functions. // -/** - * Return the content of a cookie with specified key - * @param key cookie name - */ -function getCookie(key){ - key = key + "=" - let cookies = decodeURIComponent(document.cookie).split(";"); - for (let el of cookies) { - el = el.trimStart(); - if(el.indexOf(key) == 0){ - return el.substr(key.length, el.length); - } - } - return ""; -} - /** * Function that load the file with translation from the specified lang and return a dictionnary * @param select the language to load. could be null to fetch the cookies for an answer diff --git a/frontend/src/login.js b/frontend/src/login.js index 3ca2456..5e4180d 100644 --- a/frontend/src/login.js +++ b/frontend/src/login.js @@ -1,4 +1,5 @@ import './assets/main.css' +import 'vue3-toastify/dist/index.css'; import { createApp } from 'vue' import App from './Login.vue' diff --git a/frontend/src/rest/restConsumer.js b/frontend/src/rest/restConsumer.js new file mode 100644 index 0000000..25729bd --- /dev/null +++ b/frontend/src/rest/restConsumer.js @@ -0,0 +1,45 @@ +import { getCookie } from '../utils.js' +import { toast } from 'vue3-toastify' + +const restURL = import.meta.env.PROD ? "https://clyde.herisson.ovh/api" : "http://localhost:8080" + +export async function restGet(endPoint) { + return await _rest(endPoint, {method: "GET"}); +} + +export async function restPost(endPoint, data) { + return await _rest(endPoint, {method: "POST", body: data}); +} + +export async function restDelete(endPoint, data) { + return await _rest(endPoint, {method: "DELETE", body: data}); +} + +export async function restPatch(endPoint, data) { + return await _rest(endPoint, {method: "PATCH", body: data}); +} + +/** + * backbone for the request made by the frontend + * + * specification + * - If the user has "session_token" cookie set, it will use it in the authorization field of the http request + * - The result will be returned as a json to access fields easily ( the backend should send json response ) + * + * @Example _rest("/ping", {user: data}) -> {id:0, txt:"pong"} + */ +async function _rest(endPoint, config){ + endPoint.at(0) != "/" ? console.error("Carefull, you certainly should put a / at the begenning of your endPoint ") : true; + let session_token = getCookie("session_token"); + let headers = new Headers({'Authorization': session_token}); + config['headers'] = headers; + return toast.promise(fetch(restURL + endPoint, config), + { + pending: config['pending'] != null ? config['pending'] : 'pending', + error: config['error'] != null ? config['error'] : 'Network Failure...', + success: config['success'] != null ? config['success'] : {render(res){ + return res.ok ? "Success" : "error"; + }}, + }) + .then( e => e.json()).catch( e => e ); +} diff --git a/frontend/src/utils.js b/frontend/src/utils.js new file mode 100644 index 0000000..e79eec4 --- /dev/null +++ b/frontend/src/utils.js @@ -0,0 +1,17 @@ +/** + * Return the content of a cookie with specified key + * @param key cookie name + */ +function getCookie(key){ + key = key + "=" + let cookies = decodeURIComponent(document.cookie).split(";"); + for (let el of cookies) { + el = el.trimStart(); + if(el.indexOf(key) == 0){ + return el.substr(key.length, el.length); + } + } + return ""; +} + +export {getCookie};