From 4b8472349cb6e0a59c915f9253bb0ff27e4a9d88 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 --- app/web/src/App.js | 2 +- .../src/components/pages/task/create/CreateTask.js | 0 .../components/pages/task/{ => detailed}/Task.js | 4 ++-- .../{ => detailed}/description/TaskDescription.js | 2 +- .../{ => detailed}/navigation/TabNavigation.js | 0 .../task/{ => detailed}/navigation/TaskHeader.js | 4 ++-- .../task/{ => detailed}/overview/TaskOverview.js | 2 +- .../{ => detailed}/overview/row/AssigneeRow.js | 2 +- .../{ => detailed}/overview/row/DeadlineRow.js | 14 ++++++-------- .../task/{ => detailed}/overview/row/StatusRow.js | 2 +- .../task/{ => detailed}/overview/row/TeamRow.js | 0 .../task/{ => detailed}/overview/row/TypeRow.js | 2 +- 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 +++------- 21 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 app/web/src/components/pages/task/create/CreateTask.js rename app/web/src/components/pages/task/{ => detailed}/Task.js (81%) rename app/web/src/components/pages/task/{ => detailed}/description/TaskDescription.js (95%) rename app/web/src/components/pages/task/{ => detailed}/navigation/TabNavigation.js (100%) rename app/web/src/components/pages/task/{ => detailed}/navigation/TaskHeader.js (88%) rename app/web/src/components/pages/task/{ => detailed}/overview/TaskOverview.js (95%) rename app/web/src/components/pages/task/{ => detailed}/overview/row/AssigneeRow.js (89%) rename app/web/src/components/pages/task/{ => detailed}/overview/row/DeadlineRow.js (55%) rename app/web/src/components/pages/task/{ => detailed}/overview/row/StatusRow.js (81%) rename app/web/src/components/pages/task/{ => detailed}/overview/row/TeamRow.js (100%) rename app/web/src/components/pages/task/{ => detailed}/overview/row/TypeRow.js (89%) 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/App.js b/app/web/src/App.js index d63e108..87ccc95 100644 --- a/app/web/src/App.js +++ b/app/web/src/App.js @@ -10,7 +10,7 @@ import Settings from './components/pages/settings/Settings'; import Login from './components/pages/auth/login/Login'; import Register from './components/pages/auth/register/Register'; import HandleSession from './components/pages/auth/HandleSession'; -import Task from './components/pages/task/Task'; +import Task from './components/pages/task/detailed/Task'; const App = () => { diff --git a/app/web/src/components/pages/task/create/CreateTask.js b/app/web/src/components/pages/task/create/CreateTask.js new file mode 100644 index 0000000..e69de29 diff --git a/app/web/src/components/pages/task/Task.js b/app/web/src/components/pages/task/detailed/Task.js similarity index 81% rename from app/web/src/components/pages/task/Task.js rename to app/web/src/components/pages/task/detailed/Task.js index 5e2cde5..b5be3b7 100644 --- a/app/web/src/components/pages/task/Task.js +++ b/app/web/src/components/pages/task/detailed/Task.js @@ -1,8 +1,8 @@ import {useDispatch, useSelector} from 'react-redux'; import {useEffect} from 'react'; -import {getTaskDetails} from '../../../store/controllers/taskController'; +import {getTaskDetails} from '../../../../store/controllers/taskController'; import TabNavigation from './navigation/TabNavigation'; -import {taskActions} from '../../../store/slices/taskSlice'; +import {taskActions} from '../../../../store/slices/taskSlice'; import TaskHeader from './navigation/TaskHeader'; const Task = () => diff --git a/app/web/src/components/pages/task/description/TaskDescription.js b/app/web/src/components/pages/task/detailed/description/TaskDescription.js similarity index 95% rename from app/web/src/components/pages/task/description/TaskDescription.js rename to app/web/src/components/pages/task/detailed/description/TaskDescription.js index 79edd38..bad17e6 100644 --- a/app/web/src/components/pages/task/description/TaskDescription.js +++ b/app/web/src/components/pages/task/detailed/description/TaskDescription.js @@ -3,7 +3,7 @@ import {Box} from '@mui/material'; import {useRef, useState} from 'react'; import rehypeSanitize from 'rehype-sanitize'; import MDEditor, {commands} from '@uiw/react-md-editor'; -import {updateTaskValuePatch} from '../../../../store/controllers/taskController'; +import {updateTaskValuePatch} from '../../../../../store/controllers/taskController'; const TaskDescription = () => { diff --git a/app/web/src/components/pages/task/navigation/TabNavigation.js b/app/web/src/components/pages/task/detailed/navigation/TabNavigation.js similarity index 100% rename from app/web/src/components/pages/task/navigation/TabNavigation.js rename to app/web/src/components/pages/task/detailed/navigation/TabNavigation.js diff --git a/app/web/src/components/pages/task/navigation/TaskHeader.js b/app/web/src/components/pages/task/detailed/navigation/TaskHeader.js similarity index 88% rename from app/web/src/components/pages/task/navigation/TaskHeader.js rename to app/web/src/components/pages/task/detailed/navigation/TaskHeader.js index e71dfb9..d3e0dec 100644 --- a/app/web/src/components/pages/task/navigation/TaskHeader.js +++ b/app/web/src/components/pages/task/detailed/navigation/TaskHeader.js @@ -1,8 +1,8 @@ -import Header from '../../../layout/header/Header'; +import Header from '../../../../layout/header/Header'; import {useDispatch, useSelector} from 'react-redux'; import {useState} from 'react'; import {TextField} from '@mui/material'; -import {updateTaskValuePatch} from '../../../../store/controllers/taskController'; +import {updateTaskValuePatch} from '../../../../../store/controllers/taskController'; const TaskHeader = () => { diff --git a/app/web/src/components/pages/task/overview/TaskOverview.js b/app/web/src/components/pages/task/detailed/overview/TaskOverview.js similarity index 95% rename from app/web/src/components/pages/task/overview/TaskOverview.js rename to app/web/src/components/pages/task/detailed/overview/TaskOverview.js index f264c7e..e063749 100644 --- a/app/web/src/components/pages/task/overview/TaskOverview.js +++ b/app/web/src/components/pages/task/detailed/overview/TaskOverview.js @@ -5,7 +5,7 @@ import AssigneeRow from './row/AssigneeRow'; import TypeRow from './row/TypeRow'; import DeadlineRow from './row/DeadlineRow'; import StatusRow from './row/StatusRow'; -import {deleteTask} from '../../../../store/controllers/taskController'; +import {deleteTask} from '../../../../../store/controllers/taskController'; import {useNavigate} from 'react-router-dom'; const TaskOverview = () => diff --git a/app/web/src/components/pages/task/overview/row/AssigneeRow.js b/app/web/src/components/pages/task/detailed/overview/row/AssigneeRow.js similarity index 89% rename from app/web/src/components/pages/task/overview/row/AssigneeRow.js rename to app/web/src/components/pages/task/detailed/overview/row/AssigneeRow.js index 67635fa..5772f6a 100644 --- a/app/web/src/components/pages/task/overview/row/AssigneeRow.js +++ b/app/web/src/components/pages/task/detailed/overview/row/AssigneeRow.js @@ -1,5 +1,5 @@ import {TableCell, TableRow} from '@mui/material'; -import UserAvatar from '../../../../ui/avatar/UserAvatar'; +import UserAvatar from '../../../../../ui/avatar/UserAvatar'; const AssigneeRow = ({task}) => { diff --git a/app/web/src/components/pages/task/overview/row/DeadlineRow.js b/app/web/src/components/pages/task/detailed/overview/row/DeadlineRow.js similarity index 55% rename from app/web/src/components/pages/task/overview/row/DeadlineRow.js rename to app/web/src/components/pages/task/detailed/overview/row/DeadlineRow.js index c1ad726..c214344 100644 --- a/app/web/src/components/pages/task/overview/row/DeadlineRow.js +++ b/app/web/src/components/pages/task/detailed/overview/row/DeadlineRow.js @@ -2,11 +2,11 @@ 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'; -import {updateTaskValuePatch} from '../../../../../store/controllers/taskController'; +import {updateTaskValuePatch} from '../../../../../../store/controllers/taskController'; const DeadlineRow = ({task, id, tkn}) => { @@ -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/app/web/src/components/pages/task/overview/row/StatusRow.js b/app/web/src/components/pages/task/detailed/overview/row/StatusRow.js similarity index 81% rename from app/web/src/components/pages/task/overview/row/StatusRow.js rename to app/web/src/components/pages/task/detailed/overview/row/StatusRow.js index 3a1de2c..0da1bcf 100644 --- a/app/web/src/components/pages/task/overview/row/StatusRow.js +++ b/app/web/src/components/pages/task/detailed/overview/row/StatusRow.js @@ -1,5 +1,5 @@ import {TableCell, TableRow} from '@mui/material'; -import TaskStatusChip from '../../../../ui/chip/TaskStatusChip'; +import TaskStatusChip from '../../../../../ui/chip/TaskStatusChip'; const StatusRow = ({id, statusVal, tkn}) => { diff --git a/app/web/src/components/pages/task/overview/row/TeamRow.js b/app/web/src/components/pages/task/detailed/overview/row/TeamRow.js similarity index 100% rename from app/web/src/components/pages/task/overview/row/TeamRow.js rename to app/web/src/components/pages/task/detailed/overview/row/TeamRow.js diff --git a/app/web/src/components/pages/task/overview/row/TypeRow.js b/app/web/src/components/pages/task/detailed/overview/row/TypeRow.js similarity index 89% rename from app/web/src/components/pages/task/overview/row/TypeRow.js rename to app/web/src/components/pages/task/detailed/overview/row/TypeRow.js index ba6ff9d..b1979a1 100644 --- a/app/web/src/components/pages/task/overview/row/TypeRow.js +++ b/app/web/src/components/pages/task/detailed/overview/row/TypeRow.js @@ -1,7 +1,7 @@ import {TableCell, TableRow, TextField} from '@mui/material'; import {useDispatch} from 'react-redux'; import {useState} from 'react'; -import {updateTaskValuePatch} from '../../../../../store/controllers/taskController'; +import {updateTaskValuePatch} from '../../../../../../store/controllers/taskController'; const TypeRow = ({tkn, task, id}) => { 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 -> {} } }