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
fd1a466a
Commit
fd1a466a
authored
3 years ago
by
Bernard Roland (Student Com20)
Browse files
Options
Downloads
Patches
Plain Diff
Implement part of the team adapter
parent
4b1ad06a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/src/adapters/team.ts
+97
-0
97 additions, 0 deletions
client/src/adapters/team.ts
client/src/adapters/user.ts
+9
-9
9 additions, 9 deletions
client/src/adapters/user.ts
with
106 additions
and
9 deletions
client/src/adapters/team.ts
+
97
−
0
View file @
fd1a466a
import
{
apiRoot
}
from
'
config
'
;
import
{
getAuthHeader
}
from
'
./auth
'
;
import
{
User
}
from
'
./user
'
;
import
{
Project
}
from
'
./project
'
;
import
{
Work
}
from
'
./work
'
;
export
interface
Team
{
export
interface
Team
{
id
:
string
;
id
:
string
;
name
:
string
;
name
:
string
;
role
?:
string
;
role
?:
string
;
}
}
export
interface
TeamRole
{
id
:
string
;
name
:
string
;
}
export
interface
TeamMember
extends
User
{
role
:
TeamRole
;
}
type
TeamProject
=
Exclude
<
Project
,
'
teams
'
>
;
export
async
function
getTeams
():
Promise
<
Team
[]
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
teams
;
}
else
{
throw
new
Error
(
"
Failed to get teams
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
getTeam
(
uuid
:
string
):
Promise
<
Team
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
uuid
}
`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
team
;
}
else
{
throw
new
Error
(
"
Failed to get team
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
getTeamMembers
(
uuid
:
string
):
Promise
<
TeamMember
[]
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
uuid
}
/members`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
members
;
}
else
{
throw
new
Error
(
"
Failed to get team members
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
getTeamRoles
(
uuid
:
string
):
Promise
<
TeamRole
[]
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
uuid
}
/roles`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
roles
;
}
else
{
throw
new
Error
(
"
Failed to get team roles
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
getTeamProjects
(
uuid
:
string
):
Promise
<
TeamProject
[]
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
uuid
}
/projects`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
projects
;
}
else
{
throw
new
Error
(
"
Failed to get team projects
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
export
async
function
getTeamWork
(
uuid
:
string
):
Promise
<
Work
[]
>
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/team/
${
uuid
}
/work`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
return
(
await
response
.
json
()).
work
;
}
else
{
throw
new
Error
(
"
Failed to get team work
"
);
}
}
catch
(
e
)
{
throw
e
;
}
}
This diff is collapsed.
Click to expand it.
client/src/adapters/user.ts
+
9
−
9
View file @
fd1a466a
...
@@ -5,6 +5,13 @@ import { getAuthHeader } from './auth';
...
@@ -5,6 +5,13 @@ import { getAuthHeader } from './auth';
import
{
Task
}
from
'
./task
'
;
import
{
Task
}
from
'
./task
'
;
import
{
Work
}
from
'
./work
'
;
import
{
Work
}
from
'
./work
'
;
export
interface
User
{
id
:
string
;
username
:
string
;
realname
?:
string
;
email
?:
string
;
}
export
async
function
exists
(
username
:
string
)
{
export
async
function
exists
(
username
:
string
)
{
try
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/name/
${
username
}
`
);
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/name/
${
username
}
`
);
...
@@ -15,13 +22,6 @@ export async function exists(username: string) {
...
@@ -15,13 +22,6 @@ export async function exists(username: string) {
}
}
}
}
export
interface
User
{
id
:
string
;
username
:
string
;
realname
?:
string
;
email
?:
string
;
}
export
async
function
getCurrentUser
():
Promise
<
User
>
{
export
async
function
getCurrentUser
():
Promise
<
User
>
{
try
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/`
,
{
headers
:
getAuthHeader
()
});
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/`
,
{
headers
:
getAuthHeader
()
});
...
@@ -35,7 +35,7 @@ export async function getCurrentUser(): Promise<User> {
...
@@ -35,7 +35,7 @@ export async function getCurrentUser(): Promise<User> {
}
}
}
}
export
async
function
getTasks
():
Promise
<
Array
<
Task
>>
{
export
async
function
get
User
Tasks
():
Promise
<
Array
<
Task
>>
{
try
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/tasks`
,
{
headers
:
getAuthHeader
()
});
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/tasks`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
...
@@ -52,7 +52,7 @@ export async function getTasks(): Promise<Array<Task>> {
...
@@ -52,7 +52,7 @@ export async function getTasks(): Promise<Array<Task>> {
}
}
}
}
export
async
function
getWork
():
Promise
<
Work
>
{
export
async
function
get
User
Work
():
Promise
<
Work
>
{
try
{
try
{
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/work`
,
{
headers
:
getAuthHeader
()
});
const
response
=
await
fetch
(
`
${
apiRoot
}
/user/work`
,
{
headers
:
getAuthHeader
()
});
if
(
response
.
ok
)
{
if
(
response
.
ok
)
{
...
...
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