Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
IQB
PersonalDB
Commits
3090f93a
Commit
3090f93a
authored
Feb 14, 2022
by
mechtelm
Browse files
Introduce staff member's main data
parent
21e80984
Changes
7
Hide whitespace changes
Inline
Side-by-side
apps/api/src/app/database/services/staff.service.ts
View file @
3090f93a
import
{
Injectable
}
from
'
@nestjs/common
'
;
import
{
Injectable
,
NotFoundException
}
from
'
@nestjs/common
'
;
import
{
InjectRepository
}
from
"
@nestjs/typeorm
"
;
import
{
Repository
}
from
"
typeorm
"
;
import
Staff
from
"
../entities/staff-member.entity
"
;
import
{
StaffMemberInListDto
,
UserInListDto
}
from
"
../../../../../../libs/dto/src
"
;
import
{
StaffMemberInListDto
,
StaffMemberMainDto
,
UserFullDto
,
UserInListDto
}
from
"
../../../../../../libs/dto/src
"
;
@
Injectable
()
export
class
StaffService
{
...
...
@@ -30,4 +30,25 @@ export class StaffService {
});
return
returnStaff
;
}
async
findOneMain
(
id
:
number
):
Promise
<
StaffMemberMainDto
>
{
const
staffMember
=
await
this
.
staffRepository
.
findOne
(
id
);
if
(
staffMember
)
{
return
<
StaffMemberMainDto
>
{
id
:
staffMember
.
id
,
name
:
staffMember
.
name
,
firstName
:
staffMember
.
firstName
,
canonicalName
:
staffMember
.
canonicalName
,
contractStart
:
staffMember
.
contractStart
,
contractEnd
:
staffMember
.
contractEnd
,
contractType
:
staffMember
.
contractType
,
payrollNumber
:
staffMember
.
payrollNumber
,
idmId
:
staffMember
.
idmId
,
idmRegistered
:
staffMember
.
idmRegistered
,
address
:
staffMember
.
address
}
}
else
{
throw
new
NotFoundException
();
}
}
}
apps/api/src/app/staff/staff.controller.ts
View file @
3090f93a
import
{
Controller
,
Get
,
UseGuards
}
from
'
@nestjs/common
'
;
import
{
Controller
,
Get
,
Param
,
UseGuards
}
from
'
@nestjs/common
'
;
import
{
JwtAuthGuard
}
from
"
../auth/jwt-auth.guard
"
;
import
{
IsAdminGuard
}
from
"
../app-admin/is-admin.guard
"
;
import
{
ApiBearerAuth
,
ApiCreatedResponse
,
ApiTags
}
from
"
@nestjs/swagger
"
;
import
{
StaffMemberInListDto
,
UserInListDto
}
from
"
../../../../../libs/dto/src
"
;
import
{
StaffMemberInListDto
,
StaffMemberMainDto
,
UserInListDto
}
from
"
../../../../../libs/dto/src
"
;
import
{
StaffService
}
from
"
../database/services/staff.service
"
;
@
Controller
(
'
staff
'
)
...
...
@@ -22,4 +22,14 @@ export class StaffController {
return
this
.
staffService
.
findAll
();
}
@
Get
(
'
:id/main
'
)
@
UseGuards
(
JwtAuthGuard
)
@
ApiBearerAuth
()
@
ApiCreatedResponse
({
type
:
StaffMemberMainDto
,
})
@
ApiTags
(
'
staff
'
)
async
findOneMain
(@
Param
(
'
id
'
)
id
:
number
):
Promise
<
StaffMemberMainDto
>
{
return
this
.
staffService
.
findOneMain
(
id
);
}
}
apps/frontend/src/app/staff-list/backend.service.ts
View file @
3090f93a
...
...
@@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators';
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
Injectable
,
Inject
}
from
'
@angular/core
'
;
import
{
StaffMemberInListDto
}
from
"
../../../../../libs/dto/src
"
;
import
{
StaffMemberInListDto
,
StaffMemberMainDto
}
from
"
../../../../../libs/dto/src
"
;
@
Injectable
({
providedIn
:
'
root
'
...
...
@@ -20,4 +20,12 @@ export class BackendService {
catchError
(()
=>
[])
);
}
getStaffMemberMainData
(
id
:
number
):
Observable
<
StaffMemberMainDto
|
null
>
{
return
this
.
http
.
get
<
StaffMemberMainDto
>
(
`
${
this
.
serverUrl
}
staff/
${
id
}
/main`
)
.
pipe
(
catchError
(
async
()
=>
null
)
);
}
}
apps/frontend/src/app/staff-list/main-data/main-data.component.html
View file @
3090f93a
<p>
main-data works!
</p>
<div
fxLayout=
"column"
>
<div
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
<div
fxFlex=
"30%"
>
Name: {{staffMemberData.name}}
</div>
<div
fxFlex=
"40%"
>
Vorname: {{staffMemberData.firstName}}
</div>
<button
mat-button
*ngIf=
"appService.authData.isPersonalAdmin"
><mat-icon>
edit
</mat-icon></button>
</div>
<div
*ngIf=
"staffMemberData.idmId"
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
<div>
Kennung im HU-Identitätsmanagement: {{staffMemberData.idmId}}
</div>
<div
*ngIf=
"staffMemberData.idmRegistered"
>
Registriert am {{staffMemberData.idmRegistered}}
</div>
<div
*ngIf=
"!staffMemberData.idmRegistered"
>
Nicht registriert.
</div>
<button
mat-button
*ngIf=
"appService.authData.isCmsAdmin"
matTooltip=
"Registrieren"
><mat-icon>
manage_accounts
</mat-icon></button>
</div>
<div
*ngIf=
"!staffMemberData.idmId"
fxLayout=
"row"
fxLayoutAlign=
"space-between center"
>
<div>
Kennung im HU-Identitätsmanagement nicht zugewiesen
</div>
<button
mat-button
*ngIf=
"appService.authData.isPersonalAdmin"
(click)=
"selectIdmId()"
matTooltip=
"Kennung zuweisen"
><mat-icon>
verified
</mat-icon></button>
</div>
</div>
apps/frontend/src/app/staff-list/main-data/main-data.component.ts
View file @
3090f93a
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
OnDestroy
,
OnInit
}
from
'
@angular/core
'
;
import
{
Subscription
}
from
"
rxjs
"
;
import
{
StaffListService
}
from
"
../staff-list.service
"
;
import
{
BackendService
}
from
"
../backend.service
"
;
import
{
StaffMemberMainDto
}
from
"
../../../../../../libs/dto/src
"
;
import
{
AppService
}
from
"
../../app.service
"
;
@
Component
({
selector
:
'
studio-lite-main-data
'
,
templateUrl
:
'
./main-data.component.html
'
,
styleUrls
:
[
'
./main-data.component.scss
'
]
})
export
class
MainDataComponent
implements
OnInit
{
export
class
MainDataComponent
implements
OnInit
,
OnDestroy
{
private
staffMemberIdChangedSubscription
:
Subscription
|
undefined
;
public
staffMemberData
:
StaffMemberMainDto
=
{
id
:
0
,
name
:
''
}
constructor
()
{
}
constructor
(
public
appService
:
AppService
,
public
staffListService
:
StaffListService
,
private
backendService
:
BackendService
)
{
}
ngOnInit
():
void
{
setTimeout
(()
=>
{
this
.
staffMemberIdChangedSubscription
=
this
.
staffListService
.
selectedStaffMember$
.
subscribe
(()
=>
{
this
.
backendService
.
getStaffMemberMainData
(
this
.
staffListService
.
selectedStaffMember$
.
getValue
()).
subscribe
(
staffMemberData
=>
{
if
(
staffMemberData
)
{
this
.
staffMemberData
=
staffMemberData
;
}
else
{
this
.
staffMemberData
=
{
id
:
0
,
name
:
''
}
}
})
})
})
}
selectIdmId
():
void
{
}
ngOnDestroy
():
void
{
if
(
this
.
staffMemberIdChangedSubscription
)
this
.
staffMemberIdChangedSubscription
.
unsubscribe
();
}
}
libs/dto/src/index.ts
View file @
3090f93a
export
{
StaffMemberMainDto
}
from
"
./lib/staff/staff-member-main-dto
"
;
export
{
StaffMemberInListDto
}
from
"
./lib/staff/staff-member-in-list-dto
"
;
export
{
StaffMemberMetadataDto
}
from
"
./lib/staff/staff-member-metadata-dto
"
;
export
{
AuthDataDto
}
from
"
./lib/auth-data-dto
"
;
...
...
libs/dto/src/lib/staff/staff-member-main-dto.ts
0 → 100644
View file @
3090f93a
import
{
ApiProperty
}
from
'
@nestjs/swagger
'
;
export
class
StaffMemberMainDto
{
@
ApiProperty
()
id
!
:
number
;
@
ApiProperty
()
name
!
:
string
;
@
ApiProperty
()
firstName
?:
string
;
@
ApiProperty
()
idmId
?:
string
;
@
ApiProperty
()
idmRegistered
?:
string
;
@
ApiProperty
()
canonicalName
?:
string
;
@
ApiProperty
()
contractStart
?:
string
;
@
ApiProperty
()
contractEnd
?:
string
;
@
ApiProperty
()
contractType
?:
string
;
@
ApiProperty
()
payrollNumber
?:
string
;
@
ApiProperty
()
address
?:
string
;
}
Write
Preview
Supports
Markdown
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