[ARVADOS] updated: ecaf4e935d372ed1b39ff16a908dcd2797479940

Git user git at public.curoverse.com
Fri Aug 25 22:19:41 EDT 2017


Summary of changes:
 .../app/assets/javascripts/components/sessions.js  | 26 +++++++++++++++---
 .../app/assets/javascripts/models/session_db.js    | 31 ++++++++++++++++------
 .../workbench/app/controllers/status_controller.rb | 17 ++++++++++++
 apps/workbench/app/views/layouts/body.html.erb     | 10 ++++---
 apps/workbench/config/routes.rb                    |  2 ++
 5 files changed, 71 insertions(+), 15 deletions(-)
 create mode 100644 apps/workbench/app/controllers/status_controller.rb

       via  ecaf4e935d372ed1b39ff16a908dcd2797479940 (commit)
       via  0412302971e705a539805711496bc24e374b6f50 (commit)
      from  65f13986f98a75f8da7cfe695ea5960ff741d402 (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 ecaf4e935d372ed1b39ff16a908dcd2797479940
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 25 22:18:04 2017 -0400

    12033: Improve multi-site search navigation a bit.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/components/sessions.js b/apps/workbench/app/assets/javascripts/components/sessions.js
index cbf2a7e..3d127f1 100644
--- a/apps/workbench/app/assets/javascripts/components/sessions.js
+++ b/apps/workbench/app/assets/javascripts/components/sessions.js
@@ -19,6 +19,11 @@ window.SessionsTable = {
         var db = vnode.state.db
         var sessions = db.loadAll()
         return m('.container', [
+            m('p', [
+                'You can log in to multiple Arvados sites here, then use the ',
+                m('a[href="/collections/multisite"]', 'multi-site search'),
+                ' page to search collections on all sites at once.',
+            ]),
             m('table.table.table-condensed.table-hover', [
                 m('thead', m('tr', [
                     m('th', 'status'),
diff --git a/apps/workbench/app/views/layouts/body.html.erb b/apps/workbench/app/views/layouts/body.html.erb
index a2256a0..fe1698e 100644
--- a/apps/workbench/app/views/layouts/body.html.erb
+++ b/apps/workbench/app/views/layouts/body.html.erb
@@ -29,9 +29,11 @@ SPDX-License-Identifier: AGPL-3.0 %>
           <% if current_user %>
             <% if current_user.is_active %>
             <li>
-              <%= link_to(controller: 'collections', action: 'multisite') do %>
-                Multisite search (beta)
-              <% end %>
+              <form class="navbar-form">
+                <%= link_to({controller: 'collections', action: 'multisite'}, {class: 'btn btn-default'}) do %>
+                  Multi-site search
+                <% end %>
+              </form>
             </li>
             <li>
               <form class="navbar-form" role="search"
@@ -46,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
                           action_data: {selection_param: 'uuid', success: 'redirect-to-created-object'}.to_json)
                          %>">
                 <div class="input-group" style="width: 220px">
-                  <input type="text" class="form-control" placeholder="search">
+                  <input type="text" class="form-control" placeholder="search this site">
                   <a class="input-group-addon"><span class="glyphicon glyphicon-search"></span></a>
                 </div>
               </form>

commit 0412302971e705a539805711496bc24e374b6f50
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 25 22:15:05 2017 -0400

    12033: Canary query before initiating login procedure.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/javascripts/components/sessions.js b/apps/workbench/app/assets/javascripts/components/sessions.js
index 17c144c..cbf2a7e 100644
--- a/apps/workbench/app/assets/javascripts/components/sessions.js
+++ b/apps/workbench/app/assets/javascripts/components/sessions.js
@@ -12,6 +12,8 @@ window.SessionsTable = {
     oninit: function(vnode) {
         vnode.state.db = new SessionDB()
         vnode.state.hostToAdd = m.stream('')
+        vnode.state.error = m.stream()
+        vnode.state.checking = m.stream()
     },
     view: function(vnode) {
         var db = vnode.state.db
@@ -60,12 +62,22 @@ window.SessionsTable = {
             m('.row', m('.col-md-6', [
                 m('form', {
                     onsubmit: function() {
-                        db.login(vnode.state.hostToAdd())
+                        vnode.state.error(null)
+                        vnode.state.checking(true)
+                        db.findAPI(vnode.state.hostToAdd())
+                            .then(db.login)
+                            .catch(function() {
+                                vnode.state.error(true)
+                            })
+                            .then(vnode.state.checking.bind(null, null))
                         return false
                     },
                 }, [
-                    m('.input-group', [
-                        m('input.form-control[type=text][name=apiHost][placeholder="API host"]', {
+                    m('p', [
+                        'To add a remote Arvados site, paste the remote site\'s host here (see "ARVADOS_API_HOST" on the "current token" page).',
+                    ]),
+                    m('.input-group', { className: vnode.state.error() && 'has-error' }, [
+                        m('input.form-control[type=text][name=apiHost][placeholder="zzzzz.arvadosapi.com"]', {
                             oninput: m.withAttr('value', vnode.state.hostToAdd),
                         }),
                         m('.input-group-btn', [
@@ -75,6 +87,9 @@ window.SessionsTable = {
                         ]),
                     ]),
                 ]),
+                m('p'),
+                vnode.state.error() && m('p.alert.alert-danger', 'Request failed. Make sure this is a working API server address.'),
+                vnode.state.checking() && m('p.alert.alert-info', 'Checking...'),
             ])),
         ])
     },
diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 1f5c02f..13409d9 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -41,19 +41,34 @@ window.SessionDB = function() {
             delete sessions[k]
             window.localStorage.setItem('sessions', JSON.stringify(sessions))
         },
-        login: function(host) {
-            // Initiate login procedure with given API host (which can
-            // optionally include scheme://).
+        findAPI: function(url) {
+            // Given a Workbench or API host or URL, return a promise
+            // for the corresponding API server's base URL.  Typical
+            // use:
+            // sessionDB.findAPI('https://workbench.example/foo').then(sessionDB.login)
+            if (url.indexOf('://') < 0)
+                url = 'https://' + url
+            url = new URL(url)
+            return m.request(url.origin + '/discovery/v1/apis/arvados/v1/rest').then(function() {
+                return url.origin + '/'
+            }).catch(function(err) {
+                // If url is a Workbench site (and isn't too old),
+                // /status.json will tell us its API host.
+                return m.request(url.origin + '/status.json').then(function(resp) {
+                    if (!resp.apiBaseURL)
+                        throw 'no apiBaseURL in status response'
+                    return resp.apiBaseURL
+                })
+            })
+        },
+        login: function(baseURL) {
+            // Initiate login procedure with given API base URL (e.g.,
+            // "http://api.example/").
             //
             // Any page that has a button that invokes login() must
             // also call checkForNewToken() on (at least) its first
             // render. Otherwise, the login procedure can't be
             // completed.
-            var baseURL = host
-            if (baseURL.indexOf('://') < 0)
-                baseURL = 'https://' + baseURL
-            if (!baseURL.endsWith('/'))
-                baseURL = baseURL + '/'
             document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
             return false
         },
diff --git a/apps/workbench/app/controllers/status_controller.rb b/apps/workbench/app/controllers/status_controller.rb
new file mode 100644
index 0000000..90b7be5
--- /dev/null
+++ b/apps/workbench/app/controllers/status_controller.rb
@@ -0,0 +1,17 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class StatusController < ApplicationController
+  skip_around_filter :require_thread_api_token
+  skip_before_filter :find_object_by_uuid
+  def status
+    # Allow non-credentialed cross-origin requests
+    headers['Access-Control-Allow-Origin'] = '*'
+    resp = {
+      apiBaseURL: arvados_api_client.arvados_v1_base.sub(%r{/arvados/v\d+.*}, '/'),
+      version: AppVersion.hash,
+    }
+    render json: resp
+  end
+end
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 8dcc7fd..fee49c1 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -132,6 +132,8 @@ ArvadosWorkbench::Application.routes.draw do
 
   get '/tests/mithril', to: 'tests#mithril'
 
+  get '/status', to: 'status#status'
+
   # Send unroutable requests to an arbitrary controller
   # (ends up at ApplicationController#render_not_found)
   match '*a', to: 'links#render_not_found', via: [:get, :post]

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list