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

wip

parent b6fc1a8e
...@@ -9,4 +9,18 @@ ...@@ -9,4 +9,18 @@
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 group.
</p> </p>
</div> </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> </div>
...@@ -20,6 +20,7 @@ export interface AllAuthInfo { ...@@ -20,6 +20,7 @@ export interface AllAuthInfo {
// user stuff // user stuff
export interface Group { export interface Group {
id: number;
name: string; name: string;
} }
...@@ -48,7 +49,7 @@ export interface Service { ...@@ -48,7 +49,7 @@ export interface Service {
id: number; id: number;
name: string; name: string;
sites: Site[]; sites: Site[];
group: Group[]; groups: Group[];
} }
interface JSONObject { interface JSONObject {
...@@ -84,6 +85,7 @@ export interface User { ...@@ -84,6 +85,7 @@ export interface User {
ssh_keys: SSHKey[]; ssh_keys: SSHKey[];
services: Service[]; services: Service[];
id: number; id: number;
groups: Group[];
} }
export interface UserState { export interface UserState {
......
...@@ -26,6 +26,8 @@ export class UserService { ...@@ -26,6 +26,8 @@ export class UserService {
public messages: string[] = []; public messages: string[] = [];
// local copy of services // local copy of services
public services: t.Service[] = []; public services: t.Service[] = [];
public groupMap = new Map();
public groupsParsed = false;
constructor( constructor(
...@@ -100,19 +102,29 @@ export class UserService { ...@@ -100,19 +102,29 @@ export class UserService {
private updateServices(newServices: t.Service[]){ private updateServices(newServices: t.Service[]){
if (this.services.length !== newServices.length) { if (this.services.length !== newServices.length) {
this.services = []; this.services = [];
for (let service of newServices) { for (let service of newServices) {
this.services.push(service); this.services.push(service);
} }
for (let group of this.user.groups) {
this.groupMap.set(group, this._getServices(group.name));
}
this.groupsParsed = true;
} }
} }
private _logout() { private _getServices(groupName: string) : t.Service[] {
this._loggedIn = false; let services: t.Service[] = [];
this.snackBar.open('Logged out'); return this.services.filter(
this._stompService.disconnect(); (service: t.Service) => {
this.services = []; return service.groups.some(
this.user = null; (group : t.Group) => {
this.userState = null; return group.name === groupName;
}
);
}
);
} }
private updateUserState(newState: t.UserState) { private updateUserState(newState: t.UserState) {
...@@ -137,6 +149,15 @@ export class UserService { ...@@ -137,6 +149,15 @@ export class UserService {
this.userState = newState; 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) { private stateAPIUpdate(update: t.StateAPIResult) {
if (update) { if (update) {
this.updateUser(update.user) this.updateUser(update.user)
...@@ -164,6 +185,11 @@ export class UserService { ...@@ -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> { public userInfo(): MatTableDataSource<any> {
const userInfoList = []; const userInfoList = [];
for (const key in this.user.userinfo) { 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