1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/7658dde1dd33/ changeset: 7658dde1dd33 user: carlfeberhard date: 2012-09-27 22:25:04 summary: history.js: fixed download popupmenu, display apps rendering added; ColumnDataProvider: if a line contains a column value that doesn't match the column type None is returned in it's place (prev. returned string) affected #: 7 files diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f lib/galaxy/visualization/data_providers/basic.py --- a/lib/galaxy/visualization/data_providers/basic.py +++ b/lib/galaxy/visualization/data_providers/basic.py @@ -109,10 +109,10 @@ """ Cast value based on type. """ if type == 'int': try: val = int( val ) - except: pass + except: return None elif type == 'float': try: val = float( val ) - except: pass + except: return None return val f = open( self.original_dataset.file_name ) diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f static/scripts/galaxy.base.js --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -65,6 +65,9 @@ }); }; +/** + * Sets up popupmenu rendering and binds options functions to the appropriate links + */ function make_popupmenu(button_element, initial_options) { /* Use the $.data feature to store options with the link element. This allows options to be changed at a later time @@ -101,10 +104,10 @@ x = Math.min( x, $(document).scrollLeft() + $(window).width() - $(wrapper).width() - 5 ); x = Math.max( x, $(document).scrollLeft() + 5 ); - wrapper.css( { + wrapper.css({ top: e.pageY, left: x - } ); + }); }, 10); setTimeout( function() { @@ -129,27 +132,53 @@ } -function make_popup_menus() { - jQuery( "div[popupmenu]" ).each( function() { +/** + * Convert two seperate (often adjacent) divs into galaxy popupmenu + * - div 1 contains a number of anchors which become the menu options + * - div 1 should have a 'popupmenu' attribute + * - this popupmenu attribute contains the id of div 2 + * - div 2 becomes the 'face' of the popupmenu + * + * NOTE: make_popup_menus finds and operates on all divs with a popupmenu attr (no need to point it at something) + * but (since that selector searches the dom on the page), you can send a parent in + * NOTE: make_popup_menus, and make_popupmenu are horrible names + */ +function make_popup_menus( parent ) { + // find all popupmenu menu divs (divs that contains anchors to be converted to menu options) + // either in the parent or the document if no parent passed + parent = parent || document; + $( parent ).find( "div[popupmenu]" ).each( function() { var options = {}; var menu = $(this); + + // find each anchor in the menu, convert them into an options map: { a.text : click_function } menu.find( "a" ).each( function() { var link = $(this), - link_dom = link.get(0); - var confirmtext = link_dom.getAttribute( "confirm" ), + // why do we need the DOM (mixed with jq)? + link_dom = link.get(0), + confirmtext = link_dom.getAttribute( "confirm" ), href = link_dom.getAttribute( "href" ), target = link_dom.getAttribute( "target" ); + // no href - no function (gen. a label) if (!href) { options[ link.text() ] = null; + } else { options[ link.text() ] = function() { + + // if theres confirm text, send the dialog if ( !confirmtext || confirm( confirmtext ) ) { var f; + // relocate the center panel if ( target == "_parent" ) { window.parent.location = href; + + // relocate the entire window } else if ( target == "_top" ) { window.top.location = href; + + //??...wot? } else if ( target == "demo" ) { // Http request target is a window named // demolocal on the local box @@ -157,6 +186,8 @@ f = window.open( href,target ); f.creator = self; } + + // relocate this panel } else { window.location = href; } diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f static/scripts/mvc/history.js --- a/static/scripts/mvc/history.js +++ b/static/scripts/mvc/history.js @@ -191,7 +191,8 @@ // set up canned behavior on children (bootstrap, popupmenus, editable_text, etc.) itemWrapper.find( '.tooltip' ).tooltip({ placement : 'bottom' }); - make_popup_menus(); + // we can potentially skip this step and call popupmenu directly on the download button + make_popup_menus( itemWrapper ); //TODO: better transition/method than this... this.$el.children().remove(); @@ -336,11 +337,13 @@ _render_downloadButton : function(){ // don't show anything if the data's been purged - //if( this.model.get( 'purged' ) ){ return null; } + if( this.model.get( 'purged' ) ){ return null; } // return either: a single download icon-button (if there are no meta files) // or a popupmenu with links to download assoc. meta files (if there are meta files) var downloadLinkHTML = HistoryItemView.templates.downloadLinks( this.model.toJSON() ); + this.log( '_render_downloadButton, downloadLinkHTML:', downloadLinkHTML ); + return $( downloadLinkHTML ); }, @@ -456,54 +459,23 @@ }, _render_displayApps : function(){ - if( !this.model.get( 'display_apps' ) ){ return null; } - var displayApps = this.model.get( 'displayApps' ), - displayAppsDiv = $( '<div/>' ), - displayAppSpan = $( '<span/>' ); - - this.log( this + 'displayApps:', displayApps ); - ////TODO: grrr...somethings not in the right scope here - //for( app_name in displayApps ){ - // //TODO: to template - // var display_app = displayApps[ app_name ], - // display_app_HTML = app_name + ' '; - // for( location_name in display_app ){ - // display_app_HTML += linkHTMLTemplate({ - // text : location_name, - // href : display_app[ location_name ].url, - // target : display_app[ location_name ].target - // }) + ' '; - // } - // display_app_span.append( display_app_HTML ); - //} - //displayAppsDiv.append( display_app_span ); + // render links to external genome display applications (igb, gbrowse, etc.) + if( !this.model.hasData() ){ return null; } - //displayAppsDiv.append( '<br />' ); - - //var display_appsDiv = $( '<div/>' ); - //if( this.model.get( 'display_apps' ) ){ - // - // var display_apps = this.model.get( 'display_apps' ), - // display_app_span = $( '<span/>' ); - // - // //TODO: grrr...somethings not in the right scope here - // for( app_name in display_apps ){ - // //TODO: to template - // var display_app = display_apps[ app_name ], - // display_app_HTML = app_name + ' '; - // for( location_name in display_app ){ - // display_app_HTML += linkHTMLTemplate({ - // text : location_name, - // href : display_app[ location_name ].url, - // target : display_app[ location_name ].target - // }) + ' '; - // } - // display_app_span.append( display_app_HTML ); - // } - // display_appsDiv.append( display_app_span ); - //} - ////display_appsDiv.append( '<br />' ); - //parent.append( display_appsDiv ); + var displayAppsDiv = $( '<div/>' ).addClass( 'display-apps' ); + if( !_.isEmpty( this.model.get( 'display_types' ) ) ){ + this.log( this + 'display_types:', this.model.get( 'display_types' ) ); + //TODO:?? does this ever get used? + displayAppsDiv.append( + HistoryItemView.templates.displayApps({ displayApps : this.model.toJSON().display_types }) + ); + } + if( !_.isEmpty( this.model.get( 'display_apps' ) ) ){ + this.log( this + 'display_apps:', this.model.get( 'display_apps' ) ); + displayAppsDiv.append( + HistoryItemView.templates.displayApps({ displayApps : this.model.toJSON().display_apps }) + ); + } return displayAppsDiv; }, @@ -770,10 +742,11 @@ messages : 'template-history-warning-messages', titleLink : 'template-history-titleLink', hdaSummary : 'template-history-hdaSummary', + downloadLinks : 'template-history-downloadLinks', failedMetadata : 'template-history-failedMetaData', tagArea : 'template-history-tagArea', annotationArea : 'template-history-annotationArea', - downloadLinks : 'template-history-downloadLinks' + displayApps : 'template-history-displayApps' } }); diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f static/scripts/templates/compiled/template-history-displayApps.js --- /dev/null +++ b/static/scripts/templates/compiled/template-history-displayApps.js @@ -0,0 +1,42 @@ +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; +templates['template-history-displayApps'] = template(function (Handlebars,depth0,helpers,partials,data) { + helpers = helpers || Handlebars.helpers; + var stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + +function program1(depth0,data) { + + var buffer = "", stack1, foundHelper; + buffer += "\n "; + foundHelper = helpers.label; + if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } + else { stack1 = depth0.label; stack1 = typeof stack1 === functionType ? stack1() : stack1; } + buffer += escapeExpression(stack1) + "\n "; + stack1 = depth0.links; + stack1 = helpers.each.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(2, program2, data)}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n <br />\n"; + return buffer;} +function program2(depth0,data) { + + var buffer = "", stack1, foundHelper; + buffer += "\n <a target=\""; + foundHelper = helpers.target; + if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } + else { stack1 = depth0.target; stack1 = typeof stack1 === functionType ? stack1() : stack1; } + buffer += escapeExpression(stack1) + "\" href=\""; + foundHelper = helpers.href; + if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } + else { stack1 = depth0.href; stack1 = typeof stack1 === functionType ? stack1() : stack1; } + buffer += escapeExpression(stack1) + "\">"; + foundHelper = helpers.text; + if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); } + else { stack1 = depth0.text; stack1 = typeof stack1 === functionType ? stack1() : stack1; } + buffer += escapeExpression(stack1) + "</a>\n "; + return buffer;} + + stack1 = depth0.displayApps; + stack1 = helpers.each.call(depth0, stack1, {hash:{},inverse:self.noop,fn:self.program(1, program1, data)}); + if(stack1 || stack1 === 0) { return stack1; } + else { return ''; }}); +})(); \ No newline at end of file diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f static/scripts/templates/compiled/template-history-downloadLinks.js --- a/static/scripts/templates/compiled/template-history-downloadLinks.js +++ b/static/scripts/templates/compiled/template-history-downloadLinks.js @@ -46,7 +46,7 @@ function program4(depth0,data) { - return "\n <a href=\"\" title=\"Download\" class=\"icon-button disk tooltip\"></a>\n";} + return "\n<a href=\"\" title=\"Download\" class=\"icon-button disk tooltip\"></a>\n";} stack1 = depth0.meta_files; stack1 = helpers['if'].call(depth0, stack1, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data)}); diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f static/scripts/templates/history-templates.html --- a/static/scripts/templates/history-templates.html +++ b/static/scripts/templates/history-templates.html @@ -51,6 +51,23 @@ {{/warningmessagesmall}} </script> +<script type="text/template" class="template-history" id="template-history-downloadLinks"> +{{#if meta_files}} +<div popupmenu="dataset-{{id}}-popup"> + <a class="action-button" href="{{download_url}}">Download Dataset</a> + <a>Additional Files</a> + {{#each meta_files}} + <a class="action-button" href="{{meta_download_url}}">Download {{meta_file_type}}</a> + {{/each}} +</div> +<div style="float:left;" class="menubutton split popup" id="dataset-{{id}}-popup"> + <a href="{{download_url}}" title="Download" class="icon-button disk tooltip"></a> +</div> +{{else}} +<a href="" title="Download" class="icon-button disk tooltip"></a> +{{/if}} +</script> + <script type="text/template" class="template-history" id="template-history-tagArea"> {{! TODO: move to mvc/tag.js templates }} <div class="tag-area" style="display: none;"> @@ -70,21 +87,12 @@ </div></script> -<script type="text/template" class="template-history" id="template-history-downloadLinks"> -{{#if meta_files}} -<div popupmenu="dataset-{{id}}-popup"> - <a class="action-button" href="{{download_url}}">Download Dataset</a> - <a>Additional Files</a> - {{#each meta_files}} - <a class="action-button" href="{{meta_download_url}}">Download {{meta_file_type}}</a> +<script type="text/template" class="template-history" id="template-history-displayApps"> +{{#each displayApps}} + {{label}} + {{#each links}} + <a target="{{target}}" href="{{href}}">{{text}}</a> {{/each}} -</div> -<div style="float:left;" class="menubutton split popup" id="dataset-{{id}}-popup"> - <a href="{{download_url}}" title="Download" class="icon-button disk tooltip"></a> -</div> -{{else}} - <a href="" title="Download" class="icon-button disk tooltip"></a> -{{/if}} + <br /> +{{/each}} </script> - - diff -r a995f7aca75c03bd180689aead6a8870928d8fdf -r 7658dde1dd3356bfeb6b92bdcdf8f1c4b3537a0f templates/root/alternate_history.mako --- a/templates/root/alternate_history.mako +++ b/templates/root/alternate_history.mako @@ -7,40 +7,6 @@ ## ?? add: if string != _(string) </%def> -##<%def name="render_download_links( data, dataset_id )"> -## ## -## %if data.purged: return -## <% -## from galaxy.datatypes.metadata import FileParameter -## download_url = h.url_for( controller='/dataset', action='display', dataset_id=dataset_id, to_ext=data.ext ) -## meta_files = [] -## for k in data.metadata.spec.keys(): -## if isinstance( data.metadata.spec[ k ].param, FileParameter ): -## file_type = k -## download_url = h.url_for( controller='/dataset', action='get_metadata_file', -## hda_id=dataset_id, metadata_name=file_type ) -## meta_files.append( ( file_type, download_url ) ) -## %> -## -## %if meta_files: -## <div popupmenu="dataset-${dataset_id}-popup"> -## <a class="action-button" href="${download_url}">Download Dataset</a> -## -## <a>Additional Files</a> -## %for meta_file_type, meta_download_url in zip( meta_download_types, meta_download_urls ): -## <a class="action-button" href="${meta_download_url}">Download ${meta_file_type}</a> -## %endfor -## -## <div style="float:left;" class="menubutton split popup" id="dataset-${dataset_id}-popup"> -## <a href="${download_url}" title='${_("Download")}' class="icon-button disk tooltip"></a> -## </div> -## </div> -## -## %else -## <a href="${download_url}" title='${_("Download")}' class="icon-button disk tooltip"></a> -## %endif -##</%def> - <%def name="get_page_localized_strings()"> ## a list of localized strings used in the backbone views, etc. (to be loaded and cached) ##! change on per page basis @@ -98,26 +64,8 @@ deleted = hda.deleted purged = hda.purged - # download links (for both main hda and associated meta files) - if not hda.purged: - add_to_data( download_url=h.url_for( controller='/dataset', action='display', - dataset_id=encoded_data_id, to_ext=hda.ext ) ) - - meta_files = [] - for k in hda.metadata.spec.keys(): - if isinstance( hda.metadata.spec[ k ].param, FileParameter ): - file_type = k - download_url = h.url_for( controller='/dataset', action='get_metadata_file', - hda_id=encoded_data_id, metadata_name=file_type ) - meta_files.append( dict( meta_file_type=file_type, meta_download_url=download_url ) ) - - if meta_files: - print hda.name, meta_files - add_to_data( meta_files=meta_files ) - - + # ................................................................ link actions #purged = purged or hda.dataset.purged //?? - # all of these urls are 'datasets/data_id/<action> if not ( dataset_purged or purged ) and for_editing: add_to_data( undelete_url=h.url_for( controller='dataset', action='undelete', dataset_id=encoded_data_id ) ) @@ -128,6 +76,8 @@ if not hda.visible: add_to_data( unhide_url=h.url_for( controller='dataset', action='unhide', dataset_id=encoded_data_id ) ) + + # ................................................................ title actions (display, edit, delete) display_url = '' if for_editing: display_url = h.url_for( controller='dataset', action='display', dataset_id=encoded_data_id, preview=True, filename='' ) @@ -157,11 +107,29 @@ show_deleted_on_refresh=show_deleted )) + # ................................................................ primary actions (error, info, download) + # download links (hda and associated meta files) + if not hda.purged: + add_to_data( download_url=h.url_for( controller='/dataset', action='display', + dataset_id=encoded_data_id, to_ext=hda.ext ) ) + + meta_files = [] + for k in hda.metadata.spec.keys(): + if isinstance( hda.metadata.spec[ k ].param, FileParameter ): + file_type = k + download_url = h.url_for( controller='/dataset', action='get_metadata_file', + hda_id=encoded_data_id, metadata_name=file_type ) + meta_files.append( dict( meta_file_type=file_type, meta_download_url=download_url ) ) + + if meta_files: + add_to_data( meta_files=meta_files ) + # error report if for_editing: #NOTE: no state == 'error' check add_to_data( report_error_url=h.url_for( h.url_for( controller='dataset', action='errors', id=encoded_data_id ) ) ) - + + # visualizations if hda.ext in app.datatypes_registry.get_available_tracks(): # do these need _localized_ dbkeys? trackster_urls = {} @@ -175,6 +143,48 @@ trackster_urls[ 'new-url' ] = h.url_for( controller='visualization', action='trackster', dataset_id=encoded_data_id, default_dbkey=hda.dbkey ) add_to_data( trackster_url=trackster_urls ) + # display apps (igv, uscs) + display_types = [] + display_apps = [] + if( hda.state in [ 'ok', 'failed_metadata' ] + and hda.has_data() ): + #NOTE: these two data share structures + #TODO: this doesn't seem to get called with the hda I'm using. What would call this? How can I spoof it? + for display_type in hda.datatype.get_display_types(): + display_label = hda.datatype.get_display_label( display_type ) + target_frame, display_links = hda.datatype.get_display_links( hda, display_type, app, request.base ) + if display_links: + display_links = [] + for display_name, display_href in display_links: + display_type_link = dict( + target = target_frame, + href = display_href, + text = display_name + ) + display_links.append( display_type_link ) + + # append the link list to the main map using the display_label + display_types.append( dict( label=display_label, links=display_links ) ) + + for display_app in hda.get_display_applications( trans ).itervalues(): + app_links = [] + for display_app_link in display_app.links.itervalues(): + app_link = dict( + target = display_app_link.url.get( 'target_frame', '_blank' ), + href = display_app_link.get_display_url( hda, trans ), + text = _( display_app_link.name ) + ) + app_links.append( app_link ) + + display_apps.append( dict( label=display_app.name, links=app_links ) ) + + # attach the display types and apps (if any) to the hda obj + #if display_types: print 'display_types:', display_types + #if display_apps: print 'display_apps:', display_apps + add_to_data( display_types=display_types ) + add_to_data( display_apps=display_apps ) + + # ................................................................ secondary actions (tagging, annotation) if trans.user: add_to_data( ajax_get_tag_url=( h.url_for( controller='tag', action='get_tagging_elt_async', @@ -189,34 +199,6 @@ add_to_data( ajax_set_annotation_url=( h.url_for( controller='/dataset', action='annotate_async', id=encoded_data_id ) ) ) - display_type_display_links = {} - #TODO: this doesn't seem to get called with the hda I'm using. What would call this? How can I spoof it? - for display_app in hda.datatype.get_display_types(): - # print "display_app:", display_app - target_frame, display_links = hda.datatype.get_display_links( hda, display_app, app, request.base ) - # print "target_frame:", target_frame, "display_links:", display_links - #if len( display_links ) > 0: - # display_type_display_links[ display_app ] = {} - # for display_name, display_link in display_links: - #NOTE!: localized name - #<a target="${target_frame}" href="${display_link}">${_(display_name)}</a> - #pass - # <br /> - - display_apps = {} - for display_app in hda.get_display_applications( trans ).itervalues(): - display_app_dict = display_apps[ display_app.name ] = {} - for link_app in display_app.links.itervalues(): - # print link_app.name, link_app.get_display_url( hda, trans ) - #NOTE!: localized name - display_app_dict[ _( link_app.name ) ] = { - 'url' : link_app.get_display_url( hda, trans ), - 'target' : link_app.url.get( 'target_frame', '_blank' ) - } - if display_apps: - # print display_apps - add_to_data( display_apps=display_apps ) - return data_dict %></%def> @@ -337,11 +319,12 @@ "template-history-warning-messages", "template-history-titleLink", + "template-history-failedMetadata", "template-history-hdaSummary", - "template-history-failedMetadata", + "template-history-downloadLinks", "template-history-tagArea", "template-history-annotationArea", - "template-history-downloadLinks" + "template-history-displayApps" )} ## if using in-dom templates they need to go here (before the Backbone classes are defined) @@ -382,9 +365,6 @@ glx_history_view = new HistoryView({ model: glx_history }); glx_history_view.render(); - hi = glx_history.items.at( 0 ); - hi_view = new HistoryItemView({ model: hi }); - $( 'body' ).append( hi_view.render() ); return; } Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.