Merge branch 'master' into 11454-wb-federated-search
[arvados.git] / apps / workbench / app / assets / javascripts / components / search.js
index 319622ddbd5eab2e95133b20c56875686be170ee..5cb292bd7ab7709a3004278a7e1a20810e389c0e 100644 (file)
@@ -29,10 +29,6 @@ window.SearchResultsTable = {
     },
     onupdate: function(vnode) {
         vnode.state.loader = vnode.attrs.loader
-        // This activates bootstrap tooltip feature
-        $(function () {
-            $('[data-toggle="tooltip"]').tooltip()
-        })
     },
     onremove: function(vnode) {
         window.clearInterval(vnode.state.timer)
@@ -42,8 +38,8 @@ window.SearchResultsTable = {
     view: function(vnode) {
         var loader = vnode.attrs.loader
         var iconsMap = {
-            C: m('i.fa.fa-fw.fa-archive'),
-            P: m('i.fa.fa-fw.fa-folder'),
+            collections: m('i.fa.fa-fw.fa-archive'),
+            projects: m('i.fa.fa-fw.fa-folder'),
         }
         return m('table.table.table-condensed', [
             m('thead', m('tr', [
@@ -62,7 +58,9 @@ window.SearchResultsTable = {
                                     'data-placement': 'top',
                                     'data-toggle': 'tooltip',
                                     href: item.workbenchBaseURL()+'/'+item.objectType.wb_path+'/'+item.uuid,
-                                }, iconsMap[item.objectType.label]),
+                                    // Bootstrap's tooltip feature
+                                    oncreate: function(vnode) { $(vnode.dom).tooltip() },
+                                }, iconsMap[item.objectType.wb_path]),
                         ]),
                         m('td.arvados-uuid', item.uuid),
                         m('td', item.name || '(unnamed)'),
@@ -92,7 +90,7 @@ window.SearchResultsTable = {
 
 window.Search = {
     oninit: function(vnode) {
-        vnode.state.sessionDB = new SessionDB()
+        vnode.state.sessionDB = new SessionDB(vnode.attrs.remoteHosts)
         vnode.state.searchEntered = m.stream()
         vnode.state.searchActive = m.stream()
         // When searchActive changes (e.g., when restoring state
@@ -110,37 +108,31 @@ window.Search = {
                     }
                     var searchable_objects = [
                         {
-                            wb_path: 'groups',
+                            wb_path: 'projects',
                             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,
                         // For every session, search for every object type
-                        children: searchable_objects.map(function(obj_type){
+                        children: searchable_objects.map(function(obj_type) {
                             return new MultipageLoader({
                                 sessionKey: key,
-                                objectKind: obj_type.label,
                                 loadFunc: function(filters) {
+                                    // Apply additional type dependant filters
+                                    filters = filters.concat(obj_type.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),
@@ -155,14 +147,15 @@ window.Search = {
                                     })
                                 },
                             })
-                        })
+                        }),
                     })
-                })
+                }),
             })
         })
     },
     view: function(vnode) {
-        var sessions = vnode.state.sessionDB.loadAll()
+        // FIXME: The line below seems superfluous
+        // var sessions = vnode.state.sessionDB.loadAll()
         return m('form', {
             onsubmit: function() {
                 vnode.state.searchActive(vnode.state.searchEntered())