window.CollectionsTable = {
maybeLoadMore: function(dom) {
var loader = this.loader
- if (loader.done || loader.loading)
+ if (loader.state != loader.READY)
// Can't start getting more items anyway: no point in
// checking anything else.
return
window.removeEventListener('resize', vnode.state.maybeLoadMore)
},
view: function(vnode) {
+ var loader = vnode.attrs.loader
return m('table.table.table-condensed', [
m('thead', m('tr', [
m('th'),
m('th', 'last modified'),
])),
m('tbody', [
- vnode.attrs.loader.items() && vnode.attrs.loader.items().map(function(item) {
+ loader.items().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', [
+ // Guess workbench.{apihostport} is a
+ // Workbench... unless the host part of
+ // apihostport is an IPv4 or [IPv6]
+ // address.
+ item.session.baseURL.match('://(\\[|\\d+\\.\\d+\\.\\d+\\.\\d+[:/])') ? null :
+ 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(LocalizedDateTime, {parse: item.modified_at})),
])
}),
]),
- m('tfoot', m('tr', [
- vnode.attrs.loader.done ? null : m('th[colspan=4]', m('button.btn.btn-xs', {
- className: vnode.attrs.loader.loading ? 'btn-default' : 'btn-primary',
+ loader.state == loader.DONE ? null : m('tfoot', m('tr', [
+ m('th[colspan=4]', m('button.btn.btn-xs', {
+ className: loader.state == loader.LOADING ? 'btn-default' : 'btn-primary',
style: {
display: 'block',
width: '12em',
marginLeft: 'auto',
marginRight: 'auto',
},
- disabled: vnode.attrs.loader.loading,
+ disabled: loader.state == loader.LOADING,
onclick: function() {
- vnode.attrs.loader.loadMore()
+ loader.loadMore()
return false
},
- }, vnode.attrs.loader.loading ? '(loading)' : 'Load more')),
+ }, loader.state == loader.LOADING ? '(loading)' : 'Load more')),
])),
])
},
children: Object.keys(sessions).map(function(key) {
var session = sessions[key]
return new MultipageLoader({
+ sessionKey: key,
loadFunc: function(filters) {
- if (q)
- filters.push(['any', '@@', q+':*'])
+ var tsquery = to_tsquery(q)
+ if (tsquery) {
+ filters = filters.slice(0)
+ filters.push(['any', '@@', tsquery])
+ }
return vnode.state.sessionDB.request(session, 'arvados/v1/collections', {
data: {
filters: JSON.stringify(filters),
return m('form', {
onsubmit: function() {
vnode.state.searchActive(vnode.state.searchEntered())
- vnode.state.forgetSavedState = true
+ vnode.state.forgetSavedHeight = true
return false
},
}, [
m(SaveUIState, {
defaultState: '',
currentState: vnode.state.searchActive,
- forgetSavedState: vnode.state.forgetSavedState,
+ forgetSavedHeight: vnode.state.forgetSavedHeight,
saveBodyHeight: true,
}),
vnode.state.loader && [
]),
m('.col-md-6', [
'Searching sites: ',
- Object.keys(sessions).length == 0
+ vnode.state.loader.children.length == 0
? m('span.label.label-xs.label-danger', 'none')
- : Object.keys(sessions).sort().map(function(key) {
+ : vnode.state.loader.children.map(function(child) {
return [m('span.label.label-xs', {
- className: !vnode.state.loader.children[key] ? 'label-default' :
- vnode.state.loader.children[key].items() ? 'label-success' :
- 'label-warning',
- }, key), ' ']
+ className: child.state == child.LOADING ? 'label-warning' : 'label-success',
+ }, child.sessionKey), ' ']
}),
' ',
m('a[href="/sessions"]', 'Add/remove sites'),