Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main to pwa #30

Open
wants to merge 44 commits into
base: pwa
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b3030ed
Fixed bugs internationalization
Fariusz Mar 8, 2022
04e88a5
Update .gitignore
Fariusz Mar 8, 2022
1f0a3d8
code cleanup
Fariusz Mar 8, 2022
a484220
update
Fariusz Apr 3, 2022
5fb4ff8
added lists
Fariusz Apr 5, 2022
0a6c6a2
Update activities-lists.component.css
Fariusz Apr 5, 2022
2da9026
update
Fariusz Apr 7, 2022
73dc626
dry activity
Fariusz Apr 7, 2022
b4329ee
update
Fariusz Apr 8, 2022
390a632
update
Fariusz Apr 9, 2022
302654a
update
Fariusz Apr 9, 2022
b274663
update
Fariusz Apr 11, 2022
67f1e44
update
Fariusz Apr 11, 2022
fb8af1e
update
Fariusz Apr 11, 2022
35d2156
update
Fariusz Apr 11, 2022
4cb37f3
update
Fariusz Apr 12, 2022
56c7cf8
update
Fariusz Apr 12, 2022
16f081a
fixed bug
Fariusz Apr 12, 2022
1454ac1
update
Fariusz Apr 18, 2022
38eb13d
update
Fariusz Apr 21, 2022
19c917d
Added validation
Fariusz Apr 22, 2022
b5e62ef
update
Fariusz Apr 23, 2022
c4eb35c
update
Fariusz Apr 24, 2022
883d085
Update activity-details.component.html
Fariusz Apr 24, 2022
3326d36
update
Fariusz Apr 25, 2022
5add8fc
update
Fariusz Apr 25, 2022
f151ae5
updated icons
Fariusz Apr 25, 2022
0b6d9d0
Merge pull request #27 from Fariusz/dev
Fariusz Apr 25, 2022
018a701
updated icon
Fariusz Apr 25, 2022
8b2eae8
Code cleanup
Fariusz Apr 25, 2022
cf58839
update
Fariusz Apr 26, 2022
3cfd098
update
Fariusz Apr 27, 2022
eaeeb94
update
Fariusz Apr 27, 2022
7aa1540
update
Fariusz Apr 28, 2022
3d790f4
update
Fariusz Apr 29, 2022
48dfab8
update
Fariusz May 9, 2022
2718094
Merge pull request #31 from Fariusz/dev
Fariusz May 9, 2022
8cb9cdf
update
Fariusz May 10, 2022
a06fb2c
fixed bug
Fariusz May 10, 2022
650a154
Merge pull request #32 from Fariusz/dev
Fariusz May 24, 2022
16ef484
Update README.md
Fariusz May 26, 2022
610afdc
Update README.md
Fariusz Jun 3, 2022
5d58509
Add files via upload
Fariusz Apr 7, 2023
9824c90
Update README.md
Fariusz Sep 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 4 additions & 7 deletions .idea/progress_tracker.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 16 additions & 13 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Binary file added Radoslaw_Loth_praca_inzynierska.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ public List<Activity> getUserActivities(@AuthenticationPrincipal String username
return activityService.getUserActivities(username);
}

@GetMapping("/userActivitiesByListId/{id}")
public List<Activity> userActivitiesByListId(@PathVariable long id) {
return activityService.userActivitiesByListId(id);
}

@GetMapping("/userActivities/pageable")
public List<Activity> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public List<Content> getContent() {
return contentService.getContent();
}



@GetMapping("/content/{id}")
public List<Content> getActivityContent(@PathVariable long id) {
return contentService.getActivityContent(id);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ActivitiesList> getLists() {
return listService.getLists();
}

@GetMapping("/userLists")
public List<ActivitiesList> 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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ public ResponseEntity<String> 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Activity> activities;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ public interface ActivityRepository extends JpaRepository<Activity, Long> {
@Query("select distinct a from Activity a" + " left join fetch a.content")
List<Activity> findAllActivitiesPageable(Pageable page);

@Query("select a from Activity a where author_id = ?1")
@Query("select a from Activity a where authorId = ?1")
List<Activity> findActivitiesByUserId(Long id);

@Query("select a from Activity a where author_id = ?1")
@Query("select a from Activity a where authorId = ?1")
List<Activity> findActivitiesByUserIdPageable(Long id, Pageable page);

@Query("select a from Activity a where listId = ?1")
List<Activity> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ActivitiesList, Long> {
@Query("select a from ActivitiesList a where authorId = ?1")
List<ActivitiesList> findListsByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private List<Content> extractContents(List<Content> 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);
}

Expand All @@ -101,4 +101,8 @@ public void deleteActivity(long id) {
public void clearActivities() {
//Ta metoda czyści Cache
}

public List<Activity> userActivitiesByListId(long id) {
return activityRepository.findAllByListId(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<ActivitiesList> getLists() {
return listRepository.findAll();
}

public List<ActivitiesList> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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
);
);

ALTER TABLE activity
ADD CONSTRAINT activity_list_id
FOREIGN KEY (list_id) REFERENCES activities_list (id);
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down
Loading