Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/tuvu/hackathon
This commit is contained in:
105
README.md
105
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)
|
||||
@@ -1,9 +0,0 @@
|
||||
services:
|
||||
postgres:
|
||||
image: 'postgres:latest'
|
||||
environment:
|
||||
- 'POSTGRES_DB=mydatabase'
|
||||
- 'POSTGRES_PASSWORD=secret'
|
||||
- 'POSTGRES_USER=myuser'
|
||||
ports:
|
||||
- '5432'
|
||||
@@ -11,7 +11,7 @@
|
||||
<groupId>hackathon</groupId>
|
||||
<artifactId>FrisbYEE</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<packaging>jar</packaging>
|
||||
<name>FrisbYEE</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<url/>
|
||||
@@ -35,60 +35,22 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security-oauth2-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security-oauth2-resource-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.thymeleaf.extras</groupId>
|
||||
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security-oauth2-client-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security-oauth2-resource-server-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -98,8 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.32</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
|
||||
@@ -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;
|
||||
@@ -32,21 +32,17 @@ 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)))
|
||||
@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<AthleteDTO> create(@RequestBody AthleteDTO dto) {
|
||||
@@ -57,9 +53,7 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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')")
|
||||
@@ -74,9 +68,7 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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')")
|
||||
@@ -88,13 +80,11 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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<AthleteDTO> update(@PathVariable Integer id,@RequestBody AthleteDTO dto) {
|
||||
public ResponseEntity<AthleteDTO> update(@PathVariable Integer id, @RequestBody AthleteDTO dto) {
|
||||
try {
|
||||
Athlete athlete = athleteDAO.findById(id).get();
|
||||
athlete.setName(dto.getName());
|
||||
@@ -114,16 +104,14 @@ 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)))
|
||||
@ApiResponse(responseCode = "200", description = "Suppression effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AthleteDTO.class)))
|
||||
})
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("hasRole('Admin')")
|
||||
@@ -155,19 +143,17 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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<SessionDTO> getSessionsAthlete(@PathVariable Integer athleteId) {
|
||||
public List<SessionDTO> getSessionsAthlete(@PathVariable Integer athleteId) {
|
||||
// return pet
|
||||
System.out.println("ID A CHERCHER" + athleteId);
|
||||
java.util.Optional<Athlete> j = athleteDAO.findById(athleteId);
|
||||
List<Session> sessions = sessionDAO.findAll();
|
||||
List<SessionDTO> 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());
|
||||
@@ -178,15 +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)))
|
||||
@ApiResponse(responseCode = "200", description = "Récupération effectuée", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SessionDTO.class)))
|
||||
})
|
||||
@GetMapping("/athletes/session")
|
||||
public List<SessionDTO> getAllSessions() {
|
||||
public List<SessionDTO> getAllSessions() {
|
||||
List<Session> sessions = sessionDAO.findAll();
|
||||
System.out.println(sessions);
|
||||
List<SessionDTO> sessionDTOs = new ArrayList<>();
|
||||
@@ -202,9 +186,7 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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<ActiviteDTO> getActivitiesForSession(@PathVariable Integer id) {
|
||||
@@ -228,9 +210,7 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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<SessionDTO> getSessionsAfterDate(@PathVariable Integer id, @PathVariable String date) {
|
||||
@@ -242,7 +222,11 @@ public class AthleteResource {
|
||||
List<Session> sessions = sessionDAO.findAll();
|
||||
List<SessionDTO> 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());
|
||||
@@ -257,12 +241,11 @@ public class AthleteResource {
|
||||
|
||||
@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)))
|
||||
@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<SessionDTO> getSessionsBetweenDates(@PathVariable Integer id, @PathVariable String startDate, @PathVariable String endDate) {
|
||||
public List<SessionDTO> getSessionsBetweenDates(@PathVariable Integer id, @PathVariable String startDate,
|
||||
@PathVariable String endDate) {
|
||||
// Récupérer l'athlète par ID
|
||||
java.util.Optional<Athlete> athleteOpt = athleteDAO.findById(id);
|
||||
if (athleteOpt.isPresent()) {
|
||||
@@ -271,7 +254,9 @@ public class AthleteResource {
|
||||
List<Session> sessions = sessionDAO.findAll();
|
||||
List<SessionDTO> 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());
|
||||
|
||||
@@ -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<CoachDTO> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Void> 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());
|
||||
|
||||
@@ -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
|
||||
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
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
19
backend.log
Normal file
19
backend.log
Normal file
@@ -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
|
||||
@@ -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"
|
||||
|
||||
|
||||
45
front_end/package-lock.json
generated
45
front_end/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
"resource": "Frisbyee_client",
|
||||
"auth-server-url": "http://localhost:8080",
|
||||
"public-client": true
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,5 @@
|
||||
background-color: var(--tint4);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import './App.css';
|
||||
import { ReactKeycloakProvider } from '@react-keycloak/web'
|
||||
import keycloak from './keycloak'
|
||||
@@ -15,7 +15,10 @@ const keycloakInitOptions = {
|
||||
checkLoginIframe: false
|
||||
}
|
||||
|
||||
|
||||
function App() {
|
||||
|
||||
|
||||
return (
|
||||
<ReactKeycloakProvider authClient={keycloak} /*initOptions={keycloakInitOptions}*/>
|
||||
<LocalDataProvider>
|
||||
|
||||
@@ -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;
|
||||
@@ -24,7 +24,7 @@ export class Session{
|
||||
id!: number;
|
||||
name!: String;
|
||||
activites: Activite[] = [];
|
||||
isRecurent! : Boolean;
|
||||
isRecurrent! : Boolean;
|
||||
creneau!: Date;
|
||||
coach!: Coach;
|
||||
athletes!: Athlete[]
|
||||
|
||||
@@ -37,7 +37,7 @@ export const CreateSession = () => {
|
||||
newSession.groupe = groupe;
|
||||
newSession.creneau = new Date(creneau);
|
||||
newSession.duree= duree;
|
||||
newSession.isRecurent= isRecurent;
|
||||
newSession.isRecurrent= isRecurent;
|
||||
newSession.coach= user as Coach;
|
||||
newSession.athletes= [];
|
||||
newSession.activites= activities;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useLocalData } from "../context/useLocalData"
|
||||
import './style/edt.css';
|
||||
import {updateSessionsOfUserAPI } from "../requetes";
|
||||
import EdtSession from "./edt_session";
|
||||
|
||||
import {delay} from "../requetes";
|
||||
import Loading from "./loading";
|
||||
|
||||
export function dateToString(date:Date){
|
||||
const dd_prefix = date.getDate()<10 ? "0" : "";
|
||||
@@ -28,11 +29,14 @@ export const EDT =() =>{
|
||||
const {user,setUser} = useLocalData()
|
||||
const [sessions, setSessions] = useState<Session[]>([])
|
||||
const [week,setWeek] = useState<Date>(getFirstDay(new Date()));
|
||||
const [loadedWeek,setLoadedWeek] = useState<Date|null>(null);
|
||||
const [loading,setLoading] = useState<boolean>(false);
|
||||
const week_days:String[] = ["Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"];
|
||||
const week_days_nums:number[] = [1,2,3,4,5,6,0];
|
||||
|
||||
|
||||
|
||||
|
||||
function loadSessions(date:Date){
|
||||
var maxDate = getNextDay(date,6)
|
||||
|
||||
@@ -47,18 +51,39 @@ export const EDT =() =>{
|
||||
|
||||
function changeWeek(date:Date){
|
||||
setWeek(date);
|
||||
loadSessions(date)
|
||||
}
|
||||
|
||||
function isSameDay(date1:Date,date2:Date){
|
||||
return (
|
||||
date1.getDay()===date2.getDay() &&
|
||||
date1.getMonth()===date2.getMonth() &&
|
||||
date1.getFullYear()===date2.getFullYear());
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
updateWeek();
|
||||
},[week])
|
||||
setLoadedWeek(null);
|
||||
updateWeek(week);
|
||||
loadSessions(week)
|
||||
setLoading(true);
|
||||
},[week,user])
|
||||
|
||||
useEffect(() => {
|
||||
if(loadedWeek!==null){
|
||||
if(isSameDay(week,loadedWeek)){
|
||||
loadSessions(week)
|
||||
setLoading(false);
|
||||
}
|
||||
else{
|
||||
setLoadedWeek(null);
|
||||
}
|
||||
}
|
||||
},[loadedWeek])
|
||||
|
||||
async function updateWeek(){
|
||||
async function updateWeek(week:Date){
|
||||
//TODO updateSession
|
||||
await delay(2000);
|
||||
//await updateSessionsOfUser(user,null,null);
|
||||
loadSessions(week);
|
||||
setUser(getUserTest())
|
||||
setLoadedWeek(week);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,20 +115,20 @@ export const EDT =() =>{
|
||||
|
||||
|
||||
return(
|
||||
<div className="edt">
|
||||
<div className="edt">
|
||||
<div className="edt_header">
|
||||
<button className="edt_button_week_select" onClick={() =>handlePrev()}>Prev</button>
|
||||
<button className="edt_button_week_select" onClick={() => handleNext()}>Next</button>
|
||||
</div>
|
||||
<div className="edt_colonnes">
|
||||
|
||||
<div className="edt_loading">{loading && <Loading/>}</div>
|
||||
{week_days_nums.map((num,index)=>(
|
||||
<div className="edt_colonne">
|
||||
<div className="edt_day_header">
|
||||
<div> {week_days[index]} </div>
|
||||
<div className="edt_date"> {dateToString(getNextDay(week,index))} </div>
|
||||
</div>
|
||||
<div className="edt_day_contedt">
|
||||
<div className="edt_day_content">
|
||||
{sessions.map((session,index2)=>(
|
||||
session.creneau.getDay()===num &&
|
||||
<EdtSession session={session}/>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { dateToString, hoursToString } from './edt';
|
||||
import './style/edt.css';
|
||||
import { Modal } from './Modal';
|
||||
import Loading from './loading';
|
||||
import {delay} from "../requetes";
|
||||
|
||||
|
||||
type Props = {
|
||||
@@ -21,6 +22,7 @@ function EdtSession({session}:Props){
|
||||
|
||||
async function updateActivites(){
|
||||
//TODO
|
||||
await delay(2000);
|
||||
//await updateActivitiesOfSessionAPI(session);
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -37,19 +39,24 @@ function EdtSession({session}:Props){
|
||||
return(
|
||||
<div>
|
||||
<div className="edt_session" onClick={() => handleOpen()}>
|
||||
<div className="edt_date">{hoursToString(sDate)}</div>
|
||||
<div className="edt_session_header">
|
||||
<div className="edt_date">{hoursToString(sDate)}</div>
|
||||
{!session.isRecurrent && <div className="edt_date"> recurrent</div>}
|
||||
</div>
|
||||
<div>{session.name}</div>
|
||||
</div>
|
||||
{open &&
|
||||
<Modal isOpen={open} onClose={() => setOpen(false)}>
|
||||
<div>{session.name}</div>
|
||||
<div>{hoursToString(sDate)}</div>
|
||||
<div>{dateToString(sDate)}</div>
|
||||
{session.activites.map((activite,index)=>(
|
||||
<div>activite</div>
|
||||
))}
|
||||
|
||||
{loading && <Loading/>}
|
||||
<div className="edt_session_modal">
|
||||
<div>{session.name}</div>
|
||||
<div>{hoursToString(sDate)}</div>
|
||||
<div>{dateToString(sDate)}</div>
|
||||
{session.activites.map((activite,index)=>(
|
||||
<div>activite</div>
|
||||
))}
|
||||
{loading && <div className='edt_loading'><Loading/></div>}
|
||||
</div>
|
||||
|
||||
</Modal>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,40 @@
|
||||
import { useKeycloak } from '@react-keycloak/web'
|
||||
import { useEffect } from 'react';
|
||||
import { getUserTest, User } from '../classes';
|
||||
import { useLocalData } from '../context/useLocalData';
|
||||
|
||||
|
||||
|
||||
|
||||
export const Login =() =>{
|
||||
const {user,setUser} = useLocalData()
|
||||
|
||||
|
||||
useEffect(() => { //TODO à supprimer
|
||||
setUser(getUserTest())
|
||||
},[]);
|
||||
|
||||
|
||||
function handleLogin(): void {
|
||||
keycloak.login()
|
||||
//TODO setUser
|
||||
}
|
||||
|
||||
function handleLogout(): void {
|
||||
keycloak.logout()
|
||||
setUser(new User());
|
||||
}
|
||||
|
||||
const { keycloak } = useKeycloak()
|
||||
return(
|
||||
<div>
|
||||
<div>
|
||||
Authenticated : {keycloak.authenticated ? '✅' : '❌'}
|
||||
Authenticated : {keycloak.authenticated ? 'oui' : 'non'}
|
||||
</div>
|
||||
<button onClick={() => keycloak.login()}>
|
||||
<button onClick={() => handleLogin()}>
|
||||
Se connecter
|
||||
</button>
|
||||
<button onClick={() => keycloak.logout()}>
|
||||
<button onClick={() => handleLogout()}>
|
||||
Se déconnecter
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,56 +1,74 @@
|
||||
.edt{
|
||||
justify-contedt: cedter;
|
||||
justify-content: center;
|
||||
background-color: var(--tint1);
|
||||
border-radius: 30px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
||||
.edt_header{
|
||||
justify-contedt: cedter;
|
||||
justify-content: center;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-columns: repeat(2, 0.5fr);
|
||||
/* background-color: #0000FF; */
|
||||
padding-bottom: 10px;
|
||||
gap: 30%;
|
||||
}
|
||||
|
||||
.edt_colonnes {
|
||||
position: relative;
|
||||
display: grid;
|
||||
align-items: flex-start;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
color: var(--text);
|
||||
/* background-color: #00FF00; */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.edt_loading{
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
/* place-items: center; */
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.edt_colonne {
|
||||
display: grid;
|
||||
background-color: var(--tint3);
|
||||
border-radius: 20px;
|
||||
container-type: inline-size;
|
||||
}
|
||||
.edt_day_header{
|
||||
font-size: clamp(5px, 1vw, 18px);
|
||||
padding: 8px;
|
||||
/* background-color: var(--tint2); */
|
||||
border-radius: 20px;
|
||||
height: 30px;
|
||||
text-align: cedter;
|
||||
text-align: center;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.edt_day_contedt{
|
||||
display: grid;
|
||||
.edt_day_content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
border-radius: 20px;
|
||||
min-width: 0;
|
||||
/* background-color: #FF0000; */
|
||||
}
|
||||
|
||||
|
||||
.edt_session {
|
||||
|
||||
font-size: clamp(1px, 8cqi, 18px);
|
||||
gap: 8px;
|
||||
background-color: var(--tint4);
|
||||
border-radius: 12px;
|
||||
padding: 8px;
|
||||
padding: 5%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.edt_session:hover {
|
||||
@@ -61,6 +79,11 @@
|
||||
background-color: var(--tint5);
|
||||
}
|
||||
|
||||
.edt_session_header{
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.edt_date{
|
||||
font-size: 0.75em;
|
||||
}
|
||||
@@ -72,3 +95,11 @@
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
|
||||
.edt_session_modal{
|
||||
background-color: var(--tint2);
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,16 +49,14 @@ code {
|
||||
}
|
||||
|
||||
.modal{
|
||||
background-color: var(--tint2);
|
||||
padding: 10px;
|
||||
border-radius: 20px;
|
||||
min-width: 200px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.loading{
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,21 @@ import api from "./api";
|
||||
import { Activite, Athlete, Coach, Session, User } from "./classes";
|
||||
import { useKeycloak } from '@react-keycloak/web'
|
||||
|
||||
const { keycloak } = useKeycloak()
|
||||
/*const { keycloak } = useKeycloak()
|
||||
|
||||
const useAuthHeader = () => {
|
||||
return keycloak?.token
|
||||
? { Authorization: `Bearer ${keycloak.token}` }
|
||||
: {}
|
||||
}*/
|
||||
|
||||
//debug:
|
||||
export function delay(ms: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
|
||||
|
||||
//UPDATE /////////////////////////////////////////////////////////
|
||||
|
||||
//COACH / ATHLETE
|
||||
|
||||
Reference in New Issue
Block a user