commit/galaxy-central: carlfeberhard: Remove history.mako; old history panel from root.history; remove from root: user_get_usage, history_item_updates, history_get_disk_size
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/a64e43d6d4d5/ Changeset: a64e43d6d4d5 User: carlfeberhard Date: 2013-04-05 00:16:46 Summary: Remove history.mako; old history panel from root.history; remove from root: user_get_usage, history_item_updates, history_get_disk_size Affected #: 3 files diff -r 71d6ff3f321219de3436fe553bf5c8594976b9b1 -r a64e43d6d4d52f17b53a4ceac07d48105defdc9c lib/galaxy/webapps/galaxy/controllers/root.py --- a/lib/galaxy/webapps/galaxy/controllers/root.py +++ b/lib/galaxy/webapps/galaxy/controllers/root.py @@ -1,14 +1,17 @@ """ Contains the main interface in the Universe class """ -import logging, os, string, shutil, urllib, re, socket +import os +import urllib from cgi import escape, FieldStorage + from galaxy import util, datatypes, jobs, web, util from galaxy.web.base.controller import * from galaxy.util.sanitize_html import sanitize_html from galaxy.model.orm import * from galaxy.model.item_attrs import UsesAnnotations +import logging log = logging.getLogger( __name__ ) class RootController( BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin, UsesAnnotations ): @@ -26,7 +29,6 @@ params=kwd ) ## ---- Tool related ----------------------------------------------------- - @web.expose def tool_menu( self, trans ): if trans.app.config.require_login and not trans.user: @@ -88,7 +90,6 @@ yield "</body></html>" ## ---- Root history display --------------------------------------------- - @web.expose def my_data( self, trans, **kwd ): """ @@ -105,78 +106,66 @@ params = util.Params( kwd ) message = params.get( 'message', None ) status = params.get( 'status', 'done' ) + if trans.app.config.require_login and not trans.user: return trans.fill_template( '/no_access.mako', message = 'Please log in to access Galaxy histories.' ) + history = trans.get_history( create=True ) + if as_xml: trans.response.set_content_type('text/xml') return trans.fill_template_mako( "root/history_as_xml.mako", history=history, show_deleted=util.string_as_bool( show_deleted ), show_hidden=util.string_as_bool( show_hidden ) ) - else: - show_deleted = util.string_as_bool_or_none( show_deleted ) - show_purged = show_deleted - show_hidden = util.string_as_bool_or_none( show_hidden ) - - datasets = [] - history_panel_template = "root/alternate_history.mako" - # keeping this switch here for a while - uncomment the next line to use the original mako history panel - #USE_ORIGINAL = True - if 'USE_ORIGINAL' in locals(): - datasets = self.get_history_datasets( trans, history, show_deleted, show_hidden, show_purged ) - history_panel_template = "root/history.mako" + show_deleted = util.string_as_bool_or_none( show_deleted ) + show_purged = show_deleted + show_hidden = util.string_as_bool_or_none( show_hidden ) - else: - # get all datasets server-side, client-side will get flags and render appropriately - hdas = self.get_history_datasets( trans, history, - show_deleted=True, show_hidden=True, show_purged=True ) + # get all datasets server-side, client-side will get flags and render appropriately + hdas = self.get_history_datasets( trans, history, + show_deleted=True, show_hidden=True, show_purged=True ) - #TODO: would be good to re-use the hdas above to get the history data... - history_dictionary = self.get_history_dict( trans, history ) + #TODO: would be good to re-use the hdas above to get the history data... + history_dictionary = self.get_history_dict( trans, history ) - #TODO: blech - all here for now - duplication of hist. contents, index - hda_dictionaries = [] - for hda in hdas: - try: - hda_dictionaries.append( self.get_hda_dict( trans, hda ) ) + #TODO: blech - all here for now - duplication of hist. contents, index + hda_dictionaries = [] + for hda in hdas: + try: + hda_dictionaries.append( self.get_hda_dict( trans, hda ) ) - except Exception, exc: - # don't fail entire list if hda err's, record and move on - # (making sure http recvr knows it's err'd) - encoded_hda_id = trans.security.encode_id( hda.id ) - log.error( "Error in history API at listing contents with history %s, hda %s: (%s) %s", - history_dictionary[ 'id' ], encoded_hda_id, type( exc ), str( exc ) ) - return_val = { - 'id' : encoded_hda_id, - 'name' : hda.name, - 'hid' : hda.hid, - 'history_id': history_dictionary[ 'id' ], - 'state' : trans.model.Dataset.states.ERROR, - 'visible' : True, - 'misc_info' : str( exc ), - 'misc_blurb': 'Failed to retrieve dataset information.', - 'error' : str( exc ) - } - hda_dictionaries.append( return_val ) + except Exception, exc: + # don't fail entire list if hda err's, record and move on + # (making sure http recvr knows it's err'd) + encoded_hda_id = trans.security.encode_id( hda.id ) + log.error( "Error in history API at listing contents with history %s, hda %s: (%s) %s", + history_dictionary[ 'id' ], encoded_hda_id, type( exc ), str( exc ) ) + return_val = { + 'id' : encoded_hda_id, + 'name' : hda.name, + 'hid' : hda.hid, + 'history_id': history_dictionary[ 'id' ], + 'state' : trans.model.Dataset.states.ERROR, + 'visible' : True, + 'misc_info' : str( exc ), + 'misc_blurb': 'Failed to retrieve dataset information.', + 'error' : str( exc ) + } + hda_dictionaries.append( return_val ) - history = history_dictionary - datasets = hda_dictionaries + return trans.stream_template_mako( "root/alternate_history.mako", + history_dictionary = history_dictionary, + hda_dictionaries = hda_dictionaries, + show_deleted = show_deleted, + show_hidden = show_hidden, + hda_id = hda_id, + log = log, + message = message, + status = status ) - return trans.stream_template_mako( history_panel_template, - #return trans.fill_template_mako( history_panel_template, - history = history, - annotation = self.get_item_annotation_str( trans.sa_session, trans.user, history ), - datasets = datasets, - hda_id = hda_id, - show_deleted = show_deleted, - show_hidden=show_hidden, - over_quota=trans.app.quota_agent.get_percent( trans=trans ) >= 100, - log = log, - message=message, - status=status ) - + ## ---- Dataset display / editing ---------------------------------------- @web.expose def dataset_state ( self, trans, id=None, stamp=None ): if id is not None: @@ -204,74 +193,6 @@ else: return trans.show_error_message( "Must specify a dataset id.") - @web.json - def history_item_updates( self, trans, ids=None, states=None ): - # Avoid caching - trans.response.headers['Pragma'] = 'no-cache' - trans.response.headers['Expires'] = '0' - # Create new HTML for any that have changed - rval = {} - if ids is not None and states is not None: - ids = ids.split( "," ) - states = states.split( "," ) - for encoded_id, state in zip( ids, states ): - try: - # assume encoded and decode to int - id = int( trans.app.security.decode_id( encoded_id ) ) - except: - # fallback to non-encoded id - id = int( encoded_id ) - - # fetch new data for that id - data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id ) - - # if the state has changed, - if data.state != state: - - # find out if we need to force a refresh on this data - job_hda = data - while job_hda.copied_from_history_dataset_association: - job_hda = job_hda.copied_from_history_dataset_association - force_history_refresh = False - if job_hda.creating_job_associations: - tool = trans.app.toolbox.get_tool( job_hda.creating_job_associations[ 0 ].job.tool_id ) - if tool: - force_history_refresh = tool.force_history_refresh - if not job_hda.visible: - force_history_refresh = True - - # add the new state html for the item, the refresh option and the new state, map to the id - rval[encoded_id] = { - "state": data.state, - "html": unicode( trans.fill_template( "root/history_item.mako", data=data, hid=data.hid ), 'utf-8' ), - "force_history_refresh": force_history_refresh - } - - return rval - - @web.json - def history_get_disk_size( self, trans ): - rval = { 'history' : trans.history.get_disk_size( nice_size=True ) } - for k, v in self.__user_get_usage( trans ).items(): - rval['global_' + k] = v - return rval - - @web.json - def user_get_usage( self, trans ): - return self.__user_get_usage( trans ) - - def __user_get_usage( self, trans ): - usage = trans.app.quota_agent.get_usage( trans ) - percent = trans.app.quota_agent.get_percent( trans=trans, usage=usage ) - rval = {} - if percent is None: - rval['usage'] = util.nice_size( usage ) - else: - rval['percent'] = percent - return rval - - ## ---- Dataset display / editing ---------------------------------------- - @web.expose def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", **kwd ): """ @@ -372,14 +293,12 @@ yield "No data with id=%d" % id ## ---- History management ----------------------------------------------- - @web.expose def history_options( self, trans ): """Displays a list of history related actions""" return trans.fill_template( "/history/options.mako", user=trans.get_user(), history=trans.get_history( create=True ) ) - @web.expose def history_delete( self, trans, id ): """ @@ -556,7 +475,6 @@ raise Exception("You must specify a bucket") # ---- Debug methods ---------------------------------------------------- - @web.expose def echo(self, trans, **kwd): """Echos parameters (debugging)""" diff -r 71d6ff3f321219de3436fe553bf5c8594976b9b1 -r a64e43d6d4d52f17b53a4ceac07d48105defdc9c templates/webapps/galaxy/root/alternate_history.mako --- a/templates/webapps/galaxy/root/alternate_history.mako +++ b/templates/webapps/galaxy/root/alternate_history.mako @@ -94,7 +94,6 @@ encoded_id_template = '<%= id %>' url_dict = { - ##TODO: into their own MVs 'rename' : h.url_for( controller="history", action="rename_async", id=encoded_id_template ), 'tag' : h.url_for( controller='tag', action='get_tagging_elt_async', @@ -115,7 +114,7 @@ hda_class_name = 'HistoryDatasetAssociation' encoded_id_template = '<%= id %>' - #username_template = '<%= username %>' + hda_ext_template = '<%= file_ext %>' meta_type_template = '<%= file_type %>' @@ -124,8 +123,6 @@ url_dict = { # ................................................................ warning message links - #'purge' : h.url_for( controller='dataset', action='purge', - # dataset_id=encoded_id_template ), 'purge' : h.url_for( controller='dataset', action='purge_async', dataset_id=encoded_id_template ), #TODO: hide (via api) @@ -138,9 +135,6 @@ # ................................................................ title actions (display, edit, delete), 'display' : h.url_for( controller='dataset', action='display', dataset_id=encoded_id_template, preview=True, filename='' ), - #TODO: - #'user_display_url' : h.url_for( controller='dataset', action='display_by_username_and_slug', - # username=username_template, slug=encoded_id_template, filename='' ), 'edit' : h.url_for( controller='dataset', action='edit', dataset_id=encoded_id_template ), @@ -170,9 +164,6 @@ item_class=hda_class_name, item_id=encoded_id_template ), }, 'annotation' : { - #TODO: needed? doesn't look like this is used (unless graceful degradation) - #'annotate_url' : h.url_for( controller='dataset', action='annotate', - # id=encoded_id_template ), 'get' : h.url_for( controller='dataset', action='get_annotation_async', id=encoded_id_template ), 'set' : h.url_for( controller='/dataset', action='annotate_async', @@ -184,12 +175,7 @@ </%def> ## ----------------------------------------------------------------------------- -## get the history, hda, user data from the api (as opposed to the web controllers/mako) - -## I'd rather do without these (esp. the get_hdas which hits the db twice) -## but we'd need a common map producer (something like get_api_value but more complete) -##TODO: api/web controllers should use common code, and this section should call that code -<%def name="get_history( history )"> +<%def name="get_history_json( history )"><% try: return h.to_json_string( history ) @@ -203,13 +189,11 @@ <%def name="get_current_user()"><% user_json = trans.webapp.api_controllers[ 'users' ].show( trans, 'current' ) - #assert isinstance( hdaDataList, list ), ( - # 'Bootstrapped current user was expecting a dictionary: %s' %( str( user ) ) ) return user_json %></%def> -<%def name="get_hdas( hdas )"> +<%def name="get_hda_json( hdas )"><% try: return h.to_json_string( hdas ) @@ -228,12 +212,7 @@ ${h.js( "libs/jquery/jstorage", "libs/jquery/jquery.autocomplete", "galaxy.autocom_tagging", - ##"libs/json2", - ##"libs/bootstrap", - ## I think we can remove some of these - ##"libs/backbone/backbone-relational", "mvc/base-mvc", - ##"mvc/ui" )} ${h.templates( @@ -258,13 +237,7 @@ ##TODO: fix: curr hasta be _after_ h.templates bc these use those templates - move somehow ${h.js( "mvc/user/user-model", "mvc/user/user-quotameter", - - "mvc/dataset/hda-model", - "mvc/dataset/hda-base", - "mvc/dataset/hda-edit", - - ##"mvc/tags", "mvc/annotations" - + "mvc/dataset/hda-model", "mvc/dataset/hda-base", "mvc/dataset/hda-edit", "mvc/history/history-model", "mvc/history/history-panel" )} @@ -327,8 +300,8 @@ page_show_hidden = ${ 'true' if show_hidden == True else ( 'null' if show_hidden == None else 'false' ) }, user = ${ get_current_user() }, - history = ${ get_history( history ) }, - hdas = ${ get_hdas( datasets ) }; + history = ${ get_history_json( history_dictionary ) }, + hdas = ${ get_hda_json( hda_dictionaries ) }; // add user data to history // i don't like this history+user relationship, but user authentication changes views/behaviour @@ -345,17 +318,6 @@ }); historyPanel.render(); - // ...or LOAD FROM THE API - //historyPanel = new HistoryPanel({ - // model: new History(), - // urlTemplates : galaxy_paths.attributes, - // logger : ( debugging )?( console ):( null ), - // // is page sending in show settings? if so override history's - // show_deleted : page_show_deleted, - // show_hidden : page_show_hidden - //}); - //historyPanel.model.loadFromApi( history.id ); - // set it up to be accessible across iframes //TODO:?? mem leak top.Galaxy.currHistoryPanel = historyPanel; @@ -416,7 +378,6 @@ windowJQ = $( top )[0].jQuery, popupMenu = ( windowJQ && $historyMenuButton[0] )?( windowJQ.data( $historyMenuButton[0], 'PopupMenu' ) ) :( null ); - //console.debug( // '$historyButtonWindow:', $historyButtonWindow, // '$historyMenuButton:', $historyMenuButton, @@ -556,15 +517,6 @@ } </style> - - <noscript> - ## js disabled: degrade gracefully - <style> - .historyItemBody { - display: block; - } - </style> - </noscript></%def><body class="historyPage"></body> diff -r 71d6ff3f321219de3436fe553bf5c8594976b9b1 -r a64e43d6d4d52f17b53a4ceac07d48105defdc9c templates/webapps/galaxy/root/history.mako --- a/templates/webapps/galaxy/root/history.mako +++ /dev/null @@ -1,711 +0,0 @@ -<%namespace file="/message.mako" import="render_msg" /> - -<% _=n_ %> -<!DOCTYPE HTML> - -<html> - -<head> -<title>${_('Galaxy History')}</title> - -## This is now only necessary for tests -%if bool( [ data for data in history.active_datasets if data.state in ['running', 'queued', '', None ] ] ): -<!-- running: do not change this comment, used by TwillTestCase.wait --> -%endif - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<meta http-equiv="Pragma" content="no-cache"> - -${h.css( "base", "history", "autocomplete_tagging" )} -${h.js( - "libs/jquery/jquery", - "libs/bootstrap", - "galaxy.base", - "libs/json2", - "libs/jquery/jstorage", - "libs/jquery/jquery.autocomplete", - "galaxy.autocom_tagging", - "libs/underscore" -)} - -<script type="text/javascript"> - -<% TERMINAL_STATES = ["ok", "error", "empty", "deleted", "discarded", "failed_metadata", "paused"] %> -TERMINAL_STATES = ${ h.to_json_string(TERMINAL_STATES) }; - -// Tag handling. -function tag_handling(parent_elt) { - $(parent_elt).find("a.icon-button.tags").each( function() { - // Use links parameters but custom URL as ajax URL. - $(this).click( function() { - // Get tag area, tag element. - var history_item = $(this).parents(".historyItem"); - var tag_area = history_item.find(".tag-area"); - var tag_elt = history_item.find(".tag-elt"); - - // Show or hide tag area; if showing tag area and it's empty, fill it. - if ( tag_area.is( ":hidden" ) ) { - if (!tag_elt.html()) { - // Need to fill tag element. - var href_parms = $(this).attr("href").split("?")[1]; - var ajax_url = "${h.url_for( controller='tag', action='get_tagging_elt_async' )}?" + href_parms; - $.ajax({ - url: ajax_url, - error: function() { alert( "Tagging failed" ) }, - success: function(tag_elt_html) { - tag_elt.html(tag_elt_html); - tag_elt.find(".tooltip").tooltip({ placement : 'bottom' }); - tag_area.slideDown("fast"); - } - }); - } else { - // Tag element is filled; show. - tag_area.slideDown("fast"); - } - } else { - // Hide. - tag_area.slideUp("fast"); - } - return false; - }); - }); -}; - -// Annotation handling. -function annotation_handling(parent_elt) { - $(parent_elt).find("a.icon-button.annotate").each( function() { - // Use links parameters but custom URL as ajax URL. - $(this).click( function() { - // Get tag area, tag element. - var history_item = $(this).parents(".historyItem"); - var annotation_area = history_item.find(".annotation-area"); - var annotation_elt = history_item.find(".annotation-elt"); - - // Show or hide annotation area; if showing annotation area and it's empty, fill it. - if ( annotation_area.is( ":hidden" ) ) { - if (!annotation_elt.html()) { - // Need to fill annotation element. - var href_parms = $(this).attr("href").split("?")[1]; - var ajax_url = "${h.url_for( controller='dataset', action='get_annotation_async' )}?" + href_parms; - $.ajax({ - url: ajax_url, - error: function() { alert( "Annotations failed" ) }, - success: function(annotation) { - if (annotation == "") { - annotation = "<em>Describe or add notes to dataset</em>"; - } - annotation_elt.html(annotation); - annotation_area.find(".tooltip").tooltip({ placement : 'bottom' }); - async_save_text( - annotation_elt.attr("id"), annotation_elt.attr("id"), - "${h.url_for( controller='dataset', action='annotate_async')}?" + href_parms, - "new_annotation", 18, true, 4); - annotation_area.slideDown("fast"); - } - }); - } else { - // Annotation element is filled; show. - annotation_area.slideDown("fast"); - } - } else { - // Hide. - annotation_area.slideUp("fast"); - } - return false; - }); - }); -}; - -// ----------------------------------------------------------------------------- -function applyTooltip( elem ){ - // apply twitter bootstrap tooltip to elem - - //!! 2 line tooltips placed above do not render properly - //TODO: hack (github has an issue on this - see how it's resolved) - var $this = $( elem ); - if( $this.hasClass( 'tooltip' ) ){ - - // remove original tooltip - if( $this.attr( 'data-original-title' ) ){ - // documented method - that doesn't seem to work - //$( this ).tooltip( 'destroy' ); - $this.data( 'tooltip', false ); - - // swap title back - var title = $this.attr( 'data-original-title' ); - $this.attr( 'data-original-title', null ); - $this.attr( 'title', title ); - } - - // (re-)apply tooltip - // place them on the bottom for now - $this.tooltip({ placement : 'bottom' }); - } - return this; -} - -function applyTooltips( elem ){ - // apply twitter bootstrap tooltips to this element and all children - $( $( elem ).find( '.tooltip' ).andSelf() ).each( function(){ - applyTooltip( this ); - }); - return this; -} - -// ----------------------------------------------------------------------------- -// Create trackster action function. -function create_trackster_action_fn(vis_url, dataset_params, dbkey) { - return function() { - var params = {}; - if (dbkey) { params['dbkey'] = dbkey; } - $.ajax({ - url: vis_url + '/list_tracks?f-' + $.param(params), - dataType: "html", - error: function() { alert( "Could not add this dataset to browser." ); }, - success: function(table_html) { - var parent = window.parent; - - parent.show_modal("View Data in a New or Saved Visualization", "", { - "Cancel": function() { - parent.hide_modal(); - }, - "View in saved visualization": function() { - // Show new modal with saved visualizations. - parent.show_modal("Add Data to Saved Visualization", table_html, { - "Cancel": function() { - parent.hide_modal(); - }, - "Add to visualization": function() { - $(parent.document).find('input[name=id]:checked').each(function() { - var vis_id = $(this).val(); - dataset_params['id'] = vis_id - parent.location = vis_url + "/trackster?" + $.param(dataset_params); - }); - }, - }); - }, - "View in new visualization": function() { - parent.location = vis_url + "/trackster?" + $.param(dataset_params); - } - }); - } - }); - return false; - }; -}; - -function create_scatterplot_action_fn( url, params ){ - action = function() { - var galaxy_main = $( window.parent.document ).find( 'iframe#galaxy_main' ), - final_url = url + '/scatterplot?' + $.param(params); - galaxy_main.attr( 'src', final_url ); - $( 'div.popmenu-wrapper' ).remove(); - return false; - }; - return action; -} - -/** - * Create popup menu for visualization icon. - */ -function init_viz_icon(icon) { - var icon = $(icon), - vis_url = icon.attr('href'), - dataset_id = icon.attr('dataset_id'), - visualizations = icon.attr('visualizations').split(','), - dbkey = icon.attr('dbkey'), - popup_menu_dict = {}, - - // Create visualization action. - create_viz_action = function(visualization) { - var action; - switch( visualization ){ - - case 'trackster': - action = create_trackster_action_fn(vis_url, params, dbkey); - break; - - case 'scatterplot': - action = create_scatterplot_action_fn( vis_url, params ); - break; - - default: - action = function(){ - window.parent.location = vis_url + '/' + visualization + '?' + $.param(params); - } - } - return action; - }, - params = { - dataset_id: dataset_id, - hda_ldda: 'hda' - }; - - // Add dbkey to params if it exists. - if (dbkey) { params['dbkey'] = dbkey; } - - // Populate menu dict with visualizations. - _.each(visualizations, function(visualization) { - popup_menu_dict[ - visualization.charAt(0).toUpperCase() + visualization.slice(1) - ] = create_viz_action(visualization); - }); - - // Set up action or menu. - if (visualizations.length === 1) { - // No need for popup menu because there's a single visualization. - icon.attr( 'title', visualizations[0] ); - icon.click(create_viz_action(visualizations[0])); - } - else { - make_popupmenu(icon, popup_menu_dict); - } -}; - - -// Update the message for async operations -function render_message(message, status) { - $("div#message-container").html( "<div class=\"" + status + "message\">" + message + "</div><br/>" ); -} - -$(function() { - var historywrapper = $("div.historyItemWrapper"); - init_history_items(historywrapper); - historywrapper.each( function() { - // Delete link - $(this).find("div.historyItemButtons > .delete" ).each( function() { - var data_id = this.id.split( "-" )[1]; - $(this).click( function() { - $( '#historyItem-' + data_id + "> div.historyItemTitleBar" ).addClass( "spinner" ); - $.ajax({ - url: "${h.url_for( controller='dataset', action='delete_async', dataset_id='XXX' )}".replace( 'XXX', data_id ), - error: function() { render_message( "Dataset deletion failed", "error" ); }, - success: function(msg) { - if (msg === "OK") { - %if show_deleted: - var to_update = {}; - to_update[data_id] = "none"; - updater( to_update ); - %else: - $( "#historyItem-" + data_id ).fadeOut( "fast", function() { - $( "#historyItemContainer-" + data_id ).remove(); - if ( $( "div.historyItemContainer" ).length < 1 ) { - $( "#emptyHistoryMessage" ).show(); - } - }); - %endif - } else { - render_message( "Dataset deletion failed", "error" ); - } - } - }); - return false; - }); - }); - - // Check to see if the dataset data is cached or needs to be pulled in - // via objectstore - $(this).find("a.display").each( function() { - var history_item = $(this).parents(".historyItem")[0]; - var history_id = history_item.id.split( "-" )[1]; - $(this).click(function() { - check_transfer_status($(this), history_id); - }); - }); - - // If dataset data is not cached, keep making ajax calls to check on the - // data status and update the dataset UI element accordingly - function check_transfer_status(link, history_id) { - $.getJSON("${h.url_for( controller='dataset', action='transfer_status', dataset_id='XXX' )}".replace( 'XXX', link.attr("dataset_id") ), - function(ready) { - if (ready === false) { - // $("<div/>").text("Data is loading from S3... please be patient").appendTo(link.parent()); - $( '#historyItem-' + history_id).removeClass( "historyItem-ok" ); - $( '#historyItem-' + history_id).addClass( "historyItem-running" ); - setTimeout(function(){check_transfer_status(link, history_id)}, 4000); - } else { - $( '#historyItem-' + history_id).removeClass( "historyItem-running" ); - $( '#historyItem-' + history_id).addClass( "historyItem-ok" ); - } - } - ); - } - - // Undelete link - $(this).find("a.historyItemUndelete").each( function() { - var data_id = this.id.split( "-" )[1]; - $(this).click( function() { - $( '#historyItem-' + data_id + " > div.historyItemTitleBar" ).addClass( "spinner" ); - $.ajax({ - url: "${h.url_for( controller='dataset', action='undelete_async', dataset_id='XXX' )}".replace( 'XXX', data_id ), - error: function() { render_message( "Dataset undeletion failed", "error" ); }, - success: function() { - var to_update = {}; - to_update[data_id] = "none"; - updater( to_update ); - } - }); - return false; - }); - }); - - // Purge link - $(this).find("a.historyItemPurge").each( function() { - var data_id = this.id.split( "-" )[1]; - $(this).click( function() { - $( '#historyItem-' + data_id + " > div.historyItemTitleBar" ).addClass( "spinner" ); - $.ajax({ - url: "${h.url_for( controller='dataset', action='purge_async', dataset_id='XXX' )}".replace( 'XXX', data_id ), - error: function() { render_message( "Dataset removal from disk failed", "error" ) }, - success: function() { - var to_update = {}; - to_update[data_id] = "none"; - updater( to_update ); - } - }); - return false; - }); - }); - - // Show details icon -- Disabled since it often gets stuck, etc - /* $(this).find("a.show-details").bind("mouseenter.load-detail", function(e) { - var anchor = $(this); - $.get($(this).attr("href"), function(data) { - anchor.attr("title", data); - anchor.tipsy( { html: true, gravity: 's', opacity: 1.0, delayOut: 300 } ); - anchor.unbind("mouseenter.load-detail"); - anchor.trigger("mouseenter"); - }); - return false; - }); - - // Disable clickthrough - $(this).find("a.show-details").bind("click", function() { return false; }); - */ - - tag_handling(this); - annotation_handling(this); - applyTooltips( this ); - }); - - _.each( $(".visualize-icon"), function(icon) { - init_viz_icon(icon); - }); - - // History rename functionality. - async_save_text("history-name-container", "history-name", "${h.url_for( controller="/history", action="rename_async", id=trans.security.encode_id(history.id) )}", "new_name", 18); - - // History tagging functionality. - var historyTagArea = $('#history-tag-area'); - $('#history-tag').click( function() { - if ( historyTagArea.is( ":hidden" ) ) { - historyTagArea.slideDown("fast"); - } else { - historyTagArea.slideUp("fast"); - } - return false; - }); - - // History annotation functionality. - var historyAnnotationArea = $('#history-annotation-area'); - $('#history-annotate').click( function() { - if ( historyAnnotationArea.is( ":hidden" ) ) { - historyAnnotationArea.slideDown("fast"); - } else { - historyAnnotationArea.slideUp("fast"); - } - return false; - }); - async_save_text("history-annotation-container", "history-annotation", "${h.url_for( controller="/history", action="annotate_async", id=trans.security.encode_id(history.id) )}", "new_annotation", 18, true, 4); - - // Updater - updater( - ${ h.to_json_string( dict([(trans.app.security.encode_id(data.id), data.state) for data in reversed( datasets ) if data.visible and data.state not in TERMINAL_STATES]) ) } - ); - - // Navigate to a dataset. - %if hda_id: - self.location = "#${hda_id}"; - %endif - - // Update the Quota Meter - $.ajax( { - type: "POST", - url: "${h.url_for( controller='root', action='user_get_usage' )}", - dataType: "json", - success : function ( data ) { - $.each( data, function( type, val ) { - quota_meter_updater( type, val ); - }); - } - }); -}); - -// Updates the Quota Meter -var quota_meter_updater = function ( type, val ) { - if ( type == "usage" ) { - $("#quota-meter-bar", window.top.document).css( "width", "0" ); - $("#quota-meter-text", window.top.document).text( "Using " + val ); - } else if ( type == "percent" ) { - $("#quota-meter-bar", window.top.document).removeClass("quota-meter-bar-warn quota-meter-bar-error"); - if ( val >= 100 ) { - $("#quota-meter-bar", window.top.document).addClass("quota-meter-bar-error"); - $("#quota-message-container").slideDown(); - } else if ( val >= 85 ) { - $("#quota-meter-bar", window.top.document).addClass("quota-meter-bar-warn"); - $("#quota-message-container").slideUp(); - } else { - $("#quota-message-container").slideUp(); - } - $("#quota-meter-bar", window.top.document).css( "width", val + "px" ); - $("#quota-meter-text", window.top.document).text( "Using " + val + "%" ); - } -} - -// Looks for changes in dataset state using an async request. Keeps -// calling itself (via setTimeout) until all datasets are in a terminal -// state. -var updater = function ( tracked_datasets ) { - // Check if there are any items left to track - var empty = true; - for ( i in tracked_datasets ) { - empty = false; - break; - } - if ( !empty ) { - setTimeout( function() { updater_callback( tracked_datasets ) }, 4000 ); - } -}; -var updater_callback = function ( tracked_datasets ) { - // Build request data - var ids = [], - states = [], - force_history_refresh = false, - check_history_size = false; - - $.each( tracked_datasets, function ( id, state ) { - ids.push( id ); - states.push( state ); - }); - // Make ajax call - $.ajax( { - type: "POST", - url: "${h.url_for( controller='root', action='history_item_updates' )}", - dataType: "json", - data: { ids: ids.join( "," ), states: states.join( "," ) }, - success : function ( data ) { - $.each( data, function( id, val ) { - // Replace HTML - var container = $("#historyItemContainer-" + id); - container.html( val.html ); - init_history_items( $("div.historyItemWrapper"), "noinit" ); - - // apply ui element behaviors - tag_handling(container); - annotation_handling(container); - applyTooltips( container ); - - var viz_icon = container.find(".visualize-icon")[0]; - if (viz_icon) { init_viz_icon(viz_icon); } - - // If new state is terminal, stop tracking - if (TERMINAL_STATES.indexOf(val.state) !== -1) { - if ( val.force_history_refresh ){ - force_history_refresh = true; - } - delete tracked_datasets[id]; - // When a dataset becomes terminal, check for changes in history disk size - check_history_size = true; - } else { - tracked_datasets[id] = val.state; - } - }); - if ( force_history_refresh ) { - parent.frames.galaxy_history.location.reload(); - } else { - if ( check_history_size ) { - $.ajax( { - type: "POST", - url: "${h.url_for( controller='root', action='history_get_disk_size' )}", - dataType: "json", - success: function( data ) { - $.each( data, function( type, val ) { - if ( type == "history" ) { - $("#history-size").text( val ); - } else if ( type == "global_usage" ) { - quota_meter_updater( "usage", val ); - } else if ( type == "global_percent" ) { - quota_meter_updater( "percent", val ); - } - }); - } - }); - check_history_size = false; - } - // Keep going (if there are still any items to track) - updater( tracked_datasets ); - } - make_popup_menus(); - }, - error: function() { - // Just retry, like the old method, should try to be smarter - updater( tracked_datasets ); - } - }); -}; - -</script> - -<style> -.historyItemBody { - display: none; -} -div.form-row { - padding: 5px 5px 5px 0px; -} -#top-links { - margin-bottom: 15px; -} -#history-name-container { - color: gray; - font-weight: bold; -} -#history-name { - word-wrap: break-word; -} -.editable-text { - border: solid transparent 1px; - padding: 3px; - margin: -4px; -} -</style> - -<noscript> -<style> -.historyItemBody { - display: block; -} -</style> -</noscript> - -</head> - -<body class="historyPage"> - -<div id="top-links" class="historyLinks"> - - <a title="${_('refresh')}" class="icon-button arrow-circle tooltip" href="${h.url_for(controller='history', show_deleted=show_deleted)}"></a> - <a title='${_('collapse all')}' class='icon-button toggle tooltip' href='#' style="display: none"></a> - - %if trans.get_user(): - <div style="width: 40px; float: right; white-space: nowrap;"> - <a id="history-tag" title="Edit history tags" class="icon-button tags tooltip" target="galaxy_main" href="${h.url_for( controller='history', action='tag' )}"></a> - <a id="history-annotate" title="Edit history annotation" class="icon-button annotate tooltip" target="galaxy_main" href="${h.url_for( controller='history', action='annotate' )}"></a> - </div> - %endif -</div> - -<div class="clear"></div> - -%if show_deleted: -<div class="historyLinks"> - <a href="${h.url_for(controller='history', show_deleted=False)}">${_('hide deleted')}</a> -</div> -%endif - -%if show_hidden: -<div class="historyLinks"> - <a href="${h.url_for(controller='history', show_hidden=False)}">${_('hide hidden')}</a> -</div> -%endif - -<div id="history-name-area" class="historyLinks"> - - <div id="history-name-container" style="position: relative;"> - %if trans.get_user(): - <div id="history-size" style="position: absolute; top: 3px; right: 0px;">${history.get_disk_size(nice_size=True)}</div> - <div id="history-name" style="margin-right: 50px;" class="tooltip editable-text" title="Click to rename history">${history.get_display_name() | h}</div> - - %else: - <div id="history-size">${history.get_disk_size(nice_size=True)}</div> - %endif - </div> -</div> -<div style="clear: both;"></div> - -%if history.deleted: - <div class="warningmessagesmall"> - ${_('You are currently viewing a deleted history!')} - </div> - <p></p> -%endif - -<%namespace file="../tagging_common.mako" import="render_individual_tagging_element" /> -<%namespace file="history_common.mako" import="render_dataset" /> - -%if trans.get_user() is not None: - <div style="margin: 0px 5px 10px 5px"> - ## Tagging elt. - <div id="history-tag-area" style="display: none"> - <b>Tags:</b> - ${render_individual_tagging_element(user=trans.get_user(), tagged_item=history, elt_context="history.mako", use_toggle_link=False, input_size="20")} - </div> - - ## Annotation elt. - <div id="history-annotation-area" style="display: none"> - <strong>Annotation / Notes:</strong> - <div id="history-annotation-container"> - <div id="history-annotation" class="tooltip editable-text" title="Click to edit annotation"> - %if annotation: - ${h.to_unicode( annotation ) | h} - %else: - <em>Describe or add notes to history</em> - %endif - </div> - </div> - </div> - - </div> -%endif - -<div id="message-container"> - %if message: - ${render_msg( message, status )} - %endif -</div> - -%if over_quota: -<div id="quota-message-container"> -%else: -<div id="quota-message-container" style="display: none;"> -%endif - <div id="quota-message" class="errormessage"> - You are over your disk quota. Tool execution is on hold until your disk usage drops below your allocated quota. - </div> - <br/> -</div> - -%if not datasets: - - <div class="infomessagesmall" id="emptyHistoryMessage"> - -%else: - - ## Render requested datasets, ordered from newest to oldest - <div> - %for data in reversed( datasets ): - %if data.visible or show_hidden: - <div class="historyItemContainer" id="historyItemContainer-${trans.app.security.encode_id(data.id)}"> - ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted, for_editing = True )} - </div> - %endif - %endfor - </div> - - <div class="infomessagesmall" id="emptyHistoryMessage" style="display:none;"> -%endif - ${_("Your history is empty. Click 'Get Data' on the left pane to start")} - </div> - -</body> -</html> 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.
participants (1)
-
commits-noreply@bitbucket.org