diff --git a/README.md b/README.md index 8f43eef..8a577c8 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,30 @@ # hackathon -In order to launch any task (Maven compile, clean install ...) be sure to launch the Docker compose in the root directory with : +## Pour lancer +sudo docker compose up -d -docker compose up +### back_end +cd back_end -## Getting started +#### Pour installer java 17 +sudo apt install openjdk-17-jdk +export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 +export PATH=$JAVA_HOME/bin:$PATH -To make it easy for you to get started with GitLab, here's a list of recommended next steps. +#### Clean +mvn clean install -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +#### Pour lancer back_end +mvn spring-boot:run -## Add your files +### front_end +cd front_end -* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: +#### Install +npm install -``` -cd existing_repo -git remote add origin https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon.git -git branch -M main -git push -uf origin main -``` +#### Lancer front_end +npm start -## Integrate with your tools - -* [Set up project integrations](https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon/-/settings/integrations) - -## Collaborate with your team - -* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) -* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +#### Docker +sudo docker stop $(sudo docker ps -a -q) \ No newline at end of file diff --git a/back_end/compose.yaml b/back_end/compose.yaml deleted file mode 100644 index 7c8044f..0000000 --- a/back_end/compose.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - postgres: - image: 'postgres:latest' - environment: - - 'POSTGRES_DB=mydatabase' - - 'POSTGRES_PASSWORD=secret' - - 'POSTGRES_USER=myuser' - ports: - - '5432' diff --git a/back_end/pom.xml b/back_end/pom.xml index f9adb16..9823d1b 100644 --- a/back_end/pom.xml +++ b/back_end/pom.xml @@ -11,7 +11,7 @@ hackathon FrisbYEE 0.0.1-SNAPSHOT - war + jar FrisbYEE Demo project for Spring Boot @@ -35,60 +35,22 @@ org.springframework.boot spring-boot-starter-data-jpa - - org.springframework.boot - spring-boot-starter-security-oauth2-client - - - org.springframework.boot - spring-boot-starter-security-oauth2-resource-server - - - org.springframework.boot - spring-boot-starter-thymeleaf - org.springframework.boot spring-boot-starter-web - - org.thymeleaf.extras - thymeleaf-extras-springsecurity6 - org.postgresql postgresql runtime - org.projectlombok - lombok - true + org.springframework.boot + spring-boot-starter-security - org.springframework.boot - spring-boot-starter-tomcat - provided - - - org.springframework.boot - spring-boot-starter-data-jpa-test - test - - - org.springframework.boot - spring-boot-starter-security-oauth2-client-test - test - - - org.springframework.boot - spring-boot-starter-security-oauth2-resource-server-test - test - - - org.springframework.boot - spring-boot-starter-thymeleaf-test - test + org.springframework.boot + spring-boot-starter-oauth2-resource-server org.springframework.boot @@ -98,8 +60,7 @@ org.projectlombok lombok - 1.18.32 - provided + true org.springdoc diff --git a/back_end/src/main/java/hackathon/FrisbYEE/rest/ActiviteResource.java b/back_end/src/main/java/hackathon/FrisbYEE/rest/ActiviteResource.java index aefeed5..73a7930 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/ActiviteResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/ActiviteResource.java @@ -5,6 +5,12 @@ import hackathon.FrisbYEE.jpa.metier.Activite; import hackathon.FrisbYEE.jpa.metier.Session; import hackathon.FrisbYEE.jpa.service.ActiviteDAO; import hackathon.FrisbYEE.jpa.service.SessionDAO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -30,6 +36,12 @@ public class ActiviteResource { * */ + @Operation(summary = "Créer une activité") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Création effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @PostMapping("/create") @ResponseBody @PreAuthorize("hasRole('Coach')") @@ -46,6 +58,12 @@ public class ActiviteResource { return ResponseEntity.status(HttpStatus.CREATED).body("Activity created"); } + @Operation(summary = "Supprime l'activité ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Suppression effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @DeleteMapping("/delete/{id}") @ResponseBody @PreAuthorize("hasRole('Coach')") @@ -60,6 +78,12 @@ public class ActiviteResource { return ResponseEntity.ok("Activity deleted"); } + @Operation(summary = "Modifie l'activité ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Modification effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @PostMapping("/update/{id}") @ResponseBody @PreAuthorize("hasRole('Coach')") @@ -80,6 +104,12 @@ public class ActiviteResource { } + @Operation(summary = "Récupère l'activité ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @GetMapping("/{id}") @PreAuthorize("hasRole('Coach') or hasRole('Athlete')") @ResponseBody @@ -93,6 +123,12 @@ public class ActiviteResource { } } + @Operation(summary = "Récupère toutes les activités") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @GetMapping("/all") @PreAuthorize("hasRole('Coach') or hasRole('Athlete')") @ResponseBody @@ -107,6 +143,12 @@ public class ActiviteResource { } + @Operation(summary = "Récupère les activités correspondant au thème donné") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = ActiviteDTO.class))) + }) @GetMapping("/theme/{theme}") @PreAuthorize("hasRole('Coach') or hasRole('Athlete')") @ResponseBody diff --git a/back_end/src/main/java/hackathon/FrisbYEE/rest/AthleteResource.java b/back_end/src/main/java/hackathon/FrisbYEE/rest/AthleteResource.java index a0230f0..acbb466 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/AthleteResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/AthleteResource.java @@ -9,13 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.DeleteMapping; 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.PutMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestMapping; import hackathon.FrisbYEE.jpa.dto.ActiviteDTO; @@ -26,14 +26,23 @@ import hackathon.FrisbYEE.jpa.metier.Athlete; import hackathon.FrisbYEE.jpa.metier.Session; import hackathon.FrisbYEE.jpa.service.AthleteDAO; import hackathon.FrisbYEE.jpa.service.SessionDAO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; -@RestController -@RequestMapping("/athletes") +@Controller +@RequestMapping("/athlete") public class AthleteResource { @Autowired private AthleteDAO athleteDAO; private SessionDAO sessionDAO; + @Operation(summary = "Crée un Athlète avec les informations fournies") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Renvoie l'athlète créé", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class))) + }) @PostMapping("/create") @PreAuthorize("hasRole('Admin')") // Only admin can create?? public ResponseEntity create(@RequestBody AthleteDTO dto) { @@ -42,7 +51,11 @@ public class AthleteResource { return ResponseEntity.status(HttpStatus.CREATED).body(mapToDTO(athlete)); } - @PostMapping("/all") + @Operation(summary = "Récupère tous les athlètes") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupère tous les athlètes", content = @Content(mediaType = "application/json", schema = @Schema(implementation = List.class))) + }) + @GetMapping("/all") @PreAuthorize("hasRole('Admin') or hasRole('Coach') or hasRole('Athlete')") public ResponseEntity> all() { List athletes = athleteDAO.findAll(); @@ -53,6 +66,10 @@ public class AthleteResource { return ResponseEntity.ok(dtos); } + @Operation(summary = "Récupère l'athlète ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class))) + }) @GetMapping("/{id}") @PreAuthorize("hasRole('Admin') or hasRole('Coach') or hasRole('Athlete')") public ResponseEntity getById(@PathVariable Integer id) { @@ -61,9 +78,13 @@ public class AthleteResource { .orElse(ResponseEntity.notFound().build()); } + @Operation(summary = "Met à jour l'athlète ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Mise à jour effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class))) + }) @PutMapping("/{id}") @PreAuthorize("hasRole('ADMIN') or #id == principal.id") - public ResponseEntity update(@PathVariable Integer id,@RequestBody AthleteDTO dto) { + public ResponseEntity update(@PathVariable Integer id, @RequestBody AthleteDTO dto) { try { Athlete athlete = athleteDAO.findById(id).get(); athlete.setName(dto.getName()); @@ -83,11 +104,15 @@ public class AthleteResource { athleteDAO.save(athlete); return ResponseEntity.ok(mapToDTO(athlete)); - }catch (Exception ex){ + } catch (Exception ex) { return ResponseEntity.noContent().build(); } } + @Operation(summary = "Supprime l'athlète ayant l'identifiant correspondant") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Suppression effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class))) + }) @DeleteMapping("/{id}") @PreAuthorize("hasRole('Admin')") public ResponseEntity delete(@PathVariable Integer id) { @@ -116,15 +141,19 @@ public class AthleteResource { return athlete; } + @Operation(summary = "Récupère les sessions correspondant à l'athlète donné") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class))) + }) @GetMapping("/athlete/{id}/session") - public List getSessionsAthlete(@PathVariable Integer athleteId) { + public List getSessionsAthlete(@PathVariable Integer athleteId) { // return pet System.out.println("ID A CHERCHER" + athleteId); java.util.Optional j = athleteDAO.findById(athleteId); List sessions = sessionDAO.findAll(); List athleteSessions = new ArrayList<>(); - for(Session s : sessions){ - if(s.getAthletes().contains(j.get())){ + for (Session s : sessions) { + if (s.getAthletes().contains(j.get())) { SessionDTO dto = new SessionDTO(); dto.setId(s.getId()); dto.setName(s.getName()); @@ -135,9 +164,13 @@ public class AthleteResource { System.out.println(j); return athleteSessions; } - + + @Operation(summary = "Récupère toutes les sessions") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class))) + }) @GetMapping("/athletes/session") - public List getAllSessions() { + public List getAllSessions() { List sessions = sessionDAO.findAll(); System.out.println(sessions); List sessionDTOs = new ArrayList<>(); @@ -151,6 +184,10 @@ public class AthleteResource { return sessionDTOs; } + @Operation(summary = "Récupère les activités correspondant à la session donnée") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ActiviteDTO.class))) + }) @GetMapping("/athletes/session/{id}/activities") public List getActivitiesForSession(@PathVariable Integer id) { // Récupérer la session par ID @@ -171,6 +208,10 @@ public class AthleteResource { return new ArrayList<>(); } + @Operation(summary = "Récupère toutes les sessions après une date donnée") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class))) + }) @GetMapping("/athletes/{id}/session/after/{date}") public List getSessionsAfterDate(@PathVariable Integer id, @PathVariable String date) { // Récupérer l'athlète par ID @@ -181,7 +222,11 @@ public class AthleteResource { List sessions = sessionDAO.findAll(); List filteredSessions = new ArrayList<>(); for (Session session : sessions) { - if (session.getAthletes().contains(athlete) && session.getCreneau().isAfter(ChronoLocalDateTime.from(LocalDate.parse(date)))) { //WTF toujours sympa les dates + if (session.getAthletes().contains(athlete) + && session.getCreneau().isAfter(ChronoLocalDateTime.from(LocalDate.parse(date)))) { // WTF + // toujours + // sympa les + // dates SessionDTO dto = new SessionDTO(); dto.setId(session.getId()); dto.setName(session.getName()); @@ -194,8 +239,13 @@ public class AthleteResource { return new ArrayList<>(); } + @Operation(summary = "Récupère les sessions entre deux dates") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class))) + }) @GetMapping("/athletes/{id}/session/between/{startDate}/{endDate}") - public List getSessionsBetweenDates(@PathVariable Integer id, @PathVariable String startDate, @PathVariable String endDate) { + public List getSessionsBetweenDates(@PathVariable Integer id, @PathVariable String startDate, + @PathVariable String endDate) { // Récupérer l'athlète par ID java.util.Optional athleteOpt = athleteDAO.findById(id); if (athleteOpt.isPresent()) { @@ -204,7 +254,9 @@ public class AthleteResource { List sessions = sessionDAO.findAll(); List filteredSessions = new ArrayList<>(); for (Session session : sessions) { - if (session.getAthletes().contains(athlete) && session.getCreneau().isAfter(ChronoLocalDateTime.from(LocalDate.parse(startDate))) && session.getCreneau().isBefore(ChronoLocalDateTime.from(LocalDate.parse(endDate)))) { + if (session.getAthletes().contains(athlete) + && session.getCreneau().isAfter(ChronoLocalDateTime.from(LocalDate.parse(startDate))) + && session.getCreneau().isBefore(ChronoLocalDateTime.from(LocalDate.parse(endDate)))) { SessionDTO dto = new SessionDTO(); dto.setId(session.getId()); dto.setName(session.getName()); diff --git a/back_end/src/main/java/hackathon/FrisbYEE/rest/CoachResource.java b/back_end/src/main/java/hackathon/FrisbYEE/rest/CoachResource.java index c6027a9..bac7b21 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/CoachResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/CoachResource.java @@ -7,12 +7,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; import java.util.ArrayList; import java.util.List; +@Controller +@RequestMapping("/coach") public class CoachResource { @Autowired private CoachDAO coachDAO; @@ -49,7 +52,8 @@ public class CoachResource { public ResponseEntity update(@PathVariable Integer id, @RequestBody CoachDTO dto) { Coach coach = coachDAO.findById(id) .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Coach not found")); - if (dto.getName() != null) coach.setName(dto.getName()); + if (dto.getName() != null) + coach.setName(dto.getName()); coachDAO.save(coach); CoachDTO updatedDto = mapToDTO(coach); return ResponseEntity.ok(updatedDto); @@ -78,4 +82,3 @@ public class CoachResource { return coach; } } - diff --git a/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java b/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java index ec03899..03c542f 100644 --- a/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java +++ b/back_end/src/main/java/hackathon/FrisbYEE/rest/SessionResource.java @@ -13,13 +13,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import org.springframework.web.server.ResponseStatusException; import java.util.ArrayList; import java.util.List; -@RestController +@Controller @RequestMapping("/session") public class SessionResource { @@ -87,7 +88,7 @@ public class SessionResource { @PreAuthorize("hasRole('Coach')") public ResponseEntity updateSession(@PathVariable Integer id, @RequestBody SessionDTO dto) { Session session = sessionDAO.findById(id).orElseThrow(() -> new ResponseStatusException( - HttpStatus.NOT_FOUND, "Session not found with id " + id)); + HttpStatus.NOT_FOUND, "Session not found with id " + id)); if (dto.getDuree() != null) { session.setDuree(dto.getDuree()); diff --git a/back_end/src/main/resources/application.properties b/back_end/src/main/resources/application.properties index 655b818..f81f9e4 100644 --- a/back_end/src/main/resources/application.properties +++ b/back_end/src/main/resources/application.properties @@ -6,4 +6,6 @@ spring.datasource.driver-class-name=org.postgresql.Driver spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect -server.port=8081 \ No newline at end of file +server.port=8081 +spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8080/realms/Frisbyee_realm +spring.security.oauth2.resourceserver.jwt.jwk-set-uri: http://localhost:8080/realms/Frisbyee_realm/protocol/openid-connect/certs \ No newline at end of file diff --git a/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java b/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java new file mode 100644 index 0000000..38165dc --- /dev/null +++ b/back_end/src/test/java/hackathon/FrisbYEE/FrisbYeeApplicationTests.java @@ -0,0 +1,27 @@ +package hackathon.FrisbYEE; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.test.web.servlet.client.RestTestClient; + +import hackathon.FrisbYEE.rest.AthleteResource; + + +class FrisbYEEApplicationTests { + + //Controller + private AthleteResource athleteResource; + private RestTestClient mockMvc; + + @BeforeEach + void setUp() { + athleteResource = new AthleteResource(); + mockMvc = RestTestClient.bindToController(athleteResource).build(); + } + + @Test + void testGetUsers() throws Exception { + //mockMvc.perform(get("/api/users")) + // .andExpect(status().isOk()); + } +} diff --git a/backend.log b/backend.log new file mode 100644 index 0000000..92f49c0 --- /dev/null +++ b/backend.log @@ -0,0 +1,19 @@ +nohup: ignoring input +[INFO] Scanning for projects... +Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml +Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml +Progress (1): 3.4 kB Progress (1): 7.3 kB Progress (2): 7.3 kB | 4.6 kB Progress (2): 13 kB | 4.6 kB Progress (2): 13 kB | 9.9 kB Progress (2): 19 kB | 9.9 kB Progress (2): 20 kB | 9.9 kB Progress (2): 20 kB | 14 kB Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml (20 kB at 8.9 kB/s) +Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-metadata.xml (14 kB at 6.3 kB/s) +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD FAILURE +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 5.475 s +[INFO] Finished at: 2026-01-07T09:56:46+01:00 +[INFO] ------------------------------------------------------------------------ +[ERROR] No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/alexis/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1] +[ERROR] +[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. +[ERROR] Re-run Maven using the -X switch to enable full debug logging. +[ERROR] +[ERROR] For more information about the errors and possible solutions, please read the following articles: +[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException diff --git a/docker-compose.yml b/docker-compose.yml index aa785fe..8f1f05b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,12 @@ services: keycloak: - container_name: baeldung-keycloak.openid-provider + container_name: baeldung-keycloak image: quay.io/keycloak/keycloak:26.4 command: - start-dev - --import-realm ports: - - 8080:8080 + - "8080:8080" volumes: - ./keycloak/:/opt/keycloak/data/import/ environment: @@ -16,10 +16,6 @@ services: KC_HOSTNAME_URL: http://localhost:8080 KC_HOSTNAME_ADMIN_URL: http://localhost:8080 KC_HOSTNAME_STRICT_BACKCHANNEL: true - KC_HTTP_RELATIVE_PATH: / - KC_HTTP_ENABLED: true - KC_HEALTH_ENABLED: true - KC_METRICS_ENABLED: true extra_hosts: - "host.docker.internal:host-gateway" healthcheck: @@ -43,20 +39,3 @@ volumes: postgres_data: version: "3.9" - postgres: - image: postgres:16 - container_name: frisbyee-postgres - ports: - - "5432:5432" - environment: - POSTGRES_DB: frisbyee - POSTGRES_USER: frisbyee_user - POSTGRES_PASSWORD: secret - volumes: - - postgres_data:/var/lib/postgresql/data - -volumes: - postgres_data: - -version: "3.9" - diff --git a/front_end/package-lock.json b/front_end/package-lock.json index cfd5383..f9312ef 100644 --- a/front_end/package-lock.json +++ b/front_end/package-lock.json @@ -72,7 +72,6 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz", "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -722,7 +721,6 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.27.1.tgz", "integrity": "sha512-p9OkPbZ5G7UT1MofwYFigGebnrzGJacoBSQM0/6bi/PUMVE+qlWDD/OalvQKbwgQzU6dl0xAv6r4X7Jme0RYxA==", "license": "MIT", - "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" }, @@ -1606,7 +1604,6 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.27.1.tgz", "integrity": "sha512-2KH4LWGSrJIkVf5tSiBFYuXDAoWRq2MMwgivCf+93dd0GQi8RXLjKA/0EvRnVV5G0hrHczsquXuD01L8s6dmBw==", "license": "MIT", - "peer": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.27.1", "@babel/helper-module-imports": "^7.27.1", @@ -3378,7 +3375,6 @@ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", @@ -3758,7 +3754,6 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.7.tgz", "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", "license": "MIT", - "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -3768,7 +3763,6 @@ "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", "license": "MIT", - "peer": true, "peerDependencies": { "@types/react": "^19.2.0" } @@ -3883,7 +3877,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", "@typescript-eslint/scope-manager": "5.62.0", @@ -3937,7 +3930,6 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "license": "BSD-2-Clause", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "5.62.0", "@typescript-eslint/types": "5.62.0", @@ -4307,7 +4299,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4406,7 +4397,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -5327,7 +5317,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -7167,7 +7156,6 @@ "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -9923,7 +9911,6 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-27.5.1.tgz", "integrity": "sha512-Yn0mADZB89zTtjkPJEXwrac3LHudkQMR+Paqa8uxJHCBr9agxztUifWCyiYrjhMPBoUVBjyny0I7XH6ozDr7QQ==", "license": "MIT", - "peer": true, "dependencies": { "@jest/core": "^27.5.1", "import-local": "^3.0.2", @@ -10821,7 +10808,6 @@ "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", "license": "MIT", - "peer": true, "bin": { "jiti": "bin/jiti.js" } @@ -11025,7 +11011,6 @@ "resolved": "https://registry.npmjs.org/keycloak-js/-/keycloak-js-26.2.2.tgz", "integrity": "sha512-ug7pNZ1xNkd7PPkerOJCEU2VnUhS7CYStDOCFJgqCNQ64h53ppxaKrh4iXH0xM8hFu5b1W6e6lsyYWqBMvaQFg==", "license": "Apache-2.0", - "peer": true, "workspaces": [ "test" ] @@ -12185,7 +12170,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -13320,7 +13304,6 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", "license": "MIT", - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -13686,7 +13669,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -13818,7 +13800,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -13849,7 +13830,6 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -14296,7 +14276,6 @@ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "license": "MIT", - "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -14539,7 +14518,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -15786,6 +15764,23 @@ } } }, + "node_modules/tailwindcss/node_modules/yaml": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", + "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", + "license": "ISC", + "optional": true, + "peer": true, + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, "node_modules/tapable": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", @@ -16003,7 +15998,6 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -16172,7 +16166,6 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "license": "(MIT OR CC0-1.0)", - "peer": true, "engines": { "node": ">=10" }, @@ -16281,7 +16274,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -16596,7 +16588,6 @@ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.104.1.tgz", "integrity": "sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==", "license": "MIT", - "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", @@ -16668,7 +16659,6 @@ "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz", "integrity": "sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g==", "license": "MIT", - "peer": true, "dependencies": { "@types/bonjour": "^3.5.9", "@types/connect-history-api-fallback": "^1.3.5", @@ -17082,7 +17072,6 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", diff --git a/front_end/public/keycloak.json b/front_end/public/keycloak.json index 4f622b4..119260d 100644 --- a/front_end/public/keycloak.json +++ b/front_end/public/keycloak.json @@ -3,4 +3,4 @@ "resource": "Frisbyee_client", "auth-server-url": "http://localhost:8080", "public-client": true -} +} \ No newline at end of file diff --git a/front_end/src/api.ts b/front_end/src/api.ts index bafad8f..e6cd610 100644 --- a/front_end/src/api.ts +++ b/front_end/src/api.ts @@ -3,13 +3,76 @@ import keycloak from "./keycloak"; const api = axios.create({ baseURL: "http://localhost:8081/api", + headers: { + "Content-Type": "application/json", + }, }); api.interceptors.request.use((config) => { if (keycloak?.token) { + // eslint-disable-next-line no-param-reassign config.headers.Authorization = `Bearer ${keycloak.token}`; } return config; }); +export const athleteService = { + create: (data: any) => api.post("/athletes/create", data), + getAll: () => api.get("/athletes/all"), + getById: (id: number | string) => api.get(`/athletes/${id}`), + update: (id: number | string, data: any) => api.put(`/athletes/${id}`, data), + delete: (id: number | string) => api.delete(`/athletes/${id}`), + + // session-related endpoints exposed by AthleteResource + getSessionsForAthlete: (athleteId: number | string) => api.get(`/athletes/athlete/${athleteId}/session`), + getAllSessions: () => api.get(`/athletes/session`), + getActivitiesForSession: (sessionId: number | string) => api.get(`/athletes/session/${sessionId}/activities`), + getSessionsAfterDate: (athleteId: number | string, date: string) => api.get(`/athletes/${athleteId}/session/after/${encodeURIComponent(date)}`), + getSessionsBetweenDates: (athleteId: number | string, startDate: string, endDate: string) => api.get(`/athletes/${athleteId}/session/between/${encodeURIComponent(startDate)}/${encodeURIComponent(endDate)}`), +}; + +export const activiteService = { + create: (data: any) => api.post("/activite/create", data), + delete: (id: number | string) => api.delete(`/activite/delete/${id}`), + update: (id: number | string, data: any) => api.post(`/activite/update/${id}`, data), + getById: (id: number | string) => api.get(`/activite/${id}`), + getAll: () => api.get(`/activite/all`), + getByTheme: (theme: string) => api.get(`/activite/theme/${encodeURIComponent(theme)}`), +}; + +export const sessionService = { + // controller uses singular /session/* endpoints + create: (data: any) => api.post(`/session/create`, data), + getAll: () => api.get(`/session/all`), + getById: (id: number | string) => api.get(`/session/${id}`), + delete: (id: number | string) => api.delete(`/session/delete/${id}`), + update: (id: number | string, data: any) => api.put(`/session/update/${id}`, data), + + // plural variants used around the frontend (keep for compatibility) + createPlural: (data: any) => api.post(`/sessions`, data), + getAllPlural: () => api.get(`/sessions`), + getActivities: (sessionId: number | string) => api.get(`/sessions/${sessionId}/activities`), + addActivity: (sessionId: number | string, activity: any) => api.post(`/sessions/${sessionId}/activities`, activity), + subscribe: (sessionId: number | string, userId: number | string) => api.post(`/sessions/${sessionId}/subscribe`, { userId }), + unsubscribe: (sessionId: number | string, userId: number | string) => api.post(`/sessions/${sessionId}/unsubscribe`, { userId }), +}; + +export const coachService = { + // controller doesn't declare a class-level path consistently; support both common patterns + create: (data: any) => api.post(`/coach/create`, data), + getAll: () => api.get(`/coach/all`), + getById: (id: number | string) => api.get(`/coach/${id}`), + update: (id: number | string, data: any) => api.put(`/coach/update/${id}`, data), + delete: (id: number | string) => api.delete(`/coach/delete/${id}`), + + // plural convenience + createPlural: (data: any) => api.post(`/coaches`, data), + getAllPlural: () => api.get(`/coaches`), +}; + +export const userService = { + getById: (id: number | string) => api.get(`/users/${id}`), + getAll: () => api.get(`/users`), +}; + export default api; \ No newline at end of file diff --git a/front_end/src/components/login.tsx b/front_end/src/components/login.tsx index 8facb90..3a8d05a 100644 --- a/front_end/src/components/login.tsx +++ b/front_end/src/components/login.tsx @@ -29,7 +29,7 @@ export const Login =() =>{ return(
- Authenticated : {keycloak.authenticated ? '✅' : '❌'} + Authenticated : {keycloak.authenticated ? 'oui' : 'non'}