Commit 410fbb8d authored by Chris Hines's avatar Chris Hines
Browse files

allow the user info scripts to send me a table to be rendered

parent 547ae2cb
Pipeline #7523 passed with stages
in 2 minutes and 57 seconds
...@@ -152,11 +152,11 @@ export class AuthorisationService { ...@@ -152,11 +152,11 @@ export class AuthorisationService {
//Verify that the state matched the nonce we used when initiating login //Verify that the state matched the nonce we used when initiating login
let tuple = JSON.parse(localStorage.getItem('authservice')); let tuple = JSON.parse(localStorage.getItem('authservice'));
if (tuple == null) { //if (tuple == null) {
console.log('unable to get the authservice from localStorage'); // console.log('unable to get the authservice from localStorage');
console.log(localStorage.getItem('authservice')); // console.log(localStorage.getItem('authservice'));
return // return
} //}
if (tuple[1] != state) { if (tuple[1] != state) {
return return
} }
...@@ -306,8 +306,6 @@ public getKeys(id?: Identity) { ...@@ -306,8 +306,6 @@ public getKeys(id?: Identity) {
let redirect_uri = window.location.origin+this.locationStrategy.getBaseHref()+"sshauthz_callback"; let redirect_uri = window.location.origin+this.locationStrategy.getBaseHref()+"sshauthz_callback";
let nonce=Math.random().toString(36).substring(2, 15) let nonce=Math.random().toString(36).substring(2, 15)
localStorage.setItem('authservice', JSON.stringify([authservice,nonce])); localStorage.setItem('authservice', JSON.stringify([authservice,nonce]));
localStorage.setItem('path', this.location.path()); localStorage.setItem('path', this.location.path());
if (authservice.scope == null) { if (authservice.scope == null) {
......
:host { :host {
height: 100%; height: 100%;
} }
.mat-header-cell {
text-align: right;
}
.mat-row {
height: 24px;
}
...@@ -71,7 +71,6 @@ ...@@ -71,7 +71,6 @@
</div> </div>
</mat-list> </mat-list>
<!-- this is all the user level alerts that are not quota -->
<mat-list> <mat-list>
<div *ngFor="let h of ((identitySubject | async).accountalerts | async)"> <div *ngFor="let h of ((identitySubject | async).accountalerts | async)">
<div *ngIf="h.type === undefined || h.type != 'quota'"> <div *ngIf="h.type === undefined || h.type != 'quota'">
...@@ -82,49 +81,18 @@ ...@@ -82,49 +81,18 @@
</mat-list-item> </mat-list-item>
</div> </div>
<div *ngIf="h.type == 'table'"> <div *ngIf="h.type == 'table'">
<table mat-table [dataSource]="h.data"> <table mat-table [dataSource]="h.data.rows" style="width: 100%">
<ng-container *ngFor="let c of h.cols" matColumnDef="{{c.key}}"> <ng-container *ngFor="let c of h.data.cols" matColumnDef="{{c.key}}">
<th mat-header-cell *matHeaderCellDef>{{c.name}}</th> <th mat-header-cell *matHeaderCellDef>{{ c.header }} </th>
<th mat-cell *matCellDef="let row;"> {{row[c.key]}}</th> <td mat-cell *matCellDef="let row;"> {{row[c.key]}}</td>
</ng-container> </ng-container>
<!--<ng-container matColumnDef="usage">
<th mat-header-cell *matHeaderCellDef> Usage </th>
<td mat-cell *matCellDef="let row"> {{row.pu}} </td>
</ng-container>
<ng-container matColumnDef="quota">
<th mat-header-cell *matHeaderCellDef> Quota </th>
<td mat-cell *matCellDef="let row"> {{row.pq}} </td>
</ng-container>-->
<tr mat-header-row *matHeaderRowDef="displayedColumns" ></tr> <tr mat-header-row *matHeaderRowDef="calculateCols(h.data.cols); sticky: true" ></tr>
<!--<tr mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="quotaClass(row)"></tr>--> <tr mat-row *matRowDef="let row; columns: calculateCols(h.data.cols)" [ngClass]="rowClass(row)" ></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns" ></tr>
</table> </table>
</div> </div>
</div> </div>
</mat-list> </mat-list>
<!-- this table contains all the user level alerts that are quotas -->
<!--<table mat-table [dataSource]="quotas" style="width: 100%">
<ng-container matColumnDef="resource">
<th mat-header-cell *matHeaderCellDef> Resource </th>
<td mat-cell *matCellDef="let quota"> {{quota.data.resource}} </td>
</ng-container>
<ng-container matColumnDef="usage">
<th mat-header-cell *matHeaderCellDef> Usage </th>
<td mat-cell *matCellDef="let quota"> {{humanKBytes(quota.data.usage)}} </td>
</ng-container>
<ng-container matColumnDef="quota">
<th mat-header-cell *matHeaderCellDef> Quota </th>
<td mat-cell *matCellDef="let quota"> {{humanKBytes(quota.data.quota)}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="quotaClass(row)"></tr>
</table>-->
</ng-template> </ng-template>
</div> </div>
......
...@@ -54,8 +54,8 @@ export class LauncherComponent implements OnInit { ...@@ -54,8 +54,8 @@ export class LauncherComponent implements OnInit {
private launchwindow: any; private launchwindow: any;
private launchwindowWatcher: any; private launchwindowWatcher: any;
private subscriptions: Subscription[]; private subscriptions: Subscription[];
public quotas: BehaviorSubject<any[]>; //public quotas: BehaviorSubject<any[]>;
displayedColumns: string[] = ['pu','pq']; displayedColumns: string[] = [];
constructor( public dialog: MatDialog, constructor( public dialog: MatDialog,
...@@ -71,7 +71,7 @@ export class LauncherComponent implements OnInit { ...@@ -71,7 +71,7 @@ export class LauncherComponent implements OnInit {
this.subscriptions.push(this.computeSitesService.appidentities.subscribe(o => this.getHealth(o))); this.subscriptions.push(this.computeSitesService.appidentities.subscribe(o => this.getHealth(o)));
this.appSubject = new BehaviorSubject<Strudelapp>(null); this.appSubject = new BehaviorSubject<Strudelapp>(null);
this.identitySubject = new BehaviorSubject<Identity>(null); this.identitySubject = new BehaviorSubject<Identity>(null);
this.quotas = new BehaviorSubject<any[]>([]); //this.quotas = new BehaviorSubject<any[]>([]);
} }
countErrors(a: Health[], b: Health[]) { countErrors(a: Health[], b: Health[]) {
...@@ -90,6 +90,10 @@ export class LauncherComponent implements OnInit { ...@@ -90,6 +90,10 @@ export class LauncherComponent implements OnInit {
return count; return count;
} }
calculateCols(data) {
return data.map(function(r) { return r.key });
}
humanKBytes(n: number) { humanKBytes(n: number) {
if (n > 1024*1024*1024) { if (n > 1024*1024*1024) {
let v = n/1024/1024/1024; let v = n/1024/1024/1024;
...@@ -106,8 +110,8 @@ export class LauncherComponent implements OnInit { ...@@ -106,8 +110,8 @@ export class LauncherComponent implements OnInit {
return '0 MB'; return '0 MB';
} }
quotaClass(quota) { rowClass(row) {
if (quota.stat == 'error' || quota.stat == 'warn') { if (row.stat == 'error' || row.stat == 'warn') {
return 'health-warn'; return 'health-warn';
} else { } else {
return 'health-ok'; return 'health-ok';
...@@ -132,7 +136,6 @@ export class LauncherComponent implements OnInit { ...@@ -132,7 +136,6 @@ export class LauncherComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.strudelapps = []; this.strudelapps = [];
} }
ngOnDestroy() { ngOnDestroy() {
...@@ -144,13 +147,20 @@ export class LauncherComponent implements OnInit { ...@@ -144,13 +147,20 @@ export class LauncherComponent implements OnInit {
selectId(id: Identity) { selectId(id: Identity) {
this.identitySubject.next(id); this.identitySubject.next(id);
this.appSubject.next(null); this.appSubject.next(null);
if (id != null) { if (id != null) {
for (let a of id.accountalerts.value) {
console.log('acocunt alert');
console.log(a);
}
}
//if (id != null) {
// We will subscribe to account alerts until the id changes (in which case we will subscribe to account alerts // We will subscribe to account alerts until the id changes (in which case we will subscribe to account alerts
// on the next id // on the next id
// BUT // BUT
// since identitySubject is a behaviorsubject and already has a value, we must skip(1) // since identitySubject is a behaviorsubject and already has a value, we must skip(1)
id.accountalerts.pipe(takeUntil(this.identitySubject.pipe(skip(1)))).subscribe((msgs) => { this.quotas.next(msgs.filter(q => q.type =='quota')) }); // id.accountalerts.pipe(takeUntil(this.identitySubject.pipe(skip(1)))).subscribe((msgs) => { this.quotas.next(msgs.filter(q => q.type =='quota')) });
} //}
} }
selectApp(app: Strudelapp) { selectApp(app: Strudelapp) {
......
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
} }
.health-warn .mat-cell { .health-warn .mat-cell {
color: mat-color($warn); color: mat-color($warn);
text-align: right;
} }
.health-ok .mat-cell { .health-ok .mat-cell {
color: mat-color($foreground); color: mat-color($foreground);
text-align: right;
} }
.mat-menu-panel { .mat-menu-panel {
.mat-menu-item { .mat-menu-item {
......
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