Commit 86a8b8e6 authored by Lukas Burgey's avatar Lukas Burgey

Respect user preference when displaying empty VOs

parent e7cdf67d
<header feudal-header></header> <header feudal-header></header>
<div class="mat-typography" class="body" > <div class="mat-typography" class="body" >
<div *ngIf="(userService.userSrc() | async) as user" style="max-width: 800px;" class="centered"> <div *ngIf="(userService.combiSrc() | async) as combi" style="max-width: 800px;" class="centered">
<div *ngIf="(userService.sshKeysSrc() | async)?.length > 0; else noCredentials"> <div *ngIf="(userService.sshKeysSrc() | async)?.length > 0; else noCredentials">
<div style="margin-bottom: 50px;"> <div style="margin-bottom: 50px;">
<h3>Your services</h3> <h3>Your services</h3>
<mat-accordion *ngIf="(userService.servicesSrc() | async) as services; else noServices"> <div>
<app-service *ngFor="let service of services" [service]="service"></app-service> <mat-accordion *ngIf="combi.user.services.length > 0; else noServices">
</mat-accordion> <app-service *ngFor="let service of services" [service]="service"></app-service>
<ng-template #noServices> </mat-accordion>
<p> </div>
You are not permitted to use any services. <ng-template #noServices>
</p> <p>
</ng-template> You are not permitted to use any services.
</div> </p>
<div> </ng-template>
<h3>Your Virtual Organisations</h3> </div>
<mat-accordion *ngIf="(userService.vosSrc() | async) as vos; else noVOs"> <div>
<app-vo-data *ngFor="let vo of vos" [vo]="vo"></app-vo-data> <h3>Your Virtual Organisations</h3>
</mat-accordion> <div>
<ng-template #noVOs> <mat-accordion *ngIf="userService.extractVOs(combi).length > 0; else noVOs">
<p> <app-vo-data *ngFor="let vo of userService.extractVOs(combi)" [vo]="vo"></app-vo-data>
You are not member in any Virtual Organisations. </mat-accordion>
</p> </div>
<ng-template #noVOs>
<p>
You are not member in any Virtual Organisations or all your Virtual Organisations are empty.
</p>
</ng-template>
</div>
</div>
<ng-template #noCredentials>
<app-account></app-account>
<!--
<div class="mat-typography">
<div style="margin-bottom: 50px;">
<p>
Before you can start using FEUDAL you need to upload an SSH public key.
Please do so below.
</p>
<p>
Once you have uploaded a key, the SSH Key Management will be available in the toolbar above.
</p>
</div>
<app-sshkeys></app-sshkeys>
</div>
-->
</ng-template> </ng-template>
</div>
</div> </div>
<ng-template #noCredentials>
<app-account></app-account>
<!--
<div class="mat-typography">
<div style="margin-bottom: 50px;">
<p>
Before you can start using FEUDAL you need to upload an SSH public key.
Please do so below.
</p>
<p>
Once you have uploaded a key, the SSH Key Management will be available in the toolbar above.
</p>
</div>
<app-sshkeys></app-sshkeys>
</div>
-->
</ng-template>
</div>
</div> </div>
<footer feudal-footer class="footer"></footer> <footer feudal-footer class="footer"></footer>
...@@ -16,13 +16,17 @@ import { ...@@ -16,13 +16,17 @@ import {
VO, User, Update, State, Deployment, DeploymentState, SSHKey, NewSSHKey, IdP, Service, Site, JSONObject VO, User, Update, State, Deployment, DeploymentState, SSHKey, NewSSHKey, IdP, Service, Site, JSONObject
} from './types/types.module'; } from './types/types.module';
export interface Combination {
user: User;
prefs: Prefs;
}
@Injectable() @Injectable()
export class UserService { export class UserService {
private initialized = false; private initialized = false;
private loggedIn = false; private loggedIn = false;
private observerDebugging = false; private observerDebugging = true;
// relogin on failed XHR calls // relogin on failed XHR calls
// is turned off when the user is deactivated // is turned off when the user is deactivated
...@@ -370,6 +374,18 @@ export class UserService { ...@@ -370,6 +374,18 @@ export class UserService {
); );
} }
public combiSrc(): Observable<Combination> {
return this.user$.asObservable().pipe(
combineLatest(
this.prefs.connect(),
(u, p) => {
return {user: u, prefs: p};
},
),
tap(this.tapLogger('userSrc')),
);
}
public deploymentsSrc(): Observable<Deployment[]> { public deploymentsSrc(): Observable<Deployment[]> {
return this.deployments$.asObservable().pipe( return this.deployments$.asObservable().pipe(
tap(this.tapLogger('deploymentsSrc')), tap(this.tapLogger('deploymentsSrc')),
...@@ -409,6 +425,22 @@ export class UserService { ...@@ -409,6 +425,22 @@ export class UserService {
); );
} }
public extractVOs(combi: Combination): VO[] {
if (combi.prefs.showEmptyVOs) {
// filter out VOs that have no services
return combi.user.vos.filter(
(vo: VO) => combi.user.services.some(
(s: Service) => s.vos.some(
svo => svo.id === vo.id,
),
),
);
}
return combi.user.vos;
}
public vosSrc(): Observable<VO[]> { public vosSrc(): Observable<VO[]> {
return this.prefs.connect().pipe( return this.prefs.connect().pipe(
combineLatest( combineLatest(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment