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
808b2857
Commit
808b2857
authored
Dec 14, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'task-74-enhance/watcher_rights' into 'development'
Task 74 enhance/watcher rights See merge request
!80
parents
3cccf540
d6bb42d4
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
38 deletions
+83
-38
Project.ts
planner-api/src/models/Project.ts
+0
-4
copyTasks.ts
planner-api/src/routers/copyTasks.ts
+8
-11
projects.ts
planner-api/src/routers/projects.ts
+0
-5
tasks.ts
planner-api/src/routers/tasks.ts
+51
-1
users.ts
planner-api/src/routers/users.ts
+17
-1
ProfileBlock.js
...r-front/src/components/Menus/ProfileBlock/ProfileBlock.js
+0
-1
SwitchUserForm.js
...mponents/SwitchUserModal/SwitchUserForm/SwitchUserForm.js
+4
-12
SwitchUserTable.js
...onents/SwitchUserModal/SwitchUserTable/SwitchUserTable.js
+3
-3
No files found.
planner-api/src/models/Project.ts
View file @
808b2857
...
@@ -4,12 +4,8 @@ import {
...
@@ -4,12 +4,8 @@ import {
PrimaryGeneratedColumn
,
PrimaryGeneratedColumn
,
CreateDateColumn
,
CreateDateColumn
,
BaseEntity
,
BaseEntity
,
ManyToOne
,
ManyToMany
,
OneToMany
,
OneToMany
,
JoinTable
}
from
'typeorm'
;
}
from
'typeorm'
;
// import {User} from './User';
import
{
Task
}
from
'./Task'
;
import
{
Task
}
from
'./Task'
;
import
{
Member
}
from
'./Member'
;
import
{
Member
}
from
'./Member'
;
...
...
planner-api/src/routers/copyTasks.ts
View file @
808b2857
...
@@ -2,24 +2,21 @@ import express,{Router, Request, Response } from 'express';
...
@@ -2,24 +2,21 @@ 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'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfDateTimeTask
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
authAuthorOrExecutorOfDateTimeTask
,
authAuthorOrExecutorOfTask
}
from
'../helpers'
;
import
{
info
}
from
'console'
;
const
router
:
Router
=
express
.
Router
();
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
const
dataSource
=
myDataSource
;
/** make copy of task in calendar view */
/** make copy of task in calendar view */
router
.
post
(
"/make-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
post
(
"/make-copy"
,
authAuthorOrExecutorOfTask
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
const
{
taskId
,
dateTimeDue
,
dateTimeStart
}
=
req
.
body
;
const
{
taskId
,
dateTimeDue
,
dateTimeStart
,
authorStatus
,
executorStatus
,
task
}
=
req
.
body
;
const
task
=
await
taskFinderById
(
taskId
);
if
(
!
task
)
return
res
.
status
(
401
).
send
({
message
:
'task with possible user involved is not found'
})
if
(
!
task
)
return
res
.
status
(
401
).
send
({
message
:
'task with possible user involved is not found'
})
const
newDateTimeTask
=
new
DateTimeTask
();
const
newDateTimeTask
=
new
DateTimeTask
();
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
;
newDateTimeTask
.
dateTimeStart
=
dateTimeStart
;
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
;
newDateTimeTask
.
dateTimeDue
=
dateTimeDue
;
newDateTimeTask
.
task
=
taskId
;
newDateTimeTask
.
task
=
taskId
;
await
newDateTimeTask
.
save
();
await
newDateTimeTask
.
save
();
return
res
.
send
({
task
})
return
res
.
send
({
task
,
message
:
"copyTask created!"
})
}
)
}
)
/** change date time of copy of task in calendar view */
/** change date time of copy of task in calendar view */
...
...
planner-api/src/routers/projects.ts
View file @
808b2857
...
@@ -117,11 +117,6 @@ router.get('/user/:userId', async (req : Request, res : Response): Promise<Respo
...
@@ -117,11 +117,6 @@ router.get('/user/:userId', async (req : Request, res : Response): Promise<Respo
return
res
.
send
({
userProjects
})
return
res
.
send
({
userProjects
})
})
})
/** Add user to specific project */
/** Add user to specific project */
router
.
post
(
'/add-user/'
,
authAdminProject
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
router
.
post
(
'/add-user/'
,
authAdminProject
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
Response
>=>
{
...
...
planner-api/src/routers/tasks.ts
View file @
808b2857
...
@@ -2,10 +2,11 @@ import express,{Router, Request, Response } from 'express';
...
@@ -2,10 +2,11 @@ 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'
;
import
{
User
}
from
'../models/User'
;
import
{
User
}
from
'../models/User'
;
import
{
Member
}
from
'../models/Member'
;
import
{
Member
,
MemberRole
}
from
'../models/Member'
;
import
{
In
}
from
'typeorm'
;
import
{
In
}
from
'typeorm'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
DateTimeTask
}
from
'../models/DateTimeTask'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
auth
,
authAuthorOrExecutorOfTask
,
taskFinderById
}
from
'../helpers'
;
import
{
Project
}
from
'../models/Project'
;
const
router
:
Router
=
express
.
Router
();
const
router
:
Router
=
express
.
Router
();
const
dataSource
=
myDataSource
;
const
dataSource
=
myDataSource
;
...
@@ -29,7 +30,56 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
...
@@ -29,7 +30,56 @@ router.post('/', auth, async(req:Request, res:Response):Promise<Response>=>{
const
newTask
=
new
Task
();
const
newTask
=
new
Task
();
newTask
.
title
=
title
;
newTask
.
title
=
title
;
newTask
.
description
=
description
;
newTask
.
description
=
description
;
if
(
project
)
{
const
watcherOfProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
relations
:{
members
:
true
,
},
where
:
{
id
:
project
.
id
,
members
:
{
user
:{
id
:
user
.
id
},
roleProject
:
MemberRole
.
WATCHER
,
},
}
})
console
.
log
(
'watcherOfProject '
,
watcherOfProject
)
if
(
watcherOfProject
)
return
res
.
send
({
message
:
"watcher could nt make tasks"
})
newTask
.
project
=
project
;
newTask
.
project
=
project
;
}
else
{
const
personalProject
=
await
dataSource
.
getRepository
(
Project
)
.
findOne
({
where
:{
members
:{
user
:{
id
:
user
.
id
},
},
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
();
console
.
log
(
'newPersonalProject '
,
newPersonalProject
)
}
}
newTask
.
dateTimeDeadLine
=
dateTimeDeadLine
;
newTask
.
dateTimeDeadLine
=
dateTimeDeadLine
;
newTask
.
author
=
user
;
newTask
.
author
=
user
;
newTask
.
executor
=
executor
;
newTask
.
executor
=
executor
;
...
...
planner-api/src/routers/users.ts
View file @
808b2857
...
@@ -62,9 +62,25 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object>
...
@@ -62,9 +62,25 @@ router.get('/all-fields/', async (req : Request, res : Response):Promise<object>
},
},
}
}
})
})
console
.
log
(
'all fields users '
,
users
)
return
res
.
send
({
users
})
return
res
.
send
({
users
})
})
})
//** return displayName of user, requested by userId */
router
.
get
(
'/display-name/:userId'
,
auth
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
const
{
userId
}
=
req
.
params
const
displayName
=
await
dataSource
.
createQueryBuilder
()
.
select
([
'user.displayName'
])
.
from
(
User
,
"user"
)
.
where
(
"user.id = :userId"
,
{
userId
})
.
getOne
()
if
(
!
displayName
)
return
res
.
status
(
404
).
send
({
message
:
'displayName not found'
})
return
res
.
send
({
displayName
})
})
/**create new user*/
/**create new user*/
router
.
post
(
'/'
,
upload
.
single
(
"avatar"
),
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
router
.
post
(
'/'
,
upload
.
single
(
"avatar"
),
async
(
req
:
Request
,
res
:
Response
):
Promise
<
object
>
=>
{
const
{
name
,
surname
,
password
,
email
,
role
}
=
req
.
body
;
const
{
name
,
surname
,
password
,
email
,
role
}
=
req
.
body
;
...
...
planner-front/src/components/Menus/ProfileBlock/ProfileBlock.js
View file @
808b2857
...
@@ -30,7 +30,6 @@ const ProfileBlock = () => {
...
@@ -30,7 +30,6 @@ const ProfileBlock = () => {
}
}
const
switchUser
=
()
=>
{
const
switchUser
=
()
=>
{
dispatch
(
fetchUsersAllFields
());
dispatch
(
fetchUsersAllFields
());
// dispatch(fetchUsers())
handleClose
()
handleClose
()
handleOpenSwitchUser
()
handleOpenSwitchUser
()
}
}
...
...
planner-front/src/components/SwitchUserModal/SwitchUserForm/SwitchUserForm.js
View file @
808b2857
...
@@ -17,19 +17,20 @@ const SwitchUserForm=({submitFormHandler, users})=> {
...
@@ -17,19 +17,20 @@ const SwitchUserForm=({submitFormHandler, users})=> {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
currentUser
?.
members
.
length
>
0
)
{
if
(
currentUser
?.
members
.
length
>
0
)
{
let
dataArray
=
[]
for
(
let
member
of
currentUser
.
members
)
{
for
(
let
member
of
currentUser
.
members
)
{
const
newProjectRole
=
{
const
newProjectRole
=
{
"projectName"
:
member
.
project
.
title
,
"projectName"
:
member
.
project
.
title
,
"roleName"
:
member
.
roleProject
"roleName"
:
member
.
roleProject
}
}
setProjectsRole
([...
projectsRoles
,
newProjectRole
]
)
dataArray
.
push
(
newProjectRole
)
}
}
setProjectsRole
(
dataArray
)
}
}
},[
currentUser
])
},[
currentUser
])
return
(
return
(
<>
<>
{
/* <Box sx={style}> */
}
{
users
?
{
users
?
<
form
onSubmit
=
{(
e
)
=>
submitFormHandler
(
e
,
currentUser
)}
>
<
form
onSubmit
=
{(
e
)
=>
submitFormHandler
(
e
,
currentUser
)}
>
<
Grid
container
direction
=
"column"
spacing
=
{
2
}
>
<
Grid
container
direction
=
"column"
spacing
=
{
2
}
>
...
@@ -66,15 +67,7 @@ const SwitchUserForm=({submitFormHandler, users})=> {
...
@@ -66,15 +67,7 @@ const SwitchUserForm=({submitFormHandler, users})=> {
<
/Button
>
<
/Button
>
<
/Grid
>
<
/Grid
>
{
/* <Grid item>
<Button
onClick={()=>console.log('cancel form')}
color="primary"
variant="contained"
>
Отмена
</Button>
</Grid> */
}
<
/Grid
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
...
@@ -82,7 +75,6 @@ const SwitchUserForm=({submitFormHandler, users})=> {
...
@@ -82,7 +75,6 @@ const SwitchUserForm=({submitFormHandler, users})=> {
:
<><
/>
}
:
<><
/>
}
{
/* </Box> */
}
<
/
>
<
/
>
)
)
}
}
...
...
planner-front/src/components/SwitchUserModal/SwitchUserTable/SwitchUserTable.js
View file @
808b2857
...
@@ -9,7 +9,6 @@ import Paper from '@mui/material/Paper';
...
@@ -9,7 +9,6 @@ import Paper from '@mui/material/Paper';
const
SwitchUserTable
=
({
projectsRoles
})
=>
{
const
SwitchUserTable
=
({
projectsRoles
})
=>
{
return
(
return
(
<
TableContainer
component
=
{
Paper
}
>
<
TableContainer
component
=
{
Paper
}
>
...
@@ -31,7 +30,8 @@ const SwitchUserTable=({projectsRoles})=>{
...
@@ -31,7 +30,8 @@ const SwitchUserTable=({projectsRoles})=>{
<
/TableRow
>
<
/TableRow
>
<
/TableHead
>
<
/TableHead
>
<
TableBody
>
<
TableBody
>
{
projectsRoles
.
map
((
projectRole
,
index
)
=>
(
{
projectsRoles
.
map
((
projectRole
,
index
)
=>
{
return
(
<
TableRow
<
TableRow
key
=
{
index
}
key
=
{
index
}
sx
=
{{
'&:last-child td, &:last-child th'
:
{
border
:
0
}
}}
sx
=
{{
'&:last-child td, &:last-child th'
:
{
border
:
0
}
}}
...
@@ -41,7 +41,7 @@ const SwitchUserTable=({projectsRoles})=>{
...
@@ -41,7 +41,7 @@ const SwitchUserTable=({projectsRoles})=>{
<
/TableCell
>
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
projectRole
.
roleName
}
<
/TableCell
>
<
TableCell
align
=
"right"
>
{
projectRole
.
roleName
}
<
/TableCell
>
<
/TableRow
>
<
/TableRow
>
))}
)
}
)}
<
/TableBody
>
<
/TableBody
>
<
/Table
>
<
/Table
>
<
/TableContainer
>
<
/TableContainer
>
...
...
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