Commit 17af6f10 authored by Lukas Burgey's avatar Lukas Burgey

wip

parent b6fc1a8e
......@@ -9,4 +9,18 @@
This is due services requiring users to be member of a certain group.
</p>
</div>
<div *ngIf="userService.groupsParsed" style="padding-bottom: 30px;">
<h2>Virtual Organisations</h2>
<mat-accordion *ngIf="userService.groupMap.size > 0">
<div *ngFor="let group of userService.groupMap.keys()">
<h3>{{ group.name }}</h3>
<p *ngFor="let service of userService.groupMap.get(key)">
{{ service | json }}
</p>
</div>
</mat-accordion>
<p *ngIf="userService.groupMap.size == 0">
You are not a member in any groups.
</p>
</div>
</div>
......@@ -20,6 +20,7 @@ export interface AllAuthInfo {
// user stuff
export interface Group {
id: number;
name: string;
}
......@@ -48,7 +49,7 @@ export interface Service {
id: number;
name: string;
sites: Site[];
group: Group[];
groups: Group[];
}
interface JSONObject {
......@@ -84,6 +85,7 @@ export interface User {
ssh_keys: SSHKey[];
services: Service[];
id: number;
groups: Group[];
}
export interface UserState {
......
......@@ -26,6 +26,8 @@ export class UserService {
public messages: string[] = [];
// local copy of services
public services: t.Service[] = [];
public groupMap = new Map();
public groupsParsed = false;
constructor(
......@@ -100,19 +102,29 @@ export class UserService {
private updateServices(newServices: t.Service[]){
if (this.services.length !== newServices.length) {
this.services = [];
for (let service of newServices) {
this.services.push(service);
}
for (let group of this.user.groups) {
this.groupMap.set(group, this._getServices(group.name));
}
this.groupsParsed = true;
}
}
private _logout() {
this._loggedIn = false;
this.snackBar.open('Logged out');
this._stompService.disconnect();
this.services = [];
this.user = null;
this.userState = null;
private _getServices(groupName: string) : t.Service[] {
let services: t.Service[] = [];
return this.services.filter(
(service: t.Service) => {
return service.groups.some(
(group : t.Group) => {
return group.name === groupName;
}
);
}
);
}
private updateUserState(newState: t.UserState) {
......@@ -137,6 +149,15 @@ export class UserService {
this.userState = newState;
}
private _logout() {
this._loggedIn = false;
this.snackBar.open('Logged out');
this._stompService.disconnect();
this.services = [];
this.user = null;
this.userState = null;
}
private stateAPIUpdate(update: t.StateAPIResult) {
if (update) {
this.updateUser(update.user)
......@@ -164,6 +185,11 @@ export class UserService {
}
);
}
public getServices(group: t.Group): t.Service[] | undefined {
return this.groupMap.get(group.name);
}
public userInfo(): MatTableDataSource<any> {
const userInfoList = [];
for (const key in this.user.userinfo) {
......
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