diff --git a/.gitignore b/.gitignore index 2c40c41..0011a95 100755 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,7 @@ testem.log # System Files .DS_Store Thumbs.db +.idea/workspace.xml +.idea/vcs.xml +.idea/progress_tracker.iml +.idea/modules.xml diff --git a/.idea/progress_tracker.iml b/.idea/progress_tracker.iml index 0c8867d..d6ebd48 100644 --- a/.idea/progress_tracker.iml +++ b/.idea/progress_tracker.iml @@ -1,11 +1,8 @@ - - - - - - - + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index cd982ca..dd53c22 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,8 +1,14 @@ - - + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index f891a8c..4665dbb 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ -https://dbdiagram.io/d/61d9b7b4f8370f0a2ee67553 - -http://localhost:8080/swagger-ui/index.html +BEng thesis, all details described here: +https://github.com/Fariusz/progress_tracker/blob/5d58509860e5fef9c6be81173061fa6ac5b0b655/Radoslaw_Loth_praca_inzynierska.pdf diff --git a/Radoslaw_Loth_praca_inzynierska.pdf b/Radoslaw_Loth_praca_inzynierska.pdf new file mode 100644 index 0000000..a155c80 Binary files /dev/null and b/Radoslaw_Loth_praca_inzynierska.pdf differ diff --git a/backend/src/main/java/com/rloth/progress_tracker/controllers/ActivityController.java b/backend/src/main/java/com/rloth/progress_tracker/controllers/ActivityController.java index 4150797..049660c 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/controllers/ActivityController.java +++ b/backend/src/main/java/com/rloth/progress_tracker/controllers/ActivityController.java @@ -23,13 +23,17 @@ public List getUserActivities(@AuthenticationPrincipal String username return activityService.getUserActivities(username); } + @GetMapping("/userActivitiesByListId/{id}") + public List userActivitiesByListId(@PathVariable long id) { + return activityService.userActivitiesByListId(id); + } + @GetMapping("/userActivities/pageable") public List getUserActivitiesPageable(@AuthenticationPrincipal String username, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer pageSize, Sort.Direction sort) { int pageNumber = page != null && page > 0 ? page : 1; Sort.Direction sortDirection = sort != null ? sort : Sort.Direction.ASC; return activityService.getUserActivitiesPageable(username, pageNumber - 1, pageSize, sortDirection); - } @GetMapping("/activities") diff --git a/backend/src/main/java/com/rloth/progress_tracker/controllers/ContentController.java b/backend/src/main/java/com/rloth/progress_tracker/controllers/ContentController.java index 79f9ffd..1c1af8e 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/controllers/ContentController.java +++ b/backend/src/main/java/com/rloth/progress_tracker/controllers/ContentController.java @@ -18,6 +18,8 @@ public List getContent() { return contentService.getContent(); } + + @GetMapping("/content/{id}") public List getActivityContent(@PathVariable long id) { return contentService.getActivityContent(id); diff --git a/backend/src/main/java/com/rloth/progress_tracker/controllers/ListController.java b/backend/src/main/java/com/rloth/progress_tracker/controllers/ListController.java new file mode 100644 index 0000000..210dd57 --- /dev/null +++ b/backend/src/main/java/com/rloth/progress_tracker/controllers/ListController.java @@ -0,0 +1,42 @@ +package com.rloth.progress_tracker.controllers; + +import com.rloth.progress_tracker.models.ActivitiesList; +import com.rloth.progress_tracker.services.ListService; +import lombok.RequiredArgsConstructor; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +public class ListController { + + private final ListService listService; + + @GetMapping("/lists") + public List getLists() { + return listService.getLists(); + } + + @GetMapping("/userLists") + public List getUserLists(@AuthenticationPrincipal String username) { + return listService.getUserLists(username); + } + + @PostMapping("/list") + public ActivitiesList addList(@RequestBody ActivitiesList list, @AuthenticationPrincipal String username) { + return listService.addList(list, username); + } + + @PutMapping("/list") + public ActivitiesList editList(@RequestBody ActivitiesList list) { + return listService.editList(list); + } + + @DeleteMapping("/list/{id}") + public void deleteList(@PathVariable long id) { + listService.deleteList(id); + } + +} diff --git a/backend/src/main/java/com/rloth/progress_tracker/controllers/LoginController.java b/backend/src/main/java/com/rloth/progress_tracker/controllers/LoginController.java index d383e43..39204da 100644 --- a/backend/src/main/java/com/rloth/progress_tracker/controllers/LoginController.java +++ b/backend/src/main/java/com/rloth/progress_tracker/controllers/LoginController.java @@ -33,11 +33,9 @@ public ResponseEntity processRegister(@RequestBody UserDto accountDto) { return new ResponseEntity<>("{\n" + " \"message\" : \"EMAIL_EXISTS\"\n" + "}\n", HttpStatus.BAD_REQUEST); } else if (loginService.usernameExist(accountDto)) { return new ResponseEntity<>("{\n" + " \"message\" : \"USERNAME_EXISTS\"\n" + "}\n", HttpStatus.BAD_REQUEST); - } else if (!loginService.emailExist(accountDto) || !loginService.usernameExist(accountDto)) { + } else { loginService.register(accountDto); return new ResponseEntity<>("{\n" + " \"message\" : \"REGISTER_SUCCESS\"\n" + "}\n", HttpStatus.CREATED); - } else { - return new ResponseEntity<>("{\n" + " \"message\" : \"UNKNOWN\"\n" + "}\n", HttpStatus.NOT_IMPLEMENTED); } } diff --git a/backend/src/main/java/com/rloth/progress_tracker/models/ActivitiesList.java b/backend/src/main/java/com/rloth/progress_tracker/models/ActivitiesList.java new file mode 100644 index 0000000..c3376c5 --- /dev/null +++ b/backend/src/main/java/com/rloth/progress_tracker/models/ActivitiesList.java @@ -0,0 +1,26 @@ +package com.rloth.progress_tracker.models; + +import lombok.Getter; +import lombok.Setter; + +import javax.persistence.*; +import java.time.LocalDateTime; +import java.util.List; + +@Entity +@Getter +@Setter +public class ActivitiesList { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + private String listName; + private boolean isTraining; + private long authorId; + private LocalDateTime created; + + //Relacja jeden (Activity) do wielu (Content) + @OneToMany(cascade = CascadeType.REMOVE) + @JoinColumn(name = "listId", updatable = false, insertable = false) + private List activities; +} \ No newline at end of file diff --git a/backend/src/main/java/com/rloth/progress_tracker/models/Activity.java b/backend/src/main/java/com/rloth/progress_tracker/models/Activity.java index f06719a..48563bc 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/models/Activity.java +++ b/backend/src/main/java/com/rloth/progress_tracker/models/Activity.java @@ -14,8 +14,9 @@ public class Activity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; + private long listId; private String activityName; - private long author_id; + private long authorId; private LocalDateTime created; //Relacja jeden (Activity) do wielu (Content) diff --git a/backend/src/main/java/com/rloth/progress_tracker/models/Content.java b/backend/src/main/java/com/rloth/progress_tracker/models/Content.java index a9f319c..be2eae0 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/models/Content.java +++ b/backend/src/main/java/com/rloth/progress_tracker/models/Content.java @@ -7,6 +7,7 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import java.time.LocalDate; import java.time.LocalDateTime; @Entity @@ -18,6 +19,7 @@ public class Content { private long id; private long activityId; private String content; - private LocalDateTime created; + private String repetitions; + private LocalDate created; } diff --git a/backend/src/main/java/com/rloth/progress_tracker/repos/ActivityRepository.java b/backend/src/main/java/com/rloth/progress_tracker/repos/ActivityRepository.java index c91cc68..de81f2d 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/repos/ActivityRepository.java +++ b/backend/src/main/java/com/rloth/progress_tracker/repos/ActivityRepository.java @@ -19,15 +19,18 @@ public interface ActivityRepository extends JpaRepository { @Query("select distinct a from Activity a" + " left join fetch a.content") List findAllActivitiesPageable(Pageable page); - @Query("select a from Activity a where author_id = ?1") + @Query("select a from Activity a where authorId = ?1") List findActivitiesByUserId(Long id); - @Query("select a from Activity a where author_id = ?1") + @Query("select a from Activity a where authorId = ?1") List findActivitiesByUserIdPageable(Long id, Pageable page); + @Query("select a from Activity a where listId = ?1") + List findAllByListId(long id); + /* - findAllByActivityName i findActivityWithContent działają w jednakowy sposób XDD + findAllByActivityName i findActivityWithContent działają w jednakowy sposób @Query("select a from Activity a" + " left join fetch a.content" + " where activity_name = :name") Activity findActivityWithContent(@Param("name") String name); diff --git a/backend/src/main/java/com/rloth/progress_tracker/repos/ListRepository.java b/backend/src/main/java/com/rloth/progress_tracker/repos/ListRepository.java new file mode 100644 index 0000000..c7b1f5c --- /dev/null +++ b/backend/src/main/java/com/rloth/progress_tracker/repos/ListRepository.java @@ -0,0 +1,12 @@ +package com.rloth.progress_tracker.repos; + +import com.rloth.progress_tracker.models.ActivitiesList; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +public interface ListRepository extends JpaRepository { + @Query("select a from ActivitiesList a where authorId = ?1") + List findListsByUserId(Long userId); +} diff --git a/backend/src/main/java/com/rloth/progress_tracker/services/ActivityService.java b/backend/src/main/java/com/rloth/progress_tracker/services/ActivityService.java index b122fb0..2175c10 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/services/ActivityService.java +++ b/backend/src/main/java/com/rloth/progress_tracker/services/ActivityService.java @@ -79,7 +79,7 @@ private List extractContents(List contents, long id) { } public Activity addActivity(Activity activity, String username) { - activity.setAuthor_id(loginService.getUserId(username)); + activity.setAuthorId(loginService.getUserId(username)); return activityRepository.save(activity); } @@ -101,4 +101,8 @@ public void deleteActivity(long id) { public void clearActivities() { //Ta metoda czyści Cache } + + public List userActivitiesByListId(long id) { + return activityRepository.findAllByListId(id); + } } diff --git a/backend/src/main/java/com/rloth/progress_tracker/services/ContentService.java b/backend/src/main/java/com/rloth/progress_tracker/services/ContentService.java index 0b02158..d9f7292 100755 --- a/backend/src/main/java/com/rloth/progress_tracker/services/ContentService.java +++ b/backend/src/main/java/com/rloth/progress_tracker/services/ContentService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; import javax.transaction.Transactional; +import java.time.LocalDateTime; import java.util.Collections; import java.util.List; @@ -36,6 +37,7 @@ public Content editContent(Content content) { Content contentEdited = contentRepository.findById(content.getId()).orElseThrow(); contentEdited.setContent(content.getContent()); contentEdited.setCreated(content.getCreated()); + contentEdited.setRepetitions(content.getRepetitions()); return contentEdited; } } \ No newline at end of file diff --git a/backend/src/main/java/com/rloth/progress_tracker/services/ListService.java b/backend/src/main/java/com/rloth/progress_tracker/services/ListService.java new file mode 100644 index 0000000..34f082c --- /dev/null +++ b/backend/src/main/java/com/rloth/progress_tracker/services/ListService.java @@ -0,0 +1,42 @@ +package com.rloth.progress_tracker.services; + +import com.rloth.progress_tracker.models.ActivitiesList; +import com.rloth.progress_tracker.repos.ListRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class ListService { + + private final ListRepository listRepository; + private final LoginService loginService; + + public List getLists() { + return listRepository.findAll(); + } + + public List getUserLists(String username) { + return listRepository.findListsByUserId(loginService.getUserId(username)); + } + + public ActivitiesList addList(ActivitiesList list, String username) { + list.setAuthorId(loginService.getUserId(username)); + return listRepository.save(list); + } + + @Transactional + public ActivitiesList editList(ActivitiesList list) { + ActivitiesList listEdited = listRepository.findById(list.getId()).orElseThrow(); + listEdited.setListName(list.getListName()); + listEdited.setActivities(list.getActivities()); + return listEdited; + } + + public void deleteList(long id) { + listRepository.deleteById(id); + } +} diff --git a/backend/src/main/resources/database/2021-11-01/01-create-activity.sql b/backend/src/main/resources/database/2021-11-01/01-create-activity.sql index 29ca017..8bdd842 100644 --- a/backend/src/main/resources/database/2021-11-01/01-create-activity.sql +++ b/backend/src/main/resources/database/2021-11-01/01-create-activity.sql @@ -1,10 +1,24 @@ --liquibase formatted sql --changeset rloth:1 +CREATE TABLE activities_list +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + list_name VARCHAR(400) NOT NULL, + is_training BOOLEAN NOT NULL, + author_id BIGINT, + created timestamp +); + CREATE TABLE activity ( id BIGINT AUTO_INCREMENT PRIMARY KEY, + list_id BIGINT NOT NULL, activity_name VARCHAR(400) NOT NULL, author_id BIGINT, created timestamp -); \ No newline at end of file +); + +ALTER TABLE activity + ADD CONSTRAINT activity_list_id + FOREIGN KEY (list_id) REFERENCES activities_list (id); \ No newline at end of file diff --git a/backend/src/main/resources/database/2021-11-01/02-create-content.sql b/backend/src/main/resources/database/2021-11-01/02-create-content.sql index 2d68bd3..24ee0c7 100644 --- a/backend/src/main/resources/database/2021-11-01/02-create-content.sql +++ b/backend/src/main/resources/database/2021-11-01/02-create-content.sql @@ -6,6 +6,7 @@ CREATE TABLE content id BIGINT AUTO_INCREMENT PRIMARY KEY, activity_id BIGINT NOT NULL, content VARCHAR(2000) NULL, + repetitions VARCHAR(100) NULL, created timestamp ); diff --git a/backend/src/main/resources/database/2021-11-01/03-activity-content-data.sql b/backend/src/main/resources/database/2021-11-01/03-activity-content-data.sql index a08eabd..270e6c7 100644 --- a/backend/src/main/resources/database/2021-11-01/03-activity-content-data.sql +++ b/backend/src/main/resources/database/2021-11-01/03-activity-content-data.sql @@ -1,86 +1,54 @@ --liquibase formatted sql --changeset rloth:3 -insert into activity (id, activity_name, author_id, created) -values (1, 'Push ups', 1, '2020-04-20T13:14:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (2, 'Bench press', 1, '2020-04-20T13:14:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (3, 'Squad', 1, '2020-04-20T13:14:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (4, 'Dead lift', 1, '2020-04-20T13:14:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (5, 'Over head press', 1, '2020-04-20T13:14:05.724885500'); +insert into activities_list (id, list_name, is_training, author_id, created) +values (1, 'Trening siłowy A', true, 1 ,'2022-01-01T08:00:00'); +insert into activities_list (id, list_name, is_training, author_id, created) +values (2, 'Trening siłowy B', true, 1 ,'2022-01-01T08:00:00'); + +insert into activities_list (id, list_name, is_training, author_id, created) +values (3, 'Pomiary ciała', false, 1 ,'2022-01-01T08:00:00'); + +insert into activity (id, list_id, activity_name, author_id, created) +values (1, 1, 'Przysiad klasyczny ze sztangą trzymaną z tyłu - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (2, 1, 'Ściąganie drążka wyciągu górnego szerokim chwytem - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (3, 1, 'Wyciskanie hantli na ławce skośnej dodatniej - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (4, 1, 'Wyciskanie żołnierskie - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (5, 1, 'Zginanie przedramion ze sztangą łamaną stojąc - 3 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (6, 1, 'Spięcia mięśni brzucha przy użyciu linki wyciągu górnego – 3 serie', 1, '2022-01-01T08:00:00'); + + +insert into activity (id, list_id, activity_name, author_id, created) +values (7, 2, 'Martwy ciąg na "prostych" nogach - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (8, 2, 'Podciąganie na drążku nachwytem – 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (9, 2, 'Wyciskanie sztangi na ławce poziomej - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (10, 2, 'Wyciskanie hantli siedząc na ławce - 4 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (11, 2, 'Pompki na poręczach (z dodatkowym obciążeniem) - 3 serie', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (12, 2, 'Wznosy zgiętych nóg w zwisie na drążku - 3 serie', 1, '2022-01-01T08:00:00'); + +insert into activity (id, list_id, activity_name, author_id, created) +values (13, 3, 'Obwód talii', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (14, 3, 'Obwód pasa', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id, activity_name, author_id, created) +values (15, 3, 'Obwód uda', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (16, 3, 'Obwód łydki', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (17, 3, 'Obwód ramienia', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (18, 3, 'Obwód klatki piersiowej', 1, '2022-01-01T08:00:00'); +insert into activity (id, list_id , activity_name, author_id, created) +values (19, 3, 'Waga', 1, '2022-01-01T08:00:00'); -insert into activity (id, activity_name, author_id, created) -values (6, 'Books', 2, '2021-06-20T22:54:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (7, 'Water', 2, '2021-08-20T07:13:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (8, 'Tidy room', 2, '2021-02-20T09:14:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (9, 'Cigarettes', 2, '2021-09-20T16:20:05.724885500'); -insert into activity (id, activity_name, author_id, created) -values (10, 'Coffees', 2, '2021-01-20T15:10:05.724885500'); ---changeset rloth:4 -insert into content (id, activity_id, content, created) -values (1, 1, '15', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (6, 1, '17', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (7, 1, '23', '2021-06-20T08:00:00.0'); -insert into content (id, activity_id, content, created) -values (2, 2, '80', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (8, 2, '85', '2021-06-20T08:00:00.0'); -insert into content (id, activity_id, content, created) -values (9, 2, '90', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (3, 3, '100', '2021-06-20T08:00:00.0'); -insert into content (id, activity_id, content, created) -values (10, 3, '105', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (11, 3, '110', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (12, 4, '90', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (13, 4, '95', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (14, 4, '100', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (5, 5, '60', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (15, 5, '62', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (16, 5, '64', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (17, 6, '15', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (18, 6, '17', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (19, 6, '23', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (20, 7, '2 l', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (21, 7, '2 l', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (22, 7, '1 l', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (23, 8, '1', '2022-01-01T08:00:0'); -insert into content (id, activity_id, content, created) -values (24, 8, '1', '2022-01-04T08:00:0'); -insert into content (id, activity_id, content, created) -values (25, 8, '1', '2022-01-08T08:00:0'); -insert into content (id, activity_id, content, created) -values (26, 9, '10', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (27, 9, '12', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (28, 9, '17', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (29, 10, '2', '2020-04-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (30, 10, '3', '2020-05-20T13:14:05.724885500'); -insert into content (id, activity_id, content, created) -values (31, 10, '2', '2020-06-20T13:14:05.724885500'); \ No newline at end of file diff --git a/backend/src/main/resources/database/2021-11-01/04-insert-content.sql b/backend/src/main/resources/database/2021-11-01/04-insert-content.sql new file mode 100644 index 0000000..d1f48b6 --- /dev/null +++ b/backend/src/main/resources/database/2021-11-01/04-insert-content.sql @@ -0,0 +1,212 @@ +--liquibase formatted sql +--changeset rloth:4 + +insert into content (activity_id, content, repetitions, created) +values (1, '50','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (1, '55','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (1, '60','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (1, '65','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (1, '70','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (2, '15','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (2, '20','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (2, '25','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (2, '30','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (2, '35','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (3, '10','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (3, '15','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (3, '20','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (3, '25','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (3, '30','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (4, '20','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (4, '25','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (4, '30','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (4, '35','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (4, '40','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (5, '5','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (5, '10','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (5, '15','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (5, '20','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (5, '25','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (6, '5','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (6, '10','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (6, '15','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (6, '20','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (6, '25','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (7, '50','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (7, '55','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (7, '60','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (7, '65','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (7, '70','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (8, '15','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (8, '20','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (8, '25','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (8, '30','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (8, '35','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (9, '10','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (9, '15','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (9, '20','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (9, '25','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (9, '30','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (10, '20','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (10, '25','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (10, '30','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (10, '35','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (10, '40','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (11, '5','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (11, '10','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (11, '15','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (11, '20','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (11, '25','10', '2022-05-01'); + +insert into content (activity_id, content, repetitions, created) +values (12, '5','10', '2022-01-01'); +insert into content (activity_id, content, repetitions, created) +values (12, '10','10', '2022-02-01'); +insert into content (activity_id, content, repetitions, created) +values (12, '15','10', '2022-03-01'); +insert into content (activity_id, content, repetitions, created) +values (12, '20','10', '2022-04-01'); +insert into content (activity_id, content, repetitions, created) +values (12, '25','10', '2022-05-01'); + +insert into content (activity_id, content, created) +values (13, '90', '2022-01-01'); +insert into content (activity_id, content, created) +values (13, '89', '2022-02-01'); +insert into content (activity_id, content, created) +values (13, '88', '2022-03-01'); +insert into content (activity_id, content, created) +values (13, '87', '2022-04-01'); +insert into content (activity_id, content, created) +values (13, '86', '2022-05-01'); + +insert into content (activity_id, content, created) +values (14, '100', '2022-01-01'); +insert into content (activity_id, content, created) +values (14, '99', '2022-02-01'); +insert into content (activity_id, content, created) +values (14, '98', '2022-03-01'); +insert into content (activity_id, content, created) +values (14, '97', '2022-04-01'); +insert into content (activity_id, content, created) +values (14, '96', '2022-05-01'); + +insert into content (activity_id, content, created) +values (15, '67', '2022-01-01'); +insert into content (activity_id, content, created) +values (15, '66', '2022-02-01'); +insert into content (activity_id, content, created) +values (15, '65', '2022-03-01'); +insert into content (activity_id, content, created) +values (15, '64', '2022-04-01'); +insert into content (activity_id, content, created) +values (15, '63', '2022-05-01'); + +insert into content (activity_id, content, created) +values (16, '43', '2022-01-01'); +insert into content (activity_id, content, created) +values (16, '44', '2022-02-01'); +insert into content (activity_id, content, created) +values (16, '45', '2022-03-01'); +insert into content (activity_id, content, created) +values (16, '46', '2022-04-01'); +insert into content (activity_id, content, created) +values (16, '47', '2022-05-01'); + +insert into content (activity_id, content, created) +values (17, '37', '2022-01-01'); +insert into content (activity_id, content, created) +values (17, '38', '2022-02-01'); +insert into content (activity_id, content, created) +values (17, '39', '2022-03-01'); +insert into content (activity_id, content, created) +values (17, '40', '2022-04-01'); +insert into content (activity_id, content, created) +values (17, '41', '2022-05-01'); + +insert into content (activity_id, content, created) +values (18, '100', '2022-01-01'); +insert into content (activity_id, content, created) +values (18, '101', '2022-02-01'); +insert into content (activity_id, content, created) +values (18, '102', '2022-03-01'); +insert into content (activity_id, content, created) +values (18, '103', '2022-04-01'); +insert into content (activity_id, content, created) +values (18, '104', '2022-05-01'); + +insert into content (activity_id, content, created) +values (19, '100', '2022-01-01'); +insert into content (activity_id, content, created) +values (19, '97', '2022-02-01'); +insert into content (activity_id, content, created) +values (19, '95', '2022-03-01'); +insert into content (activity_id, content, created) +values (19, '94', '2022-04-01'); +insert into content (activity_id, content, created) +values (19, '92', '2022-05-01'); + diff --git a/frontend/README.md b/frontend/README.md index 2aeeefc..535271f 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -4,11 +4,13 @@ This project was generated with [Angular CLI](https://github.com/angular/angular ## Development server -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change +any of the source files. ## Code scaffolding -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. +Run `ng generate component component-name` to generate a new component. You can also +use `ng generate directive|pipe|service|class|guard|interface|enum|module`. ## Build @@ -20,8 +22,10 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github. ## Running end-to-end tests -Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. +Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a +package that implements end-to-end testing capabilities. ## Further help -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. +To get more help on the Angular CLI use `ng help` or go check out +the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. diff --git a/frontend/angular.json b/frontend/angular.json index 2a595da..46c63df 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -30,16 +30,16 @@ "src/assets" ], "styles": [ - "node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss", - "node_modules/@fortawesome/fontawesome-free/scss/solid.scss", - "node_modules/@fortawesome/fontawesome-free/scss/regular.scss", - "node_modules/@fortawesome/fontawesome-free/scss/brands.scss", + "node_modules/bootstrap/dist/css/bootstrap.min.css", + "node_modules/@fortawesome/fontawesome-free/css/fontawesome.css", + "node_modules/@fortawesome/fontawesome-free/css/solid.css", + "node_modules/@fortawesome/fontawesome-free/css/regular.css", + "node_modules/@fortawesome/fontawesome-free/css/brands.css", "node_modules/angular-bootstrap-md/assets/scss/bootstrap/bootstrap.scss", "node_modules/angular-bootstrap-md/assets/scss/mdb.scss", "node_modules/animate.css/animate.css", "node_modules/ngx-toastr/toastr.css", "src/styles.css", - "node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/flag-icon-css/css/flag-icons.min.css" ], "scripts": [ diff --git a/frontend/karma.conf.js b/frontend/karma.conf.js index 3635639..bd5e9b8 100644 --- a/frontend/karma.conf.js +++ b/frontend/karma.conf.js @@ -28,8 +28,8 @@ module.exports = function (config) { dir: require('path').join(__dirname, './coverage/frontend'), subdir: '.', reporters: [ - { type: 'html' }, - { type: 'text-summary' } + {type: 'html'}, + {type: 'text-summary'} ] }, reporters: ['progress', 'kjhtml'], diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 5f0fbb4..810db86 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -35,6 +35,7 @@ "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "jquery": "^3.6.0", + "material-icons": "^1.10.8", "ngx-pagination": "^5.1.1", "ngx-toastr": "^14.2.1", "rxjs": "^7.5.2", @@ -7595,6 +7596,11 @@ "node": ">= 10" } }, + "node_modules/material-icons": { + "version": "1.10.8", + "resolved": "https://registry.npmjs.org/material-icons/-/material-icons-1.10.8.tgz", + "integrity": "sha512-CbtQXCmC9MXIIkz/0CmEfxELosxKxLegrjoa0mxM0zPA+GgAuhnWX6ITo/5oON/JFaCi/bh4MydEUNu0erbaxw==" + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -17111,6 +17117,11 @@ "ssri": "^8.0.0" } }, + "material-icons": { + "version": "1.10.8", + "resolved": "https://registry.npmjs.org/material-icons/-/material-icons-1.10.8.tgz", + "integrity": "sha512-CbtQXCmC9MXIIkz/0CmEfxELosxKxLegrjoa0mxM0zPA+GgAuhnWX6ITo/5oON/JFaCi/bh4MydEUNu0erbaxw==" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index a85e3d8..aaa6ab2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -37,6 +37,7 @@ "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "jquery": "^3.6.0", + "material-icons": "^1.10.8", "ngx-pagination": "^5.1.1", "ngx-toastr": "^14.2.1", "rxjs": "^7.5.2", diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 2b5a45c..4253872 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -1,26 +1,29 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; import {HomeComponent} from "./components/pages/home/home.component"; -import {MainComponent} from "./components/pages/main/main.component"; -import {ActivitiesComponent} from "./components/pages/activities/activities.component"; +import {LandingPageComponent} from "./components/pages/landing-page/landing-page.component"; import {LoginComponent} from "./components/pages/login/login.component"; import {AuthGuardService} from "./components/auth/auth-guard.service"; import {ActivityDetailsComponent} from "./components/pages/activity-details/activity-details.component"; +import {ActivitiesListsComponent} from "./components/pages/activities-lists/activities-lists.component"; +import {PageNotFoundComponent} from "./components/pages/page-not-found/page-not-found.component"; const routes: Routes = [ - {path: '', component: MainComponent}, + {path: '', component: LandingPageComponent}, + {path: 'trainings', component: ActivitiesListsComponent, canActivate: [AuthGuardService]}, + {path: 'measurements', component: ActivitiesListsComponent, canActivate: [AuthGuardService]}, { - path: 'activities', children: [ - {path: '', component: ActivitiesComponent, canActivate: [AuthGuardService]} - ] + path: 'trainings/details', + children: [{path: ':id', component: ActivityDetailsComponent, canActivate: [AuthGuardService]}] }, { - path: 'details', children: [ - {path: ':id', component: ActivityDetailsComponent, canActivate: [AuthGuardService]} - ] + path: 'measurements/details', + children: [{path: ':id', component: ActivityDetailsComponent, canActivate: [AuthGuardService]}] }, {path: 'home', component: HomeComponent, canActivate: [AuthGuardService]}, {path: 'login', component: LoginComponent}, + {path: 'lists', component: ActivitiesListsComponent, canActivate: [AuthGuardService]}, + {path: '**', component: PageNotFoundComponent} ]; @NgModule({ diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index ded2634..fa84db0 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -9,7 +9,8 @@ import {AuthService} from "./components/auth/auth.service"; export class AppComponent implements OnInit { title = 'Progress tracker'; - constructor(private authService: AuthService) {} + constructor(private authService: AuthService) { + } ngOnInit() { this.authService.autoLogin(); diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 75739a2..f9bcdd1 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -10,7 +10,7 @@ import {ActivitiesComponent} from './components/pages/activities/activities.comp import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {HomeComponent} from './components/pages/home/home.component'; import {LoadingspinnerComponent} from './components/loadingspinner/loadingspinner.component'; -import {MainComponent} from './components/pages/main/main.component'; +import {LandingPageComponent} from './components/pages/landing-page/landing-page.component'; import {LoginComponent} from './components/pages/login/login.component'; import {ActivitiesService} from "./components/pages/activities/activities.service"; import {AuthInterceptorService} from "./components/auth/auth-interceptor.service"; @@ -24,11 +24,14 @@ import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; import {CommonModule} from "@angular/common"; import {ToastrModule} from "ngx-toastr"; import {FooterComponent} from './components/footer/footer.component'; -import {MainComponentComponent} from './components/main-component/main-component.component'; import {TranslateHttpLoader} from "@ngx-translate/http-loader"; import {TranslateLoader, TranslateModule} from "@ngx-translate/core"; +import {ActivitiesListsComponent} from './components/pages/activities-lists/activities-lists.component'; +import {SortDirective} from './util/sort.directive'; +import {PageNotFoundComponent} from './components/pages/page-not-found/page-not-found.component'; +import {MainComponentComponent} from "./components/main-component/main-component.component"; -export function HttpLoaderFactory(http: HttpClient){ +export function HttpLoaderFactory(http: HttpClient) { return new TranslateHttpLoader(http); } @@ -39,15 +42,19 @@ export function HttpLoaderFactory(http: HttpClient){ ActivitiesComponent, HomeComponent, LoadingspinnerComponent, - MainComponent, + LandingPageComponent, LoginComponent, ActivityDetailsComponent, LineChartComponent, ModalComponent, FooterComponent, MainComponentComponent, + ActivitiesListsComponent, + SortDirective, + PageNotFoundComponent, ], imports: [ + NgbModule, BrowserModule, AppRoutingModule, FormsModule, @@ -57,12 +64,10 @@ export function HttpLoaderFactory(http: HttpClient){ FontAwesomeModule, NgxPaginationModule, MDBBootstrapModule.forRoot(), - NgbModule, CommonModule, ToastrModule.forRoot(), - HttpClientModule, TranslateModule.forRoot({ - loader:{ + loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpClient] diff --git a/frontend/src/app/components/auth/auth.service.ts b/frontend/src/app/components/auth/auth.service.ts index 6a3f8ff..9783841 100644 --- a/frontend/src/app/components/auth/auth.service.ts +++ b/frontend/src/app/components/auth/auth.service.ts @@ -100,29 +100,44 @@ export class AuthService { private handleError(errorRes: HttpErrorResponse) { - let errorMessage = 'An unknown error occurred!'; + /* + let errorMessage = 'An unknown error occurred!'; + */ + let errorMessage = 'Wystąpił błąd!'; if (errorRes.status == 401) { - return throwError("Wrong username or password."); + /* + return throwError("Wrong username or password."); + */ + return throwError("Błędna nazwa użytkownika lub hasło."); } else if (!errorRes.error || !errorRes.error.message) { return throwError(errorMessage); } switch (errorRes.error.message) { case 'EMAIL_EXISTS': - errorMessage = 'There is an account with that email adress.'; + /* + errorMessage = 'There is an account with that email adress.'; + */ + errorMessage = 'Podany adres email jest zajęty.'; break; } switch (errorRes.error.message) { case 'USERNAME_EXISTS': - errorMessage = 'There is an account with that username.'; + /* + errorMessage = 'There is an account with that username.'; + */ + errorMessage = 'Podana nazwa użytkownika jest zajęta.'; break; } switch (errorRes.error.message) { case 'UNKNOWN': - errorMessage = 'UNKNOWN'; + /* + errorMessage = 'UNKNOWN'; + */ + errorMessage = 'Niezdefiniowany błąd'; break; } diff --git a/frontend/src/app/components/footer/footer.component.html b/frontend/src/app/components/footer/footer.component.html index e79a808..25662b8 100644 --- a/frontend/src/app/components/footer/footer.component.html +++ b/frontend/src/app/components/footer/footer.component.html @@ -1,69 +1,8 @@ -