Skip to content

Commit

Permalink
Merge pull request #40 from CodeURJC-DAW-2022-23/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
BraisCabo authored Apr 17, 2023
2 parents 092b0af + 41c376a commit b7f1267
Show file tree
Hide file tree
Showing 98 changed files with 45,299 additions and 14 deletions.
160 changes: 159 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Key Whale

### Video:
https://youtu.be/EwkY_QF8p4E
## Table of contents

- [Phase 0](#phase-0)
Expand Down Expand Up @@ -560,4 +562,160 @@ Javier has created the class diagram updated with rest api and necesary methods
| #2 | [UserProfile](code/backend/src/main/java/app/model/modelRest/UserProfile.java) |
| #3 | [ClassDiagram](screenshots/DiagramaDeClases3.png)|
| #4 | [Readme](README.md) |
| #5 | |

# Phase 4

## Preparation of the development environment

1. Install Docker Desktop.
2. Create and account on Dockerhub.
3. Open any shell of type "bash".
4. Clone this repository using the command "git clone https://github.com/CodeURJC-DAW-2022-23/webapp5.git".
5. Use command "cd webapp5/code/docker" .
6. Execute the command "docker-compose up" on the shell.
7. Open another shell in the root of the project.
8. Execute the command "cd code/frontend".
9. Execute the command "npm install".
10. Execute the command "npm start".

## SPA class diagram and templates

![diagram](screenshots/DiagramaClases3.png)

## Deployment link

https://10.100.139.196:8443/new/
https://10.100.139.196:8443/

## Group members participation
### Brais Cabo Felpete
#### Textual description:
Brais has done the dockerfile to deploy the angular app, in the angular project he seted the project up and did the register and the navbar. He also implemented the register, the app routing, the security and the component to edit the user.

#### The five most important commits:

| Commit number | Description | Link |
| ------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| #1 | Docker Deployment | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/e8485fb155545a3ee90ab826b286ea44467c1cf8 |
| #2 | App Routing | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/66330871e3426344c839093b7cdc8d054a1ee0ee |
| #3 | Register Page | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/bcdd6f965cc4c2a14274b78d3a24b472b9caefb9 |
| #4 | Login | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/bcdd6f965cc4c2a14274b78d3a24b472b9caefb9 |
| #5 | Edit Profile | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/281f73454c09c08278e825306e6028a0bad08de7 |


#### The five most participated files:

| File number | File |
| ------------- | ------------------ |
| #1 | [Dockerfile](code/docker/Dockerfile) |
| #2 | [docker-compose.yml](code/docker/docker-compose.yml) |
| #3 | [GameComponent](code/frontend/src/app/components/games/game-page.component.ts) |
| #4 | [MainPage](code/frontend/src/app/components/games/games.component.ts) |
| #5 | [Register](code/frontend/src/app/components/auth/register.component.html) |


### Sergio Octavio Mancebo
#### Textual description:
Sergio Octavio has made the Control Panel and Search with Angular.

#### The five most important commits:

| Commit number | Description | Link |
| ------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| #1 | Control Panel |https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/65ac78844f41f5bc7c35c3dae8aacc242d0e76a8 |
| #2 | Search | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/5889e1eb4cbc245909734cabeca714400e9f7a45 |
| #3 | Readme|https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/bad5529eb4c6e402161205f6487bffd4660da4ed |
| #4 | | |
| #5 | | |


#### The five most participated files:

| File number | File |
| ------------- | ------------------ |
| #1 | [App Module ts](code/frontend/src/app/app.module.ts) |
| #2 | [App Routing ts](code/frontend/src/app/app.routing.ts) |
| #3 | [Control Panel Component](code/frontend/src/app/components/games/control-panel.component.html) |
| #4 | [Side Search Block](backend/target/classes/templates/sideSearchBlock.html) |
| #5 | [Search Component](code/frontend/src/app/components/games/search.component.html) |





### Iker Pizarro Fernández
#### Textual description:
Iker has made the edit-game and add-game front with Angular.

#### The five most important commits:

| Commit number | Description | Link |
| ------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| #1 | Add Game Front | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/a16d707c8004a322223b3491e721bf24889f9e28#diff-eb715df54195b66df020ea446cf297ad03657233f1d17269bee9d20502a7e75f |
| #2 | Add Game Front Final Release | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/ffbc429d9ad8e827bded2bb0c9fa86d990acfe5e |
| #3 | Edit Game Front | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/9b8a2ef6a55856efe58dae181b0888acf61bee85 |
| #4 | Edit Game Front Final Release | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/ae9e463df5fdfe173c0fc352264220bc0aa03202#diff-44db907bfdc2a278fb08caa5a50449ccaf6654550f0cb91012a061be29182787 |
| #5 | Edit Game Images Fix | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/6ca4957b7fcdb7eddf5dd81d7604313df13b6e18 |


#### The five most participated files:

| File number | File |
| ------------- | ------------------ |
| #1 | [Add game ts](code/frontend/src/app/components/games/add-game.component.ts) |
| #2 | [Add game html](code/frontend/src/app/components/games/add-game.component.html) |
| #3 | [Edit game ts](code/frontend/src/app/components/games/edit-game.component.ts) |
| #4 | [Edit game html](code/frontend/src/app/components/games/edit-game.component.html) |
| #5 | [Game Service ts](code/frontend/src/app/services/game.service.ts) |


### Sergio Pérez Sampedro
#### Textual description:
Sergio has made the carrusel the cart and video.

#### The five most important commits:

| Commit number | Description | Link |
| ------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| #1 | Video | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/bad5529eb4c6e402161205f6487bffd4660da4ed |
| #2 | Carrusel | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/5528ac9bfe5be0a9597c15931d35817d9f30fbd4 |
| #3 | Cart | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/422991cd842e4834c3da9c2120cb7885557e08c1 |
| #4 | | |
| #5 | | |


#### The five most participated files:

| File number | File |
| ------------- | ------------------ |
| #1 |[ReviewRestController](code/backend/src/main/java/app/controller/restController/ReviewRestController.java) |
| #2 |[game-page.component](code/frontend/src/app/components/games/game-page.component.html) |
| #3 | [game.service](code/frontend/src/app/services/game.service.ts)|
| #4 | [cart.component](code/frontend/src/app/components/users/cart.component.html)|
| #5 | [Readme](README.md) |


### Javier Gaspariño Muñoz
#### Textual description:
Javier has made the navbar cart improvements, the checkout. He also collaborated in the edit game and made the class diagram.

#### The five most important commits:

| Commit number | Description | Link |
| ------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
| #1 | Navbar Cart Improvement | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/327dccd752e1f9d340c7aa626487c3dceafccfb8 |
| #2 | Checkout | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/2e4868ffd6959bb6fb9170eed566eb452faf351b#diff-6b8da21fcb1421857b98413e6f40d52d14596e393cf766d992ef47c7404a7104 |
| #3 | Edit Game Components and Service creation | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/9b8a2ef6a55856efe58dae181b0888acf61bee85 |
| #4 | Updates and Finish Edit Game | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/ae9e463df5fdfe173c0fc352264220bc0aa03202 |
| #5 | Class Diagram Phase 4 | https://github.com/CodeURJC-DAW-2022-23/webapp5/commit/596175b91f985003cd3d980c1da9270c0231852b |


#### The five most participated files:

| File number | File |
| ------------- | ------------------ |
| #1 | [Navbar ts](code/frontend/src/app/components/navbar/navbar.component.ts) |
| #2 | [Edit game ts](code/frontend/src/app/components/games/edit-game.component.ts) |
| #3 | [Checkout html](code/frontend/src/app/components/users/checkout.component.html) |
| #4 | [Checkout ts](code/frontend/src/app/components/users/checkout.component.ts) |
| #5 | [Class Diagram](screenshots/DiagramaClases3.png) |
12 changes: 12 additions & 0 deletions code/backend/src/main/java/app/controller/SPAController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package app.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class SPAController {
@GetMapping({"/new/**/{path:[^\\.]*}", "/{path:new[^\\.]*}"})
public String redirect() {
return "forward:/new/index.html";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,17 @@ public ResponseEntity<Review> getReview(@Parameter(description = "Id of the user
}
}

}
@GetMapping("/review/{userId}/{gameId}")
public ResponseEntity<Boolean> getReview(@PathVariable long userId, @PathVariable long gameId) {
// Before returning a page it confirms that there are more left
Optional<User> opUser = userService.findById(userId);
Optional<Game> opGame = gameService.findById(gameId);
try{
Boolean opReview = reviewService.reviewedByUser(opUser.get(), opGame.get());
return new ResponseEntity<>(opReview, HttpStatus.OK);
}catch (Exception e){
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}

}
1 change: 0 additions & 1 deletion code/backend/src/main/java/app/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class User{
private List<String> roles;

@ManyToMany
@JsonIgnore
private List<Game> cart = new ArrayList<>();

@Lob
Expand Down
10 changes: 7 additions & 3 deletions code/backend/src/main/java/app/service/GameService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import java.sql.Blob;
import org.hibernate.engine.jdbc.BlobProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
Expand All @@ -22,6 +23,7 @@
import app.model.Game;
import app.model.User;
import app.repository.GameRepository;
import java.util.ArrayList;

@Service
public class GameService {
Expand Down Expand Up @@ -163,15 +165,17 @@ public int countByCategoryAndName(String name, String category) {

private void updateGameplayImages(Game game, List<MultipartFile> imageFields) {
if (imageFields != null && !imageFields.get(0).getOriginalFilename().equals("") && !imageFields.isEmpty()) {
game.setGameplayImages(new ArrayList<>());
game.setGameplayImagesFiles(imageFields.stream().map(file -> {
try {
return BlobProxy.generateProxy(file.getInputStream(), file.getSize());
Blob generateProxy = BlobProxy.generateProxy(file.getInputStream(), file.getSize());
game.getGameplayImages().add("isNice");
return generateProxy;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.toList()));
game.setGameplayImages(imageFields.stream().map(file -> "").collect(Collectors.toList()));
} else {
Game dbGame = games.findById(game.getId()).orElseThrow();
game.setGameplayImagesFiles(dbGame.getGameplayImagesFiles());
Expand All @@ -181,7 +185,7 @@ private void updateGameplayImages(Game game, List<MultipartFile> imageFields) {
private void updateImageGame(Game game, MultipartFile imageField) throws IOException, SQLException {
if (imageField != null && !imageField.isEmpty()) {
game.setTitleImageFile(BlobProxy.generateProxy(imageField.getInputStream(), imageField.getSize()));
game.setTitleImage("");
game.setTitleImage("isNice");
} else {
Game dbGame = games.findById(game.getId()).orElseThrow();
game.setTitleImageFile(dbGame.getTitleImageFile());
Expand Down
12 changes: 11 additions & 1 deletion code/backend/src/main/java/app/service/SampleDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,24 @@ public List<Game> generateGames() throws IOException {

private void setGameplayImage(Game game, List<String> gameplayImages) {
List<Blob> auxArray = new ArrayList<>();
int index = 0;
try {
for (String string : gameplayImages) {
Resource image = new ClassPathResource(string);
auxArray.add(BlobProxy.generateProxy(image.getInputStream(), image.contentLength()));
game.setGameplayImagesFiles(auxArray);
index++;
}
} catch (IOException e) {
e.printStackTrace();
try {
for (int i = index; i < gameplayImages.size(); i++) {
Resource image = new ClassPathResource(gameplayImages.get(0));
auxArray.add(BlobProxy.generateProxy(image.getInputStream(), image.contentLength()));
game.setGameplayImagesFiles(auxArray);
}
} catch (Exception e2) {
e.printStackTrace();
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions code/backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ spring.datasource.username=${MYSQLUSER:root}
spring.datasource.password=${MYSQLROOT:password}
spring.jpa.hibernate.ddl-auto=create-drop

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=keywhaledaw@gmail.com
spring.mail.password=bmbedntubnrwmdiz
spring.mail.username=keywhalecorreo@gmail.com
spring.mail.password=ospqdybigktxzzte
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

Expand Down
23 changes: 19 additions & 4 deletions code/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
FROM maven:3-openjdk-17 as builder
# Stage 1 - Build Angular app
FROM node:16-alpine AS builder

WORKDIR /project

COPY backend/pom.xml /project/
COPY frontend/ .

RUN npm install
RUN npm run build -- --prod --base-href=/new/


# Stage 2 - Build Spring Boot app
FROM maven:3-openjdk-17 as backend

WORKDIR /project

COPY backend/pom.xml /project/
COPY backend/src /project/src

# Copy Angular build files to Spring Boot static resources
COPY --from=builder /project/dist/ejem0 /project/src/main/resources/static/new

RUN mvn package -DskipTests=true

# Stage 3 - Build Docker image
FROM openjdk:17

ENV JAVA_TOOL_OPTIONS="-Xss256K -XX:ReservedCodeCacheSize=64M -XX:MaxMetaspaceSize=100000K -Xmx64M"

WORKDIR /usr/src/app/

COPY --from=builder /project/target/*.jar /usr/src/app/
COPY --from=backend /project/target/*.jar /usr/src/app/

EXPOSE 8443

CMD ["java", "-jar", "backend-0.0.1-SNAPSHOT.jar" ]
CMD ["java", "-jar", "backend-0.0.1-SNAPSHOT.jar"]
4 changes: 3 additions & 1 deletion code/docker/create_image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

docker build -f Dockerfile -t $1 ../
docker push $1
docker push $1
sleep 10000

17 changes: 17 additions & 0 deletions code/frontend/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
16 changes: 16 additions & 0 deletions code/frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
Loading

0 comments on commit b7f1267

Please sign in to comment.