Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Portal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
nmaas
nmaas Portal
Commits
f911db14
Commit
f911db14
authored
1 year ago
by
kbeyro
Browse files
Options
Downloads
Patches
Plain Diff
change cacheDomain
parent
1058f0e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/shared/users/list/userslist.component.ts
+273
-275
273 additions, 275 deletions
src/app/shared/users/list/userslist.component.ts
with
273 additions
and
275 deletions
src/app/shared/users/list/userslist.component.ts
+
273
−
275
View file @
f911db14
...
...
@@ -8,326 +8,324 @@ import {Observable, of} from 'rxjs';
import
{
Role
,
UserRole
}
from
'
../../../model/userrole
'
;
import
{
UserDataService
}
from
'
../../../service/userdata.service
'
;
import
{
AuthService
}
from
'
../../../auth/auth.service
'
;
import
{
debounceTime
,
map
,
shareReplay
,
take
}
from
'
rxjs/operators
'
;
import
{
UntypedFormControl
}
from
'
@angular/forms
'
;
import
{
ComponentMode
}
from
'
../../common/componentmode
'
;
import
{
Router
}
from
'
@angular/router
'
;
function
userMatches
(
u
:
User
,
term
:
string
):
boolean
{
const
t
=
term
||
''
return
(
u
.
username
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
email
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
firstname
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
lastname
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
const
t
=
term
||
''
return
(
u
.
username
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
email
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
firstname
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
||
(
u
.
lastname
||
''
).
toLowerCase
().
includes
(
t
.
toLowerCase
())
}
@
Component
({
selector
:
'
nmaas-userslist
'
,
templateUrl
:
'
./userslist.component.html
'
,
styleUrls
:
[
'
./userslist.component.css
'
]
selector
:
'
nmaas-userslist
'
,
templateUrl
:
'
./userslist.component.html
'
,
styleUrls
:
[
'
./userslist.component.css
'
]
})
export
class
UsersListComponent
extends
BaseComponent
implements
OnInit
,
OnChanges
{
public
users_item_number_key
=
'
NUMBER_OF_USERS_ITEM_KEY
'
;
public
users_item_number_key
=
'
NUMBER_OF_USERS_ITEM_KEY
'
;
@
Input
()
public
users
:
User
[]
=
[];
// provided list of users
@
Input
()
public
users
:
User
[]
=
[];
// provided list of users
@
Input
()
public
domainMode
=
false
;
@
Input
()
public
domainMode
=
false
;
public
displayUsers
:
User
[]
=
[];
// list of users after transformations
public
displayUsers
:
User
[]
=
[];
// list of users after transformations
public
domainId
:
number
;
public
domainId
:
number
;
@
Output
()
public
onDelete
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onDelete
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onView
:
EventEmitter
<
number
>
=
new
EventEmitter
<
number
>
();
@
Output
()
public
onView
:
EventEmitter
<
number
>
=
new
EventEmitter
<
number
>
();
@
Output
()
public
onAddToDomain
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onAddToDomain
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onRemoveFromDomain
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onRemoveFromDomain
:
EventEmitter
<
User
>
=
new
EventEmitter
<
User
>
();
@
Output
()
public
onModeChange
:
EventEmitter
<
number
>
=
new
EventEmitter
<
number
>
();
@
Output
()
public
onModeChange
:
EventEmitter
<
number
>
=
new
EventEmitter
<
number
>
();
@
Output
()
public
onUserRoleChange
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
@
Output
()
public
onUserRoleChange
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
public
domainCache
:
CacheService
<
number
,
Domain
>
=
new
CacheService
<
number
,
Domain
>
();
public
domainCache
:
CacheService
<
number
,
Domain
>
=
new
CacheService
<
number
,
Domain
>
();
private
lastSearchCriteria
:
CustomerSearchCriteria
=
undefined
;
private
lastSearchCriteria
:
CustomerSearchCriteria
=
undefined
;
public
pageNumber
=
1
;
public
paginatorName
=
'
paginator-identifier
'
;
public
itemsPerPage
:
number
[]
=
[
15
,
20
,
25
,
30
,
50
];
public
maxItemsOnPage
=
15
;
public
pageNumber
=
1
;
public
paginatorName
=
'
paginator-identifier
'
;
public
itemsPerPage
:
number
[]
=
[
15
,
20
,
25
,
30
,
50
];
public
maxItemsOnPage
=
15
;
public
filteredUsers
:
User
[]
=
[];
public
filteredUsers
:
User
[]
=
[];
public
searchText
=
new
UntypedFormControl
(
''
);
public
Role
=
Role
;
public
searchText
=
new
UntypedFormControl
(
''
);
public
Role
=
Role
;
constructor
(
private
userService
:
UserService
,
public
domainService
:
DomainService
,
private
userDataService
:
UserDataService
,
public
authService
:
AuthService
,
private
router
:
Router
)
{
super
();
userDataService
.
selectedDomainId
.
subscribe
(
domain
=>
this
.
domainId
=
domain
);
}
constructor
(
private
userService
:
UserService
,
public
domainService
:
DomainService
,
private
userDataService
:
UserDataService
,
public
authService
:
AuthService
,
private
router
:
Router
)
{
super
();
userDataService
.
selectedDomainId
.
subscribe
(
domain
=>
this
.
domainId
=
domain
);
}
ngOnInit
()
{
// set stored value of maxElementsPerPage
const
i
=
sessionStorage
.
getItem
(
this
.
users_item_number_key
);
if
(
i
)
{
this
.
maxItemsOnPage
=
+
i
;
}
this
.
searchText
.
valueChanges
.
subscribe
(
term
=>
this
.
onSearch
(
term
)
)
this
.
userDataService
.
selectedDomainId
.
subscribe
(
domain
=>
this
.
domainId
=
domain
);
this
.
getAllDomain
();
}
ngOnInit
()
{
// set stored value of maxElementsPerPage
const
i
=
sessionStorage
.
getItem
(
this
.
users_item_number_key
);
if
(
i
)
{
this
.
maxItemsOnPage
=
+
i
;
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
this
.
displayUsers
=
this
.
users
;
}
this
.
searchText
.
valueChanges
.
subscribe
(
term
=>
this
.
onSearch
(
term
)
)
this
.
userDataService
.
selectedDomainId
.
subscribe
(
domain
=>
this
.
domainId
=
domain
);
this
.
getAllDomain
();
}
ngOnChanges
(
changes
:
SimpleChanges
):
void
{
this
.
displayUsers
=
this
.
users
;
// this.getAllDomain();
}
public
getAllDomain
()
{
this
.
domainService
.
getAll
().
subscribe
(
domains
=>
{
domains
.
forEach
(
domain
=>
{
this
.
domainCache
.
setData
(
domain
.
id
,
domain
)
})
})
}
public
getDomainName
(
domainId
:
number
):
Observable
<
string
>
{
if
(
this
.
domainCache
.
hasData
(
domainId
))
{
return
of
(
this
.
domainCache
.
getData
(
domainId
).
name
);
}
else
{
return
new
Observable
<
string
>
()
public
getAllDomain
()
{
this
.
domainService
.
getAll
().
subscribe
(
domains
=>
{
domains
.
forEach
(
domain
=>
{
this
.
domainCache
.
setData
(
domain
.
id
,
domain
)
})
})
}
}
public
filterDomainNames
(
user
:
User
):
UserRole
[]
{
return
user
.
roles
.
filter
(
role
=>
role
.
domainId
!==
this
.
domainService
.
getGlobalDomainId
());
}
public
getOnlyDomainRoles
(
user
:
User
):
UserRole
{
return
user
.
roles
.
find
(
role
=>
role
.
domainId
===
this
.
domainId
);
}
public
getGlobalRole
(
user
:
User
):
string
{
const
userRole
:
UserRole
[]
=
user
.
roles
.
filter
(
role
=>
role
.
domainId
===
this
.
domainService
.
getGlobalDomainId
());
return
userRole
[
0
].
role
.
toString
();
}
public
getUserDomainIds
(
user
:
User
):
number
[]
{
if
(
user
!==
undefined
)
{
return
user
.
getDomainIds
();
}
else
{
return
[];
public
getDomainName
(
domainId
:
number
):
Observable
<
string
>
{
if
(
this
.
domainCache
.
hasData
(
domainId
))
{
return
of
(
this
.
domainCache
.
getData
(
domainId
).
name
);
}
else
{
return
new
Observable
<
string
>
()
}
}
}
public
remove
(
user
:
User
)
{
this
.
onDelete
.
emit
(
user
);
}
public
filterDomainNames
(
user
:
User
):
UserRole
[]
{
return
user
.
roles
.
filter
(
role
=>
role
.
domainId
!==
this
.
domainService
.
getGlobalDomainId
()
);
}
public
view
(
userId
:
number
):
void
{
if
(
!
this
.
domainMode
)
{
this
.
onView
.
emit
(
userId
);
public
getOnlyDomainRoles
(
user
:
User
):
UserRole
{
return
user
.
roles
.
find
(
role
=>
role
.
domainId
===
this
.
domainId
);
}
}
public
changeUserStatus
(
user
:
User
,
enabled
:
boolean
):
void
{
this
.
userService
.
changeUserStatus
(
user
.
id
,
enabled
).
subscribe
();
user
.
enabled
=
enabled
;
// sort after changing params
if
(
this
.
lastSearchCriteria
)
{
this
.
handleSortEvent
(
this
.
lastSearchCriteria
);
public
getGlobalRole
(
user
:
User
):
string
{
const
userRole
:
UserRole
[]
=
user
.
roles
.
filter
(
role
=>
role
.
domainId
===
this
.
domainService
.
getGlobalDomainId
());
return
userRole
[
0
].
role
.
toString
();
}
}
onSorted
(
$event
)
{
console
.
log
(
'
onSort
'
,
$event
);
this
.
displayUsers
=
this
.
users
;
this
.
handleSearchEvent
(
this
.
searchText
.
value
)
this
.
handleSortEvent
(
$event
);
}
onSearch
(
term
)
{
console
.
log
(
'
onSearch
'
,
term
)
this
.
displayUsers
=
this
.
users
;
this
.
handleSearchEvent
(
term
)
this
.
handleSortEvent
(
this
.
lastSearchCriteria
);
}
handleSearchEvent
(
term
:
string
)
{
console
.
warn
(
this
.
displayUsers
.
filter
(
u
=>
userMatches
(
u
,
term
)
))
this
.
displayUsers
=
this
.
displayUsers
.
filter
(
u
=>
userMatches
(
u
,
term
)
)
}
handleSortEvent
(
criteria
:
CustomerSearchCriteria
)
{
this
.
lastSearchCriteria
=
criteria
;
const
baseSortFunc
=
(
a
:
any
,
b
:
any
):
number
=>
{
if
(
a
<
b
)
{
return
-
1
;
}
if
(
a
>
b
)
{
return
1
;
}
return
0
;
};
this
.
displayUsers
.
sort
(
(
a
:
User
,
b
:
User
)
=>
{
if
(
!
criteria
)
{
return
0
;
}
const
direction
=
criteria
.
sortDirection
===
'
asc
'
?
1
:
-
1
;
let
result
:
number
;
let
p1
:
any
,
p2
:
any
;
// sorting rules for custom columns
if
(
criteria
.
sortColumn
===
'
domains
'
)
{
const
ad
=
this
.
filterDomainNames
(
a
);
const
bd
=
this
.
filterDomainNames
(
b
);
if
(
!
ad
)
{
console
.
log
(
ad
);
public
getUserDomainIds
(
user
:
User
):
number
[]
{
if
(
user
!==
undefined
)
{
return
user
.
getDomainIds
();
}
else
{
return
[];
}
}
public
remove
(
user
:
User
)
{
this
.
onDelete
.
emit
(
user
);
}
public
view
(
userId
:
number
):
void
{
if
(
!
this
.
domainMode
)
{
this
.
onView
.
emit
(
userId
);
}
}
public
changeUserStatus
(
user
:
User
,
enabled
:
boolean
):
void
{
this
.
userService
.
changeUserStatus
(
user
.
id
,
enabled
).
subscribe
();
user
.
enabled
=
enabled
;
// sort after changing params
if
(
this
.
lastSearchCriteria
)
{
this
.
handleSortEvent
(
this
.
lastSearchCriteria
);
}
}
onSorted
(
$event
)
{
console
.
log
(
'
onSort
'
,
$event
);
this
.
displayUsers
=
this
.
users
;
this
.
handleSearchEvent
(
this
.
searchText
.
value
)
this
.
handleSortEvent
(
$event
);
}
onSearch
(
term
)
{
console
.
log
(
'
onSearch
'
,
term
)
this
.
displayUsers
=
this
.
users
;
this
.
handleSearchEvent
(
term
)
this
.
handleSortEvent
(
this
.
lastSearchCriteria
);
}
handleSearchEvent
(
term
:
string
)
{
console
.
warn
(
this
.
displayUsers
.
filter
(
u
=>
userMatches
(
u
,
term
)
))
this
.
displayUsers
=
this
.
displayUsers
.
filter
(
u
=>
userMatches
(
u
,
term
)
)
}
handleSortEvent
(
criteria
:
CustomerSearchCriteria
)
{
this
.
lastSearchCriteria
=
criteria
;
const
baseSortFunc
=
(
a
:
any
,
b
:
any
):
number
=>
{
if
(
a
<
b
)
{
return
-
1
;
}
if
(
!
bd
)
{
console
.
log
(
bd
)
;
if
(
a
>
b
)
{
return
1
;
}
const
ar
=
ad
.
length
>
0
?
ad
[
0
].
domainId
:
0
;
const
br
=
bd
.
length
>
0
?
bd
[
0
].
domainId
:
0
;
p1
=
ar
;
p2
=
br
;
}
else
if
(
criteria
.
sortColumn
===
'
globalRole
'
)
{
p1
=
this
.
getGlobalRole
(
a
);
p2
=
this
.
getGlobalRole
(
b
);
}
else
if
(
criteria
.
sortColumn
===
'
roles
'
)
{
const
ad
=
this
.
getOnlyDomainRoles
(
a
);
const
bd
=
this
.
getOnlyDomainRoles
(
b
);
const
ar
=
ad
!==
undefined
?
ad
[
0
].
role
.
toString
()
:
''
;
const
br
=
bd
!==
undefined
?
bd
[
0
].
role
.
toString
()
:
''
;
p1
=
ar
;
p2
=
br
;
}
else
{
p1
=
a
[
criteria
.
sortColumn
];
p2
=
b
[
criteria
.
sortColumn
];
}
if
(
typeof
p1
===
'
string
'
&&
typeof
p2
===
'
string
'
)
{
p1
=
p1
.
toLowerCase
();
p2
=
p2
.
toLowerCase
();
}
result
=
baseSortFunc
(
p1
,
p2
);
return
result
*
direction
;
}
)
}
public
setItems
(
item
)
{
// store max items per page value in this session
sessionStorage
.
setItem
(
this
.
users_item_number_key
,
item
);
this
.
maxItemsOnPage
=
item
;
}
public
isGlobalGuestAndHasNoRoleInThisDomain
(
user
:
User
):
boolean
{
const
isGlobalGuest
=
user
.
roles
.
filter
(
r
=>
r
.
domainId
===
this
.
domainService
.
getGlobalDomainId
()
&&
typeof
r
.
role
===
'
string
'
?
Role
[
r
.
role
]
:
r
.
role
===
Role
.
ROLE_GUEST
).
length
>
0
;
// console.log('is global guest:\t' + isGlobalGuest);
const
hasNoRoleInThisDomain
=
user
.
roles
.
filter
(
r
=>
r
.
domainId
===
this
.
domainId
).
length
===
0
;
return
isGlobalGuest
&&
hasNoRoleInThisDomain
;
}
public
addToCurrentDomain
(
user
:
User
)
{
this
.
onAddToDomain
.
emit
(
user
);
this
.
changeMode
();
}
public
changeMode
()
{
this
.
onModeChange
.
emit
(
0
);
}
public
canUserBeDeleted
(
user
:
User
):
boolean
{
if
(
user
.
enabled
)
{
return
false
;
return
0
;
};
this
.
displayUsers
.
sort
(
(
a
:
User
,
b
:
User
)
=>
{
if
(
!
criteria
)
{
return
0
;
}
const
direction
=
criteria
.
sortDirection
===
'
asc
'
?
1
:
-
1
;
let
result
:
number
;
let
p1
:
any
,
p2
:
any
;
// sorting rules for custom columns
if
(
criteria
.
sortColumn
===
'
domains
'
)
{
const
ad
=
this
.
filterDomainNames
(
a
);
const
bd
=
this
.
filterDomainNames
(
b
);
if
(
!
ad
)
{
console
.
log
(
ad
);
}
if
(
!
bd
)
{
console
.
log
(
bd
);
}
const
ar
=
ad
.
length
>
0
?
ad
[
0
].
domainId
:
0
;
const
br
=
bd
.
length
>
0
?
bd
[
0
].
domainId
:
0
;
p1
=
ar
;
p2
=
br
;
}
else
if
(
criteria
.
sortColumn
===
'
globalRole
'
)
{
p1
=
this
.
getGlobalRole
(
a
);
p2
=
this
.
getGlobalRole
(
b
);
}
else
if
(
criteria
.
sortColumn
===
'
roles
'
)
{
const
ad
=
this
.
getOnlyDomainRoles
(
a
);
const
bd
=
this
.
getOnlyDomainRoles
(
b
);
const
ar
=
ad
!==
undefined
?
ad
[
0
].
role
.
toString
()
:
''
;
const
br
=
bd
!==
undefined
?
bd
[
0
].
role
.
toString
()
:
''
;
p1
=
ar
;
p2
=
br
;
}
else
{
p1
=
a
[
criteria
.
sortColumn
];
p2
=
b
[
criteria
.
sortColumn
];
}
if
(
typeof
p1
===
'
string
'
&&
typeof
p2
===
'
string
'
)
{
p1
=
p1
.
toLowerCase
();
p2
=
p2
.
toLowerCase
();
}
result
=
baseSortFunc
(
p1
,
p2
);
return
result
*
direction
;
}
)
}
if
(
user
.
ssoUser
)
{
return
false
;
public
setItems
(
item
)
{
// store max items per page value in this session
sessionStorage
.
setItem
(
this
.
users_item_number_key
,
item
);
this
.
maxItemsOnPage
=
item
;
}
const
result
=
user
.
roles
.
find
(
role
=>
!
(
roleConvert
(
role
.
role
)
===
Role
.
ROLE_GUEST
&&
role
.
domainId
===
this
.
domainService
.
getGlobalDomainId
())
);
return
!
result
;
}
public
searchUsers
(
search
:
string
)
{
if
(
search
===
''
)
{
this
.
filteredUsers
=
[];
}
else
{
if
(
this
.
allowedModes
.
find
(
v
=>
v
===
ComponentMode
.
EDIT
)
!==
undefined
)
{
this
.
userService
.
getUserBySearch
(
search
,
this
.
domainId
).
subscribe
(
data
=>
{
this
.
filteredUsers
=
data
;
this
.
displayUsers
=
this
.
filteredUsers
;
})
}
else
{
// this.displayUsers = this.users;
}
public
isGlobalGuestAndHasNoRoleInThisDomain
(
user
:
User
):
boolean
{
const
isGlobalGuest
=
user
.
roles
.
filter
(
r
=>
r
.
domainId
===
this
.
domainService
.
getGlobalDomainId
()
&&
typeof
r
.
role
===
'
string
'
?
Role
[
r
.
role
]
:
r
.
role
===
Role
.
ROLE_GUEST
).
length
>
0
;
// console.log('is global guest:\t' + isGlobalGuest);
const
hasNoRoleInThisDomain
=
user
.
roles
.
filter
(
r
=>
r
.
domainId
===
this
.
domainId
).
length
===
0
;
return
isGlobalGuest
&&
hasNoRoleInThisDomain
;
}
}
public
getAllowedRoles
():
Role
[]
{
let
roles
:
Role
[];
if
(
this
.
authService
.
hasRole
(
Role
[
Role
.
ROLE_SYSTEM_ADMIN
])
&&
Number
(
this
.
domainId
===
this
.
domainService
.
getGlobalDomainId
()))
{
// admin (global) role set
roles
=
[
Role
.
ROLE_OPERATOR
,
Role
.
ROLE_TOOL_MANAGER
,
Role
.
ROLE_SYSTEM_ADMIN
];
// roles = this.filterRoles(roles, this.domainId);
}
else
if
(
this
.
domainId
!=
null
)
{
// default (domain) role set
roles
=
[
Role
.
ROLE_USER
,
Role
.
ROLE_DOMAIN_ADMIN
,
Role
.
ROLE_GUEST
];
}
else
{
// no roles
roles
=
[];
public
addToCurrentDomain
(
user
:
User
)
{
this
.
onAddToDomain
.
emit
(
user
);
this
.
changeMode
();
}
return
roles
;
}
public
changeMode
()
{
this
.
onModeChange
.
emit
(
0
);
}
public
changeUserRole
(
user
:
User
,
domainId
:
number
,
event
:
any
)
{
console
.
warn
(
event
);
this
.
onUserRoleChange
.
emit
({
userId
:
user
.
id
,
domainId
:
domainId
,
role
:
event
.
value
})
}
public
canUserBeDeleted
(
user
:
User
):
boolean
{
if
(
user
.
enabled
)
{
return
false
;
}
if
(
user
.
ssoUser
)
{
return
false
;
}
const
result
=
user
.
roles
.
find
(
role
=>
!
(
roleConvert
(
role
.
role
)
===
Role
.
ROLE_GUEST
&&
role
.
domainId
===
this
.
domainService
.
getGlobalDomainId
())
);
return
!
result
;
}
public
checkUserIfIsCurrentUser
(
userName
:
string
)
{
return
this
.
authService
.
getUsername
()
===
userName
}
public
searchUsers
(
search
:
string
)
{
if
(
search
===
''
)
{
this
.
filteredUsers
=
[];
}
else
{
if
(
this
.
allowedModes
.
find
(
v
=>
v
===
ComponentMode
.
EDIT
)
!==
undefined
)
{
this
.
userService
.
getUserBySearch
(
search
,
this
.
domainId
).
subscribe
(
data
=>
{
this
.
filteredUsers
=
data
;
this
.
displayUsers
=
this
.
filteredUsers
;
})
}
else
{
// this.displayUsers = this.users;
}
}
}
public
getAllowedRoles
():
Role
[]
{
let
roles
:
Role
[];
if
(
this
.
authService
.
hasRole
(
Role
[
Role
.
ROLE_SYSTEM_ADMIN
])
&&
Number
(
this
.
domainId
===
this
.
domainService
.
getGlobalDomainId
()))
{
// admin (global) role set
roles
=
[
Role
.
ROLE_OPERATOR
,
Role
.
ROLE_TOOL_MANAGER
,
Role
.
ROLE_SYSTEM_ADMIN
];
// roles = this.filterRoles(roles, this.domainId);
}
else
if
(
this
.
domainId
!=
null
)
{
// default (domain) role set
roles
=
[
Role
.
ROLE_USER
,
Role
.
ROLE_DOMAIN_ADMIN
,
Role
.
ROLE_GUEST
];
}
else
{
// no roles
roles
=
[];
}
return
roles
;
}
public
changeUserRole
(
user
:
User
,
domainId
:
number
,
event
:
any
)
{
console
.
warn
(
event
);
this
.
onUserRoleChange
.
emit
({
userId
:
user
.
id
,
domainId
:
domainId
,
role
:
event
.
value
})
}
public
checkUserIfIsCurrentUser
(
userName
:
string
)
{
return
this
.
authService
.
getUsername
()
===
userName
}
}
function
roleConvert
(
role
:
string
|
Role
):
Role
{
if
(
typeof
role
===
'
string
'
)
{
return
Role
[
role
];
}
return
role
;
function
roleConvert
(
role
:
string
|
Role
):
Role
{
if
(
typeof
role
===
'
string
'
)
{
return
Role
[
role
];
}
return
role
;
}
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