11454: Removed unnecessary call on migrateNonFederatedSessions()
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 2 Feb 2018 14:53:48 +0000 (11:53 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 2 Feb 2018 14:53:48 +0000 (11:53 -0300)
Added auto loading of remote hosts listed on home cluster's api discovery doc. (WIP)

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

apps/workbench/app/assets/javascripts/components/search.js
apps/workbench/app/assets/javascripts/components/sessions.js
apps/workbench/app/assets/javascripts/models/session_db.js

index 0839491696277baebebbc603cec1045b43dae9a9..17055b3207356b3767bbd47144f00687e5fbe2c8 100644 (file)
@@ -2,11 +2,6 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-$(document).on('ready', function() {
-    var db = new SessionDB()
-    db.migrateNonFederatedSessions()
-})
-
 window.SearchResultsTable = {
     maybeLoadMore: function(dom) {
         var loader = this.loader
index 6a203420447bc2904dfbee7b74a3d62ff71eac35..12015b0ea1b50d99623d7b90b03ca15762922fcf 100644 (file)
@@ -7,6 +7,7 @@ $(document).on('ready', function() {
     db.checkForNewToken()
     db.fillMissingUUIDs()
     db.migrateNonFederatedSessions()
+    db.autoLoadRemoteHosts()
 })
 
 window.SessionsTable = {
index 26306b8b104e3d762281bbc50cdefb9e6e7907c8..2d22a98958b2129025c83bd7521aaa6903e91ff2 100644 (file)
@@ -238,5 +238,23 @@ window.SessionDB = function() {
                 }
             })
         },
+        // If remoteHosts is listed on the local API discovery doc, try to add any
+        // listed remote without an active session.
+        autoLoadRemoteHosts: function() {
+            var activeSessions = db.loadActive()
+            var doc = db.discoveryDoc(db.loadLocal())
+            doc.map(function(d) {
+                // NOTE: the below line is to simulate that 9tee4 is included as a remote host
+                // the current test cluster
+                // d.remoteHosts = {"9tee4":"9tee4.arvadosapi.com"}
+                Object.keys(d.remoteHosts).map(function(uuidPrefix) {
+                    if (!(uuidPrefix in Object.keys(activeSessions))) {
+                        db.findAPI(d.remoteHosts[uuidPrefix]).then(function(baseURL) {
+                            db.login(baseURL, false)
+                        })
+                    }
+                })
+            })
+        },
     })
 }