Commit db143283 authored by Chris Hines's avatar Chris Hines
Browse files

remove the use of environment to specify the initial backend server. also tweak layout

parent 5c865999
Pipeline #7455 failed with stages
in 2 minutes and 53 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 } from 'rxjs/Observable'; import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { of } from 'rxjs/observable/of'; import { catchError, map, tap, take,filter } from 'rxjs/operators';
import { catchError, map, tap } 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';
import * as keypair from 'keypair'; import * as keypair from 'keypair';
import * as forge from "node-forge"; import * as forge from "node-forge";
import { Identity, AuthToken, KeyCert, SshAuthzServer } from './identity'; import { Identity, AuthToken, KeyCert, SshAuthzServer } from './identity';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Subject} from 'rxjs/Subject';
import {BackendSelectionService} from './backend-selection.service'; import {BackendSelectionService} from './backend-selection.service';
import { throwError } from 'rxjs'; import { throwError } from 'rxjs';
import { environment } from '../environments/environment';
export class SshauthzServer {} export class SshauthzServer {}
...@@ -53,14 +48,15 @@ export class AuthorisationService { ...@@ -53,14 +48,15 @@ export class AuthorisationService {
this.sshAuthzServers = new BehaviorSubject<SshAuthzServer[]>([]); this.sshAuthzServers = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]); this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]); this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.backendURI = ''; this.backendURI = null;
this.agentContents = new BehaviorSubject([]); this.agentContents = new BehaviorSubject([]);
this.keys = []; this.keys = [];
this.getSshAuthzServers(); this.getSshAuthzServers();
this.keys = []; this.keys = [];
this.backendSelectionService.apiserver.subscribe((value) => { if (value != null) {this.backendURI = value.tes ; this.updateAgentContents()} }) this.backendSelectionService.apiserver.pipe(filter((v) => v !== null && v !== undefined))
this.agentContents.subscribe((value) => this.updateLoggedAuthZ()); .subscribe((value) => { this.backendURI = value.tes ; this.updateAgentContents() })
this.sshAuthzServers.subscribe((value) => this.updateLoggedAuthZ()); this.agentContents.subscribe((value) => this.updateLoggedAuthZ());
this.sshAuthzServers.subscribe((value) => this.updateLoggedAuthZ());
} }
public setStatusMsg(statusMsg: BehaviorSubject<any>) { public setStatusMsg(statusMsg: BehaviorSubject<any>) {
...@@ -166,7 +162,13 @@ export class AuthorisationService { ...@@ -166,7 +162,13 @@ export class AuthorisationService {
} }
public getCert(token: AuthToken) { public getCert() {
if (this.backendSelectionService.apiserver.value === null) {
this.backendSelectionService.apiserver.pipe(take(1)).subscribe(() => this.getCert())
}
let token = this.token
if (token.token === undefined || token.token === '' || token.token == null) { if (token.token === undefined || token.token === '' || token.token == null) {
return return
} }
...@@ -230,6 +232,12 @@ public getKeys(id?: Identity) { ...@@ -230,6 +232,12 @@ public getKeys(id?: Identity) {
} }
public updateAgentContents() { public updateAgentContents() {
if (this.backendURI == null) {
return
}
console.log('attempting to update agent contents');
console.log(this.backendSelectionService.apiserver)
console.log(this.backendURI);
if (this.statusMsg !== undefined) { if (this.statusMsg !== undefined) {
this.statusMsg.next("Updating the list of available accounts"); this.statusMsg.next("Updating the list of available accounts");
}; };
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { APIServer } from './apiserver'; import { APIServer } from './apiserver';
import {BehaviorSubject} from 'rxjs/BehaviorSubject'; import {BehaviorSubject} from 'rxjs';
import {take, filter} from 'rxjs/operators';
import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http'; import { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
...@@ -14,7 +16,7 @@ export class BackendSelectionService { ...@@ -14,7 +16,7 @@ export class BackendSelectionService {
constructor(private http: HttpClient) { constructor(private http: HttpClient) {
this.apiservers = new BehaviorSubject([]); this.apiservers = new BehaviorSubject([]);
this.apiserver = new BehaviorSubject(undefined); this.apiserver = new BehaviorSubject(null);
this.initApiServer(); this.initApiServer();
this.getAPIServers(); this.getAPIServers();
} }
...@@ -22,12 +24,20 @@ export class BackendSelectionService { ...@@ -22,12 +24,20 @@ export class BackendSelectionService {
private initApiServer() { private initApiServer() {
try { try {
this.apiserver.next(<APIServer>JSON.parse(localStorage.getItem('apiserver'))); this.apiserver.next(<APIServer>JSON.parse(localStorage.getItem('apiserver')));
console.log('selected api server');
console.log(this.apiserver.value);
} catch { } catch {
this.apiserver.next(<APIServer>environment.apiserver); this.apiserver.next(null);
}
if (this.apiserver.value == null) {
this.apiserver.next(<APIServer>environment.apiserver);
} }
if (this.apiserver.value === null) {
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.subscribe((v) => {console.log('got some apiservers to choose from'); this.defaultApiServer(v)})
}
}
private defaultApiServer(v: APIServer[]) {
this.apiserver.next(v[0]);
} }
private saveLastApiServer(s: APIServer) { private saveLastApiServer(s: APIServer) {
...@@ -50,6 +60,7 @@ export class BackendSelectionService { ...@@ -50,6 +60,7 @@ export class BackendSelectionService {
} }
getAPIServers() { getAPIServers() {
console.log('retrieving api servers');
let headers = new HttpHeaders(); let headers = new HttpHeaders();
let options = { headers: headers, withCredentials: false}; let options = { headers: headers, withCredentials: false};
this.http.get<APIServer[]>('./assets/config/apiservers.json',options) this.http.get<APIServer[]>('./assets/config/apiservers.json',options)
...@@ -57,6 +68,7 @@ export class BackendSelectionService { ...@@ -57,6 +68,7 @@ export class BackendSelectionService {
} }
private updateAPIServers(resp) { private updateAPIServers(resp) {
console.log('got some api servers merging them');
var s: APIServer; var s: APIServer;
var list: APIServer[] = [] var list: APIServer[] = []
var current: APIServer; var current: APIServer;
...@@ -71,7 +83,7 @@ export class BackendSelectionService { ...@@ -71,7 +83,7 @@ export class BackendSelectionService {
} }
for (s of <APIServer[]>resp) { for (s of <APIServer[]>resp) {
if (s.name == current.name) { if (current !== undefined && current !== null && s.name == current.name) {
list.push(current); list.push(current);
found = true; found = true;
} else { } else {
...@@ -80,7 +92,7 @@ export class BackendSelectionService { ...@@ -80,7 +92,7 @@ export class BackendSelectionService {
} }
if (localServers !== null) { if (localServers !== null) {
for (s of localServers) { for (s of localServers) {
if (s.name == current.name) { if (current !== null && s.name == current.name) {
list.push(current); list.push(current);
found = true; found = true;
} else { } else {
...@@ -92,6 +104,7 @@ export class BackendSelectionService { ...@@ -92,6 +104,7 @@ export class BackendSelectionService {
list.push(current); list.push(current);
} }
this.apiservers.next(list); this.apiservers.next(list);
console.log('apiserver merge complete');
} }
} }
...@@ -14,29 +14,22 @@ ...@@ -14,29 +14,22 @@
<mat-sidenav #idSideNav mode="side" opened> <mat-sidenav #idSideNav mode="side" opened>
<div fxLayout="column" style="height: 100%"> <div fxLayout="column" style="height: 100%">
<div> <div>
<mat-accordion> <mat-accordion style="width: 100%">
<div *ngFor="let id of (computeSitesService.appidentities | async)"> <div *ngFor="let id of (computeSitesService.appidentities | async)">
<mat-expansion-panel (opened)="selectId(id)"> <mat-expansion-panel (opened)="selectId(id)" style="width: 100%">
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title> <mat-panel-title>
<span fxFlex matBadge="{{ (id.healthalerts | async).length }}"
<!--<button mat-button style="width: 100%">--> [matBadgeHidden]= "(id.healthalerts | async).length == 0"
<div fxLayout="row"> matBadgePosition="above before"
<div style="width: 20px;"></div> matBadgeColor="warn"
<div fxFlex fxLayout="column"> matBadgeOverlap="false" matBadgeSize="small"
<div style="height: 15px"></div> style="text-align: left; margin-left: 20px; margin-top: 10px" >
<span fxFlex matBadge="{{ (id.healthalerts | async).length }}" {{ id.displayName() }}
[matBadgeHidden]= "(id.healthalerts | async).length == 0" </span>
matBadgePosition="above before"
matBadgeColor="warn" style=" text-align: left" matBadgeOverlap="false" matBadgeSize="small">
{{ id.displayName() }}
</span>
</div>
</div>
<!--</button>-->
</mat-panel-title> </mat-panel-title>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<app-strudelapplist [applist]=id.site.appCatalog [identity]="id" (appChange)="selectApp($event)"></app-strudelapplist> <app-strudelapplist [applist]=id.site.appCatalog [identity]="id" (appChange)="selectApp($event)" style="width: 100%"></app-strudelapplist>
</mat-expansion-panel> </mat-expansion-panel>
</div> </div>
</mat-accordion> </mat-accordion>
...@@ -57,12 +50,6 @@ ...@@ -57,12 +50,6 @@
<mat-sidenav-content> <mat-sidenav-content>
<div fxLayout="column" style="height: 100%"> <div fxLayout="column" style="height: 100%">
<!-- The dialog asking how many resources to use to run a job -->
<div *ngIf="app !== null && identity !== null" >
<app-launch-dialog [identity]="identitySubject | async" [appSubject]="appSubject"></app-launch-dialog>
</div>
<!-- the list of warning either on the computer system or the users account --> <!-- the list of warning either on the computer system or the users account -->
<div *ngIf="(identitySubject | async) !== null" > <div *ngIf="(identitySubject | async) !== null" >
<mat-list> <mat-list>
...@@ -78,6 +65,13 @@ ...@@ -78,6 +65,13 @@
</mat-list> </mat-list>
</div> </div>
<!-- The dialog asking how many resources to use to run a job -->
<div *ngIf="app !== null && identity !== null" >
<app-launch-dialog [identity]="identitySubject | async" [appSubject]="appSubject"></app-launch-dialog>
</div>
<!-- the list of running jobs --> <!-- the list of running jobs -->
<app-joblist [identitySubject]="identitySubject" [appSubject]="appSubject"></app-joblist> <app-joblist [identitySubject]="identitySubject" [appSubject]="appSubject"></app-joblist>
......
...@@ -91,58 +91,5 @@ export class LoginComponent implements OnInit { ...@@ -91,58 +91,5 @@ export class LoginComponent implements OnInit {
signup(sshauthzserver) { signup(sshauthzserver) {
window.open(sshauthzserver.signup); window.open(sshauthzserver.signup);
} }
loadConfig(event) {
const reader = new FileReader();
reader.onload = (e: any) => {
try {
this.config = JSON.parse(e.target.result);
if ('computesites' in this.config) {
this.computeSitesService.storeLocalComputeSites(this.config['computesites'])
}
if ('apps' in this.config) {
this.computeSitesService.storeLocalStrudelApps(this.config['sitename'],this.config['apps']);
}
if ('authz' in this.config) {
this.authService.storeLocalAuthZ(this.config['authz'])
}
} catch {
console.log('local config file is invalid')
}
};
reader.readAsText(event.target.files[0]);
}
resetConfig() {
this.computeSitesService.removeLocalStrudelApps();
this.computeSitesService.removeLocalComputeSites();
this.authService.removeLocalAuthZ()
}
setTheme(v) {
console.log('Theme selected');
console.log(v);
let theme = v;
console.log(this.overlayContainer.getContainerElement().classList);
let classList = document.querySelector('app-root').classList
console.log('this theme');
console.log(this.theme);
if (theme == 'strudel-light-theme') {
classList.remove('strudel-dark-theme');
classList.add('strudel-light-theme');
}
if (theme == 'strudel-dark-theme') {
classList.remove('strudel-light-theme');
classList.add('strudel-dark-theme');
}
console.log('setting localStorage theme',v);
}
selectTheme(event) {
localStorage.setItem('strudel-theme',event.value);
}
} }
<mat-list style="margin-left: 30px"> <mat-list style="width: 100%">
<div *ngFor="let app of applist | async"> <div *ngFor="let app of applist | async" >
<div *ngIf="app.startscript != null"> <mat-list-item *ngIf="app.startscript != null" style="width: 100%">
<button mat-button (click)=select(app) style="width: 100%; text-align: right">{{ app.name }}</button> <button mat-button (click)=select(app) style="width: 100%; text-align: left">{{ app.name }}</button>
</div> </mat-list-item>
<div *ngIf="app.applist != null">
<mat-list-item>
<app-strudelapplist [applist]=app.applist [identity]=identity (appChange)="select($event)"></app-strudelapplist>
</mat-list-item>
</div>
</div>
<!-- The following allows for a nested set of apps --> <!-- The following allows for a nested set of apps -->
<div *ngIf="app.applist != null">
<app-strudelapplist [applist]=app.applist [identity]=identity (appChange)="select($event)"></app-strudelapplist>
</div>
</div>
</mat-list> </mat-list>
[ [
{
"name": "Testing",
"tes": "https://strudel2-api-test.cloud.cvl.org.au/tes",
"tws": "https://strudel2-api-test.cloud.cvl.org.au"
},
{ {
"name": "Dev", "name": "Dev",
"tes": "https://strudel2-api-dev.cloud.cvl.org.au/tes", "tes": "https://strudel2-api-dev.cloud.cvl.org.au/tes",
"tws": "https://strudel2-api-dev.cloud.cvl.org.au" "tws": "https://strudel2-api-dev.cloud.cvl.org.au"
}, },
{
"name": "Testing",
"tes": "https://strudel2-api-test.cloud.cvl.org.au/tes",
"tws": "https://strudel2-api-test.cloud.cvl.org.au"
},
{ {
"name": "Dev - Pawsey", "name": "Dev - Pawsey",
"tes": "https://strudel2-api-dev-pawsey.cloud.cvl.org.au/tes", "tes": "https://strudel2-api-dev-pawsey.cloud.cvl.org.au/tes",
......
[ [
{ {
"url": "http://localhost:5000", "url": "https://strudel2-api-dev.cloud.cvl.org.au/m3/",
"name": "M3", "name": "M3",
"host": "m3-login1.massive.org.au", "host": "m3-login1.massive.org.au",
"dtn": "m3-dtn1.massive.org.au", "dtn": "m3-dtn1.massive.org.au",
......
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