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 e375dc2 commit 49eaec0
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 26 deletions.
12 changes: 5 additions & 7 deletions app/web/src/components/pages/task/overview/row/DeadlineRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
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
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 49eaec0

Please sign in to comment.