Skip to content
Snippets Groups Projects
Commit 1483343c authored by Chris Hines's avatar Chris Hines
Browse files

refactor the connect method for opening a window to make it clearer

parent 9dce3905
No related branches found
No related tags found
3 merge requests!106if stat fails, display the error instead of immediately refreshing...,!99Dev,!44Dev
Pipeline #9191 passed
......@@ -20,11 +20,12 @@ export class SshauthzServer {}
})
export class AuthorisationService {
// public token: BehaviorSubject<AuthToken>;
public token: BehaviorSubject<AuthToken>;
public readonly sshAuthzServers: BehaviorSubject<SshAuthzServer[]>;
public readonly agentContents: BehaviorSubject<any>;
public loggedInAuthZ: BehaviorSubject<SshAuthzServer[]>;
public loggedOutAuthZ: BehaviorSubject<SshAuthzServer[]>;
public loggedInAuthZ$: Observable<SshAuthzServer[]>;
public loggedOutAuthZ$: Observable<SshAuthzServer[]>;
//public progress: Subject<string>;
// private keyCert: Subject<KeyCert>;
public backendURI: string;
......@@ -36,7 +37,6 @@ export class AuthorisationService {
private backendSelectionService: BackendSelectionService,
private location: Location,
private notifications: NotificationsService) {
this.token = new BehaviorSubject<AuthToken>(null);
this.sshAuthzServers = new BehaviorSubject<SshAuthzServer[]>([]);
this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>(null);
this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
......@@ -54,15 +54,27 @@ export class AuthorisationService {
// Once we have backend server, check what our ssh agent has in it
this.backendSelectionService.apiserver.pipe(
filter((v) => v !== null && v !== undefined),
switchMap((v) => this.updateAgentContents(v.tes))
).subscribe((_) => { return }); // An empty subscription is necessary for the observables to fire
switchMap((v) => this.updateAgentContents(v.tes)),
tap((v) => console.log(v))
).subscribe((_) => { return }, (err) => console.error(err)); // An empty subscription is necessary for the observables to fire
/* Once we have a value for agent Conents, and a list of servers, we can figure out which ones we hav elogged into and which ones we haven't */
/*
combineLatest([this.agentContents.pipe(filter((v) => v !== null && v !== undefined)),this.sshAuthzServers.pipe(filter((v) => v !== null && v !== undefined))]).pipe(
map(([agentContents,authzServers]) => { return this.updateLoggedAuthZ(agentContents,authzServers)}),
catchError((e) => { console.error('errort getting values for logged in and out',e); throwError(e) ; return of([]) }),
).subscribe(([loggedin,loggedout]) => { this.loggedInAuthZ.next(loggedin); this.loggedOutAuthZ.next(loggedout); console.log('updated subjects'); })
*/
var authZ$: Observable<any>;
authZ$ = combineLatest([this.agentContents.pipe(filter((v) => v !== null && v !== undefined)),this.sshAuthzServers.pipe(filter((v) => v !== null && v !== undefined))]).pipe(
map(([agentContents,authzServers]) => { return this.updateLoggedAuthZ(agentContents,authzServers)}),
catchError((e) => { console.error('errort getting values for logged in and out',e); return throwError(e) })
);
authZ$.subscribe(([loggedin,loggedout]) => { this.loggedInAuthZ.next(loggedin); this.loggedOutAuthZ.next(loggedout); console.log('updated subjects'); })
this.loggedInAuthZ$ = authZ$[0];
this.loggedOutAuthZ$ = authZ$[1];
}
......@@ -200,6 +212,7 @@ public getKeys(id?: Identity) {
let agentpipe$ = agentquery$.pipe(
catchError((e) => { this.querySshAgentError(e); return of([])}),
tap((resp) => this.agentContents.next(resp)),
tap((resp) => console.log('update agent contents with',resp)),
tap((v) => console.log('agentContents.next called')),
tap((_) => this.notifications.notify(""))
)
......
......@@ -10,6 +10,7 @@ import { Strudelapp } from '../strudelapp';
import { TesService } from '../tes.service';
import { Job } from '../job';
import { Identity } from '../identity';
import { AuthorisationService } from '../authorisation.service';
......@@ -26,7 +27,7 @@ export class JoblistComponent implements OnInit {
public joblist: Job[];
constructor(private tes: TesService ) {
constructor(private tes: TesService, private authService: AuthorisationService ) {
}
public ngOnInit(): void {
......@@ -45,6 +46,11 @@ export class JoblistComponent implements OnInit {
}
getJobsError(error,identitiy) {
// if an error occurs, pause polling, update the list of sites, and attempt to resume polling
// if the current site is no longer logged in, nagivate away
this.sub.unsubscribe()
this.authService.updateAgentContents().subscribe((v) =>
{this.sub = timer(5000).pipe(repeat()).subscribe( () => this.getJobs() )});
console.log('getjobs error',error);
}
updateJoblist(jobquery: Job[], identity: Identity) {
......
......@@ -58,6 +58,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
],
......@@ -91,6 +92,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
......@@ -168,6 +170,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
],
......@@ -209,6 +212,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
],
......
......@@ -27,6 +27,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
......@@ -62,6 +63,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
......@@ -96,6 +98,7 @@
"name": "Remove log",
"paramscmd": "/usr/local/sv2/dev/rmlog.py {jobid}",
"client": null,
"notunnel": true,
"states": ["Finished"]
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment