Skip to content

Commit

Permalink
Add simple search functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
davebx committed Feb 23, 2016
1 parent 9f239a0 commit 5d1e86c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 31 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def index( self, trans, **kwd ):
return tool_shed_repository_dicts

@expose_api
@web.require_admin
def install( self, trans, **kwd ):
"""
POST /api/tool_shed_repositories/install
Expand Down
12 changes: 9 additions & 3 deletions lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,15 @@ def browse_toolshed( self, trans, **kwd ):
tool_shed_url = kwd.get( 'tool_shed_url', '' )
tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( trans.app, tool_shed_url )
url = common_util.url_join( tool_shed_url, pathspec=[ 'api', 'categories' ] )
json_data = json.loads( common_util.tool_shed_get( trans.app, url ) )
return trans.fill_template( '/admin/tool_shed_repository/browse_categories.mako', tool_shed_url=tool_shed_url, categories=json_data )
categories = json.loads( common_util.tool_shed_get( trans.app, url ) )
repositories = []
url = common_util.url_join( tool_shed_url, pathspec=[ 'api', 'repositories' ] )
for repo in json.loads( common_util.tool_shed_get( trans.app, url ) ):
repositories.append( dict( value=repo[ 'id' ], label='%s/%s' % ( repo[ 'owner' ], repo[ 'name' ] ) ) )
return trans.fill_template( '/admin/tool_shed_repository/browse_categories.mako',
tool_shed_url=tool_shed_url,
categories=categories,
repositories=json.dumps( repositories ) )

@web.expose
@web.require_admin
Expand All @@ -224,7 +231,6 @@ def browse_tool_shed_category( self, trans, **kwd ):
json_data[ 'repositories' ][ idx ][ 'metadata' ] = metadata
except:
json_data[ 'repositories' ][ idx ][ 'metadata' ] = { 'tools_functionally_correct': True }
log.debug(json_data[ 'repositories' ][ idx ])
return trans.fill_template( '/admin/tool_shed_repository/browse_category.mako', tool_shed_url=tool_shed_url, category=json_data )

@web.expose
Expand Down
60 changes: 32 additions & 28 deletions templates/admin/tool_shed_repository/browse_categories.mako
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,41 @@
%if message:
${render_msg( message, status )}
%endif
<script type="text/javascript">
var repositories = ${repositories};
var preview_repo_url = '${h.url_for(controller='admin_toolshed', action='preview_repository', tool_shed_url=tool_shed_url)}';
var repository_listing = {};
$(function() {
console.log(repositories);
require(["libs/jquery/jquery-ui"], function() {
$( "#repository_search" ).autocomplete({
source: repositories,
select: function(event, ui) {
window.location.href = preview_repo_url + '&tsr_id=' + ui.item.value;
}
});
});
});
</script>
<style type="text/css">
.ui-autocomplete {
width: 30%;
border: 1px solid #000;
background: #fff;
}
.ui-state-focus {
background: #bbf;
}
</style>
<div class="grid-header"><h2>Repositories by Category</h2><ul class="manage-table-actions"></ul>
<div id="standard-search" style="display: block;">
<table>
<tbody><tr><td style="padding: 0;">
<table>
<tbody>
<tr>
<td style="padding: 0;">
<form class="text-filter-form" column_key="free-text-search" action="/repository/browse_categories?sort=name" method="get">
<span id="free-text-search-filtering-criteria"></span>
<span class="search-box">
<input class="search-box-input" id="input-free-text-search-filter" name="f-free-text-search" value="non-functional search box for cosmetic purposes" size="39" type="text">
<button class="submit-image" type="submit" title="Search" />
</span>
</form>
</td>
</tr>
</tbody>
</table>
</td></tr>
</tbody></table>
<span class="ui-widget">
<input class="search-box-input" id="repository_search" name="search" value="Search" size="39" type="text">
<input class="search-box-input" id="repo_id" name="search" value="Search" size="39" type="hidden">
<button class="submit-image" type="submit" title="Search" />
</span>
</div>

<div id="advanced-search" style="display: none; margin-top: 5px; border: 1px solid #ccc;">
<table>
<tbody><tr><td style="text-align: left" colspan="100">
<a href="/repository/browse_categories?sort=name&amp;advanced-search=False" class="advanced-search-toggle">Close Advanced Search</a>
</td></tr>
</tbody></table>
</div>
<div id="standard-search" style="display: block;"><table><tbody><tr><td style="padding: 0;"><table></table></td></tr><tr><td></td></tr></tbody></table></div><div id="advanced-search" style="display: none; margin-top: 5px; border: 1px solid #ccc;"><table><tbody><tr><td style="text-align: left" colspan="100"><a href="" class="advanced-search-toggle">Close Advanced Search</a></td></tr></tbody></table></div></div>
</div>
<table class="grid">
<thead id="grid-table-header">
<tr>
Expand Down

0 comments on commit 5d1e86c

Please sign in to comment.