From ad0e7b3e354ac9d6bed0570ff18ada6432be06a8 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sat, 23 Mar 2024 14:08:03 +0100 Subject: [PATCH 01/56] =?UTF-8?q?-=20Ajoute=20un=20champ=20year=20dans=20U?= =?UTF-8?q?serCurriculum=20pour=20diff=C3=A9rencier=20les=20anciers=20curs?= =?UTF-8?q?us=20de=20l'actuel=20pour=20l'=C3=A9tudiant=20-=20Ajoute=20la?= =?UTF-8?q?=20table=20ExemptionsRequest=20-=20Ajoute=20la=20table=20Schola?= =?UTF-8?q?rshipRequest=20-=20Ajoute=20la=20table=20UninscriptionRequest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clyde/Services/InscriptionService.java | 2 +- .../Clyde/Tables/ExemptionsRequest.java | 66 +++++++++++++++++++ .../Clyde/Tables/ScholarshipRequest.java | 59 +++++++++++++++++ .../Clyde/Tables/UninscriptionRequest.java | 28 ++++++++ .../herisson/Clyde/Tables/UserCurriculum.java | 13 +++- frontend/src/Apps/AboutStudent.vue | 24 +++++++ 6 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java create mode 100644 frontend/src/Apps/AboutStudent.vue diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java index 311dbf2..48e2717 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java @@ -81,7 +81,7 @@ public class InscriptionService { ); userRepo.save(userFromRequest); - userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()))); + userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); } inscrRequest.setState(requestState); save(inscrRequest); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java new file mode 100644 index 0000000..1feacc8 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java @@ -0,0 +1,66 @@ +package ovh.herisson.Clyde.Tables; + + +import jakarta.persistence.*; + +@Entity +public class ExemptionsRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name = "Users") + private User user; + + @ManyToOne + @JoinColumn(name = "Course") + private Course course; + private String justifDocument; + + private RequestState state; + + + public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state){ + this.user = user; + this.course = course; + this.justifDocument = justifDocument; + this.state = state; + } + + + public ExemptionsRequest(){} + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } + + public String getJustifDocument() { + return justifDocument; + } + + public void setJustifDocument(String justifDocument) { + this.justifDocument = justifDocument; + } + + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java new file mode 100644 index 0000000..1182911 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ScholarshipRequest.java @@ -0,0 +1,59 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +@Entity +public class ScholarshipRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name = "Users") + private User user; + private RequestState state; + private String requestForm; + private int amount; + + + public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){ + this.user = user; + this.state = state; + this.requestForm = requestForm; + this.amount = amount; + } + + public ScholarshipRequest(){} + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } + + public String getRequestForm() { + return requestForm; + } + + public void setRequestForm(String requestForm) { + this.requestForm = requestForm; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java new file mode 100644 index 0000000..d2cbf73 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UninscriptionRequest.java @@ -0,0 +1,28 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class UninscriptionRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + private RequestState state; + + public UninscriptionRequest(RequestState state){ + this.state = state; + } + + public UninscriptionRequest(){} + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java index f42e588..b79295b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java @@ -21,9 +21,12 @@ public class UserCurriculum { @OnDelete(action = OnDeleteAction.CASCADE) private Curriculum curriculum; - public UserCurriculum(User user, Curriculum curriculum){ + private int year; + + public UserCurriculum(User user, Curriculum curriculum, int year){ this.user = user; this.curriculum = curriculum; + this.year = year; } public UserCurriculum() {} @@ -47,4 +50,12 @@ public class UserCurriculum { public void setCurriculum(Curriculum curriculum) { this.curriculum = curriculum; } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } } diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue new file mode 100644 index 0000000..442fd35 --- /dev/null +++ b/frontend/src/Apps/AboutStudent.vue @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file From 67fa630ecfbe0105212a04f8b4f3c8d7b55aacd4 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sat, 23 Mar 2024 18:04:36 +0100 Subject: [PATCH 02/56] e --- frontend/src/Apps/AboutStudent.vue | 84 +++++++++++++++++++++++++----- frontend/src/rest/apps.js | 3 ++ 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue index 442fd35..aaaeafc 100644 --- a/frontend/src/Apps/AboutStudent.vue +++ b/frontend/src/Apps/AboutStudent.vue @@ -1,24 +1,82 @@ - \ No newline at end of file diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index 99cbc10..44fb7c4 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 AboutStudent from "@/Apps/AboutStudent.vue"; const apps = { '/login': LoginPage, @@ -17,6 +18,7 @@ const apps = { '/manage-courses' : Courses, '/users-list' : Users, '/students-list' : Students, + '/about-students': AboutStudent } const appsList = { @@ -28,6 +30,7 @@ const appsList = { 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, 'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")}, 'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")}, + 'AboutStudent':{ path: '#/about-users', icon: 'fa-users', text:i18n("app.aboutStudent")} } const currentPath = ref(window.location.hash) From 2dfa0a0ee08b8e1c4b3dcf32e8a3b727227f42d2 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Fri, 22 Mar 2024 13:54:52 +0100 Subject: [PATCH 03/56] base msg --- frontend/src/Apps/Msg.vue | 37 +++++++++++++++++++++++++++++++++++++ frontend/src/rest/apps.js | 2 ++ frontend/src/rest/msg.js | 25 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 frontend/src/Apps/Msg.vue create mode 100644 frontend/src/rest/msg.js diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue new file mode 100644 index 0000000..feecdbe --- /dev/null +++ b/frontend/src/Apps/Msg.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index 99cbc10..b6568e8 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 Msg from "@/Apps/Msg.vue" const apps = { '/login': LoginPage, @@ -17,6 +18,7 @@ const apps = { '/manage-courses' : Courses, '/users-list' : Users, '/students-list' : Students, + '/msg' : Msg, } const appsList = { diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js new file mode 100644 index 0000000..648f231 --- /dev/null +++ b/frontend/src/rest/msg.js @@ -0,0 +1,25 @@ +/******************************************************* + * File: msg.js + * Author: Anthony Debucquoy + * Scope: Extension messagerie + * Description: Messages frontend api consumer + *******************************************************/ + +import { restGet } from './restConsumer.js' + +export async function getDiscussions(){ + return [ + { + id: 1, + name: "Discussion#1", + members: [1, 2, 3, 4], + }, + { + id: 2, + name: "Discussion#2", + members: [1, 4], + } + ] + return restGet("/discussions"); +} + From 7b9f021c243af94d7a6878aac3a1bc4e7fe26d30 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 23 Mar 2024 01:06:32 +0100 Subject: [PATCH 04/56] first version of the frontend for messages --- frontend/src/Apps/Msg.vue | 100 ++++++++++++++++++++++++++++++++++++-- frontend/src/rest/msg.js | 62 ++++++++++++++++++++++- 2 files changed, 158 insertions(+), 4 deletions(-) diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue index feecdbe..5a09e18 100644 --- a/frontend/src/Apps/Msg.vue +++ b/frontend/src/Apps/Msg.vue @@ -1,12 +1,35 @@ + + @@ -25,13 +48,84 @@ div#discList{ margin: 30px 0 30px 30px; background-color: rgba(255, 255, 255, 0.05); border-radius: 10px; + overflow: hidden; + padding: 10px; } +.discItem{ + color: darkorange; + display: flex; + font-family: sans-serif; + font-weight: bold; + height: 4vh; + margin: 5px; + border-radius: 0 30px 30px 0; + align-items: center; + justify-content: center; + border: 1px solid darkorange; +} + div#discussion{ + display: flex; + flex-direction: column; margin: 30px; background-color: rgba(255, 255, 255, 0.05); border-radius: 10px; } +#msgName{ + text-align: center; + display: block; + background-color: #0202f755; + border-radius: 5px; + color: white; + width: 75%; + margin: 30px auto; +} + +.discItem:hover{ + background-color: gray; +} + +#msgs{ + display: flex; + flex-grow: 1; + flex-direction: column; +} + +.msg { + background-color: aliceblue; + font-family: sans-serif; + margin: 10px; + padding: 5px; + border-radius: 3px; + max-width: 50%; + align-self: start; +} + +.msg[sender=true]{ + background-color: darkorange; + align-self: end; +} + +#messageBox{ + display: flex; + margin: 10px; + border-radius: 5px; +} + +#messageBox input[type="text"]{ + align-self: end; + flex-grow: 1; +} + +#messageBox input[type="submit"]{ + position: absolute; + right: 50px; + margin: 2px; + border: none; + padding: 0 10px; +} + diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js index 648f231..9f3bf3e 100644 --- a/frontend/src/rest/msg.js +++ b/frontend/src/rest/msg.js @@ -6,6 +6,9 @@ *******************************************************/ import { restGet } from './restConsumer.js' +import { ref } from 'vue' + +export const currentDiscussion = ref({}); export async function getDiscussions(){ return [ @@ -18,8 +21,65 @@ export async function getDiscussions(){ id: 2, name: "Discussion#2", members: [1, 4], + }, + { + id: 3, + name: "Discussion#3", + members: [1, 3], } ] - return restGet("/discussions"); + // return restGet("/discussions"); +} + +export async function fetchDiscussion(id){ + currentDiscussion.value = { + id: id, + name: "Discussion#2", + msgs: [ + { + id: 1, + author: 1, + sender: true, + attachment: null, + text: "Hello world!" + }, + { + id: 2, + author: 2, + sender: false, + attachment: null, + text: "Hello What?" + }, + { + id: 3, + author: 2, + sender: false, + attachment: null, + text: "You morron" + }, + { + id: 4, + author: 1, + sender: true, + attachment: null, + text: "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." + }, + // { + // id: 5, + // author: 1, + // sender: true, + // attachment: null, + // text: "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." + // }, + { + id: 6, + author: 2, + sender: false, + attachment: null, + text: "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." + } + ] + } + // currentDiscussion.value = restGet("/discussion/" + id); } From 66e7fa24a1478ba872b51680c497b0567870cbd7 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Mon, 25 Mar 2024 00:08:44 +0100 Subject: [PATCH 05/56] Adding the discussion architectures and creating new discussions --- backend/build.gradle.kts | 2 + .../EndPoints/Msg/MessagesController.java | 49 +++++++++++++++++++ .../Msg/DiscussionRepository.java | 14 ++++++ .../Clyde/Services/Msg/DiscussionService.java | 24 +++++++++ .../herisson/Clyde/Tables/Msg/Discussion.java | 44 +++++++++++++++++ .../java/ovh/herisson/Clyde/Tables/User.java | 7 +++ frontend/src/Apps/Msg.vue | 18 ++++++- frontend/src/rest/msg.js | 35 ++++++------- 8 files changed, 172 insertions(+), 21 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/Msg/DiscussionRepository.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Services/Msg/DiscussionService.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.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/EndPoints/Msg/MessagesController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java new file mode 100644 index 0000000..e5534f4 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java @@ -0,0 +1,49 @@ +package ovh.herisson.Clyde.EndPoints.Msg; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +import lombok.AllArgsConstructor; +import ovh.herisson.Clyde.Responses.UnauthorizedResponse; +import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Services.Msg.DiscussionService; +import ovh.herisson.Clyde.Tables.User; +import ovh.herisson.Clyde.Tables.Msg.Discussion; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +@AllArgsConstructor +public class MessagesController { + + private AuthenticatorService authServ; + private DiscussionService discServ; + + @GetMapping("/discussions") + public ResponseEntity> getDiscussions(@RequestHeader("Authorization") String token ){ + User user = authServ.getUserFromToken(token); + if(user == null){ + return new UnauthorizedResponse<>(null); + } + + Iterable mock = discServ.getOwned(authServ.getUserFromToken(token)); + + return new ResponseEntity<>(mock, HttpStatus.OK); + } + + @GetMapping("/discussion/{id}") + public ResponseEntity getDiscussion(@RequestHeader("Authorization") String token, @PathVariable long id){ + return null; // TODO + } + + @PostMapping("/discussion") + public ResponseEntity createDiscussion(@RequestHeader("Authorization") String token, @RequestBody Discussion data){ + return new ResponseEntity<>(discServ.create(data.getName(), authServ.getUserFromToken(token)), HttpStatus.OK); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Msg/DiscussionRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Msg/DiscussionRepository.java new file mode 100644 index 0000000..3e74cb4 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Msg/DiscussionRepository.java @@ -0,0 +1,14 @@ +package ovh.herisson.Clyde.Repositories.Msg; + +import java.util.List; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; + +import ovh.herisson.Clyde.Tables.Msg.Discussion; + +public interface DiscussionRepository extends CrudRepository{ + + @Query("SELECT d FROM Discussion d INNER JOIN FETCH d.members dm WHERE dm.id = ?1") + List findByMembership(long userid); +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/Msg/DiscussionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/Msg/DiscussionService.java new file mode 100644 index 0000000..e1b36e5 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/Msg/DiscussionService.java @@ -0,0 +1,24 @@ +package ovh.herisson.Clyde.Services.Msg; + +import org.springframework.stereotype.Service; + +import lombok.AllArgsConstructor; +import ovh.herisson.Clyde.Repositories.Msg.DiscussionRepository; +import ovh.herisson.Clyde.Tables.User; +import ovh.herisson.Clyde.Tables.Msg.Discussion; + +@Service +@AllArgsConstructor +public class DiscussionService { + + private DiscussionRepository discRepo; + + public Discussion create(String name, User author){ + return discRepo.save(new Discussion(name, author)); + } + + public Iterable getOwned(User author){ + return discRepo.findByMembership(author.getRegNo()); + } + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java new file mode 100644 index 0000000..57e5958 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java @@ -0,0 +1,44 @@ +package ovh.herisson.Clyde.Tables.Msg; + +import java.util.List; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import ovh.herisson.Clyde.Tables.User; + +@Entity +@Getter +@Setter +@NoArgsConstructor +public class Discussion{ + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + private String name; + + @ManyToMany + @JoinTable( + name = "discussion_members", + joinColumns = @JoinColumn(name = "discussion_id"), + inverseJoinColumns = @JoinColumn(name = "user_id") + ) + private List members; + + public Discussion(String name){ + this.name = name; + } + + public Discussion(String name, User user){ + this.name = name; + this.members = List.of(user); + } +} 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 de958df..300a58c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -1,7 +1,10 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.Msg.Discussion; + import java.util.Date; +import java.util.List; @Entity @@ -20,6 +23,10 @@ public class User { private String profilePictureUrl; private ovh.herisson.Clyde.Tables.Role role; private String password; + + @ManyToMany( mappedBy = "members" ) + private List discussions; + public User(String lastName, String firstName, String email, String address, String country, Date birthDate, String profilePictureUrl, Role role, String password) { diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue index 5a09e18..254df1d 100644 --- a/frontend/src/Apps/Msg.vue +++ b/frontend/src/Apps/Msg.vue @@ -7,9 +7,9 @@ @@ -17,6 +17,7 @@
{{ discussion.name }}
+

{{currentDiscussion.name}}

@@ -50,6 +51,8 @@ div#discList{ border-radius: 10px; overflow: hidden; padding: 10px; + display: flex; + flex-direction: column; } @@ -66,6 +69,17 @@ div#discList{ border: 1px solid darkorange; } +#createDiscussion{ + height: 4vh; + margin: 5px; + color: white; + background-color: green; + border-radius: 0 30px 30px 0; + border: none; + font-weight: 900; + font-size: 2em; +} + div#discussion{ display: flex; flex-direction: column; diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js index 9f3bf3e..06c084c 100644 --- a/frontend/src/rest/msg.js +++ b/frontend/src/rest/msg.js @@ -5,30 +5,19 @@ * Description: Messages frontend api consumer *******************************************************/ -import { restGet } from './restConsumer.js' +import { restGet, restPost } from './restConsumer.js' import { ref } from 'vue' export const currentDiscussion = ref({}); +/** + * @return array of + * - id + * - name + * - members + */ export async function getDiscussions(){ - return [ - { - id: 1, - name: "Discussion#1", - members: [1, 2, 3, 4], - }, - { - id: 2, - name: "Discussion#2", - members: [1, 4], - }, - { - id: 3, - name: "Discussion#3", - members: [1, 3], - } - ] - // return restGet("/discussions"); + return restGet("/discussions"); } export async function fetchDiscussion(id){ @@ -83,3 +72,11 @@ export async function fetchDiscussion(id){ // currentDiscussion.value = restGet("/discussion/" + id); } +export async function createDiscussion(name){ + restPost("/discussion", {name: name}); +} + + +export async function invite(id, regNo){ + restPost("/discussion/"+ id+ "/invite", {user: regNo}); +} From 914f6bdf365e0df43f03086121e428871764c9f8 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Mon, 25 Mar 2024 09:43:45 +0100 Subject: [PATCH 06/56] fix for new discussions not appearing right away --- frontend/src/Apps/Msg.vue | 4 ++-- frontend/src/rest/msg.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue index 254df1d..433300c 100644 --- a/frontend/src/Apps/Msg.vue +++ b/frontend/src/Apps/Msg.vue @@ -9,7 +9,7 @@ import { ref, reactive } from 'vue' import { getDiscussions, currentDiscussion, fetchDiscussion, createDiscussion } from '@/rest/msg.js' - const discussionsList = ref(await getDiscussions()); + const discussionsList = reactive(await getDiscussions()); @@ -17,7 +17,7 @@
{{ discussion.name }}
- +

{{currentDiscussion.name}}

diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js index 06c084c..1cecd42 100644 --- a/frontend/src/rest/msg.js +++ b/frontend/src/rest/msg.js @@ -73,7 +73,7 @@ export async function fetchDiscussion(id){ } export async function createDiscussion(name){ - restPost("/discussion", {name: name}); + return restPost("/discussion", {name: name}); } From eafff6ec2d9c2f605cc414f461e75289fd9add71 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 25 Mar 2024 09:57:35 +0100 Subject: [PATCH 07/56] =?UTF-8?q?Ajoute=20le=20d=C3=A9tail=20des=20=C3=A9t?= =?UTF-8?q?udiants=20(big=20update)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clyde/EndPoints/CurriculumController.java | 23 +++- .../Clyde/EndPoints/MockController.java | 17 ++- .../UserCurriculumRepository.java | 4 + .../Clyde/Services/CurriculumService.java | 1 - .../Clyde/Services/UserCurriculumService.java | 32 +++++- frontend/src/Apps/AboutStudent.vue | 106 ++++++++++++++++-- frontend/src/Apps/Profil.vue | 1 - frontend/src/Apps/StudentsList.vue | 21 +++- frontend/src/rest/apps.js | 2 - frontend/src/rest/curriculum.js | 4 + 10 files changed, 188 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java index 409e269..bef813a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -8,7 +8,9 @@ import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.Role; +import ovh.herisson.Clyde.Tables.User; +import java.util.HashMap; import java.util.Map; @RestController @@ -22,11 +24,14 @@ public class CurriculumController { private final UserCurriculumService userCurriculumServ; private final CurriculumCourseService curriculumCourseServ; - public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ){ + private final UserService userServ; + + public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, UserService userServ){ this.curriculumServ = curriculumServ; this.authServ = authServ; this.userCurriculumServ = userCurriculumServ; this.curriculumCourseServ = curriculumCourseServ; + this.userServ = userServ; } @GetMapping("/curriculum/{id}") @@ -52,6 +57,22 @@ public class CurriculumController { return new ResponseEntity<>(curriculumCourseServ.getDepthCurriculum(curriculum),HttpStatus.OK); } + + //Return the list of all curicullums of an user + @GetMapping("/onescurriculum/{userId}") + public ResponseEntity> findOnesCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){ + if (authServ.getUserFromToken(token) == null) + return new UnauthorizedResponse<>(null); + + User u = userServ.getUserById(Long.parseLong(userId)); + HashMap toReturn = userCurriculumServ.findAllCurriculumByStudent(u); + + if (toReturn == null) + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + + return new ResponseEntity<>(toReturn,HttpStatus.OK); + } + @GetMapping("/curriculums") public ResponseEntity>> findAllIndDepth(){ return new ResponseEntity<>(curriculumCourseServ.getAllDepthCurriculum(),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..76414ed 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -3,6 +3,7 @@ package ovh.herisson.Clyde.EndPoints; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.web.bind.annotation.*; import ovh.herisson.Clyde.Repositories.TokenRepository; +import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Services.*; import ovh.herisson.Clyde.Tables.*; @@ -26,8 +27,9 @@ public class MockController { public final InscriptionService inscriptionService; ArrayList mockUsers; + public final UserCurriculumRepository ucr; - 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, UserCurriculumRepository ucr){ this.tokenRepo = tokenRepo; this.userRepo = userRepo; this.tokenService = tokenService; @@ -35,6 +37,7 @@ public class MockController { this.curriculumService = curriculumService; this.courseService = courseService; this.inscriptionService = inscriptionService; + this.ucr = ucr; } /** Saves an example of each user type by : @@ -47,15 +50,14 @@ public class MockController { public void postMock(){ // user part - - User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin")); User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary")); User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService")); - mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo)); + User popo = new User("Smith", "Paul", "paulsmith@gmail.com", "306 rue du poulet", "belgique", new Date(0), null, Role.Student, passwordEncoder.encode("jesuispaulleroi")); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo, popo)); userRepo.saveAll(mockUsers); @@ -64,11 +66,18 @@ public class MockController { Curriculum infoBab1 = new Curriculum(1,"info"); Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); Curriculum psychologyBab1 = new Curriculum(1,"psychology"); + Curriculum infoBab2 = new Curriculum(2,"info"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); + curriculumService.save(infoBab2); + ucr.save(new UserCurriculum(joe, infoBab1, 2022)); + ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); + ucr.save(new UserCurriculum(joe, psychologyBab1, 2020)); + ucr.save(new UserCurriculum(popo, infoBab1, 2022)); + ucr.save(new UserCurriculum(popo, infoBab2, 2023)); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course chemistry1 = new Course(12, "Thermochimie",joke); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java index 32f207a..2f1c2a3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java @@ -6,8 +6,12 @@ import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.User; import ovh.herisson.Clyde.Tables.UserCurriculum; +import java.util.ArrayList; + public interface UserCurriculumRepository extends CrudRepository { @Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1") Curriculum findByUser(User student); + + ArrayList findByUserOrderByCurriculum(User student); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java index af04d78..790c51f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumService.java @@ -18,7 +18,6 @@ public class CurriculumService { public Curriculum findById(long id){ return curriculumRepo.findById(id); } - public void delete(Curriculum curriculum) { curriculumRepo.delete(curriculum); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java index 6484e2b..99c4669 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -1,20 +1,50 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.User; +import ovh.herisson.Clyde.Tables.UserCurriculum; + +import java.util.ArrayList; +import java.util.HashMap; @Service public class UserCurriculumService { private final UserCurriculumRepository userCurriculumRepository; + private final CurriculumRepository curriculumRepo; - public UserCurriculumService(UserCurriculumRepository userCurriculumRepository) { + public UserCurriculumService(UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepo) { this.userCurriculumRepository = userCurriculumRepository; + this.curriculumRepo = curriculumRepo; } public Curriculum findByUser(User student){ return userCurriculumRepository.findByUser(student); } + + public HashMap findAllCurriculumByStudent(User student) { + ArrayList list = userCurriculumRepository.findByUserOrderByCurriculum(student); + + ArrayList> curriculumlist = new ArrayList>(); + + for (int i = 0; i < list.size(); i++) { + HashMap element = new HashMap<>(); + Curriculum c = list.get(i).getCurriculum(); + + + element.put("curriculumId", c.getCurriculumId()); + element.put("year", c.getYear()); + element.put("option", c.getOption()); + element.put("dateyear", list.get(i).getYear()); + curriculumlist.add(element); + } + + HashMap toReturn = new HashMap(); + toReturn.put("curriculumList", curriculumlist); + return toReturn; + } + } diff --git a/frontend/src/Apps/AboutStudent.vue b/frontend/src/Apps/AboutStudent.vue index aaaeafc..52f0fe1 100644 --- a/frontend/src/Apps/AboutStudent.vue +++ b/frontend/src/Apps/AboutStudent.vue @@ -1,16 +1,29 @@ - \ No newline at end of file diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 3e2eacc..36f926a 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -210,7 +210,6 @@ \ No newline at end of file diff --git a/frontend/src/Apps/Inscription.vue b/frontend/src/Apps/Inscription.vue index 94a1811..b5a5333 100644 --- a/frontend/src/Apps/Inscription.vue +++ b/frontend/src/Apps/Inscription.vue @@ -2,9 +2,13 @@ import i18n from "@/i18n.js" import {ref} from 'vue' import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js' + import AboutRequest from "@/Apps/AboutRequest.vue"; const requests = ref(await getAllRegisters()); - console.log(requests); + let targetId = ""; + + //0 = liste, 1 = détails, 2 = sure? + let windowsState = ref(0); async function upPage(id,review){ await validateRegister(id,review); @@ -15,19 +19,29 @@ - @@ -42,7 +47,7 @@ div#msg{ height: 100%; display: grid; - grid-template-columns: 20% auto; + grid-template-columns: 20% auto 10%; } div#discList{ @@ -53,7 +58,17 @@ div#discList{ padding: 10px; display: flex; flex-direction: column; +} +div#members{ + margin: 30px 0; + border-radius: 10px 0 0 10px; + background-color: red; + background-color: rgba(255, 255, 255, 0.05); + overflow: hidden; + display: flex; + padding: 10px 0 0 10px; + flex-direction: column; } .InputTitle{ @@ -74,6 +89,19 @@ div#discList{ border: 1px solid darkorange; } +.memberItem{ + color: darkorange; + display: flex; + font-family: sans-serif; + font-weight: bold; + height: 4vh; + margin: 5px; + border-radius: 30px 0 0 30px; + align-items: center; + justify-content: center; + border: 1px solid darkorange; +} + #createDiscussion{ height: 4vh; margin: 5px; @@ -84,6 +112,17 @@ div#discList{ font-weight: 900; font-size: 2em; } +#addMembers{ + height: 4vh; + margin: 5px; + text-align: center; + color: white; + background-color: green; + border-radius: 30px 0 0 30px; + border: none; + font-weight: 900; + font-size: 2em; +} div#discussion{ display: flex; diff --git a/frontend/src/rest/msg.js b/frontend/src/rest/msg.js index d1a9521..a27161b 100644 --- a/frontend/src/rest/msg.js +++ b/frontend/src/rest/msg.js @@ -13,8 +13,8 @@ import { ref } from 'vue' * - name * - members */ -export const discussionsList = ref({}); -export const currentDiscussion = ref({}); +export const discussionsList = ref(); +export const currentDiscussion = ref([]); export async function createDiscussion(name){ @@ -24,7 +24,7 @@ export async function createDiscussion(name){ export async function invite(id, regNo){ - restPost("/discussion/"+ id+ "/invite", {user: regNo}); + restPatch("/discussion/"+ id+ "/add", {regNo: parseInt(regNo)}).then(() => fetchDiscussion(id)) } export async function sendMessage(id, content, responseId){ From a3c9d6a7c02318b6ec29c974050a07c5f24c8e8e Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Fri, 29 Mar 2024 10:55:59 +0100 Subject: [PATCH 13/56] Fix the profilepicture url issue (it wasn't sent to the db) add a prototype of a more generic uploadfile function in uploads.js makes the distinction between a master cursus and a bachelor cursus in display --- .../Clyde/EndPoints/MockController.java | 4 +++ frontend/src/Apps/AboutRequest.vue | 4 +-- frontend/src/Apps/Inscription.vue | 1 - frontend/src/Apps/Login.vue | 29 ++++++++++++++----- frontend/src/rest/Users.js | 8 +++-- frontend/src/rest/uploads.js | 14 ++++++++- 6 files changed, 46 insertions(+), 14 deletions(-) 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 df79ede..96e7be4 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -67,11 +67,15 @@ public class MockController { Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); Curriculum psychologyBab1 = new Curriculum(1,"psychology"); Curriculum infoBab2 = new Curriculum(2,"info"); + Curriculum masterinfo1 = new Curriculum(4, "info"); + Curriculum masterinfo2 = new Curriculum(5, "info"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); curriculumService.save(infoBab2); + curriculumService.save(masterinfo1); + curriculumService.save(masterinfo2); ucr.save(new UserCurriculum(joe, infoBab1, 2022)); ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); diff --git a/frontend/src/Apps/AboutRequest.vue b/frontend/src/Apps/AboutRequest.vue index c443ad0..a818e18 100644 --- a/frontend/src/Apps/AboutRequest.vue +++ b/frontend/src/Apps/AboutRequest.vue @@ -9,10 +9,10 @@ let request = await getRegisters(props.target); const cursus = await getcurriculum(request.curriculum); function getPP(){ - if(request.profilePicture === null){ + if(request.profilePictureUrl === null){ return "/Clyde.png" } - return request.profilePicture; + return request.profilePictureUrl; } diff --git a/frontend/src/Apps/Inscription.vue b/frontend/src/Apps/Inscription.vue index 6f79966..b02cfcd 100644 --- a/frontend/src/Apps/Inscription.vue +++ b/frontend/src/Apps/Inscription.vue @@ -13,7 +13,6 @@ async function upPage(id,review){ await validateRegister(id,review); requests.value = await getAllRegisters(); - } diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index cf68d13..036b6fb 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -24,9 +24,12 @@ const submitValue= ref(i18n("login.guest.submit")) const passwordConfirm=ref("") - + + //Allows to display MA or BAB for years + let yearprefix = ""; + const imageSaved = ref(false) - const ppData = ref(false) + let ppData = ""; const curricula= await getAllCurriculums(); @@ -50,7 +53,20 @@ disconnect(); window.location.reload();} - + async function uploadPP(arg){ + const data = await uploadProfilePicture(arg); + ppData = data.url; + console.log(ppData); + } + + //This functions makes the distinction between a master cursus (year 4 or more) and a bachelor cursus (year 3 or less) + function getCursusDisplay(cursus){ + if (cursus.year <= 3){ + return "BAB " + cursus.year + " " + cursus.option; + }else{ + return "MA" + (parseInt(cursus.year)-3).toString() + " " + cursus.option; + } + } @@ -130,16 +146,16 @@

{{i18n("profile.picture").toUpperCase()}}

- +

{{i18n("Curriculum").toUpperCase()}}

-
@@ -153,7 +169,6 @@
Carte d'identité : -
diff --git a/frontend/src/rest/Users.js b/frontend/src/rest/Users.js index 760bfc7..6d9d05b 100644 --- a/frontend/src/rest/Users.js +++ b/frontend/src/rest/Users.js @@ -26,7 +26,7 @@ export function disconnect(){ * @param curriculum * @param imageId id of the image in database returned when uploaded */ -export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId){ +export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId, identityCardId, submissionDate){ return restPost("/register", { firstName: firstname, lastName: lastname, @@ -36,7 +36,9 @@ export async function register(firstname, lastname, birthDate, password, email, address: address, country: country, curriculumId: curriculumId, - profilePictureUrl: imageId, + profilePicture: imageId, + identityCard : identityCardId, + submissionDate : submissionDate }); } @@ -52,7 +54,7 @@ export async function register(firstname, lastname, birthDate, password, email, * @param country * @param imageId id of the image in database returned when uploaded * - * PS: the password is not is not required as it is generated by the backend and sent to the user + * PS: the password is not required as it is generated by the backend and sent to the user * by mail. it's up to the user to change it if he cares about security */ export async function createUser(firstname, lastname, birthDate, email, address, country, role, imageId){ diff --git a/frontend/src/rest/uploads.js b/frontend/src/rest/uploads.js index 48623cf..856024d 100644 --- a/frontend/src/rest/uploads.js +++ b/frontend/src/rest/uploads.js @@ -7,5 +7,17 @@ import { restPostFile } from '@/rest/restConsumer.js' export async function uploadProfilePicture(file){ const formData = new FormData(); formData.append("file", file[0]); - return restPostFile("/upload/ProfilePicture", formData) + + return restPostFile("/upload/ProfilePicture", formData); } + + +/** + * More generic version of the upload method + */ + +export async function uploadFile(file, type){ + const formData = new FormData(); + formData.append("file", file[0]); + return restPostFile("/upload/"+type, formData) +} \ No newline at end of file From 2bdffe6ab4962d660a6302e114b2028f8f439aef Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Fri, 29 Mar 2024 14:30:46 +0100 Subject: [PATCH 14/56] remove member of a discussion --- .../Clyde/EndPoints/Msg/MessagesController.java | 16 +++++++++++++++- .../herisson/Clyde/Tables/Msg/Discussion.java | 4 ++++ frontend/src/Apps/Msg.vue | 17 +++++++++++++++-- frontend/src/rest/msg.js | 4 ++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java index 8cee27c..591e172 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Msg/MessagesController.java @@ -65,7 +65,7 @@ public class MessagesController { } @PatchMapping("/discussion/{id}/add") - public ResponseEntity AlterDiscussion(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody User data){ + public ResponseEntity invite(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody User data){ User user = authServ.getUserFromToken(token); if(user == null){ return new UnauthorizedResponse<>(null); @@ -78,6 +78,20 @@ public class MessagesController { return new ResponseEntity<>(disc, HttpStatus.OK); } + @PatchMapping("/discussion/{id}/remove") + public ResponseEntity removeMember(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody User data){ + User user = authServ.getUserFromToken(token); + if(user == null){ + return new UnauthorizedResponse<>(null); + } + + Discussion disc = discRepo.findById(id).orElse(null); + User member = userServ.getUserById(data.getRegNo()); + disc.delMember(member); + discRepo.save(disc); + return new ResponseEntity<>(disc, HttpStatus.OK); + } + @PostMapping("/discussion/{id}") public ResponseEntity sendMessage(@RequestHeader("Authorization") String token, @PathVariable long id, @RequestBody Message msg){ User user = authServ.getUserFromToken(token); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java index e98bd1e..ee0912e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Msg/Discussion.java @@ -55,4 +55,8 @@ public class Discussion{ public void addMember(User user) { members.add(user); } + + public void delMember(User user) { + members.remove(user); + } } diff --git a/frontend/src/Apps/Msg.vue b/frontend/src/Apps/Msg.vue index b74f980..a5aa1f4 100644 --- a/frontend/src/Apps/Msg.vue +++ b/frontend/src/Apps/Msg.vue @@ -7,7 +7,7 @@ @@ -164,7 +168,7 @@ changer de cursus/réinscription sinon continuez ici.

-
@@ -249,7 +253,6 @@ .switchpage{ width:100px; - background:rgb(255, 0,255); border: none; padding-right:0; padding-top:10px; diff --git a/frontend/src/Apps/StudentsList.vue b/frontend/src/Apps/StudentsList.vue index ded264b..62f4acb 100644 --- a/frontend/src/Apps/StudentsList.vue +++ b/frontend/src/Apps/StudentsList.vue @@ -12,7 +12,7 @@