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

Switch from using groups to VOs (groups + entitlemnts)

parent 09dee3bf
......@@ -5,10 +5,10 @@
<div class="mat-typography" class="body">
<h3>Your Virtual Organisations</h3>
<div>
<mat-accordion *ngIf="(userService.subscribeGroups() | async) as groups">
<app-vo-data *ngFor="let group of groups" [group]="group"></app-vo-data>
<mat-accordion *ngIf="(userService.subscribeVOs() | async) as vos">
<app-vo-data *ngFor="let vo of vos" [vo]="vo"></app-vo-data>
</mat-accordion>
<ng-template #noGroups>
<ng-template #noVOs>
<p>
You are not member in any Virtual Organisations.
</p>
......@@ -26,7 +26,7 @@
<ng-template #noServices>
<p>
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>
</ng-template>
</div>
......
......@@ -19,18 +19,19 @@ export interface AllAuthInfo {
}
// user stuff
export interface GroupDescription {
description: string;
export interface EntitlementNameSpace {
name: string;
}
export interface Group {
export interface VO {
id: number;
name: string;
description: GroupDescription;
pretty_name: string;
description: string;
resourceType: string;
name_space?: EntitlementNameSpace;
}
export type GroupMap = Map<Group, Service[]>
export interface Site {
id: number;
name: string;
......@@ -57,7 +58,7 @@ export interface Service {
name: string;
site: Site[];
description: string;
groups: Group[];
vos: VO[];
}
interface JSONObject {
......@@ -74,7 +75,7 @@ export interface CredentialState {
export interface DeploymentStateItem {
id: number;
service: Service | undefined;
group: Group | undefined;
vo: VO | undefined;
services: Service[];
site: Site;
state: string;
......@@ -88,7 +89,7 @@ export interface DeploymentStateItem {
export interface Deployment {
id: number;
service: Service | undefined;
group: number | undefined; // the group id
vo: number | undefined; // the vo id
services: Service[];
sites: Site[];
state_items: DeploymentStateItem[];
......@@ -97,7 +98,7 @@ export interface Deployment {
}
export interface UserInfo {
groups: string[];
vos: string[];
}
export interface User {
......@@ -105,7 +106,7 @@ export interface User {
profile_name: string;
userinfo: UserInfo;
ssh_keys: SSHKey[];
groups: Group[];
vos: VO[];
// these are additions here
services: Service[];
......
......@@ -11,7 +11,7 @@ import { Message } from '@stomp/stompjs';
import { SnackBarService } from './snackbar.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()
......@@ -28,7 +28,7 @@ export class UserService {
private deployments: Map<number, Deployment> = new Map([]);
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 : [] : [];
constructor(
......@@ -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 = {
'type': action,
'group': group.id,
'vo': vo.id,
};
return this.http.post<Deployment>('/backend/api/deployments', body).pipe(
catchError(this.catchError(true, "Error changing deployment")),
......@@ -316,9 +316,9 @@ export class UserService {
return this.deployments$.asObservable();
}
public subscribeGroups(): Observable<Group[]> {
let groupSelector = (user: User) => user ? user.groups : [];
return this.subscribeSpecific<Group[]>(groupSelector);
public subscribeVOs(): Observable<VO[]> {
let voSelector = (user: User) => user ? user.vos : [];
return this.subscribeSpecific<VO[]>(voSelector);
}
public subscribeServiceDeployment(service: Service): Observable<Deployment> {
......@@ -332,11 +332,11 @@ export class UserService {
);
}
public subscribeGroupDeployment(group: Group): Observable<Deployment> {
public subscribeVODeployment(vo: VO): Observable<Deployment> {
return this.subscribeDeployments().pipe(
map((deployments: Deployment[]) => {
return deployments.find(
(dep: Deployment) => dep.group == group.id
(dep: Deployment) => dep.vo == vo.id
);
}
),
......
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title style="min-width: 100px;">{{ group.name }}</mat-panel-title>
<mat-panel-description>{{ group.description?.description }}</mat-panel-description>
<mat-panel-title style="min-width: 100px;">{{ vo.pretty_name }}</mat-panel-title>
<mat-panel-description>{{ vo.description }}</mat-panel-description>
</mat-expansion-panel-header>
<!-- expansion body -->
......@@ -23,7 +23,7 @@
<ng-container *ngFor="let site of sites$$ | async">
<tr *ngFor="let service of servicesAtSite(site) | async">
<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>
{{ site.name }}
</span>
......@@ -88,13 +88,13 @@
</span>
</div>
<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
</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
</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
</button>
</div>
......
......@@ -5,7 +5,7 @@ import { map } from 'rxjs/operators';
import { UserService } from '../user.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({
selector: 'app-vo-data',
......@@ -14,18 +14,18 @@ import * as t from '../types/types.module';
})
export class VoDataComponent implements OnInit {
@Input() group: t.Group;
@Input() vo: VO;
private services: t.Service[];
private services$ = new BehaviorSubject<t.Service[]>([]);
public services$$: Observable<t.Service[]>;
private services: Service[];
private services$ = new BehaviorSubject<Service[]>([]);
public services$$: Observable<Service[]>;
private sites: Map<number, t.Site> = new Map();
private sites$ = new BehaviorSubject<t.Site[]>([]);
public sites$$: Observable<t.Site[]>;
private sites: Map<number, Site> = new Map();
private sites$ = new BehaviorSubject<Site[]>([]);
public sites$$: Observable<Site[]>;
private deployment$ = <BehaviorSubject<t.Deployment>> new BehaviorSubject(new Object);
public deployment$$: Observable<t.Deployment>;
private deployment$ = <BehaviorSubject<Deployment>> new BehaviorSubject(new Object);
public deployment$$: Observable<Deployment>;
constructor(
public userService: UserService,
......@@ -35,19 +35,19 @@ export class VoDataComponent implements OnInit {
ngOnInit(): void {
this.userService.subscribeSpecific(this.userService.serviceSelector).subscribe(
(services: t.Service[]) => {
// filter by the group of this vo
(services: Service[]) => {
// filter by the vo of this vo
this.services = services.filter(
(s: t.Service) => s.groups.some(
(g: t.Group) => this.group.name == g.name
(s: Service) => s.vos.some(
(g: VO) => this.vo.name == g.name
),
);
this.services$.next(this.services);
// generate the sites from the services
this.services.map(
(s: t.Service) => s.site.forEach(
(site: t.Site) => this.sites.set(site.id, site)
(s: Service) => s.site.forEach(
(site: Site) => this.sites.set(site.id, site)
)
);
......@@ -58,8 +58,8 @@ export class VoDataComponent implements OnInit {
this.sites$.next(uniqueSites);
}
);
this.userService.subscribeGroupDeployment(this.group).subscribe(
(dep: t.Deployment) => {
this.userService.subscribeVODeployment(this.vo).subscribe(
(dep: Deployment) => {
if (dep){
this.deployment$.next(dep);
}
......@@ -77,25 +77,25 @@ export class VoDataComponent implements OnInit {
this.deployment$.complete();
}
public servicesAtSite(site: t.Site): Observable<t.Service[]> {
public servicesAtSite(site: Site): Observable<Service[]> {
return this.services$$.pipe(
map(
(services: t.Service[]) => services.filter(
(service: t.Service) => service.site.some(
(s: t.Site) => s.id === site.id
(services: Service[]) => services.filter(
(service: Service) => service.site.some(
(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(
map(
(dep: t.Deployment) => {
(dep: Deployment) => {
if (dep.state_items) {
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 {
}
public changeDeployment(action: string): void {
this.userService.changeDeployment(action, this.group).subscribe(
(dep: t.Deployment) => {
this.userService.changeDeployment(action, this.vo).subscribe(
(dep: Deployment) => {
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