loader.items().map(function(item) {
return m('tr', [
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 :
+ item.workbenchBaseURL() &&
m('a.btn.btn-xs.btn-default', {
- href: item.session.baseURL.replace('://', '://workbench.')+'collections/'+item.uuid,
- }, 'Show'),
+ title: 'Show '+item.objectType.description,
+ href: item.workbenchBaseURL()+'/'+item.objectType.wb_path+'/'+item.uuid,
+ }, item.objectType.label),
]),
m('td.arvados-uuid', item.uuid),
m('td', item.name || '(unnamed)'),
vnode.state.loader = new MergingLoader({
children: Object.keys(sessions).map(function(key) {
var session = sessions[key]
- return new MultipageLoader({
+ var workbenchBaseURL = function() {
+ return vnode.state.sessionDB.workbenchBaseURL(session)
+ }
+ var searchable_objects = [
+ {
+ wb_path: 'groups',
+ api_path: 'arvados/v1/groups',
+ filters: [['group_class', '=', 'project']],
+ label: 'P',
+ description: 'Project',
+ },
+ {
+ wb_path: 'collections',
+ api_path: 'arvados/v1/collections',
+ filters: [],
+ label: 'C',
+ description: 'Collection',
+ },
+ ]
+ return new MergingLoader({
sessionKey: key,
- loadFunc: function(filters) {
- if (q)
- filters.push(['any', '@@', q+':*'])
- return vnode.state.sessionDB.request(session, 'arvados/v1/collections', {
- data: {
- filters: JSON.stringify(filters),
- count: 'none',
+ // 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
+ })
},
- }).then(function(resp) {
- resp.items.map(function(item) {
- item.session = session
- })
- return resp
})
- },
+ })
})
})
})
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('.row', [
m('.col-md-6', [
m('.input-group', [
- m('input#search.form-control[placeholder=Search]', {
+ m('input#search.form-control[placeholder=Search collections and projects]', {
oninput: m.withAttr('value', vnode.state.searchEntered),
value: vnode.state.searchEntered(),
}),