[ARVADOS] updated: 1.1.2-143-g0312a5e

Git user git at public.curoverse.com
Fri Feb 2 17:33:14 EST 2018


Summary of changes:
 .../app/assets/javascripts/components/search.js    | 11 +++++++-
 .../app/assets/javascripts/models/session_db.js    | 32 ++++++++++++++++++++--
 apps/workbench/app/views/search/index.html         | 10 +++++--
 apps/workbench/app/views/sessions/index.html       |  7 +++++
 4 files changed, 54 insertions(+), 6 deletions(-)

       via  0312a5e5aa076fa3458dd83a33e72663d23bb1ba (commit)
       via  d20683e4d068d673c481191b56e770f61c3cb208 (commit)
      from  0e3c1f9c71f537d000459cbd3159ca6c198461c8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 0312a5e5aa076fa3458dd83a33e72663d23bb1ba
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Fri Feb 2 19:29:37 2018 -0300

    11454: On /search & /sessions page, check if the current user is
    from a remote cluster, and if that's the case, redirect to the
    proper home cluster workbench's page.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 2d22a98..0c3a081 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -244,9 +244,6 @@ window.SessionDB = 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) {
@@ -256,5 +253,34 @@ window.SessionDB = function() {
                 })
             })
         },
+        autoRedirectToHomeCluster: function(path = '/') {
+            var session = db.loadLocal()
+            var userUUIDPrefix = session.user.uuid.slice(0, 5)
+            // If the current user is local to the cluster, do nothing.
+            if (userUUIDPrefix == session.user.owner_uuid.slice(0, 5)) {
+                return
+            }
+            var doc = db.discoveryDoc(session)
+            doc.map(function(d) {
+                // Guess the remote host from the local discovery doc settings
+                var rHost = null
+                if (d.remoteHosts[userUUIDPrefix]) {
+                    rHost = d.remoteHosts[userUUIDPrefix]
+                } else if (d.remoteHostsViaDNS) {
+                    rHost = userUUIDPrefix + '.arvadosapi.com'
+                } else {
+                    // This should not happen: having remote user whose uuid prefix
+                    // isn't listed on remoteHosts and dns mechanism is deactivated
+                    return
+                }
+                // Get the remote cluster workbench url & redirect there.
+                db.findAPI(rHost).then(function(apiUrl) {
+                    var doc = db.discoveryDoc({baseURL: apiUrl})
+                    doc.map(function(d) {
+                        document.location = d.workbenchUrl + path
+                    })
+                })
+            })
+        },
     })
 }
diff --git a/apps/workbench/app/views/search/index.html b/apps/workbench/app/views/search/index.html
index d2a83864..c26a643 100644
--- a/apps/workbench/app/views/search/index.html
+++ b/apps/workbench/app/views/search/index.html
@@ -2,5 +2,11 @@
 
 SPDX-License-Identifier: AGPL-3.0 -->
 
-<div data-mount-mithril="Search">
-</div>
+<script type="text/javascript">
+    $(document).on('ready', function() {
+        var db = new SessionDB()
+        db.autoRedirectToHomeCluster('/search')
+    })
+</script>
+
+<div data-mount-mithril="Search"></div>
diff --git a/apps/workbench/app/views/sessions/index.html b/apps/workbench/app/views/sessions/index.html
index bf23028..ee1f636 100644
--- a/apps/workbench/app/views/sessions/index.html
+++ b/apps/workbench/app/views/sessions/index.html
@@ -2,4 +2,11 @@
 
 SPDX-License-Identifier: AGPL-3.0 -->
 
+<script type="text/javascript">
+    $(document).on('ready', function() {
+        var db = new SessionDB()
+        db.autoRedirectToHomeCluster('/sessions')
+    })
+</script>
+
 <div data-mount-mithril="SessionsTable"></div>

commit d20683e4d068d673c481191b56e770f61c3cb208
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Fri Feb 2 17:49:00 2018 -0300

    11454: Add the salted token on search result links from federated
    remote hosts to get auto-logged in when clicking through.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/components/search.js b/apps/workbench/app/assets/javascripts/components/search.js
index 17055b3..51d352a 100644
--- a/apps/workbench/app/assets/javascripts/components/search.js
+++ b/apps/workbench/app/assets/javascripts/components/search.js
@@ -41,6 +41,8 @@ window.SearchResultsTable = {
             collections: m('i.fa.fa-fw.fa-archive'),
             projects: m('i.fa.fa-fw.fa-folder'),
         }
+        var db = new SessionDB()
+        var sessions = db.loadActive()
         return m('table.table.table-condensed', [
             m('thead', m('tr', [
                 m('th'),
@@ -50,6 +52,13 @@ window.SearchResultsTable = {
             ])),
             m('tbody', [
                 loader.items().map(function(item) {
+                    var session = sessions[item.uuid.slice(0,5)]
+                    var tokenParam = ''
+                    // Add the salted token to search result links from federated
+                    // remote hosts.
+                    if (!session.isFromRails && session.token.indexOf('v2/') == 0) {
+                        tokenParam = '?api_token='+session.token
+                    }
                     return m('tr', [
                         m('td', [
                             item.workbenchBaseURL() &&
@@ -57,7 +66,7 @@ window.SearchResultsTable = {
                                     'data-original-title': 'show '+item.objectType.description,
                                     'data-placement': 'top',
                                     'data-toggle': 'tooltip',
-                                    href: item.workbenchBaseURL()+'/'+item.objectType.wb_path+'/'+item.uuid,
+                                    href: item.workbenchBaseURL()+'/'+item.objectType.wb_path+'/'+item.uuid+tokenParam,
                                     // Bootstrap's tooltip feature
                                     oncreate: function(vnode) { $(vnode.dom).tooltip() },
                                 }, iconsMap[item.objectType.wb_path]),

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list