Commit d1563201 authored by Lukas Burgey's avatar Lukas Burgey

Fix updating of vo data when services change

parent c444e602
...@@ -8,42 +8,44 @@ ...@@ -8,42 +8,44 @@
</mat-panel-description> </mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<!-- expansion body --> <ng-template matExpansionPanelContent>
<p *ngIf="vo.description != ''"> <!-- expansion body -->
{{ vo.description }} <p *ngIf="vo.description != ''">
</p> {{ vo.description }}
<div *ngIf="(services$$ | async) as services; else noServiceList"> </p>
<div *ngIf="services != undefined && services.length > 0; else noServiceList"> <div *ngIf="(services$$ | async) as services; else noServiceList">
<p> <div *ngIf="services != undefined && services.length > 0; else noServiceList">
These services are provided for members of this VO. <p>
</p> These services are provided for members of this VO.
<table> </p>
<thead> <table>
<tr> <thead>
<td>Site</td> <tr>
<td>Service</td> <td>Site</td>
<td>State</td> <td>Service</td>
</tr> <td>State</td>
</thead> </tr>
<tbody> </thead>
<ng-container *ngFor="let site of sites$$ | async"> <tbody>
<tr *ngFor="let service of servicesAtSite(site) | async" deployment-state-tr [service]="service" [site]="site"></tr> <ng-container *ngFor="let site of sites$$ | async">
</ng-container> <tr *ngFor="let service of servicesAtSite(site) | async" deployment-state-tr [service]="service" [site]="site"></tr>
</tbody> </ng-container>
</table> </tbody>
</table>
</div>
</div> </div>
</div> <ng-template #noServiceList>
<ng-template #noServiceList> <div *ngIf="(deployment$ | async) as deployment; else noDeployment">
<div *ngIf="(deployment$ | async) as deployment; else noDeployment"> <p *ngIf="deployment.state_target === 'deployed'; else noDeployment">
<p *ngIf="deployment.state_target === 'deployed'; else noDeployment"> Currently, no services need membership of this VO. We will deploy your credentials to new services.
Currently, no services need membership of this VO. We will deploy your credentials to new services. </p>
</div>
</ng-template>
<ng-template #noDeployment>
<p>
Currently, no services need membership of this VO. You can request a deployment anyway. We will deploy them to new services.
</p> </p>
</div> </ng-template>
</ng-template>
<ng-template #noDeployment>
<p>
Currently, no services need membership of this VO. You can request a deployment anyway. We will deploy them to new services.
</p>
</ng-template> </ng-template>
<mat-action-row deployment-action-row [deployment$]="deployment$" [vo]="vo"></mat-action-row> <mat-action-row deployment-action-row [deployment$]="deployment$" [vo]="vo"></mat-action-row>
</mat-expansion-panel> </mat-expansion-panel>
...@@ -35,34 +35,44 @@ export class VoDataComponent implements OnInit { ...@@ -35,34 +35,44 @@ export class VoDataComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.services$$ = this.services$.asObservable();
this.sites$$ = this.sites$.asObservable();
this.deployment$ = this.userService.subscribeDeployment(
(dep: Deployment) => dep.vo ? dep.vo.id == this.vo.id : false
);
// this is just used when no deployment exists
this.userService.subscribeServices().subscribe( this.userService.subscribeServices().subscribe(
(services: Service[]) => { (services: Service[]) => {
// filter by the vo of this vo this.services = services;
this.services = services.filter(
(s: Service) => s.vos.some(
(g: VO) => this.vo.name == g.name
),
);
this.services$.next(this.services); this.services$.next(this.services);
}
);
// generate the sites from the services this.deployment$.subscribe(
this.services.map( (dep: Deployment) => {
if (dep != undefined) {
this.services = dep.services;
this.services$.next(this.services);
}
}
);
this.services$$.subscribe(
(services: Service[]) => {
services.map(
(s: Service) => this.sites.set(s.site.id, s.site) (s: Service) => this.sites.set(s.site.id, s.site)
); );
let uniqueSites = [] const uniqueSites = []
this.sites.forEach( this.sites.forEach(
site => uniqueSites.push(site) site => uniqueSites.push(site)
); );
this.sites$.next(uniqueSites); this.sites$.next(uniqueSites);
} }
); );
this.services$$ = this.services$.asObservable();
this.sites$$ = this.sites$.asObservable();
this.deployment$ = this.userService.subscribeDeployment(
(dep: Deployment) => dep.vo ? dep.vo.id == this.vo.id : false
);
} }
ngOnDestroy(): void { ngOnDestroy(): void {
......
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