# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1283367408 14400 # Node ID 4ee5fca864a44b2bf7e7efac7a97f564961df3f2 # Parent f41f4ace420a58e7316fbeddacd301ff6d5dfaf1 lims: find samples - the search settings are saved after the search - search now case insensitive and wildcard support added - masthead problem fixed when showing find samples page in user mode --- a/templates/requests/common/find.mako +++ b/templates/requests/common/find.mako @@ -54,47 +54,60 @@ <div class="toolFormBody"><form name="find_request" id="find_request" action="${h.url_for( controller='requests_common', action='find', cntrller=cntrller)}" method="post" ><div class="form-row"> - <label>Find in sequencing requests in state:</label> - <select name="request_state"> - <option value="In Progress" selected>In-Progress</option> - <option value="Complete">Complete</option> - <option value="Both">Both</option> - </select> + <label>Find sample(s) using:</label> + ${search_type.get_html()} + <div class="toolParamHelp" style="clear: both;"> + Select a sample attribute to search through all the samples.<br/> + To search for a sample with a dataset name, select the dataset + option above. This will return all the sample(s) which has a + dataset with the given name associated with it. To search for + all samples created on a certain date select the 'date created' + option above. Enter date in 'YYYY-MM-DD' format. + </div></div><div class="form-row"> - <label>Find by sample:</label> - <select name="search_type"> - <option value="name" selected>name</option> - <option value="bar_code">barcode</option> - </select> + <label>Filter sequencing requests in state:</label> + ${request_states.get_html()} + <div class="toolParamHelp" style="clear: both;"> + This will filter the search results to show only those sample(s) <br/> + whose parent sequencing request is in the selected state. + </div></div><div class="form-row"> - <input type="text" name="search_string" size="40" value=""> - <input type="submit" name="go_button" value="Go"/> + ${search_box.get_html()} + <input type="submit" name="go_button" value="Find"/> + <div class="toolParamHelp" style="clear: both;"> + Wildcard search (%) can be used as placeholder for any sequence of characters or words.<br/> + For example, to search for samples starting with 'mysample' use 'mysample%' as the search string. + </div></div> %if results: <div class="form-row"><label><i>${results}</i></label> + <div class="toolParamHelp" style="clear: both;"> + The search results are sorted by the date the samples where created. + </div></div> %endif <div class="form-row"> %if samples: %for s in samples: <div class="form-row"> - <a href="${h.url_for( controller=cntrller, action='list', operation='show', id=trans.security.encode_id(s.request.id))}"><label>Sequencing request: ${s.request.name} | Type: ${s.request.type.name} | State: ${s.request.state()}</label></a> + + Sample: ${s.name} | Barcode: ${s.bar_code}<br/> + State: ${s.current_state().name}<br/> + Datasets: <a href="${h.url_for(controller='requests_common', cntrller=cntrller, action='show_datatx_page', sample_id=trans.security.encode_id(s.id))}">${s.transferred_dataset_files()}/${len(s.datasets)}</a><br/> %if cntrller == 'requests_admin': <i>User: ${s.request.user.email}</i> %endif - <div class="toolParamHelp" style="clear: both;"> - Sample: ${s.name}<br/> - Barcode: ${s.bar_code}<br/> - State: ${s.current_state().name} - </div> + <div class="toolParamHelp" style="clear: both;"> + <a href="${h.url_for( controller=cntrller, action='list', operation='show', id=trans.security.encode_id(s.request.id))}">Sequencing request: ${s.request.name} | Type: ${s.request.type.name} | State: ${s.request.state()}</a> + </div> + </div><br/> %endfor %endif - </div></form></div> --- /dev/null +++ b/templates/requests/find_index.mako @@ -0,0 +1,16 @@ +<%inherit file="/webapps/galaxy/base_panels.mako"/> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.active_view="requests" + self.message_box_visible=False +%> +</%def> + +<%def name="center_panel()"> + + <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="${h.url_for( controller="requests_common", action="find" )}"></iframe> + +</%def> --- a/lib/galaxy/web/controllers/requests.py +++ b/lib/galaxy/web/controllers/requests.py @@ -135,6 +135,11 @@ class Requests( BaseController ): @web.require_login( "create/submit sequencing requests" ) def index( self, trans ): return trans.fill_template( "requests/index.mako" ) + + @web.expose + @web.require_login( "create/submit sequencing requests" ) + def find_index( self, trans ): + return trans.fill_template( "requests/find_index.mako" ) @web.expose @web.require_login( "create/submit sequencing requests" ) --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -1256,6 +1256,25 @@ class RequestsCommon( BaseController, Us # # Find sequencing requests & samples # + def __find_widgets(self, trans, **kwd): + params = util.Params( kwd ) + request_states = SelectField('request_states', multiple=True, display="checkboxes") + sel_op = kwd.get('request_states', trans.app.model.Request.states.SUBMITTED) + for i, s in trans.app.model.Request.states.items(): + if s in sel_op: + request_states.add_option(s, s, True) + else: + request_states.add_option(s, s) + search_type = SelectField('search_type') + sel_op = kwd.get('search_type', 'sample name') + for s in ['sample name', 'barcode', 'dataset']: + if s in sel_op: + search_type.add_option(s, s, True) + else: + search_type.add_option(s, s) + search_box = TextField('search_box', 50, kwd.get('search_box', '')) + return request_states, search_type, search_box + @web.expose @web.require_admin def find( self, trans, **kwd ): @@ -1263,26 +1282,31 @@ class RequestsCommon( BaseController, Us cntrller = params.get( 'cntrller', 'requests' ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - search_string = kwd.get( 'search_string', '' ) - search_type = params.get( 'search_type', '' ) - if params.get( 'request_state', 'In Progress' ) == 'Both': - request_states = ['In Progress', 'Complete'] - else: - request_states = [params.get( 'request_state', 'In Progress' )] - - samples_list = [] results = '' - if params.get('go_button', '') == 'Go': - if search_type == 'bar_code': + if params.get('go_button', '') == 'Find': + search_string = kwd.get( 'search_box', '' ) + search_type = params.get( 'search_type', '' ) + request_states = params.get( 'request_states', '' ) + samples = [] + if search_type == 'barcode': samples = trans.sa_session.query( trans.app.model.Sample ) \ .filter( and_( trans.app.model.Sample.table.c.deleted==False, trans.app.model.Sample.table.c.bar_code.like(search_string) ) )\ + .order_by( trans.app.model.Sample.table.c.create_time.desc())\ .all() - elif search_type == 'name': + elif search_type == 'sample name': samples = trans.sa_session.query( trans.app.model.Sample ) \ .filter( and_( trans.app.model.Sample.table.c.deleted==False, - trans.app.model.Sample.table.c.name.like(search_string) ) )\ + trans.app.model.Sample.table.c.name.ilike(search_string) ) )\ + .order_by( trans.app.model.Sample.table.c.create_time.desc())\ + .all() + elif search_type == 'dataset': + samples = trans.sa_session.query( trans.app.model.Sample ) \ + .filter( and_( trans.app.model.Sample.table.c.deleted==False, + trans.app.model.SampleDataset.table.c.sample_id==trans.app.model.Sample.table.c.id, + trans.app.model.SampleDataset.table.c.name.ilike(search_string) ) )\ + .order_by( trans.app.model.Sample.table.c.create_time.desc())\ .all() if cntrller == 'requests': for s in samples: @@ -1295,11 +1319,12 @@ class RequestsCommon( BaseController, Us if not s.request.deleted \ and s.request.state() in request_states: samples_list.append(s) - results = 'There are %i sequencing requests matching the search parameters.' % len(samples_list) + results = 'There are %i sample(s) matching the search parameters.' % len(samples_list) + request_states, search_type, search_box = self.__find_widgets(trans, **kwd) return trans.fill_template( '/requests/common/find.mako', - cntrller=cntrller, - samples=samples_list, - results=results ) + cntrller=cntrller, request_states=request_states, + samples=samples_list, search_type=search_type, + results=results, search_box=search_box ) --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -82,7 +82,7 @@ <% menu_options = [ [ 'Sequencing Requests', h.url_for( controller='/requests', action='index' ) ], - [ 'Find Samples', h.url_for( controller='/requests_common', action='find' ) ], + [ 'Find Samples', h.url_for( controller='/requests', action='find_index' ) ], [ 'Help', app.config.get( "lims_doc_url", "http://main.g2.bx.psu.edu/u/rkchak/p/sts" ), "galaxy_main" ] ] tab( "lab", "Lab", None, menu_options=menu_options )