Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
8d19d7f9
Commit
8d19d7f9
authored
Jan 09, 2023
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error throw package added
parent
d56c1f40
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
155 additions
and
101 deletions
+155
-101
package-lock.json
planner-api/package-lock.json
+15
-0
package.json
planner-api/package.json
+1
-0
helpers.ts
planner-api/src/helpers.ts
+2
-1
tasks.ts
planner-api/src/routers/tasks.ts
+64
-48
Select.js
planner-front/src/components/UI/Select/Select.js
+0
-6
NewTaskForm.js
...-front/src/components/UsersTasksCompoments/NewTaskForm.js
+1
-1
TableRowTask.js
...ponents/UsersTasksCompoments/TableRowTask/TableRowTask.js
+69
-45
UsersTasks.js
planner-front/src/containers/UsersTasks/UsersTasks.js
+3
-0
No files found.
planner-api/package-lock.json
View file @
8d19d7f9
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
"class-validator"
:
"^0.13.2"
,
"class-validator"
:
"^0.13.2"
,
"cors"
:
"^2.8.5"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.18.2"
,
"express"
:
"^4.18.2"
,
"express-async-errors"
:
"^3.1.1"
,
"mongoose"
:
"^6.7.0"
,
"mongoose"
:
"^6.7.0"
,
"multer"
:
"^1.4.5-lts.1"
,
"multer"
:
"^1.4.5-lts.1"
,
"nanoid"
:
"^3.3.4"
,
"nanoid"
:
"^3.3.4"
,
...
@@ -3329,6 +3330,14 @@
...
@@ -3329,6 +3330,14 @@
"node"
:
">= 0.10.0"
"node"
:
">= 0.10.0"
}
}
},
},
"node_modules/express-async-errors"
:
{
"version"
:
"3.1.1"
,
"resolved"
:
"https://registry.npmjs.org/express-async-errors/-/express-async-errors-3.1.1.tgz"
,
"integrity"
:
"sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng=="
,
"peerDependencies"
:
{
"express"
:
"^4.16.2"
}
},
"node_modules/express/node_modules/debug"
:
{
"node_modules/express/node_modules/debug"
:
{
"version"
:
"2.6.9"
,
"version"
:
"2.6.9"
,
"resolved"
:
"https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
,
"resolved"
:
"https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
,
...
@@ -8887,6 +8896,12 @@
...
@@ -8887,6 +8896,12 @@
}
}
}
}
},
},
"express-async-errors"
:
{
"version"
:
"3.1.1"
,
"resolved"
:
"https://registry.npmjs.org/express-async-errors/-/express-async-errors-3.1.1.tgz"
,
"integrity"
:
"sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng=="
,
"requires"
:
{}
},
"fast-deep-equal"
:
{
"fast-deep-equal"
:
{
"version"
:
"3.1.3"
,
"version"
:
"3.1.3"
,
"resolved"
:
"https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
,
"resolved"
:
"https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
,
...
...
planner-api/package.json
View file @
8d19d7f9
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
"class-validator"
:
"^0.13.2"
,
"class-validator"
:
"^0.13.2"
,
"cors"
:
"^2.8.5"
,
"cors"
:
"^2.8.5"
,
"express"
:
"^4.18.2"
,
"express"
:
"^4.18.2"
,
"express-async-errors"
:
"^3.1.1"
,
"mongoose"
:
"^6.7.0"
,
"mongoose"
:
"^6.7.0"
,
"multer"
:
"^1.4.5-lts.1"
,
"multer"
:
"^1.4.5-lts.1"
,
"nanoid"
:
"^3.3.4"
,
"nanoid"
:
"^3.3.4"
,
...
...
planner-api/src/helpers.ts
View file @
8d19d7f9
import
'express-async-errors'
;
import
express
,
{
NextFunction
,
Request
,
Response
,
Router
}
from
"express"
;
import
express
,
{
NextFunction
,
Request
,
Response
,
Router
}
from
"express"
;
import
{
myDataSource
}
from
"./app-data-source"
;
import
{
myDataSource
}
from
"./app-data-source"
;
import
{
Task
}
from
"./models/Task"
;
import
{
Task
}
from
"./models/Task"
;
...
@@ -59,7 +60,7 @@ export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next
...
@@ -59,7 +60,7 @@ export const authAuthorOrExecutorOfTask = async(req: Request,res: Response, next
}
}
const
{
executorStatus
,
authorStatus
}
=
req
.
body
const
{
executorStatus
,
authorStatus
}
=
req
.
body
if
(
!
executorStatus
&&
!
authorStatus
)
{
if
(
!
executorStatus
&&
!
authorStatus
)
{
res
.
status
(
403
).
send
({
message
:
'user is not authorized'
})
re
turn
re
s
.
status
(
403
).
send
({
message
:
'user is not authorized'
})
}
}
req
.
body
=
{...
req
.
body
,
task
:
task
}
req
.
body
=
{...
req
.
body
,
task
:
task
}
next
()
next
()
...
...
planner-api/src/routers/tasks.ts
View file @
8d19d7f9
import
'express-async-errors'
;
import
express
,{
Router
,
Request
,
Response
}
from
'express'
;
import
express
,{
Router
,
Request
,
Response
}
from
'express'
;
import
{
Task
}
from
'../models/Task'
;
import
{
Task
}
from
'../models/Task'
;
import
{
myDataSource
}
from
'../app-data-source'
;
import
{
myDataSource
}
from
'../app-data-source'
;
...
@@ -196,8 +197,11 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
...
@@ -196,8 +197,11 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
/**check tasks of current user where he is executor(works for tbl MyTasks), search by id*/
/**check tasks of current user where he is executor(works for tbl MyTasks), search by id*/
router
.
get
(
'/my'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
get
(
'/my'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
let
projectsRawId
=
[]
try
{
const
user
=
req
.
body
.
user
const
user
=
req
.
body
.
user
const
projectsRawId
=
await
dataSource
projectsRawId
=
await
dataSource
.
getRepository
(
Project
)
.
getRepository
(
Project
)
.
find
({
.
find
({
select
:{
select
:{
...
@@ -245,7 +249,13 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
...
@@ -245,7 +249,13 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
id
:
In
(
projectsList
)
id
:
In
(
projectsList
)
}
}
})
})
return
res
.
send
({
tasks
,
projects
})
return
res
.
send
({
tasks
,
projects
})
}
catch
(
e
){
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
})
})
...
@@ -386,6 +396,7 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
...
@@ -386,6 +396,7 @@ router.post('/project',async (req: Request, res: Response):Promise<Response>=>{
/**check other users tasks that are related to the user through common projects, by user token*/
/**check other users tasks that are related to the user through common projects, by user token*/
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
}
=
req
.
body
const
{
user
}
=
req
.
body
try
{
const
projectsWithTasks
=
await
dataSource
const
projectsWithTasks
=
await
dataSource
.
getRepository
(
Project
)
.
getRepository
(
Project
)
.
find
(
.
find
(
...
@@ -407,6 +418,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
...
@@ -407,6 +418,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
}
}
}
}
}})
}})
if
(
!
projectsWithTasks
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
if
(
!
projectsWithTasks
)
return
res
.
status
(
404
).
send
({
Message
:
'projects not found'
})
let
tasks
:
Task
[]
=
[]
let
tasks
:
Task
[]
=
[]
if
(
projectsWithTasks
.
length
>
0
)
{
if
(
projectsWithTasks
.
length
>
0
)
{
...
@@ -416,6 +428,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
...
@@ -416,6 +428,7 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
}
}
}
}
}
}
const
projectIds
=
projectsWithTasks
.
map
(
project
=>
{
return
project
.
id
})
const
projectIds
=
projectsWithTasks
.
map
(
project
=>
{
return
project
.
id
})
const
projects
=
await
dataSource
const
projects
=
await
dataSource
.
getRepository
(
Project
)
.
getRepository
(
Project
)
...
@@ -430,9 +443,12 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
...
@@ -430,9 +443,12 @@ router.get('/users-tasks', auth,async (req: Request, res: Response):Promise<Resp
roleProject
:
Not
(
MemberRole
.
WATCHER
)
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
}
},
},
})
})
return
res
.
send
({
projects
,
tasks
})
return
res
.
send
({
projects
,
tasks
})
}
catch
(
e
){
console
.
log
(
'Error: '
,(
e
as
Error
).
message
);
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
}
})
})
...
...
planner-front/src/components/UI/Select/Select.js
View file @
8d19d7f9
...
@@ -6,11 +6,6 @@ import FormControl from "@mui/material/FormControl";
...
@@ -6,11 +6,6 @@ import FormControl from "@mui/material/FormControl";
import
Select
from
"@mui/material/Select"
;
import
Select
from
"@mui/material/Select"
;
export
default
function
BasicSelect
({
value
,
label
,
name
,
onChange
,
task
,
items
})
{
export
default
function
BasicSelect
({
value
,
label
,
name
,
onChange
,
task
,
items
})
{
// console.log('select value ', value)
// console.log('select label ', label)
// console.log('select name ', name)
// console.log('select task ', task)
// console.log('select items ', items)
return
(
return
(
<
Box
sx
=
{{
minWidth
:
60
,
m
:
0
}}
>
<
Box
sx
=
{{
minWidth
:
60
,
m
:
0
}}
>
<
FormControl
fullWidth
>
<
FormControl
fullWidth
>
...
@@ -20,7 +15,6 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
...
@@ -20,7 +15,6 @@ export default function BasicSelect({value,label,name,onChange,task,items}) {
id
=
"demo-simple-select"
id
=
"demo-simple-select"
value
=
{
value
}
value
=
{
value
}
defaultValue
=
''
defaultValue
=
''
// displayEmpty={true}
label
=
{
label
}
label
=
{
label
}
name
=
{
name
}
name
=
{
name
}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
onChange
=
{(
e
)
=>
onChange
(
e
,
task
)}
...
...
planner-front/src/components/UsersTasksCompoments/NewTaskForm.js
View file @
8d19d7f9
...
@@ -178,7 +178,7 @@ export default function NewTaskForm({
...
@@ -178,7 +178,7 @@ export default function NewTaskForm({
task
=
{
task
}
task
=
{
task
}
onChange
=
{
onExecutorChange
}
onChange
=
{
onExecutorChange
}
name
=
"executor"
name
=
"executor"
value
=
{
task
.
executor
?.
id
}
value
=
{
task
?
.
executor
?.
id
}
defaultValue
=
{
user
.
id
}
defaultValue
=
{
user
.
id
}
/
>
/
>
<
/TableCell
>
<
/TableCell
>
...
...
planner-front/src/components/UsersTasksCompoments/TableRowTask/TableRowTask.js
View file @
8d19d7f9
import
*
as
React
from
"react"
;
import
React
,{
useState
}
from
"react"
;
import
{
import
{
TableCell
,
TableCell
,
TableRow
,
TableRow
,
...
@@ -33,17 +33,20 @@ const TableRowTask= ({
...
@@ -33,17 +33,20 @@ const TableRowTask= ({
deleteDateTimeTask
,
deleteDateTimeTask
,
onChange
,
onChange
,
onModalOpen
,
onModalOpen
,
onProjectChange
,
//
onProjectChange,
onExecutorChange
,
//
onExecutorChange,
uniqueProjects
,
uniqueProjects
,
executors
,
// executors,
onAuthorChange
,
onDateChange
,
onDateChange
,
onToggleEditMode
,
onToggleEditMode
,
onToggleEditModeDone
,
onToggleEditModeDone
,
})
=>
{
})
=>
{
const
[
open
,
setOpen
]
=
React
.
useState
(
false
);
const
[
open
,
setOpen
]
=
useState
(
false
);
const
[
defaultExecutor
,
setDefaultExecutor
]
=
useState
(
task
.
executor
?.
id
)
const
[
executors
,
setExecutors
]
=
useState
([])
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
roudHourUp
=
(
dateIso
)
=>
{
const
roudHourUp
=
(
dateIso
)
=>
{
let
m
=
moment
(
dateIso
);
let
m
=
moment
(
dateIso
);
...
@@ -61,6 +64,64 @@ const TableRowTask= ({
...
@@ -61,6 +64,64 @@ const TableRowTask= ({
return
weekDays
[
date
.
day
()];
return
weekDays
[
date
.
day
()];
}
}
const
onProjectChange
=
(
e
,
task
)
=>
{
e
.
preventDefault
()
setDefaultExecutor
(
user
)
const
projectId
=
e
.
target
.
value
;
const
project
=
uniqueProjects
.
length
>
0
?
uniqueProjects
.
find
((
uniqueProject
)
=>
uniqueProject
.
id
===
projectId
):
null
;
console
.
log
(
'change project '
,
project
)
setCurrentProject
(
project
)
let
executorList
=
[]
if
(
project
?.
members
){
for
(
let
member
of
project
.
members
){
executorList
.
push
(
member
.
user
)
}
}
setExecutors
(
executorList
)
// const { id } = task;
// const newTasks = recievedTasks.map((task) => {
// if (task.id === id) {
// const updated = { ...task };
// updated.project = project;
// updated.projectName =project.title? project.title:null;
// return updated;
// }
task
.
project
=
project
;
task
.
projectName
=
project
.
title
?
project
.
title
:
null
;
return
task
;
// });
// setRecievedTasks(newTasks);
};
const
onExecutorChange
=
(
e
,
task
)
=>
{
const
executorId
=
e
.
target
.
value
;
const
executor
=
executors
.
find
((
executor
)
=>
executor
.
id
===
executorId
);
// const { id } = task;
// const newTasks = recievedTasks.map((task) => {
// if (task.id === id) {
// const updated = { ...task };
// updated.executor = executor;
// updated.executorName = executor.displayName;
// return updated;
// }
// return task;
// });
// setRecievedTasks(newTasks);
task
.
executor
=
executor
;
task
.
executorName
=
executor
.
displayName
;
return
task
;
};
return
(
return
(
<>
<>
<
TableRow
hover
key
=
{
task
.
id
}
>
<
TableRow
hover
key
=
{
task
.
id
}
>
...
@@ -159,7 +220,7 @@ const TableRowTask= ({
...
@@ -159,7 +220,7 @@ const TableRowTask= ({
task
=
{
task
}
task
=
{
task
}
onChange
=
{
onExecutorChange
}
onChange
=
{
onExecutorChange
}
name
=
"executor"
name
=
"executor"
value
=
{
task
.
e
xecutor
?.
id
}
defaultValue
=
{
defaultE
xecutor
?.
id
}
/
>
/
>
<
/TableCell
>
<
/TableCell
>
)
:
(
)
:
(
...
@@ -180,19 +241,11 @@ const TableRowTask= ({
...
@@ -180,19 +241,11 @@ const TableRowTask= ({
task
,
task
,
name
:
"author"
,
name
:
"author"
,
value
:
task
.
author
.
displayName
,
value
:
task
.
author
.
displayName
,
// onChange: onAuthorChange,
user
:
user
user
:
user
}}
}}
/
>
/
>
{
task
.
isEditMode
&&
task
.
author
.
id
===
user
.
id
?
(
{
task
.
isEditMode
&&
task
.
author
.
id
===
user
.
id
?
(
<
TableCell
>
<
TableCell
>
{
/* <MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
user={user}
/> */
}
{
/* <TableCell> */
}
<
Tooltip
title
=
"Перейти в календарь"
>
<
Tooltip
title
=
"Перейти в календарь"
>
<
IconButton
<
IconButton
onClick
=
{(
id
)
=>
{
deleteHandle
(
task
.
id
);}}
onClick
=
{(
id
)
=>
{
deleteHandle
(
task
.
id
);}}
...
@@ -200,7 +253,6 @@ const TableRowTask= ({
...
@@ -200,7 +253,6 @@ const TableRowTask= ({
<
CalendarMonthIcon
/>
<
CalendarMonthIcon
/>
<
/IconButton
>
<
/IconButton
>
<
/Tooltip
>
<
/Tooltip
>
{
/* </TableCell> */
}
<
/TableCell
>
<
/TableCell
>
)
:
(
)
:
(
...
@@ -236,15 +288,6 @@ const TableRowTask= ({
...
@@ -236,15 +288,6 @@ const TableRowTask= ({
)}
)}
{
/* <TableCell>
<MaterialUIPickers
task={task}
name="dateTimeStart"
onChange={onDateChange}
user={user}
/>
</TableCell> */
}
{
task
.
isEditMode
&&
task
.
author
.
id
===
user
.
id
?
(
{
task
.
isEditMode
&&
task
.
author
.
id
===
user
.
id
?
(
<
TableCell
>
<
TableCell
>
<
MaterialUIPickers
<
MaterialUIPickers
...
@@ -373,26 +416,7 @@ const TableRowTask= ({
...
@@ -373,26 +416,7 @@ const TableRowTask= ({
<
TableCell
<
TableCell
// style={{width:'0%'}}
// style={{width:'0%'}}
>
>
{
/* <Tooltip title="Редактировать Копию">
{task.isEditMode ? (
<IconButton
aria-label="done"
onClick={() => {
onToggleEditModeDone(dateTimeTask.id);
handleEditDateTimeTask(dateTimeTask);
}}
>
<Done />
</IconButton>
) : (
<IconButton
aria-label="edit"
onClick={() => onToggleEditMode(dateTimeTask.id)}
>
<Edit />
</IconButton>
)}
</Tooltip> */
}
<
/TableCell
>
<
/TableCell
>
{
/* delete option datetimeTask */
}
{
/* delete option datetimeTask */
}
...
...
planner-front/src/containers/UsersTasks/UsersTasks.js
View file @
8d19d7f9
...
@@ -27,6 +27,7 @@ export default function UsersTasks() {
...
@@ -27,6 +27,7 @@ export default function UsersTasks() {
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
user
=
useSelector
((
state
)
=>
state
.
users
.
user
);
const
[
executors
,
setExecutors
]
=
useState
([])
const
[
executors
,
setExecutors
]
=
useState
([])
// const [currentExecutor, setCurrentExecutor]= useState(task.executor.id?task.executor:'')
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
currentProject
,
setCurrentProject
]
=
useState
(
null
);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
recievedTasks
,
setRecievedTasks
]
=
useState
([]);
const
[
addTaskForm
,
setAddTaskForm
]
=
useState
(
false
);
const
[
addTaskForm
,
setAddTaskForm
]
=
useState
(
false
);
...
@@ -39,6 +40,7 @@ export default function UsersTasks() {
...
@@ -39,6 +40,7 @@ export default function UsersTasks() {
task
:
null
,
task
:
null
,
});
});
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
fetchAllTasksByMembership
());
dispatch
(
fetchAllTasksByMembership
());
if
(
tasks
&&
tasks
?.
length
>
0
)
{
if
(
tasks
&&
tasks
?.
length
>
0
)
{
...
@@ -152,6 +154,7 @@ export default function UsersTasks() {
...
@@ -152,6 +154,7 @@ export default function UsersTasks() {
const
onToggleEditModeDone
=
(
id
)
=>
{
const
onToggleEditModeDone
=
(
id
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
const
newTasks
=
recievedTasks
.
map
((
task
)
=>
{
if
(
task
.
id
===
id
)
{
if
(
task
.
id
===
id
)
{
console
.
log
(
'toggledDone task '
,
task
)
return
{
return
{
...
task
,
...
task
,
isEditMode
:
false
,
isEditMode
:
false
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment