Commit 2b1fc21f authored by Chris Hines's avatar Chris Hines
Browse files

fix up a bunch of errors with site selection

parent 9b29e26f
Pipeline #7512 passed with stages
in 2 minutes and 59 seconds
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable, Subject, BehaviorSubject } from 'rxjs'; import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { catchError, map, tap, take,filter } from 'rxjs/operators'; import { catchError, map, tap, take,filter,skip } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import {LocationStrategy, Location} from '@angular/common'; import {LocationStrategy, Location} from '@angular/common';
// import { keypair } from 'keypair'; // import { keypair } from 'keypair';
...@@ -164,12 +164,18 @@ export class AuthorisationService { ...@@ -164,12 +164,18 @@ export class AuthorisationService {
public getCert() { public getCert() {
var token: AuthToken; var token: AuthToken;
token = this.token.value token = this.token.value;
if (this.backendSelectionService.apiserver.value === null) { // if (this.backendSelectionService.apiserver.value === null) {
this.backendSelectionService.apiserver.pipe(take(1)).subscribe(() => this.getCert()) // this.backendSelectionService.apiserver.pipe(take(1)).subscribe(() => this.getCert())
} // return
//}
if (token.token === undefined || token.token === '' || token.token == null) { if (token.token === undefined || token.token === '' || token.token == null) {
this.token.pipe(take(1)).subscribe(() => this.getCert()) this.token.pipe(take(1)).subscribe(() => this.getCert())
return
}
if (this.backendSelectionService.apiserver.value === null || this.backendSelectionService.apiserver.value == undefined) {
this.backendSelectionService.apiserver.pipe(skip(1),take(1)).subscribe(() => this.getCert())
return
} }
...@@ -184,7 +190,7 @@ export class AuthorisationService { ...@@ -184,7 +190,7 @@ export class AuthorisationService {
let data = {'token': token.token, 'pubkey': sshpub, 'signing_url': token.sshauthzservice.sign}; let data = {'token': token.token, 'pubkey': sshpub, 'signing_url': token.sshauthzservice.sign};
this.http.post<any>(this.backendURI+'/getcert',data, options) this.http.post<any>(this.backendSelectionService.apiserver.value.tes+'/getcert',data, options)
.pipe(catchError(this.handleError([]))) .pipe(catchError(this.handleError([])))
.subscribe(resp => this.makeKeyCert(newkeypair.private, resp, token.sshauthzservice), .subscribe(resp => this.makeKeyCert(newkeypair.private, resp, token.sshauthzservice),
error => this.signingError(error,token.sshauthzservice)); error => this.signingError(error,token.sshauthzservice));
...@@ -220,7 +226,11 @@ public getKeys(id?: Identity) { ...@@ -220,7 +226,11 @@ public getKeys(id?: Identity) {
window.open(sshauthzservice.logout); window.open(sshauthzservice.logout);
} }
let path=localStorage.getItem('path'); let path=localStorage.getItem('path');
this.readyToNavigate.next([true,path]); console.log('I should have a keycert now');
this.updateAgentContents();
console.log('requested agent contens update');
// only navigate once the agent contents has been refreshed
this.loggedInAuthZ.pipe(take(1)).subscribe( () => {this.readyToNavigate.next([true,path])});
} }
public querySshAgentError(error: any) { public querySshAgentError(error: any) {
...@@ -331,11 +341,12 @@ public getKeys(id?: Identity) { ...@@ -331,11 +341,12 @@ public getKeys(id?: Identity) {
} }
private signingError(error: any,sshauthzservice: SshAuthzServer) { private signingError(error: any,sshauthzservice: SshAuthzServer) {
this.statusMsg.next('You don\'t appear to have an account on '+sshauthzservice.name); this.statusMsg.next('You don\'t appear to have an account on '+sshauthzservice.name);
console.log(error);
if (!(sshauthzservice.logout === null)) { if (!(sshauthzservice.logout === null)) {
window.open(sshauthzservice.logout); window.open(sshauthzservice.logout);
} }
let path=localStorage.getItem('path'); //let path=localStorage.getItem('path');
this.readyToNavigate.next([true,path]); //this.readyToNavigate.next([true,path]);
} }
......
...@@ -33,6 +33,7 @@ export class BackendSelectionService { ...@@ -33,6 +33,7 @@ export class BackendSelectionService {
console.log('no saved api server, waitin for a list to choose the first one') console.log('no saved api server, waitin for a list to choose the first one')
//this.apiservers.pipe(filter((v) => v !== []),take(1)).subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)}) //this.apiservers.pipe(filter((v) => v !== []),take(1)).subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)})
this.apiservers.subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)}) this.apiservers.subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)})
this.apiservers.subscribe((l) => {console.log('api servers changed'); console.log(l);});
} }
} }
...@@ -100,7 +101,7 @@ export class BackendSelectionService { ...@@ -100,7 +101,7 @@ export class BackendSelectionService {
} }
} }
} }
if (!found) { if (!found && current !== undefined) {
list.push(current); list.push(current);
} }
this.apiservers.next(list); this.apiservers.next(list);
......
...@@ -81,11 +81,33 @@ ...@@ -81,11 +81,33 @@
</div> </div>
</mat-list-item> </mat-list-item>
</div> </div>
<!--<div *ngIf="h.type == 'table'">
<table mat-table [dataSource]="h.data">
<div *ngFor="let c of h.cols">
<ng-container *matColumnDef="c.key">
<th mat-header-cell *matHeaderCellDef>{{c.name}}</th>
<th mat-cell *matCellDef="let row;"> {{row[c.key]}}</th>
</ng-container>
</div>
<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-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="quotaClass(row)"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns" ></tr>
</table>
</div>-->
</div> </div>
</mat-list> </mat-list>
<!-- this table contains all the user level alerts that are quotas --> <!-- this table contains all the user level alerts that are quotas -->
<table mat-table [dataSource]="quotas" style="width: 100%"> <!--<table mat-table [dataSource]="quotas" style="width: 100%">
<ng-container matColumnDef="resource"> <ng-container matColumnDef="resource">
<th mat-header-cell *matHeaderCellDef> Resource </th> <th mat-header-cell *matHeaderCellDef> Resource </th>
...@@ -103,7 +125,7 @@ ...@@ -103,7 +125,7 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="quotaClass(row)"></tr> <tr mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="quotaClass(row)"></tr>
</table> </table>-->
</ng-template> </ng-template>
</div> </div>
......
...@@ -55,7 +55,7 @@ export class LauncherComponent implements OnInit { ...@@ -55,7 +55,7 @@ export class LauncherComponent implements OnInit {
private launchwindowWatcher: any; private launchwindowWatcher: any;
private subscriptions: Subscription[]; private subscriptions: Subscription[];
public quotas: BehaviorSubject<any[]>; public quotas: BehaviorSubject<any[]>;
displayedColumns: string[] = ['resource', 'usage', 'quota']; displayedColumns: string[] = ['usage'];
constructor( public dialog: MatDialog, constructor( public dialog: MatDialog,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<div gdAreas = "header header | apiselect apiselect | themeselect themeselect | loadconfig resetconfig | done done"> <div gdAreas = "header header | apiselect apiselect | themeselect themeselect | loadconfig resetconfig | done done">
<div gdArea="header"><h2 style="width: 100%">Settings</h2></div> <div gdArea="header"><h2 style="width: 100%">Settings</h2></div>
<div gdArea="apiselect"> <div gdArea="apiselect">
<div *ngIf="(backendSelectionService.apiservers | async) !== undefined">
<mat-form-field> <mat-form-field>
<mat-label>API Server</mat-label> <mat-label>API Server</mat-label>
<mat-select [ngModel]="selectedApiServer" (selectionChange)="backendSelectionService.setApiServer($event.value)"> <mat-select [ngModel]="selectedApiServer" (selectionChange)="backendSelectionService.setApiServer($event.value)">
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div>
</div> </div>
<div gdArea="themeselect"> <div gdArea="themeselect">
<mat-form-field > <mat-form-field >
......
...@@ -19,13 +19,17 @@ export class SettingsComponent implements OnInit { ...@@ -19,13 +19,17 @@ export class SettingsComponent implements OnInit {
public themeSubject: BehaviorSubject<string>; public themeSubject: BehaviorSubject<string>;
public themes: any[] = [ {'name':'Light','value':'strudel-light-theme'}, public themes: any[] = [ {'name':'Light','value':'strudel-light-theme'},
{'name': 'Dark','value':'strudel-dark-theme'}] {'name': 'Dark','value':'strudel-dark-theme'}]
public apiservers: any[]
constructor( constructor(
public backendSelectionService: BackendSelectionService, public backendSelectionService: BackendSelectionService,
public authService: AuthorisationService, public authService: AuthorisationService,
public computeSitesService: ComputesitesService, public computeSitesService: ComputesitesService,
public overlayContainer: OverlayContainer, public overlayContainer: OverlayContainer,
) { ) {
this.selectedApiServer = null;
this.backendSelectionService.apiserver.subscribe((s) => this.selectedApiServer = s); this.backendSelectionService.apiserver.subscribe((s) => this.selectedApiServer = s);
this.apiservers = []
this.backendSelectionService.apiservers.subscribe((l) => this.apiservers = l);
} }
ngOnInit() { ngOnInit() {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"appCatalogUri": "./assets/config/m3apps.dev.json", "appCatalogUri": "./assets/config/m3apps.dev.json",
"cancelcmd": "/usr/local/sv2/dev/sv2scancel.sh {jobid}", "cancelcmd": "/usr/local/sv2/dev/sv2scancel.sh {jobid}",
"statcmd": "/usr/local/sv2/dev/sv2stat.py", "statcmd": "/usr/local/sv2/dev/sv2stat.py",
"userhealth": "/home/chines/userhealth/uijson.py", "userhealth": "/usr/local/sv2/dev/userhealth/bin/uijson",
"cacheturis": ["https://cachet-dev.erc.monash.edu.au/api/v1/incidents"] "cacheturis": ["https://cachet-dev.erc.monash.edu.au/api/v1/incidents"]
}, },
{ {
......
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