[ARVADOS] updated: 1.1.0-140-g6247858
Git user
git at public.curoverse.com
Fri Nov 17 15:54:23 EST 2017
Summary of changes:
.../assets/javascripts/components/collections.js | 85 +++++++++-------------
1 file changed, 36 insertions(+), 49 deletions(-)
via 6247858b8041caf4899da501456661d25dd5491b (commit)
from 336973bf211f462aa826a1702991e056a30fd6ae (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 6247858b8041caf4899da501456661d25dd5491b
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Fri Nov 17 17:53:38 2017 -0300
12519: Simplified code by nesting an additional MergingLoader
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/apps/workbench/app/assets/javascripts/components/collections.js b/apps/workbench/app/assets/javascripts/components/collections.js
index c514de8..3d42491 100644
--- a/apps/workbench/app/assets/javascripts/components/collections.js
+++ b/apps/workbench/app/assets/javascripts/components/collections.js
@@ -93,9 +93,7 @@ window.CollectionsSearch = {
vnode.state.searchActive.map(function(q) {
var sessions = vnode.state.sessionDB.loadActive()
vnode.state.loader = new MergingLoader({
- // For every session, search for every object type, and finally
- // flatten the list of lists of MultipageLoaders
- children: [].concat.apply([], Object.keys(sessions).map(function(key) {
+ children: Object.keys(sessions).map(function(key) {
var session = sessions[key]
var workbenchBaseURL = function() {
return vnode.state.sessionDB.workbenchBaseURL(session)
@@ -116,49 +114,45 @@ window.CollectionsSearch = {
description: 'Collection',
},
]
- return searchable_objects.map(function(obj_type){
- return new MultipageLoader({
- sessionKey: key,
- objectKind: obj_type.label,
- loadFunc: function(filters) {
- var tsquery = to_tsquery(q)
- if (tsquery) {
- filters = filters.slice(0)
- filters.push(['any', '@@', tsquery])
- }
- // Apply additional type dependant filters, if any.
- for (var f of obj_type.filters) {
- filters.push(f)
- }
- return vnode.state.sessionDB.request(session, obj_type.api_path, {
- data: {
- filters: JSON.stringify(filters),
- count: 'none',
- },
- }).then(function(resp) {
- resp.items.map(function(item) {
- item.workbenchBaseURL = workbenchBaseURL
- item.objectType = obj_type
+ return new MergingLoader({
+ sessionKey: key,
+ // For every session, search for every object type
+ children: searchable_objects.map(function(obj_type){
+ return new MultipageLoader({
+ sessionKey: key,
+ objectKind: obj_type.label,
+ loadFunc: function(filters) {
+ var tsquery = to_tsquery(q)
+ if (tsquery) {
+ filters = filters.slice(0)
+ filters.push(['any', '@@', tsquery])
+ }
+ // Apply additional type dependant filters, if any.
+ for (var f of obj_type.filters) {
+ filters.push(f)
+ }
+ return vnode.state.sessionDB.request(session, obj_type.api_path, {
+ data: {
+ filters: JSON.stringify(filters),
+ count: 'none',
+ },
+ }).then(function(resp) {
+ resp.items.map(function(item) {
+ item.workbenchBaseURL = workbenchBaseURL
+ item.objectType = obj_type
+ })
+ return resp
})
- return resp
- })
- },
+ },
+ })
})
})
- }))
+ })
})
})
},
view: function(vnode) {
var sessions = vnode.state.sessionDB.loadAll()
- var group_sessions = function(sessionList) {
- var grouped = {}
- for (session of sessionList) {
- grouped[session.sessionKey] = grouped[session.sessionKey] || []
- grouped[session.sessionKey].push(session)
- }
- return grouped
- }
return m('form', {
onsubmit: function() {
vnode.state.searchActive(vnode.state.searchEntered())
@@ -189,17 +183,10 @@ window.CollectionsSearch = {
'Searching sites: ',
vnode.state.loader.children.length == 0
? m('span.label.label-xs.label-danger', 'none')
- : Object.entries(group_sessions(vnode.state.loader.children)).map(function(e) {
- var key = e[0] // sessionKey (cluster id)
- var childs = e[1] // Array of loader children
- var labels = childs.map(function(child) {
- return m('span.label.label-xs', {
- className: child.state == child.LOADING ? 'label-warning' : 'label-success',
- }, child.objectKind)
- })
- return [m('span.label.label-xs',
- {className:'label-info'},
- key)].concat(labels).concat(' ')
+ : vnode.state.loader.children.map(function(child) {
+ return [m('span.label.label-xs', {
+ className: child.state == child.LOADING ? 'label-warning' : 'label-success',
+ }, child.sessionKey), ' ']
}),
' ',
m('a[href="/sessions"]', 'Add/remove sites'),
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list