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 { HttpClientModule, HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { catchError, map, tap } from 'rxjs/operators';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
import { catchError, map, tap, take,filter } from 'rxjs/operators';
import { ActivatedRoute, Router } from '@angular/router';
import {LocationStrategy, Location} from '@angular/common';
// import { keypair } from 'keypair';
import * as keypair from 'keypair';
import * as forge from "node-forge";
import { Identity, AuthToken, KeyCert, SshAuthzServer } from './identity';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Subject} from 'rxjs/Subject';
import {BackendSelectionService} from './backend-selection.service';
import { throwError } from 'rxjs';
import { environment } from '../environments/environment';
export class SshauthzServer {}
......@@ -53,12 +48,13 @@ export class AuthorisationService {
this.sshAuthzServers = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
this.backendURI = '';
this.backendURI = null;
this.agentContents = new BehaviorSubject([]);
this.keys = [];
this.getSshAuthzServers();
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))
.subscribe((value) => { this.backendURI = value.tes ; this.updateAgentContents() })
this.agentContents.subscribe((value) => this.updateLoggedAuthZ());
this.sshAuthzServers.subscribe((value) => this.updateLoggedAuthZ());
}
......@@ -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) {
return
}
......@@ -230,6 +232,12 @@ public getKeys(id?: Identity) {
}
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) {
this.statusMsg.next("Updating the list of available accounts");
};
......
import { Injectable } from '@angular/core';
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 { environment } from '../environments/environment';
......@@ -14,7 +16,7 @@ export class BackendSelectionService {
constructor(private http: HttpClient) {
this.apiservers = new BehaviorSubject([]);
this.apiserver = new BehaviorSubject(undefined);
this.apiserver = new BehaviorSubject(null);
this.initApiServer();
this.getAPIServers();
}
......@@ -22,12 +24,20 @@ export class BackendSelectionService {
private initApiServer() {
try {
this.apiserver.next(<APIServer>JSON.parse(localStorage.getItem('apiserver')));
console.log('selected api server');
console.log(this.apiserver.value);
} catch {
this.apiserver.next(<APIServer>environment.apiserver);
this.apiserver.next(null);
}
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)})
}
if (this.apiserver.value == null) {
this.apiserver.next(<APIServer>environment.apiserver);
}
private defaultApiServer(v: APIServer[]) {
this.apiserver.next(v[0]);
}
private saveLastApiServer(s: APIServer) {
......@@ -50,6 +60,7 @@ export class BackendSelectionService {
}
getAPIServers() {
console.log('retrieving api servers');
let headers = new HttpHeaders();
let options = { headers: headers, withCredentials: false};
this.http.get<APIServer[]>('./assets/config/apiservers.json',options)
......@@ -57,6 +68,7 @@ export class BackendSelectionService {
}
private updateAPIServers(resp) {
console.log('got some api servers merging them');
var s: APIServer;
var list: APIServer[] = []
var current: APIServer;
......@@ -71,7 +83,7 @@ export class BackendSelectionService {
}
for (s of <APIServer[]>resp) {
if (s.name == current.name) {
if (current !== undefined && current !== null && s.name == current.name) {
list.push(current);
found = true;
} else {
......@@ -80,7 +92,7 @@ export class BackendSelectionService {
}
if (localServers !== null) {
for (s of localServers) {
if (s.name == current.name) {
if (current !== null && s.name == current.name) {
list.push(current);
found = true;
} else {
......@@ -92,6 +104,7 @@ export class BackendSelectionService {
list.push(current);
}
this.apiservers.next(list);
console.log('apiserver merge complete');
}
}
......@@ -14,29 +14,22 @@
<mat-sidenav #idSideNav mode="side" opened>
<div fxLayout="column" style="height: 100%">
<div>
<mat-accordion>
<mat-accordion style="width: 100%">
<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-panel-title>
<!--<button mat-button style="width: 100%">-->
<div fxLayout="row">
<div style="width: 20px;"></div>
<div fxFlex fxLayout="column">
<div style="height: 15px"></div>
<span fxFlex matBadge="{{ (id.healthalerts | async).length }}"
[matBadgeHidden]= "(id.healthalerts | async).length == 0"
matBadgePosition="above before"
matBadgeColor="warn" style=" text-align: left" matBadgeOverlap="false" matBadgeSize="small">
matBadgeColor="warn"
matBadgeOverlap="false" matBadgeSize="small"
style="text-align: left; margin-left: 20px; margin-top: 10px" >
{{ id.displayName() }}
</span>
</div>
</div>
<!--</button>-->
</mat-panel-title>
</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>
</div>
</mat-accordion>
......@@ -57,12 +50,6 @@
<mat-sidenav-content>
<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 -->
<div *ngIf="(identitySubject | async) !== null" >
<mat-list>
......@@ -78,6 +65,13 @@
</mat-list>
</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 -->
<app-joblist [identitySubject]="identitySubject" [appSubject]="appSubject"></app-joblist>
......
......@@ -91,58 +91,5 @@ export class LoginComponent implements OnInit {
signup(sshauthzserver) {
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">
<div *ngFor="let app of applist | async">
<div *ngIf="app.startscript != null">
<button mat-button (click)=select(app) style="width: 100%; text-align: right">{{ app.name }}</button>
</div>
<!-- The following allows for a nested set of apps -->
<mat-list style="width: 100%">
<div *ngFor="let app of applist | async" >
<mat-list-item *ngIf="app.startscript != null" style="width: 100%">
<button mat-button (click)=select(app) style="width: 100%; text-align: left">{{ app.name }}</button>
</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>
</div>
<!-- The following allows for a nested set of apps -->
</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",
"tes": "https://strudel2-api-dev.cloud.cvl.org.au/tes",
"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",
"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",
"host": "m3-login1.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