From 5c5c0db60cd8fd6c4f65d991df36f952803613f5 Mon Sep 17 00:00:00 2001
From: Chris Hines <chris.hines@monash.edu>
Date: Wed, 13 Mar 2019 20:15:13 +1100
Subject: [PATCH] fix backend selection

---
 src/app/authorisation.service.ts |  4 ++--
 src/app/tes.service.ts           | 11 ++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/app/authorisation.service.ts b/src/app/authorisation.service.ts
index 0eeda95..ce21cbe 100644
--- a/src/app/authorisation.service.ts
+++ b/src/app/authorisation.service.ts
@@ -31,7 +31,7 @@ export class AuthorisationService {
   public readyToNavigate: Subject<[Boolean,string]>;
   public progress: Subject<string>;
   // private keyCert: Subject<KeyCert>;
-  private backendURI: string;
+  public backendURI: string;
   public statusMsg: BehaviorSubject<string>;
   public agentContents: BehaviorSubject<any>;
   public keys: KeyCert[];
@@ -53,7 +53,7 @@ export class AuthorisationService {
                 this.sshAuthzServers = new BehaviorSubject<SshAuthzServer[]>([]);
                 this.loggedInAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
                 this.loggedOutAuthZ = new BehaviorSubject<SshAuthzServer[]>([]);
-                this.backendURI = environment.tesurl;
+                this.backendURI = '';
                 this.agentContents = new BehaviorSubject([]);
                 this.keys = [];
                 this.getSshAuthzServers();
diff --git a/src/app/tes.service.ts b/src/app/tes.service.ts
index 662bf7a..2f78fb0 100644
--- a/src/app/tes.service.ts
+++ b/src/app/tes.service.ts
@@ -110,6 +110,7 @@ private loadLastApiServer() {
     }
     this.Base = this.apiserver.value.tes;
     this.twsproxy = this.apiserver.value.tws;
+    this.authorisationService.backendURI = this.Base;
     console.log('load succeeded');
 }
 private saveLastApiServer(s: APIServer) {
@@ -166,7 +167,9 @@ private saveLastApiServer(s: APIServer) {
    var lastjoblist: Job[] = this.joblist.value;
    var qjobids: any[] = [];
    var jobids: any[] = [];
-   var j: Job
+   var j: Job;
+   var newjob: Job;
+   var idx: number;
 
    for (j of jobquery) {
        qjobids.push(j.jobid);
@@ -174,6 +177,12 @@ private saveLastApiServer(s: APIServer) {
    for (j of lastjoblist) {
        if (qjobids.indexOf(j.jobid) != -1) {
            if (jobids.indexOf(j.jobid) == -1) {
+               idx = qjobids.indexOf(j.jobid)
+               newjob = jobquery[idx]
+               // These values in the job may change, but we need to keep using the old object
+               j.state  = newjob.state;
+               j.endtime = newjob.endtime;
+               j.batch_host = newjob.batch_host;
                joblist.push(j);
                jobids.push(j.jobid);
            }
-- 
GitLab