Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WIE_202021_CSBillero11
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bernard Roland (Student Com20)
WIE_202021_CSBillero11
Commits
e1609e53
Commit
e1609e53
authored
3 years ago
by
Bernard Roland (Student Com20)
Browse files
Options
Downloads
Patches
Plain Diff
Added the possibility to add tasks
parent
f742a0b3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/src/v1/project.ts
+0
-2
0 additions, 2 deletions
server/src/v1/project.ts
server/src/v1/task.ts
+99
-0
99 additions, 0 deletions
server/src/v1/task.ts
with
99 additions
and
2 deletions
server/src/v1/project.ts
+
0
−
2
View file @
e1609e53
...
...
@@ -29,7 +29,6 @@ project.get('/', async (req, res) => {
projects
:
projects
,
});
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
failed to get project
'
,
...
...
@@ -76,7 +75,6 @@ project.get('/:uuid', async (req, res) => {
});
}
}
catch
(
e
)
{
console
.
log
(
e
);
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
failed to get project
'
,
...
...
This diff is collapsed.
Click to expand it.
server/src/v1/task.ts
+
99
−
0
View file @
e1609e53
...
...
@@ -57,6 +57,105 @@ task.get('/:uuid', async (req, res) => {
}
});
interface
TaskRequirement
{
role
:
string
;
time
:
number
;
}
interface
AddTaskBody
{
project
:
string
;
name
:
string
;
text
:
string
;
priority
:
string
;
dependentcies
:
Array
<
string
>
;
requirements
:
Array
<
TaskRequirement
>
;
token
:
Token
;
}
task
.
post
(
'
/
'
,
async
(
req
,
res
)
=>
{
if
(
isOfType
<
AddTaskBody
>
(
req
.
body
,
[
[
'
project
'
,
'
string
'
],
[
'
name
'
,
'
string
'
],
[
'
text
'
,
'
string
'
],
[
'
priority
'
,
'
string
'
],
[
'
dependentcies
'
,
'
object
'
],
[
'
requirements
'
,
'
object
'
],
]))
{
try
{
const
project_id
=
req
.
body
.
project
;
const
dependentcy_ids
=
req
.
body
.
dependentcies
;
const
requirements
=
req
.
body
.
requirements
;
const
requirement_ids
=
requirements
.
map
(
req
=>
req
.
role
);
for
(
const
team_id
of
dependentcy_ids
.
concat
(
requirement_ids
).
concat
([
project_id
]))
{
if
(
!
validate
(
team_id
))
{
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
malformed uuid
'
,
});
return
;
}
}
const
task_id
=
uuid
();
const
project
=
await
database
(
'
users
'
)
.
innerJoin
(
'
team_members
'
,
'
users.id
'
,
'
team_members.user_id
'
)
.
innerJoin
(
'
team_projects
'
,
'
team_members.team_id
'
,
'
team_projects.team_id
'
)
.
innerJoin
(
'
projects
'
,
'
team_projects.project_id
'
,
'
projects.id
'
)
.
select
({
id
:
'
projects.id
'
})
.
where
({
'
users.id
'
:
req
.
body
.
token
.
id
,
'
projects.id
'
:
project_id
,
})
.
groupBy
(
'
projects.id
'
);
if
(
project
.
length
>=
1
)
{
await
database
.
transaction
(
async
transaction
=>
{
await
transaction
(
'
tasks
'
).
insert
({
id
:
task_id
,
project_id
:
project_id
,
name
:
req
.
body
.
name
,
text
:
req
.
body
.
text
,
priority
:
req
.
body
.
priority
,
status
:
'
open
'
,
created
:
new
Date
(),
edited
:
new
Date
(),
});
if
(
requirements
.
length
!==
0
)
{
await
transaction
(
'
task_requirements
'
).
insert
(
requirements
.
map
(
requirement
=>
({
task_id
:
task_id
,
role_id
:
requirement
.
role
,
time
:
requirement
.
time
,
}))
);
}
if
(
dependentcy_ids
.
length
!==
0
)
{
await
transaction
(
'
task_dependencies
'
).
insert
(
dependentcy_ids
.
map
(
dependentcy_id
=>
({
task_id
:
task_id
,
requires_id
:
dependentcy_id
,
}))
);
}
});
res
.
status
(
200
).
json
({
status
:
'
success
'
,
id
:
task_id
,
});
}
else
{
res
.
status
(
404
).
json
({
status
:
'
error
'
,
message
:
'
project not found
'
,
});
}
}
catch
(
e
)
{
console
.
error
(
e
);
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
failed to create task
'
,
});
}
}
else
{
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
missing request fields
'
,
});
}
});
export
default
task
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment