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
b60d8caf
Commit
b60d8caf
authored
Feb 21, 2023
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#166
remove some rows and eddit a little create task router
parent
f986cafc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
50 deletions
+10
-50
tasks.ts
planner-api/src/routers/tasks.ts
+10
-50
No files found.
planner-api/src/routers/tasks.ts
View file @
b60d8caf
...
...
@@ -11,7 +11,6 @@ import { Project } from '../models/Project';
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
/**get all tasks */
router
.
get
(
'/'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>
=>
{
try
{
...
...
@@ -33,13 +32,9 @@ router.get('/', async(req:Request, res:Response):Promise<Response> => {
router
.
post
(
'/'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
try
{
const
{
user
,
title
,
description
,
project
,
executor
,
dateTimeStart
,
dateTimeDue
,
dateTimeDeadLine
,
priority
,
calendar
}
=
req
.
body
;
let
dateTimeDueFinal
=
dateTimeDue
let
dateTimeStartFinal
=
dateTimeStart
const
dateTimeDeadlineFinal
=
dateTimeDeadLine
if
(
!
dateTimeDue
&&
dateTimeDeadLine
)
{
dateTimeDueFinal
=
dateTimeDeadLine
dateTimeStartFinal
=
subtractHours
(
dateTimeDueFinal
,
1
)
}
let
dateTimeDueFinal
=
dateTimeDue
??
dateTimeDeadLine
;
let
dateTimeStartFinal
=
dateTimeStart
??
subtractHours
(
dateTimeDueFinal
,
1
);
const
newTask
=
new
Task
();
newTask
.
title
=
title
;
...
...
@@ -74,22 +69,9 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
title
:
"Личные дела"
}
})
if
(
personalProject
){
newTask
.
project
=
personalProject
;
}
else
{
const
newPersonalProject
=
new
Project
();
newPersonalProject
.
title
=
"Личные дела"
;
newPersonalProject
.
color
=
"green"
;
await
newPersonalProject
.
save
()
newTask
.
project
=
newPersonalProject
;
const
newMember
=
new
Member
();
newMember
.
user
=
user
;
newMember
.
project
=
newPersonalProject
;
newMember
.
roleProject
=
MemberRole
.
ADMIN
;
await
newMember
.
save
();
}
if
(
personalProject
)
newTask
.
project
=
personalProject
;
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadlineFinal
;
newTask
.
author
=
user
;
if
(
newTask
.
project
.
title
===
"Личные дела"
){
...
...
@@ -151,20 +133,7 @@ router.post('/users', auth, async(req:Request, res:Response):Promise<Response>=>
title
:
"Не определено"
}
})
if
(
personalProject
){
newTask
.
project
=
personalProject
;
}
else
{
const
newPersonalProject
=
new
Project
();
newPersonalProject
.
title
=
"Не определено"
;
newPersonalProject
.
color
=
"green"
;
await
newPersonalProject
.
save
()
newTask
.
project
=
newPersonalProject
;
const
newMember
=
new
Member
();
newMember
.
user
=
user
;
newMember
.
project
=
newPersonalProject
;
newMember
.
roleProject
=
MemberRole
.
ADMIN
;
await
newMember
.
save
();
}
if
(
personalProject
)
newTask
.
project
=
personalProject
;
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadLine
;
...
...
@@ -201,8 +170,7 @@ router.get('/user/:userId', async (req: Request, res: Response):Promise<Response
{
executor
:{
id
:
userId
}
},
}},
})
return
res
.
send
({
tasks
})
}
catch
(
e
){
...
...
@@ -229,9 +197,7 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
id
:
user
.
id
},
roleProject
:
Not
(
MemberRole
.
WATCHER
)
}
}
}
}}}
)
const
projectsList
=
projectsRawId
.
map
(
project
=>
{
return
project
.
id
})
...
...
@@ -249,9 +215,7 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
},
project
:{
id
:
In
(
projectsList
)
}
}
}
}}}
)
const
projects
=
await
dataSource
.
getRepository
(
Project
)
...
...
@@ -261,8 +225,7 @@ router.get('/my',auth, async (req: Request, res: Response):Promise<Response>=>{
},
where
:{
id
:
In
(
projectsList
)
}
})
}})
return
res
.
send
({
tasks
,
projects
})
}
catch
(
e
){
return
res
.
status
(
502
).
send
({
message
:(
e
as
Error
).
message
})
...
...
@@ -306,9 +269,7 @@ router.get('/related', auth,async (req: Request, res: Response):Promise<Response
members
:
{
project
:
In
(
projectsIdArray
)}
}
})
)}}})
}
return
res
.
send
({
tasks
,
users
})
}
catch
(
e
){
...
...
@@ -423,7 +384,6 @@ 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*/
router
.
get
(
'/users-tasks'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
user
}
=
req
.
body
...
...
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