[ARVADOS] updated: 14edbf1a2327edf9e797928f6095153f22b486be

Git user git at public.curoverse.com
Fri Aug 11 11:47:13 EDT 2017


Summary of changes:
 .../assets/javascripts/components/collections.js   | 41 +++++++++++--
 .../app/assets/javascripts/components/sessions.js  | 68 +++++++++++++---------
 .../app/assets/javascripts/models/loader.js        | 14 +++--
 .../app/assets/javascripts/models/session_db.js    | 32 +++++++++-
 .../app/controllers/sessions_controller.rb         |  6 +-
 .../app/views/layouts/application.html.erb         |  5 ++
 6 files changed, 122 insertions(+), 44 deletions(-)

       via  14edbf1a2327edf9e797928f6095153f22b486be (commit)
       via  a20ea2d9b6b861829d9daa91990ce064b1000170 (commit)
       via  c97e090a3c26363f750903edb86e422c43b95233 (commit)
       via  6e1eda9ff559bb61df8880c8f53aca008aa95c9c (commit)
       via  16231ef0f56005b487cde9a7fb7dfb62952205a6 (commit)
       via  ea9b417bc727f859878f17898571ec9f997e4f11 (commit)
       via  9ff99b73aa200fa21bfcad1ae8a7098b593864bb (commit)
      from  2220f7f54be3445457a82c71e1e60d6492ede3a3 (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 14edbf1a2327edf9e797928f6095153f22b486be
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 11 11:43:49 2017 -0400

    12033: Fix double slash in href.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index 6167b2c..9e1db75 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -46,7 +46,7 @@ window.components.collection_table = {
             m('tbody', [
                 vnode.attrs.loader.displayable.map(function(item) {
                     return m('tr', [
-                        m('td', m('a.btn.btn-xs.btn-default', {href: item.session.baseURL.replace('://', '://workbench.')+'/collections/'+item.uuid}, 'Show')),
+                        m('td', m('a.btn.btn-xs.btn-default', {href: item.session.baseURL.replace('://', '://workbench.')+'collections/'+item.uuid}, 'Show')),
                         m('td.arvados-uuid', item.uuid),
                         m('td', item.name || '(unnamed)'),
                         m('td', m(window.components.datetime, {parse: item.modified_at})),

commit a20ea2d9b6b861829d9daa91990ce064b1000170
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 11 11:40:08 2017 -0400

    12033: Log out and back in to a site without forgetting it.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index a06e2bb..6167b2c 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -119,7 +119,9 @@ window.components.collection_search = {
                         ? m('span.label.label-xs.label-danger', 'none')
                         : Object.keys(sessions).sort().map(function(key) {
                             return [m('span.label.label-xs', {
-                                className: vnode.state.loader.pagers[key].items() ? 'label-info' : 'label-default',
+                                className: !vnode.state.loader.pagers[key] ? 'label-default' :
+                                    vnode.state.loader.pagers[key].items() ? 'label-success' :
+                                    'label-warning',
                             }, key), ' ']
                         }),
                     ' ',
diff --git a/apps/workbench/app/assets/javascripts/components/sessions.js b/apps/workbench/app/assets/javascripts/components/sessions.js
index 3ff9f4d..19a481d 100644
--- a/apps/workbench/app/assets/javascripts/components/sessions.js
+++ b/apps/workbench/app/assets/javascripts/components/sessions.js
@@ -18,36 +18,46 @@ window.components.sessions = {
         var db = vnode.state.db
         var sessions = db.loadAll()
         return m('container', [
-            m('table.table.table-condensed.table-hover', m('tbody', [
-                Object.keys(sessions).map(function(uuidPrefix) {
-                    var session = sessions[uuidPrefix]
-                    return m('tr', [
-                        session.token && session.user ? [
-                            m('td', session.isFromRails ? null : m('a.btn.btn-xs.btn-default', {
+            m('table.table.table-condensed.table-hover', [
+                m('thead', m('tr', [
+                    m('th', 'status'),
+                    m('th', 'cluster ID'),
+                    m('th', 'username'),
+                    m('th', 'email'),
+                    m('th', 'actions'),
+                    m('th'),
+                ])),
+                m('tbody', [
+                    Object.keys(sessions).map(function(uuidPrefix) {
+                        var session = sessions[uuidPrefix]
+                        return m('tr', [
+                            session.token && session.user ? [
+                                m('td', m('span.label.label-success', 'logged in')),
+                                m('td', {title: session.baseURL}, uuidPrefix),
+                                m('td', session.user.username),
+                                m('td', session.user.email),
+                                m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
+                                    uuidPrefix: uuidPrefix,
+                                    onclick: m.withAttr('uuidPrefix', db.logout),
+                                }, 'Log out ', m('span.glyphicon.glyphicon-log-out'))),
+                            ] : [
+                                m('td', m('span.label.label-default', 'logged out')),
+                                m('td', {title: session.baseURL}, uuidPrefix),
+                                m('td'),
+                                m('td'),
+                                m('td', m('a.btn.btn-xs.btn-primary', {
+                                    uuidPrefix: uuidPrefix,
+                                    onclick: db.login.bind(db, session.baseURL),
+                                }, 'Log in ', m('span.glyphicon.glyphicon-log-in'))),
+                            ],
+                            m('td', session.isFromRails ? null : m('button.btn.btn-xs.btn-default', {
                                 uuidPrefix: uuidPrefix,
-                                onclick: m.withAttr('uuidPrefix', db.logout),
-                            }, 'log out')),
-                            m('td', m('span.label.label-info', 'logged in')),
-                            m('td', {title: session.baseURL}, uuidPrefix),
-                            m('td', session.user.username),
-                            m('td', session.user.email),
-                        ] : [
-                            m('td', m('a.btn.btn-xs.btn-info', {
-                                uuidPrefix: uuidPrefix,
-                                onclick: m.withAttr('uuidPrefix', db.login),
-                            }, 'log in')),
-                            m('td', 'span.label.label-default', 'logged out'),
-                            m('td', {title: session.baseURL}, uuidPrefix),
-                            m('td'),
-                            m('td'),
-                        ],
-                        m('td', session.isFromRails ? null : m('a.glyphicon.glyphicon-trash', {
-                            uuidPrefix: uuidPrefix,
-                            onclick: m.withAttr('uuidPrefix', db.trash),
-                        })),
-                    ])
-                }),
-            ])),
+                                onclick: m.withAttr('uuidPrefix', db.trash),
+                            }, 'Remove ', m('span.glyphicon.glyphicon-trash'))),
+                        ])
+                    }),
+                ]),
+            ]),
             m('.row', m('.col-md-6', [
                 m('form', {
                     onsubmit: function() {
diff --git a/apps/workbench/app/assets/javascripts/models/loader.js b/apps/workbench/app/assets/javascripts/models/loader.js
index 0a3181b..17b2ad5 100644
--- a/apps/workbench/app/assets/javascripts/models/loader.js
+++ b/apps/workbench/app/assets/javascripts/models/loader.js
@@ -65,7 +65,7 @@ window.models.MultisiteLoader = function(config) {
         // displayed).
         lowWaterMark: 23,
     })
-    var sessions = loader.sessionDB.loadAll()
+    var sessions = loader.sessionDB.loadActive()
     m.stream.merge(Object.keys(sessions).map(function(key) {
         var pager = new window.models.Pager(loader.loadFunc.bind(null, sessions[key]))
         loader.pagers[key] = pager
diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 13d3eaf..b64481e 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -20,6 +20,14 @@ window.models.SessionDB = function() {
             }
             return all
         },
+        loadActive: function() {
+            var sessions = db.loadAll()
+            Object.keys(sessions).forEach(function(key) {
+                if (!sessions[key].token)
+                    delete sessions[key]
+            })
+            return sessions
+        },
         save: function(k, v) {
             var sessions = db.loadAll()
             sessions[k] = v
@@ -50,6 +58,14 @@ window.models.SessionDB = function() {
             document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
             return false
         },
+        logout: function(k) {
+            // Forget the token, but leave the other info in the db so
+            // the user can log in again without providing the login
+            // host again.
+            var sessions = db.loadAll()
+            delete sessions[k].token
+            db.save(k, sessions[k])
+        },
         checkForNewToken: function() {
             // If there's a token and baseURL in the location bar (i.e.,
             // we just landed here after a successful login), save it and

commit c97e090a3c26363f750903edb86e422c43b95233
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 11 10:05:19 2017 -0400

    12033: Fix logging in from location with non-empty query string.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index fde02f6..13d3eaf 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -47,7 +47,7 @@ window.models.SessionDB = function() {
                 baseURL = 'https://' + baseURL
             if (!baseURL.endsWith('/'))
                 baseURL = baseURL + '/'
-            document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href+'?baseURL='+encodeURIComponent(baseURL))
+            document.location = baseURL + 'login?return_to=' + encodeURIComponent(document.location.href.replace(/\?.*/, '')+'?baseURL='+encodeURIComponent(baseURL))
             return false
         },
         checkForNewToken: function() {

commit 6e1eda9ff559bb61df8880c8f53aca008aa95c9c
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 11 10:03:30 2017 -0400

    12033: Ensure current Rails login is always in sessions list.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/sessions.js b/apps/workbench/app/assets/javascripts/components/sessions.js
index be4b7e3..3ff9f4d 100644
--- a/apps/workbench/app/assets/javascripts/components/sessions.js
+++ b/apps/workbench/app/assets/javascripts/components/sessions.js
@@ -23,7 +23,7 @@ window.components.sessions = {
                     var session = sessions[uuidPrefix]
                     return m('tr', [
                         session.token && session.user ? [
-                            m('td', m('a.btn.btn-xs.btn-default', {
+                            m('td', session.isFromRails ? null : m('a.btn.btn-xs.btn-default', {
                                 uuidPrefix: uuidPrefix,
                                 onclick: m.withAttr('uuidPrefix', db.logout),
                             }, 'log out')),
@@ -41,7 +41,7 @@ window.components.sessions = {
                             m('td'),
                             m('td'),
                         ],
-                        m('td', m('a.glyphicon.glyphicon-trash', {
+                        m('td', session.isFromRails ? null : m('a.glyphicon.glyphicon-trash', {
                             uuidPrefix: uuidPrefix,
                             onclick: m.withAttr('uuidPrefix', db.trash),
                         })),
diff --git a/apps/workbench/app/assets/javascripts/models/session_db.js b/apps/workbench/app/assets/javascripts/models/session_db.js
index 75fe6f9..fde02f6 100644
--- a/apps/workbench/app/assets/javascripts/models/session_db.js
+++ b/apps/workbench/app/assets/javascripts/models/session_db.js
@@ -6,15 +6,27 @@ window.models = window.models || {}
 window.models.SessionDB = function() {
     var db = this
     Object.assign(db, {
-        loadAll: function() {
+        loadFromLocalStorage: function() {
             try {
                 return JSON.parse(window.localStorage.getItem('sessions')) || {}
             } catch(e) {}
             return {}
         },
+        loadAll: function() {
+            var all = db.loadFromLocalStorage()
+            if (window.defaultSession) {
+                window.defaultSession.isFromRails = true
+                all[window.defaultSession.user.uuid.slice(0, 5)] = window.defaultSession
+            }
+            return all
+        },
         save: function(k, v) {
             var sessions = db.loadAll()
             sessions[k] = v
+            Object.keys(sessions).forEach(function(key) {
+                if (sessions[key].isFromRails)
+                    delete sessions[key]
+            })
             window.localStorage.setItem('sessions', JSON.stringify(sessions))
         },
         trash: function(k) {
diff --git a/apps/workbench/app/controllers/sessions_controller.rb b/apps/workbench/app/controllers/sessions_controller.rb
index f72b451..48fbc6b 100644
--- a/apps/workbench/app/controllers/sessions_controller.rb
+++ b/apps/workbench/app/controllers/sessions_controller.rb
@@ -3,9 +3,9 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 class SessionsController < ApplicationController
-  skip_around_filter :require_thread_api_token, :only => [:destroy, :index]
-  skip_around_filter :set_thread_api_token, :only => [:destroy, :index]
-  skip_before_filter :find_object_by_uuid, :only => [:destroy, :index]
+  skip_around_filter :require_thread_api_token, :only => [:destroy, :logged_out]
+  skip_around_filter :set_thread_api_token, :only => [:destroy, :logged_out]
+  skip_before_filter :find_object_by_uuid
   skip_before_filter :find_objects_for_index
   skip_before_filter :ensure_arvados_api_exists
 
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 71b1cd1..b59bad4 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -18,6 +18,11 @@ SPDX-License-Identifier: AGPL-3.0 %>
   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
   <meta name="description" content="">
   <meta name="author" content="">
+  <% if current_user %>
+    <% content_for :js do %>
+      window.defaultSession = <%=raw({baseURL: Rails.configuration.arvados_v1_base.sub(/\/arvados\/v1$/, '/'), token: Thread.current[:arvados_api_token], user: current_user}.to_json)%>
+    <% end %>
+  <% end %>
   <% if current_user and $arvados_api_client.discovery[:websocketUrl] %>
   <meta name="arv-websocket-url" content="<%=$arvados_api_client.discovery[:websocketUrl]%>?api_token=<%=Thread.current[:arvados_api_token]%>">
   <% end %>

commit 16231ef0f56005b487cde9a7fb7dfb62952205a6
Author: Tom Clegg <tom at curoverse.com>
Date:   Fri Aug 11 01:23:07 2017 -0400

    12033: Fix auto scroll after search; acknowledge end of results.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index 19f2fd2..a06e2bb 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -4,30 +4,36 @@
 
 window.components = window.components || {}
 window.components.collection_table = {
-    oncreate: function(vnode) {
-        vnode.state.autoload = function() {
-            if (!vnode.attrs.loader.loadMore)
-                // Can't load more content anyway: no point in
-                // checking anything else.
-                return
-            var contentRect = vnode.dom.getBoundingClientRect()
-            var scroller = window // TODO: use vnode.dom's nearest ancestor with scrollbars
-            if (contentRect.bottom < 2 * scroller.innerHeight) {
-                // We have less than 1 page worth of content available
-                // below the visible area. Load more.
-                vnode.attrs.loader.loadMore()
-                // Indicate loading is in progress.
-                window.requestAnimationFrame(m.redraw)
-            }
+    maybeLoadMore: function(dom) {
+        var loader = this.loader
+        if (loader.done || !loader.loadMore)
+            // Can't load more content anyway: no point in
+            // checking anything else.
+            return
+        var contentRect = dom.getBoundingClientRect()
+        var scroller = window // TODO: use dom's nearest ancestor with scrollbars
+        if (contentRect.bottom < 2 * scroller.innerHeight) {
+            // We have less than 1 page worth of content available
+            // below the visible area. Load more.
+            loader.loadMore()
+            // Indicate loading is in progress.
+            window.requestAnimationFrame(m.redraw)
         }
-        window.addEventListener('scroll', vnode.state.autoload)
-        window.addEventListener('resize', vnode.state.autoload)
-        vnode.state.autoloadTimer = window.setInterval(vnode.state.autoload, 200)
+    },
+    oncreate: function(vnode) {
+        vnode.state.maybeLoadMore = vnode.state.maybeLoadMore.bind(vnode.state, vnode.dom)
+        window.addEventListener('scroll', vnode.state.maybeLoadMore)
+        window.addEventListener('resize', vnode.state.maybeLoadMore)
+        vnode.state.timer = window.setInterval(vnode.state.maybeLoadMore, 200)
+        vnode.state.onupdate(vnode)
+    },
+    onupdate: function(vnode) {
+        vnode.state.loader = vnode.attrs.loader
     },
     onremove: function(vnode) {
-        window.clearInterval(vnode.state.autoloadTimer)
-        window.removeEventListener('scroll', vnode.state.autoload)
-        window.removeEventListener('resize', vnode.state.autoload)
+        window.clearInterval(vnode.state.timer)
+        window.removeEventListener('scroll', vnode.state.maybeLoadMore)
+        window.removeEventListener('resize', vnode.state.maybeLoadMore)
     },
     view: function(vnode) {
         return m('table.table.table-condensed', [
@@ -48,7 +54,7 @@ window.components.collection_table = {
                 }),
             ]),
             m('tfoot', m('tr', [
-                m('th[colspan=4]', m('button.btn.btn-xs', {
+                vnode.attrs.loader.done ? null : m('th[colspan=4]', m('button.btn.btn-xs', {
                     className: vnode.attrs.loader.loadMore ? 'btn-primary' : 'btn-default',
                     style: {
                         display: 'block',
diff --git a/apps/workbench/app/assets/javascripts/models/loader.js b/apps/workbench/app/assets/javascripts/models/loader.js
index 1dc7079..0a3181b 100644
--- a/apps/workbench/app/assets/javascripts/models/loader.js
+++ b/apps/workbench/app/assets/javascripts/models/loader.js
@@ -10,7 +10,7 @@ window.models.Pager = function(loadFunc) {
         done: false,
         items: m.stream(),
         thresholdItem: null,
-        loadNextPage: function() {
+        loadMore: function() {
             // Get the next page, if there are any more items to get.
             if (pager.done)
                 return
@@ -53,6 +53,7 @@ window.models.MultisiteLoader = function(config) {
     Object.assign(loader, config, {
         // Sorted items ready to display, merged from all pagers.
         displayable: [],
+        done: false,
         pagers: {},
         loadMore: false,
         // Number of undisplayed items to keep on hand for each result
@@ -68,7 +69,7 @@ window.models.MultisiteLoader = function(config) {
     m.stream.merge(Object.keys(sessions).map(function(key) {
         var pager = new window.models.Pager(loader.loadFunc.bind(null, sessions[key]))
         loader.pagers[key] = pager
-        pager.loadNextPage()
+        pager.loadMore()
         // Resolve the stream with the session key when the results
         // arrive.
         return pager.items.map(function() { return key })
@@ -112,14 +113,15 @@ window.models.MultisiteLoader = function(config) {
             if (!loader.pagers[key].done)
                 loadable.push(loader.pagers[key])
         })
-        if (loadable.length == 0)
+        if (loadable.length == 0) {
+            loader.done = true
             loader.loadMore = false
-        else
+        } else
             loader.loadMore = function() {
                 loader.loadMore = false
                 loadable.map(function(pager) {
                     if (pager.items().length - pager.itemsDisplayed < loader.lowWaterMark)
-                        pager.loadNextPage()
+                        pager.loadMore()
                 })
             }
     })

commit ea9b417bc727f859878f17898571ec9f997e4f11
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Aug 10 23:35:20 2017 -0400

    12033: Load more results automatically on scroll.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index 4f995af..19f2fd2 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -4,6 +4,31 @@
 
 window.components = window.components || {}
 window.components.collection_table = {
+    oncreate: function(vnode) {
+        vnode.state.autoload = function() {
+            if (!vnode.attrs.loader.loadMore)
+                // Can't load more content anyway: no point in
+                // checking anything else.
+                return
+            var contentRect = vnode.dom.getBoundingClientRect()
+            var scroller = window // TODO: use vnode.dom's nearest ancestor with scrollbars
+            if (contentRect.bottom < 2 * scroller.innerHeight) {
+                // We have less than 1 page worth of content available
+                // below the visible area. Load more.
+                vnode.attrs.loader.loadMore()
+                // Indicate loading is in progress.
+                window.requestAnimationFrame(m.redraw)
+            }
+        }
+        window.addEventListener('scroll', vnode.state.autoload)
+        window.addEventListener('resize', vnode.state.autoload)
+        vnode.state.autoloadTimer = window.setInterval(vnode.state.autoload, 200)
+    },
+    onremove: function(vnode) {
+        window.clearInterval(vnode.state.autoloadTimer)
+        window.removeEventListener('scroll', vnode.state.autoload)
+        window.removeEventListener('resize', vnode.state.autoload)
+    },
     view: function(vnode) {
         return m('table.table.table-condensed', [
             m('thead', m('tr', [

commit 9ff99b73aa200fa21bfcad1ae8a7098b593864bb
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Aug 10 15:01:13 2017 -0400

    12033: Style uuid column.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curoverse.com>

diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index 527ce6c..4f995af 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -16,7 +16,7 @@ window.components.collection_table = {
                 vnode.attrs.loader.displayable.map(function(item) {
                     return m('tr', [
                         m('td', m('a.btn.btn-xs.btn-default', {href: item.session.baseURL.replace('://', '://workbench.')+'/collections/'+item.uuid}, 'Show')),
-                        m('td', item.uuid),
+                        m('td.arvados-uuid', item.uuid),
                         m('td', item.name || '(unnamed)'),
                         m('td', m(window.components.datetime, {parse: item.modified_at})),
                     ])

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list