Commit 8815e244 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Switch from using groups to VOs (groups + entitlemnts)

parent 09dee3bf
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<div class="mat-typography" class="body"> <div class="mat-typography" class="body">
<h3>Your Virtual Organisations</h3> <h3>Your Virtual Organisations</h3>
<div> <div>
<mat-accordion *ngIf="(userService.subscribeGroups() | async) as groups"> <mat-accordion *ngIf="(userService.subscribeVOs() | async) as vos">
<app-vo-data *ngFor="let group of groups" [group]="group"></app-vo-data> <app-vo-data *ngFor="let vo of vos" [vo]="vo"></app-vo-data>
</mat-accordion> </mat-accordion>
<ng-template #noGroups> <ng-template #noVOs>
<p> <p>
You are not member in any Virtual Organisations. You are not member in any Virtual Organisations.
</p> </p>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<ng-template #noServices> <ng-template #noServices>
<p> <p>
You have no available services.<br/> You have no available services.<br/>
This is due services requiring users to be member of a certain group. This is due services requiring users to be member of a certain vo.
</p> </p>
</ng-template> </ng-template>
</div> </div>
......
...@@ -19,18 +19,19 @@ export interface AllAuthInfo { ...@@ -19,18 +19,19 @@ export interface AllAuthInfo {
} }
// user stuff // user stuff
export interface GroupDescription { export interface EntitlementNameSpace {
description: string; name: string;
} }
export interface Group { export interface VO {
id: number; id: number;
name: string; name: string;
description: GroupDescription; pretty_name: string;
description: string;
resourceType: string;
name_space?: EntitlementNameSpace;
} }
export type GroupMap = Map<Group, Service[]>
export interface Site { export interface Site {
id: number; id: number;
name: string; name: string;
...@@ -57,7 +58,7 @@ export interface Service { ...@@ -57,7 +58,7 @@ export interface Service {
name: string; name: string;
site: Site[]; site: Site[];
description: string; description: string;
groups: Group[]; vos: VO[];
} }
interface JSONObject { interface JSONObject {
...@@ -74,7 +75,7 @@ export interface CredentialState { ...@@ -74,7 +75,7 @@ export interface CredentialState {
export interface DeploymentStateItem { export interface DeploymentStateItem {
id: number; id: number;
service: Service | undefined; service: Service | undefined;
group: Group | undefined; vo: VO | undefined;
services: Service[]; services: Service[];
site: Site; site: Site;
state: string; state: string;
...@@ -88,7 +89,7 @@ export interface DeploymentStateItem { ...@@ -88,7 +89,7 @@ export interface DeploymentStateItem {
export interface Deployment { export interface Deployment {
id: number; id: number;
service: Service | undefined; service: Service | undefined;
group: number | undefined; // the group id vo: number | undefined; // the vo id
services: Service[]; services: Service[];
sites: Site[]; sites: Site[];
state_items: DeploymentStateItem[]; state_items: DeploymentStateItem[];
...@@ -97,7 +98,7 @@ export interface Deployment { ...@@ -97,7 +98,7 @@ export interface Deployment {
} }
export interface UserInfo { export interface UserInfo {
groups: string[]; vos: string[];
} }
export interface User { export interface User {
...@@ -105,7 +106,7 @@ export interface User { ...@@ -105,7 +106,7 @@ export interface User {
profile_name: string; profile_name: string;
userinfo: UserInfo; userinfo: UserInfo;
ssh_keys: SSHKey[]; ssh_keys: SSHKey[];
groups: Group[]; vos: VO[];
// these are additions here // these are additions here
services: Service[]; services: Service[];
......
...@@ -11,7 +11,7 @@ import { Message } from '@stomp/stompjs'; ...@@ -11,7 +11,7 @@ import { Message } from '@stomp/stompjs';
import { SnackBarService } from './snackbar.service'; import { SnackBarService } from './snackbar.service';
import { IdpService } from './idp.service'; import { IdpService } from './idp.service';
import { User, Update, State, Deployment, SSHKey, NewSSHKey, Group, IdP, Service } from './types/types.module'; import { VO, User, Update, State, Deployment, SSHKey, NewSSHKey, IdP, Service } from './types/types.module';
@Injectable() @Injectable()
...@@ -28,7 +28,7 @@ export class UserService { ...@@ -28,7 +28,7 @@ export class UserService {
private deployments: Map<number, Deployment> = new Map([]); private deployments: Map<number, Deployment> = new Map([]);
private deployments$ = new BehaviorSubject<Deployment[]>([]); private deployments$ = new BehaviorSubject<Deployment[]>([]);
public groupSelector = (user: User) => user ? user.groups : []; public voSelector = (user: User) => user ? user.vos : [];
public serviceSelector = (user: User) => user ? user.services ? user.services : [] : []; public serviceSelector = (user: User) => user ? user.services ? user.services : [] : [];
constructor( constructor(
...@@ -288,10 +288,10 @@ export class UserService { ...@@ -288,10 +288,10 @@ export class UserService {
); );
} }
public changeDeployment(action: string, group: Group): Observable<Deployment> { public changeDeployment(action: string, vo: VO): Observable<Deployment> {
const body = { const body = {
'type': action, 'type': action,
'group': group.id, 'vo': vo.id,
}; };
return this.http.post<Deployment>('/backend/api/deployments', body).pipe( return this.http.post<Deployment>('/backend/api/deployments', body).pipe(
catchError(this.catchError(true, "Error changing deployment")), catchError(this.catchError(true, "Error changing deployment")),
...@@ -316,9 +316,9 @@ export class UserService { ...@@ -316,9 +316,9 @@ export class UserService {
return this.deployments$.asObservable(); return this.deployments$.asObservable();
} }
public subscribeGroups(): Observable<Group[]> { public subscribeVOs(): Observable<VO[]> {
let groupSelector = (user: User) => user ? user.groups : []; let voSelector = (user: User) => user ? user.vos : [];
return this.subscribeSpecific<Group[]>(groupSelector); return this.subscribeSpecific<VO[]>(voSelector);
} }
public subscribeServiceDeployment(service: Service): Observable<Deployment> { public subscribeServiceDeployment(service: Service): Observable<Deployment> {
...@@ -332,11 +332,11 @@ export class UserService { ...@@ -332,11 +332,11 @@ export class UserService {
); );
} }
public subscribeGroupDeployment(group: Group): Observable<Deployment> { public subscribeVODeployment(vo: VO): Observable<Deployment> {
return this.subscribeDeployments().pipe( return this.subscribeDeployments().pipe(
map((deployments: Deployment[]) => { map((deployments: Deployment[]) => {
return deployments.find( return deployments.find(
(dep: Deployment) => dep.group == group.id (dep: Deployment) => dep.vo == vo.id
); );
} }
), ),
......
<mat-expansion-panel> <mat-expansion-panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title style="min-width: 100px;">{{ group.name }}</mat-panel-title> <mat-panel-title style="min-width: 100px;">{{ vo.pretty_name }}</mat-panel-title>
<mat-panel-description>{{ group.description?.description }}</mat-panel-description> <mat-panel-description>{{ vo.description }}</mat-panel-description>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<!-- expansion body --> <!-- expansion body -->
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<ng-container *ngFor="let site of sites$$ | async"> <ng-container *ngFor="let site of sites$$ | async">
<tr *ngFor="let service of servicesAtSite(site) | async"> <tr *ngFor="let service of servicesAtSite(site) | async">
<td> <td>
<span style="margin-right: 10px;" matTooltip="Site {{ site.name }} provides the service {{ service.name }} for members of {{ group.name }}"> <span style="margin-right: 10px;" matTooltip="Site {{ site.name }} provides the service {{ service.name }} for members of {{ vo.name }}">
<mat-icon>account_balance</mat-icon> <mat-icon>account_balance</mat-icon>
{{ site.name }} {{ site.name }}
</span> </span>
...@@ -88,13 +88,13 @@ ...@@ -88,13 +88,13 @@
</span> </span>
</div> </div>
<div [ngSwitch]="(deployment$$ | async)?.state_target"> <div [ngSwitch]="(deployment$$ | async)?.state_target">
<button *ngSwitchCase="'not_deployed'" (click)="changeDeployment('add')" mat-raised-button color="primary" matTooltip="Deploy credentials to services of VO {{ group.name }}"> <button *ngSwitchCase="'not_deployed'" (click)="changeDeployment('add')" mat-raised-button color="primary" matTooltip="Deploy credentials to services of VO {{ vo.name }}">
Deploy my credentials Deploy my credentials
</button> </button>
<button *ngSwitchCase="'deployed'" (click)="changeDeployment('remove')" mat-raised-button color="primary" matTooltip="Remove credentials from services of VO {{ group.name }}"> <button *ngSwitchCase="'deployed'" (click)="changeDeployment('remove')" mat-raised-button color="primary" matTooltip="Remove credentials from services of VO {{ vo.name }}">
Remove my credentials Remove my credentials
</button> </button>
<button *ngSwitchDefault (click)="changeDeployment('add')" mat-raised-button color="primary" matTooltip="Deploy credentials to services of VO {{ group.name }} the first time"> <button *ngSwitchDefault (click)="changeDeployment('add')" mat-raised-button color="primary" matTooltip="Deploy credentials to services of VO {{ vo.name }} the first time">
Deploy my credentials Deploy my credentials
</button> </button>
</div> </div>
......
...@@ -5,7 +5,7 @@ import { map } from 'rxjs/operators'; ...@@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';
import { UserService } from '../user.service'; import { UserService } from '../user.service';
import { DialogService } from '../dialogues/dialog.service'; import { DialogService } from '../dialogues/dialog.service';
import * as t from '../types/types.module'; import { VO, Site, Service, Deployment, DeploymentStateItem } from '../types/types.module';
@Component({ @Component({
selector: 'app-vo-data', selector: 'app-vo-data',
...@@ -14,18 +14,18 @@ import * as t from '../types/types.module'; ...@@ -14,18 +14,18 @@ import * as t from '../types/types.module';
}) })
export class VoDataComponent implements OnInit { export class VoDataComponent implements OnInit {
@Input() group: t.Group; @Input() vo: VO;
private services: t.Service[]; private services: Service[];
private services$ = new BehaviorSubject<t.Service[]>([]); private services$ = new BehaviorSubject<Service[]>([]);
public services$$: Observable<t.Service[]>; public services$$: Observable<Service[]>;
private sites: Map<number, t.Site> = new Map(); private sites: Map<number, Site> = new Map();
private sites$ = new BehaviorSubject<t.Site[]>([]); private sites$ = new BehaviorSubject<Site[]>([]);
public sites$$: Observable<t.Site[]>; public sites$$: Observable<Site[]>;
private deployment$ = <BehaviorSubject<t.Deployment>> new BehaviorSubject(new Object); private deployment$ = <BehaviorSubject<Deployment>> new BehaviorSubject(new Object);
public deployment$$: Observable<t.Deployment>; public deployment$$: Observable<Deployment>;
constructor( constructor(
public userService: UserService, public userService: UserService,
...@@ -35,19 +35,19 @@ export class VoDataComponent implements OnInit { ...@@ -35,19 +35,19 @@ export class VoDataComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.userService.subscribeSpecific(this.userService.serviceSelector).subscribe( this.userService.subscribeSpecific(this.userService.serviceSelector).subscribe(
(services: t.Service[]) => { (services: Service[]) => {
// filter by the group of this vo // filter by the vo of this vo
this.services = services.filter( this.services = services.filter(
(s: t.Service) => s.groups.some( (s: Service) => s.vos.some(
(g: t.Group) => this.group.name == g.name (g: VO) => this.vo.name == g.name
), ),
); );
this.services$.next(this.services); this.services$.next(this.services);
// generate the sites from the services // generate the sites from the services
this.services.map( this.services.map(
(s: t.Service) => s.site.forEach( (s: Service) => s.site.forEach(
(site: t.Site) => this.sites.set(site.id, site) (site: Site) => this.sites.set(site.id, site)
) )
); );
...@@ -58,8 +58,8 @@ export class VoDataComponent implements OnInit { ...@@ -58,8 +58,8 @@ export class VoDataComponent implements OnInit {
this.sites$.next(uniqueSites); this.sites$.next(uniqueSites);
} }
); );
this.userService.subscribeGroupDeployment(this.group).subscribe( this.userService.subscribeVODeployment(this.vo).subscribe(
(dep: t.Deployment) => { (dep: Deployment) => {
if (dep){ if (dep){
this.deployment$.next(dep); this.deployment$.next(dep);
} }
...@@ -77,25 +77,25 @@ export class VoDataComponent implements OnInit { ...@@ -77,25 +77,25 @@ export class VoDataComponent implements OnInit {
this.deployment$.complete(); this.deployment$.complete();
} }
public servicesAtSite(site: t.Site): Observable<t.Service[]> { public servicesAtSite(site: Site): Observable<Service[]> {
return this.services$$.pipe( return this.services$$.pipe(
map( map(
(services: t.Service[]) => services.filter( (services: Service[]) => services.filter(
(service: t.Service) => service.site.some( (service: Service) => service.site.some(
(s: t.Site) => s.id === site.id (s: Site) => s.id === site.id
) )
) )
), ),
); );
} }
public subscribeStateItem(site: t.Site, service: t.Service): Observable<t.DeploymentStateItem> { public subscribeStateItem(site: Site, service: Service): Observable<DeploymentStateItem> {
return this.deployment$$.pipe( return this.deployment$$.pipe(
map( map(
(dep: t.Deployment) => { (dep: Deployment) => {
if (dep.state_items) { if (dep.state_items) {
return dep.state_items.find( return dep.state_items.find(
(dsi: t.DeploymentStateItem) => dsi.site.id == site.id && dsi.service.id == service.id, (dsi: DeploymentStateItem) => dsi.site.id == site.id && dsi.service.id == service.id,
) )
} }
}, },
...@@ -104,8 +104,8 @@ export class VoDataComponent implements OnInit { ...@@ -104,8 +104,8 @@ export class VoDataComponent implements OnInit {
} }
public changeDeployment(action: string): void { public changeDeployment(action: string): void {
this.userService.changeDeployment(action, this.group).subscribe( this.userService.changeDeployment(action, this.vo).subscribe(
(dep: t.Deployment) => { (dep: Deployment) => {
this.deployment$.next(dep); this.deployment$.next(dep);
} }
); );
......
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