[hg] galaxy 3527: UI Improvements:
details: http://www.bx.psu.edu/hg/galaxy/rev/e39c9a2a0b4c changeset: 3527:e39c9a2a0b4c user: jeremy goecks <jeremy.goecks@emory.edu> date: Fri Mar 12 14:27:04 2010 -0500 description: UI Improvements: -Make it possible to show messages in frames. -Improve import interactions by showing messages in frames and providing useful links. -Add action icons to display framework. diffstat: lib/galaxy/web/controllers/dataset.py | 16 +++++++++--- lib/galaxy/web/controllers/history.py | 35 ++++++++++++++++++--------- lib/galaxy/web/controllers/workflow.py | 22 +++++++++++++---- lib/galaxy/web/framework/__init__.py | 16 ++++++------ templates/dataset/display.mako | 10 ++++--- templates/display_base.mako | 7 +++-- templates/display_common.mako | 10 ++++++++ templates/grid_base.mako | 13 +-------- templates/grid_base_async.mako | 3 +- templates/history/display.mako | 11 +-------- templates/message.mako | 36 +++++++++++++++++++++++++++- templates/page/select_items_grid_async.mako | 3 +- templates/workflow/display.mako | 6 +---- 13 files changed, 122 insertions(+), 66 deletions(-) diffs (411 lines): diff -r f8c305ba23cb -r e39c9a2a0b4c lib/galaxy/web/controllers/dataset.py --- a/lib/galaxy/web/controllers/dataset.py Fri Mar 12 12:43:31 2010 -0500 +++ b/lib/galaxy/web/controllers/dataset.py Fri Mar 12 14:27:04 2010 -0500 @@ -418,17 +418,25 @@ return self.stored_list_grid( trans, status=status, message=message, **kwargs ) @web.expose - def imp( self, trans, id=None, **kwd ): + def imp( self, trans, dataset_id=None, **kwd ): """ Import another user's dataset via a shared URL; dataset is added to user's current history. """ msg = "" + # Set referer message. + referer = trans.request.referer + if referer is not "": + referer_message = "<a href='%s'>return to the previous page</a>" % referer + else: + referer_message = "<a href='%s'>go to Galaxy's start page</a>" % url_for( '/' ) + # Error checking. - if not id: - return trans.show_error_message( "You must specify an ID for a dataset to import." ) + if not dataset_id: + return trans.show_error_message( "You must specify a dataset to import. You can %s." % referer_message, use_panels=True ) # Do import. cur_history = trans.get_history( create=True ) - status, message = self._copy_datasets( trans, [ id ], [ cur_history ] ) + status, message = self._copy_datasets( trans, [ dataset_id ], [ cur_history ] ) + message = message + "<br>You can <a href='%s'>start using the dataset</a> or %s." % ( url_for('/'), referer_message ) return trans.show_message( message, type=status ) @web.expose diff -r f8c305ba23cb -r e39c9a2a0b4c lib/galaxy/web/controllers/history.py --- a/lib/galaxy/web/controllers/history.py Fri Mar 12 12:43:31 2010 -0500 +++ b/lib/galaxy/web/controllers/history.py Fri Mar 12 14:27:04 2010 -0500 @@ -505,16 +505,27 @@ msg = "" user = trans.get_user() user_history = trans.get_history() + # Set referer message + if 'referer' in kwd: + referer = kwd['referer'] + else: + referer = trans.request.referer + if referer is not "": + referer_message = "<a href='%s'>return to the previous page</a>" % referer + else: + referer_message = "<a href='%s'>go to Galaxy's start page</a>" % url_for( '/' ) + + # Do import. if not id: - return trans.show_error_message( "You must specify a history you want to import." ) + return trans.show_error_message( "You must specify a history you want to import.<br>You can %s." % referer_message, use_panels=True ) import_history = self.get_history( trans, id, check_ownership=False ) if not import_history: - return trans.show_error_message( "The specified history does not exist.") + return trans.show_error_message( "The specified history does not exist.<br>You can %s." % referer_message, use_panels=True ) if not import_history.importable: - error( "The owner of this history has disabled imports via this link." ) + return trans.show_error_message( "The owner of this history has disabled imports via this link.<br>You can %s." % referer_message, use_panels=True ) if user: if import_history.user_id == user.id: - return trans.show_error_message( "You cannot import your own history." ) + return trans.show_error_message( "You cannot import your own history.<br>You can %s." % referer_message, use_panels=True ) new_history = import_history.copy( target_user=user ) new_history.name = "imported: " + new_history.name new_history.user_id = user.id @@ -530,9 +541,9 @@ trans.sa_session.flush() if not user_history.datasets: trans.set_history( new_history ) - return trans.show_ok_message( """ - History "%s" has been imported. Click <a href="%s">here</a> - to begin.""" % ( new_history.name, web.url_for( '/' ) ) ) + return trans.show_ok_message( + message="""History "%s" has been imported. <br>You can <a href="%s">start using this history</a> or %s.""" + % ( new_history.name, web.url_for( '/' ), referer_message ), use_panels=True ) elif not user_history or not user_history.datasets or confirm: new_history = import_history.copy() new_history.name = "imported: " + new_history.name @@ -548,13 +559,13 @@ trans.sa_session.add( new_history ) trans.sa_session.flush() trans.set_history( new_history ) - return trans.show_ok_message( """ - History "%s" has been imported. Click <a href="%s">here</a> - to begin.""" % ( new_history.name, web.url_for( '/' ) ) ) + return trans.show_ok_message( + message="""History "%s" has been imported. <br>You can <a href="%s">start using this history</a> or %s.""" + % ( new_history.name, web.url_for( '/' ), referer_message ), use_panels=True ) return trans.show_warn_message( """ Warning! If you import this history, you will lose your current - history. Click <a href="%s">here</a> to confirm. - """ % web.url_for( id=id, confirm=True ) ) + history. <br>You can <a href="%s">continue and import this history</a> or %s. + """ % ( web.url_for( id=id, confirm=True, referer=trans.request.referer ), referer_message ), use_panels=True ) @web.expose def view( self, trans, id=None ): diff -r f8c305ba23cb -r e39c9a2a0b4c lib/galaxy/web/controllers/workflow.py --- a/lib/galaxy/web/controllers/workflow.py Fri Mar 12 12:43:31 2010 -0500 +++ b/lib/galaxy/web/controllers/workflow.py Fri Mar 12 14:27:04 2010 -0500 @@ -278,18 +278,28 @@ @web.expose @web.require_login( "use Galaxy workflows" ) def imp( self, trans, id, **kwargs ): + # Set referer message. + referer = trans.request.referer + if referer is not "": + referer_message = "<a href='%s'>return to the previous page</a>" % referer + else: + referer_message = "<a href='%s'>go to Galaxy's start page</a>" % url_for( '/' ) + + # Do import. session = trans.sa_session stored = self.get_stored_workflow( trans, id, check_ownership=False ) if stored.importable == False: - error( "The owner of this workflow has disabled imports via this link" ) + return trans.show_error_message( "The owner of this workflow has disabled imports via this link.<br>You can %s" % referer_message, use_panels=True ) elif stored.user == trans.user: - error( "You are already the owner of this workflow, can't import" ) + return trans.show_error_message( "You can't import this workflow because you own it.<br>You can %s" % referer_message, use_panels=True ) elif stored.deleted: - error( "This workflow has been deleted, can't import" ) + return trans.show_error_message( "You can't import this workflow because it has been deleted.<br>You can %s" % referer_message, use_panels=True ) elif session.query( model.StoredWorkflowUserShareAssociation ) \ .filter_by( user=trans.user, stored_workflow=stored ).count() > 0: - error( "This workflow is already shared with you" ) + # TODO: this is only reasonable as long as import creates a sharing relation. + return trans.show_error_message( "You can't import this workflow because it is already shared with you.<br>You can %s" % referer_message, use_panels=True ) else: + # TODO: Shouldn't an import provide a copy of a workflow? share = model.StoredWorkflowUserShareAssociation() share.stored_workflow = stored share.user = trans.user @@ -297,7 +307,9 @@ session.add( share ) session.flush() # Redirect to load galaxy frames. - return trans.response.send_redirect( url_for( controller='workflow' ) ) + return trans.show_ok_message( + message="""Workflow "%s" has been imported. <br>You can <a href="%s">start using this workflow</a> or %s.""" + % ( stored.name, web.url_for( controller='workflow' ), referer_message ), use_panels=True ) @web.expose @web.require_login( "use Galaxy workflows" ) diff -r f8c305ba23cb -r e39c9a2a0b4c lib/galaxy/web/framework/__init__.py --- a/lib/galaxy/web/framework/__init__.py Fri Mar 12 12:43:31 2010 -0500 +++ b/lib/galaxy/web/framework/__init__.py Fri Mar 12 14:27:04 2010 -0500 @@ -561,7 +561,7 @@ context. """ return self.template_context['message'] - def show_message( self, message, type='info', refresh_frames=[], cont=None ): + def show_message( self, message, type='info', refresh_frames=[], cont=None, use_panels=False ): """ Convenience method for displaying a simple page with a single message. @@ -571,22 +571,22 @@ `refresh_frames`: names of frames in the interface that should be refreshed when the message is displayed """ - return self.fill_template( "message.mako", message_type=type, message=message, refresh_frames=refresh_frames, cont=cont ) - def show_error_message( self, message, refresh_frames=[] ): + return self.fill_template( "message.mako", message_type=type, message=message, refresh_frames=refresh_frames, cont=cont, use_panels=use_panels ) + def show_error_message( self, message, refresh_frames=[], use_panels=False ): """ Convenience method for displaying an error message. See `show_message`. """ - return self.show_message( message, 'error', refresh_frames ) - def show_ok_message( self, message, refresh_frames=[] ): + return self.show_message( message, 'error', refresh_frames, use_panels=use_panels ) + def show_ok_message( self, message, refresh_frames=[], use_panels=False ): """ Convenience method for displaying an ok message. See `show_message`. """ - return self.show_message( message, 'done', refresh_frames ) - def show_warn_message( self, message, refresh_frames=[] ): + return self.show_message( message, 'done', refresh_frames, use_panels=use_panels ) + def show_warn_message( self, message, refresh_frames=[], use_panels=False ): """ Convenience method for displaying an warn message. See `show_message`. """ - return self.show_message( message, 'warning', refresh_frames ) + return self.show_message( message, 'warning', refresh_frames, use_panels=use_panels ) def show_form( self, form, header=None, template="form.mako" ): """ Convenience method for displaying a simple page with a single HTML diff -r f8c305ba23cb -r e39c9a2a0b4c templates/dataset/display.mako --- a/templates/dataset/display.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/dataset/display.mako Fri Mar 12 14:27:04 2010 -0500 @@ -23,7 +23,8 @@ <%def name="render_item_links( data )"> ## Provide links to save data and TODO: import dataset. - <a href="${h.url_for( controller='dataset', action='display', dataset_id=trans.security.encode_id( data.id ), to_ext=data.ext )}">save</a> + <a href="${h.url_for( controller='/dataset', action='display', dataset_id=trans.security.encode_id( data.id ), to_ext=data.ext )}" class="icon-button disk tooltip" title="Save dataset"></a> + <a href="${h.url_for( controller='/dataset', action='imp', dataset_id=trans.security.encode_id( data.id ) )}" class="icon-button import tooltip" title="Import dataset"></a> </%def> <%def name="render_item( data, data_to_render )"> @@ -49,11 +50,12 @@ <div class="unified-panel-body"> <div style="overflow: auto; height: 100%;"> <div class="page-body"> - <div style="padding: 0px 0px 5px 0px"> + <div style="float: right"> ${self.render_item_links( item )} </div> - - ${self.render_item_header( item )} + <div> + ${self.render_item_header( item )} + </div> ${self.render_item( item, item_data )} </div> diff -r f8c305ba23cb -r e39c9a2a0b4c templates/display_base.mako --- a/templates/display_base.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/display_base.mako Fri Mar 12 14:27:04 2010 -0500 @@ -156,11 +156,12 @@ <div class="unified-panel-body"> <div style="overflow: auto; height: 100%;"> <div class="page-body"> - <div style="padding: 0px 0px 5px 0px"> + <div style="float: right"> ${self.render_item_links( item )} </div> - - ${self.render_item_header( item )} + <div> + ${self.render_item_header( item )} + </div> ${self.render_item( item, item_data )} </div> diff -r f8c305ba23cb -r e39c9a2a0b4c templates/display_common.mako --- a/templates/display_common.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/display_common.mako Fri Mar 12 14:27:04 2010 -0500 @@ -128,3 +128,13 @@ %endif </%def> +## Render message. +<%def name="render_message( message, message_type )"> + %if message: + <p> + <div class="${message_type}message transient-message">${util.restore_text( message )}</div> + <div style="clear: both"></div> + </p> + %endif +</%def> + diff -r f8c305ba23cb -r e39c9a2a0b4c templates/grid_base.mako --- a/templates/grid_base.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/grid_base.mako Fri Mar 12 14:27:04 2010 -0500 @@ -9,6 +9,7 @@ return '/base.mako' %> <%inherit file="${inherit(context)}"/> +<%namespace file="/display_common.mako" import="render_message" /> <%def name="init()"> <% @@ -663,23 +664,13 @@ <tr> <td width="75%">${self.render_grid_header( grid )}</td> <td></td> - <td width="25%" id="grid-message" valign="top">${self.render_grid_message( grid )}</td> + <td width="25%" id="grid-message" valign="top">${render_message( message, message_type )}</td> </tr> </table> ${self.render_grid_table( grid )} </%def> -## Render grid message. -<%def name="render_grid_message( grid )"> - %if message: - <p> - <div class="${message_type}message transient-message">${util.restore_text( message )}</div> - <div style="clear: both"></div> - </p> - %endif -</%def> - ## Render grid header. <%def name="render_grid_header( grid, render_title=True)"> <div class="grid-header"> diff -r f8c305ba23cb -r e39c9a2a0b4c templates/grid_base_async.mako --- a/templates/grid_base_async.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/grid_base_async.mako Fri Mar 12 14:27:04 2010 -0500 @@ -1,4 +1,5 @@ <%namespace file="./grid_base.mako" import="*" /> +<%namespace file="/display_common.mako" import="render_message" /> <% # Set flag to indicate whether grid has operations that operate on multiple items. @@ -12,4 +13,4 @@ ***** ${num_pages} ***** -${render_grid_message( grid )} \ No newline at end of file +${render_message( grid )} \ No newline at end of file diff -r f8c305ba23cb -r e39c9a2a0b4c templates/history/display.mako --- a/templates/history/display.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/history/display.mako Fri Mar 12 14:27:04 2010 -0500 @@ -236,16 +236,7 @@ </%def> <%def name="render_item_links( history )"> - %if history.user != trans.get_user(): - <a href="${h.url_for( controller='/history', action='imp', id=trans.security.encode_id(history.id) )}">import and start using history</a> - %else: - ## TODO: add tooltip to indicate why this link is disabled. - import and start using history - %endif - ##<a href="${self.get_history_link( history )}">${_('refresh')}</a> - %if show_deleted: - | <a href="${h.url_for('history', show_deleted=False)}">${_('hide deleted')}</a> - %endif + <a href="${h.url_for( controller='/history', action='imp', id=trans.security.encode_id(history.id) )}" class="icon-button import tooltip" title="Import history"></a> </%def> <%def name="render_item( history, datasets )"> diff -r f8c305ba23cb -r e39c9a2a0b4c templates/message.mako --- a/templates/message.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/message.mako Fri Mar 12 14:27:04 2010 -0500 @@ -1,5 +1,21 @@ +<%! + def inherit(context): + if context.get('use_panels'): + return '/base_panels.mako' + else: + return '/base.mako' +%> +<%inherit file="${inherit(context)}"/> <% _=n_ %> -<%inherit file="/base.mako"/> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.active_view=active_view + self.message_box_visible=False +%> +</%def> <%def name="javascripts()"> ${parent.javascripts()} @@ -45,7 +61,23 @@ </script> </%def> -<div class="${message_type}messagelarge">${_(message)}</div> +## +## Override methods from base.mako and base_panels.mako +## + +<%def name="center_panel()"> + ${render_large_message( message, message_type )} +</%def> + +## Render the grid's basic elements. Each of these elements can be subclassed. +<%def name="body()"> + ${render_large_message( message, message_type )} +</%def> + +## Render large message. +<%def name="render_large_message( message, message_type )"> + <div class="${message_type}messagelarge" style="margin: 1em">${_(message)}</div> +</%def> ## Render a message <%def name="render_msg( msg, messagetype='done' )"> diff -r f8c305ba23cb -r e39c9a2a0b4c templates/page/select_items_grid_async.mako --- a/templates/page/select_items_grid_async.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/page/select_items_grid_async.mako Fri Mar 12 14:27:04 2010 -0500 @@ -1,8 +1,9 @@ <%namespace file="../grid_base.mako" import="*" /> +<%namespace file="/display_common.mako" import="render_message" /> ## Always show item checkboxes so that users can select histories. ${render_grid_table_body_contents( grid, show_item_checkboxes=True )} ***** ${num_pages} ***** -${render_grid_message( grid )} \ No newline at end of file +${render_message( message, message_type )} \ No newline at end of file diff -r f8c305ba23cb -r e39c9a2a0b4c templates/workflow/display.mako --- a/templates/workflow/display.mako Fri Mar 12 12:43:31 2010 -0500 +++ b/templates/workflow/display.mako Fri Mar 12 14:27:04 2010 -0500 @@ -77,11 +77,7 @@ <%def name="render_item_links( workflow )"> - %if workflow.user != trans.get_user(): - <a href="${h.url_for( controller='/workflow', action='imp', id=trans.security.encode_id(workflow.id) )}">import and start using workflow</a> - %else: - import and start using workflow - %endif + <a href="${h.url_for( controller='/workflow', action='imp', id=trans.security.encode_id(workflow.id) )}" class="icon-button import tooltip" title="Import workflow"></a> </%def> <%def name="render_item( workflow, steps )">
participants (1)
-
Greg Von Kuster