Skip to content

Commit

Permalink
#73: Detailed task
Browse files Browse the repository at this point in the history
Added new projections
Improved deadline date update
  • Loading branch information
Blagoja95 committed Feb 19, 2024
1 parent fb0483e commit 4b84723
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/web/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
{
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -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 = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () =>
Expand Down
Original file line number Diff line number Diff line change
@@ -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}) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}) =>
{
Expand All @@ -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);
}
Expand All @@ -26,10 +26,8 @@ const DeadlineRow = ({task, id, tkn}) =>
Deadline
</TableCell>
<TableCell>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<DemoContainer components={['DatePicker']}>
<DatePicker label="Basic date picker" value={value} onChange={handleChange}/>
</DemoContainer>
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale={'en-gb'}>
<DatePicker value={value} onChange={handleChange}/>
</LocalizationProvider>
</TableCell>
</TableRow>
Expand Down
Original file line number Diff line number Diff line change
@@ -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}) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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}) =>
{
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
10 changes: 10 additions & 0 deletions service/src/main/java/com/dashnet/dashNet/Search/Search.java
Original file line number Diff line number Diff line change
@@ -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<StoreTaskProjection> results;
}
Original file line number Diff line number Diff line change
@@ -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
{

}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.dashnet.dashNet.Task.Projections;

public interface StoreTaskProjection
{
Long getId();
String getTitle();
String getDescription();
}
4 changes: 1 addition & 3 deletions service/src/main/java/com/dashnet/dashNet/Task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ public void setTtype(String ttype)
this.ttype = ttype;
}

public Task()
{
}
public Task() {}

@Override
public int hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -55,8 +57,8 @@ public ResponseEntity<Map<String, Object>> getOne(@PathVariable Long id)
@GetMapping("/team/{teamId}")
public ResponseEntity<Map<String, Object>> getByTeam(@PathVariable Long teamId)
{
List<Task> a = taskRepository
.findByTeamId(teamId);
List<ShortTasksProjection> a = taskRepository
.findByTeamId(teamId, ShortTasksProjection.class);

if (a.isEmpty())
{
Expand All @@ -69,13 +71,13 @@ public ResponseEntity<Map<String, Object>> getByTeam(@PathVariable Long teamId)
@GetMapping("title/{param}")
public ResponseEntity<Map<String, Object>> 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<Map<String, Object>> 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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;

public interface TaskRepository extends CrudRepository<Task, Long> {
List<Task> findByTitleContaining(String title);
List<Task> findByDescriptionContaining(String description);
List<Task> findByTeamId(Long teamid);
<T> List<T> findByTitleContaining(String title, Class<T> type);
<T> List<T> findByDescriptionContaining(String description, Class<T> type);
<T> List<T> findByTeamId(Long teamid, Class<T> type);
}
10 changes: 3 additions & 7 deletions service/src/main/java/com/dashnet/dashNet/Task/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

public class TaskService
{
TaskService()
{
}
TaskService() {}

protected Task createTask(HashMap<String, String> ReqMap)
{
Expand All @@ -38,7 +36,7 @@ protected HashMap<String, Integer> countTasks(TaskRepository taskRepository, Lon

if (teamID != -1)
{
a = taskRepository.findByTeamId(teamID);
a = taskRepository.findByTeamId(teamID, Task.class);
} else
{
a = (List<Task>) taskRepository.findAll();
Expand All @@ -59,9 +57,7 @@ protected HashMap<String, Integer> countTasks(TaskRepository taskRepository, Lon
case 1 -> inProgress++;
case 2 -> review++;
case 3 -> done++;
default ->
{
}
default -> {}
}
}

Expand Down

0 comments on commit 4b84723

Please sign in to comment.