Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalWebpage
Commits
79097f6f
Commit
79097f6f
authored
Jan 18, 2019
by
Lukas Burgey
Browse files
Add filtering empty VOs
parent
e4355aa1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/user.service.ts
View file @
79097f6f
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
HttpClient
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
throwError
as
observableThrowError
,
Observable
,
BehaviorSubject
,
of
,
EMPTY
}
from
'
rxjs
'
;
import
{
map
,
catchError
}
from
'
rxjs/operators
'
;
import
{
map
,
catchError
,
combineLatest
}
from
'
rxjs/operators
'
;
import
{
CookieService
}
from
'
ngx-cookie-service
'
;
import
{
StompConfig
,
StompRService
}
from
'
@stomp/ng2-stompjs
'
;
...
...
@@ -9,6 +9,7 @@ import { Message } from '@stomp/stompjs';
import
{
SnackBarService
}
from
'
./snackbar.service
'
;
import
{
IdpService
}
from
'
./idp.service
'
;
import
{
PreferencesService
,
Prefs
}
from
'
./preferences/preferences.service
'
;
import
{
VO
,
User
,
Update
,
State
,
Deployment
,
DeploymentState
,
SSHKey
,
NewSSHKey
,
IdP
,
Service
,
Site
,
JSONObject
...
...
@@ -45,6 +46,7 @@ export class UserService {
private
snackBar
:
SnackBarService
,
private
idpService
:
IdpService
,
private
stompService
:
StompRService
,
private
prefs
:
PreferencesService
,
)
{
this
.
user$
=
new
BehaviorSubject
(
null
);
this
.
connect
();
...
...
@@ -368,11 +370,6 @@ export class UserService {
);
}
public
subscribeVOs
():
Observable
<
VO
[]
>
{
let
voSelector
=
(
user
:
User
)
=>
user
?
user
.
vos
:
[];
return
this
.
subscribeSpecific
<
VO
[]
>
(
voSelector
);
}
public
subscribeDeployment
(
selector
:
(
dep
:
Deployment
)
=>
boolean
):
Observable
<
Deployment
>
{
return
this
.
subscribeDeployments
().
pipe
(
map
((
deployments
:
Deployment
[])
=>
{
...
...
@@ -387,4 +384,28 @@ export class UserService {
public
subscribeServices
():
Observable
<
Service
[]
>
{
return
this
.
subscribeSpecific
(
this
.
serviceSelector
);
}
public
subscribeVOs
():
Observable
<
VO
[]
>
{
const
voSelector
=
(
user
:
User
)
=>
user
?
user
.
vos
:
[];
const
vos$
=
this
.
subscribeSpecific
<
VO
[]
>
(
voSelector
);
return
this
.
prefs
.
connect
().
pipe
(
combineLatest
(
vos$
,
this
.
subscribeServices
(),
(
prefs
:
Prefs
,
vos
:
VO
[],
svc
:
Service
[])
=>
{
if
(
prefs
.
showEmptyVOs
)
{
// filter VOs that have no services
return
vos
.
filter
(
(
vo
:
VO
)
=>
svc
.
some
(
(
s
:
Service
)
=>
s
.
vos
.
some
(
svo
=>
svo
.
id
===
vo
.
id
,
),
),
);
}
return
vos
;
}
)
);
}
}
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