From 8f2ad96c20edf1f068cb3e6d04646699ca512480 Mon Sep 17 00:00:00 2001 From: Chris Hines <chris.hines@monash.edu> Date: Tue, 23 Feb 2021 10:23:22 +1100 Subject: [PATCH] allow apps to specify a different batch command URL, and better detect 401 unauthorized --- src/app/jobs.service.ts | 6 ++++++ src/app/launch-dialog/launch-dialog.component.ts | 6 +++++- src/app/strudelapp.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/jobs.service.ts b/src/app/jobs.service.ts index f1da484..b1b0976 100644 --- a/src/app/jobs.service.ts +++ b/src/app/jobs.service.ts @@ -33,6 +33,7 @@ export class JobsService { public refreshJobs() { if (this.id !== undefined && this.id !== null) { var query$: Observable<Job[]>; + console.log('refreshJobs'); query$ = this.tes.runCommand(this.id, this.id.site.statcmd) query$.subscribe((qjobs) => this.jobs$.next(<Job[]>qjobs), (error) => this.getJobsError(error,this.id)) @@ -41,6 +42,10 @@ export class JobsService { } public getJobsError(error,identity: Identity) { + if (error.hasOwnProperty('status') && error.status == 401) { + this.notifications.notify("Your login appears to have expired. Please log in again", () => { this.authService.updateAgentContents().subscribe((_) => {return}) } ); + return; + } this.tsub.unsubscribe(); if (identity.expiry < Date.now()) { this.notifications.notify("Your login has expired. Please log in again", () => { this.authService.updateAgentContents().subscribe((_) => {return}) } ); @@ -53,6 +58,7 @@ export class JobsService { return; } this.notifications.notify("Unable to retrieve a list of running jobs.\nThe error messge was " + error.error.message); + console.log(error); return; } console.error(error); diff --git a/src/app/launch-dialog/launch-dialog.component.ts b/src/app/launch-dialog/launch-dialog.component.ts index 4a1ca6d..2854bf1 100644 --- a/src/app/launch-dialog/launch-dialog.component.ts +++ b/src/app/launch-dialog/launch-dialog.component.ts @@ -89,7 +89,11 @@ export class LaunchDialogComponent implements OnInit { theme = 'strudel-light-theme'; } if (this.identity !== null && this.app !== null) { - this.batchcmdurl = this.identity.site.url+"/"+encodeURIComponent(this.app.name)+"?theme="+theme; + if (this.app.batchcmdurl !== null) { + this.batchcmdurl = this.app.batchcmdurl+"?theme="+theme; + } else { + this.batchcmdurl = this.identity.site.url+"/"+encodeURIComponent(this.app.name)+"?theme="+theme; + } } this.batchcmdsafeurl = this.domSanitizer.bypassSecurityTrustResourceUrl(this.batchcmdurl); if (this.app.url !== null) { diff --git a/src/app/strudelapp.ts b/src/app/strudelapp.ts index 434343e..bb0b3e4 100644 --- a/src/app/strudelapp.ts +++ b/src/app/strudelapp.ts @@ -8,6 +8,7 @@ export class AppAction { } export class Strudelapp { url: string; // A url used to retrieve extra config options. May be null + batchcmdurl: string = null; // if an app provides a batchcommandurl it overrides the url provieded for the site. name: string; startscript: string; // batch script ... should NOT include resource directives // resource directives like #SBATCH belong in the batchinterface -- GitLab