From 49eaec0f354f6751f35a466ee6207fbf9af2ec8f Mon Sep 17 00:00:00 2001 From: Boris Blagojevic Date: Mon, 19 Feb 2024 11:59:54 +0100 Subject: [PATCH] #73: Detailed task Added new projections Improved deadline date update --- .../pages/task/overview/row/DeadlineRow.js | 12 +++++------- docker-compose.yml | 4 ++-- .../java/com/dashnet/dashNet/Search/Search.java | 10 ++++++++++ .../dashnet/dashNet/Search/SearchController.java | 11 +++++++++++ .../Task/Projections/ShortTasksProjection.java | 14 ++++++++++++++ .../Task/Projections/StoreTaskProjection.java | 8 ++++++++ .../main/java/com/dashnet/dashNet/Task/Task.java | 4 +--- .../com/dashnet/dashNet/Task/TaskController.java | 10 ++++++---- .../com/dashnet/dashNet/Task/TaskRepository.java | 6 +++--- .../java/com/dashnet/dashNet/Task/TaskService.java | 10 +++------- 10 files changed, 63 insertions(+), 26 deletions(-) create mode 100644 service/src/main/java/com/dashnet/dashNet/Search/Search.java create mode 100644 service/src/main/java/com/dashnet/dashNet/Search/SearchController.java create mode 100644 service/src/main/java/com/dashnet/dashNet/Task/Projections/ShortTasksProjection.java create mode 100644 service/src/main/java/com/dashnet/dashNet/Task/Projections/StoreTaskProjection.java diff --git a/app/web/src/components/pages/task/overview/row/DeadlineRow.js b/app/web/src/components/pages/task/overview/row/DeadlineRow.js index c1ad726..4fa4caa 100644 --- a/app/web/src/components/pages/task/overview/row/DeadlineRow.js +++ b/app/web/src/components/pages/task/overview/row/DeadlineRow.js @@ -2,7 +2,7 @@ import dayjs from 'dayjs'; import {useDispatch} from 'react-redux'; import {TableCell, TableRow} from '@mui/material'; import {useState} from 'react'; -import {DemoContainer} from '@mui/x-date-pickers/internals/demo'; +import 'dayjs/locale/en-gb'; import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider'; import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs'; import {DatePicker} from '@mui/x-date-pickers/DatePicker'; @@ -15,8 +15,8 @@ const DeadlineRow = ({task, id, tkn}) => const handleChange = (nval) => { - console.log(`${nval.$y}-${nval.$M < 10 ? '0' + nval.$M : nval.$M}-${nval.$D < 10 ? '0' + nval.$M : nval.$M}`) - dispatch(updateTaskValuePatch(tkn, id, 'deadlineDate', `${nval.$y}-${nval.$M}-${nval.$D}`)); + dispatch(updateTaskValuePatch(tkn, id, 'deadlineDate' + , `${nval.$y}-${nval.$M < 10 ? '0' + (nval.$M + 1): (nval.$M + 1)}-${nval.$D < 10 ? '0' + nval.$D : nval.$D}`)); setValue(nval); } @@ -26,10 +26,8 @@ const DeadlineRow = ({task, id, tkn}) => Deadline - - - - + + diff --git a/docker-compose.yml b/docker-compose.yml index 640d2ca..40ee36f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,8 +56,8 @@ services: deploy: mode: replicated replicas: ${NODE_REPLICAS} - volumes: - - './app/web/src:/app/src' +# volumes: +# - './app/web/src:/app/src' TODO: Volumes problem on Windows machine environment: - FAST_REFRESH=false - WDS_SOCKET_PORT=${NODE_PORT} diff --git a/service/src/main/java/com/dashnet/dashNet/Search/Search.java b/service/src/main/java/com/dashnet/dashNet/Search/Search.java new file mode 100644 index 0000000..ebcda52 --- /dev/null +++ b/service/src/main/java/com/dashnet/dashNet/Search/Search.java @@ -0,0 +1,10 @@ +package com.dashnet.dashNet.Search; + +import com.dashnet.dashNet.Task.Projections.StoreTaskProjection; + +import java.util.List; + +public class Search +{ + private List results; +} diff --git a/service/src/main/java/com/dashnet/dashNet/Search/SearchController.java b/service/src/main/java/com/dashnet/dashNet/Search/SearchController.java new file mode 100644 index 0000000..bac1287 --- /dev/null +++ b/service/src/main/java/com/dashnet/dashNet/Search/SearchController.java @@ -0,0 +1,11 @@ +package com.dashnet.dashNet.Search; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/search") +public class SearchController +{ + +} diff --git a/service/src/main/java/com/dashnet/dashNet/Task/Projections/ShortTasksProjection.java b/service/src/main/java/com/dashnet/dashNet/Task/Projections/ShortTasksProjection.java new file mode 100644 index 0000000..85bb192 --- /dev/null +++ b/service/src/main/java/com/dashnet/dashNet/Task/Projections/ShortTasksProjection.java @@ -0,0 +1,14 @@ +package com.dashnet.dashNet.Task.Projections; + +import com.dashnet.dashNet.User.User; + +import java.sql.Date; + +public interface ShortTasksProjection +{ + Long getId(); + String getTitle(); + Date getDeadlineDate(); + int getStatus(); + User getAssagnedUser(); +} diff --git a/service/src/main/java/com/dashnet/dashNet/Task/Projections/StoreTaskProjection.java b/service/src/main/java/com/dashnet/dashNet/Task/Projections/StoreTaskProjection.java new file mode 100644 index 0000000..a0ccf6b --- /dev/null +++ b/service/src/main/java/com/dashnet/dashNet/Task/Projections/StoreTaskProjection.java @@ -0,0 +1,8 @@ +package com.dashnet.dashNet.Task.Projections; + +public interface StoreTaskProjection +{ + Long getId(); + String getTitle(); + String getDescription(); +} diff --git a/service/src/main/java/com/dashnet/dashNet/Task/Task.java b/service/src/main/java/com/dashnet/dashNet/Task/Task.java index d65b279..c65f3e2 100644 --- a/service/src/main/java/com/dashnet/dashNet/Task/Task.java +++ b/service/src/main/java/com/dashnet/dashNet/Task/Task.java @@ -141,9 +141,7 @@ public void setTtype(String ttype) this.ttype = ttype; } - public Task() - { - } + public Task() {} @Override public int hashCode() diff --git a/service/src/main/java/com/dashnet/dashNet/Task/TaskController.java b/service/src/main/java/com/dashnet/dashNet/Task/TaskController.java index 3a95227..f8feca0 100644 --- a/service/src/main/java/com/dashnet/dashNet/Task/TaskController.java +++ b/service/src/main/java/com/dashnet/dashNet/Task/TaskController.java @@ -2,6 +2,8 @@ import com.dashnet.dashNet.Task.Exceptions.TaskGenericException; import com.dashnet.dashNet.Task.Exceptions.TaskNotFoundException; +import com.dashnet.dashNet.Task.Projections.ShortTasksProjection; +import com.dashnet.dashNet.Task.Projections.StoreTaskProjection; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -55,8 +57,8 @@ public ResponseEntity> getOne(@PathVariable Long id) @GetMapping("/team/{teamId}") public ResponseEntity> getByTeam(@PathVariable Long teamId) { - List a = taskRepository - .findByTeamId(teamId); + List a = taskRepository + .findByTeamId(teamId, ShortTasksProjection.class); if (a.isEmpty()) { @@ -69,13 +71,13 @@ public ResponseEntity> getByTeam(@PathVariable Long teamId) @GetMapping("title/{param}") public ResponseEntity> getByTitle(@PathVariable String param) { - return taskService.returnOkResponse(false, "", 1, true, taskRepository.findByTitleContaining(param)); + return taskService.returnOkResponse(false, "", 1, true, taskRepository.findByTitleContaining(param, StoreTaskProjection.class)); } @GetMapping("description/{param}") public ResponseEntity> getByDescription(@PathVariable String param) { - return taskService.returnOkResponse(false, "", 1, true, taskRepository.findByDescriptionContaining(param)); + return taskService.returnOkResponse(false, "", 1, true, taskRepository.findByDescriptionContaining(param, StoreTaskProjection.class)); } @PostMapping(path = "/create") diff --git a/service/src/main/java/com/dashnet/dashNet/Task/TaskRepository.java b/service/src/main/java/com/dashnet/dashNet/Task/TaskRepository.java index 9136255..b9d918e 100644 --- a/service/src/main/java/com/dashnet/dashNet/Task/TaskRepository.java +++ b/service/src/main/java/com/dashnet/dashNet/Task/TaskRepository.java @@ -5,7 +5,7 @@ import java.util.List; public interface TaskRepository extends CrudRepository { - List findByTitleContaining(String title); - List findByDescriptionContaining(String description); - List findByTeamId(Long teamid); + List findByTitleContaining(String title, Class type); + List findByDescriptionContaining(String description, Class type); + List findByTeamId(Long teamid, Class type); } \ No newline at end of file diff --git a/service/src/main/java/com/dashnet/dashNet/Task/TaskService.java b/service/src/main/java/com/dashnet/dashNet/Task/TaskService.java index 9e47e8a..f16bc2d 100644 --- a/service/src/main/java/com/dashnet/dashNet/Task/TaskService.java +++ b/service/src/main/java/com/dashnet/dashNet/Task/TaskService.java @@ -10,9 +10,7 @@ public class TaskService { - TaskService() - { - } + TaskService() {} protected Task createTask(HashMap ReqMap) { @@ -38,7 +36,7 @@ protected HashMap countTasks(TaskRepository taskRepository, Lon if (teamID != -1) { - a = taskRepository.findByTeamId(teamID); + a = taskRepository.findByTeamId(teamID, Task.class); } else { a = (List) taskRepository.findAll(); @@ -59,9 +57,7 @@ protected HashMap countTasks(TaskRepository taskRepository, Lon case 1 -> inProgress++; case 2 -> review++; case 3 -> done++; - default -> - { - } + default -> {} } }