[hg] galaxy 1544: Add axaj async undelete ability.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[hg] galaxy 1544: Add axaj async undelete ability.

Greg Von Kuster
details:   http://www.bx.psu.edu/hg/galaxy/rev/7e2ec07716b8
changeset: 1544:7e2ec07716b8
user:      Dan Blankenberg <[hidden email]>
date:      Fri Oct 03 16:06:01 2008 -0400
description:
Add axaj async undelete ability.

Fix redisplay of dataset when asynchronously deleted under history view showing deleted datasets.

5 file(s) affected in this change:

lib/galaxy/tools/parameters/basic.py
lib/galaxy/web/controllers/dataset.py
templates/root/history.mako
templates/root/history_common.mako
templates/root/history_item.mako

diffs (183 lines):

diff -r 45033114f82d -r 7e2ec07716b8 lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py Thu Oct 02 16:37:32 2008 -0400
+++ b/lib/galaxy/tools/parameters/basic.py Fri Oct 03 16:06:01 2008 -0400
@@ -1052,7 +1052,7 @@
                     hid = "%s.%d" % ( parent_hid, i + 1 )
                 else:
                     hid = str( data.hid )
-                if not data.deleted and data.state not in [data.states.ERROR] and data.visible:
+                if not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED] and data.visible:
                     if self.options and data.get_dbkey() != filter_value:
                         continue
                     if isinstance( data.datatype, self.formats):
@@ -1112,7 +1112,7 @@
                     return True
                 return False
             for i, data in enumerate( datasets ):
-                if data.visible and not data.deleted and data.state not in [data.states.ERROR] and ( isinstance( data.datatype, self.formats) or is_convertable( data ) ):
+                if data.visible and not data.deleted and data.state not in [data.states.ERROR, data.states.DISCARDED] and ( isinstance( data.datatype, self.formats) or is_convertable( data ) ):
                     if self.options and data.get_dbkey() != filter_value:
                         continue
                     most_recent_dataset[0] = data
diff -r 45033114f82d -r 7e2ec07716b8 lib/galaxy/web/controllers/dataset.py
--- a/lib/galaxy/web/controllers/dataset.py Thu Oct 02 16:37:32 2008 -0400
+++ b/lib/galaxy/web/controllers/dataset.py Fri Oct 03 16:06:01 2008 -0400
@@ -128,9 +128,8 @@
                 return open(file_path)
             except:
                 raise paste.httpexceptions.HTTPNotFound( "File Not Found (%s)." % (filename) )
-    
-    @web.expose
-    def undelete( self, trans, id ):
+    
+    def _undelete( self, trans, id ):
         history = trans.get_history()
         data = self.app.model.HistoryDatasetAssociation.get( id )
         if data and data.undeletable:
@@ -143,4 +142,16 @@
             data.mark_undeleted()
             self.app.model.flush()
             trans.log_event( "Dataset id %s has been undeleted" % str(id) )
+            return True
+        return False
+    
+    @web.expose
+    def undelete( self, trans, id ):
+        self._undelete( trans, id )
         return trans.response.send_redirect( web.url_for( controller='root', action='history', show_deleted = True ) )
+    
+    @web.expose
+    def undelete_async( self, trans, id ):
+        if self._undelete( trans, id ):
+            return "OK"
+        raise "Error undeleting"
diff -r 45033114f82d -r 7e2ec07716b8 templates/root/history.mako
--- a/templates/root/history.mako Thu Oct 02 16:37:32 2008 -0400
+++ b/templates/root/history.mako Fri Oct 03 16:06:01 2008 -0400
@@ -91,17 +91,41 @@
  url: "${h.url_for( action='delete_async', id='XXX' )}".replace( 'XXX', data_id ),
  error: function() { alert( "Delete failed" ) },
  success: function() {
-    q( "#historyItem-" + data_id ).fadeOut( "fast", function() {
- q( "div#historyItemContainer-" + data_id ).remove();
- if ( q( "div.historyItemContainer" ).length < 1 ) {
-    q ( "div#emptyHistoryMessage" ).show();
+     if ( "${show_deleted}" == "True" ){
+ var to_update = {};
+ to_update[data_id] = "none";
+ updater( to_update );
  }
-    });
+    else {
+     q( "#historyItem-" + data_id ).fadeOut( "fast", function() {
+ q( "div#historyItemContainer-" + data_id ).remove();
+ if ( q( "div.historyItemContainer" ).length < 1 ) {
+     q ( "div#emptyHistoryMessage" ).show();
+ }
+     });
+    }
  }
     });
     return false;
  });
     });
+            // Undelete link
+            q(this).find( "a.historyItemUndelete" ).each( function() {
+ var data_id = this.id.split( "-" )[1];
+ q(this).click( function() {
+    q( '#progress-' + data_id ).show();
+    q.ajax({
+ url: "${h.url_for( controller='dataset', action='undelete_async', id='XXX' )}".replace( 'XXX', data_id ),
+ error: function() { alert( "Undelete failed" ) },
+ success: function() {
+    var to_update = {};
+    to_update[data_id] = "none";
+    updater( to_update );
+ }
+    });
+    return false;
+ });
+ });
         });
     };
     // Looks for changes in dataset state using an async request. Keeps
@@ -143,7 +167,7 @@
                     setupHistoryItem( container.children( ".historyItemWrapper" ) );
                     initShowHide();
                     // If new state was terminal, stop tracking
-                    if (( val.state == "ok") || ( val.state == "error") || ( val.state == "empty") || ( val.state == "deleted" )) {
+                    if (( val.state == "ok") || ( val.state == "error") || ( val.state == "empty") || ( val.state == "deleted" ) || ( val.state == "discarded" )) {
                         delete tracked_datasets[ parseInt(id) ];
                     } else {
                         tracked_datasets[ parseInt(id) ] = val.state;
@@ -239,7 +263,7 @@
     %for data in reversed( datasets_to_show ):
         %if data.visible:
             <div class="historyItemContainer" id="historyItemContainer-${data.id}">
-                ${render_dataset( data, data.hid )}
+                ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted )}
             </div>
         %endif
     %endfor
diff -r 45033114f82d -r 7e2ec07716b8 templates/root/history_common.mako
--- a/templates/root/history_common.mako Thu Oct 02 16:37:32 2008 -0400
+++ b/templates/root/history_common.mako Fri Oct 03 16:06:01 2008 -0400
@@ -1,5 +1,5 @@
 ## Render the dataset `data` as history item, using `hid` as the displayed id
-<%def name="render_dataset( data, hid )">
+<%def name="render_dataset( data, hid, show_deleted_on_refresh = False )">
     <%
  if data.state in ['no state','',None]:
     data_state = "queued"
@@ -10,7 +10,7 @@
         
     %if data.deleted:
         <div class="warningmessagesmall">
-            <strong>This dataset has been deleted. Click <a href="${h.url_for( controller='dataset', action='undelete', id=data.id )}" target="galaxy_history">here</a> to undelete.</strong>
+            <strong>This dataset has been deleted. Click <a href="${h.url_for( controller='dataset', action='undelete', id=data.id )}" class="historyItemUndelete" id="historyItemUndeleter-${data.id}" target="galaxy_history">here</a> to undelete.</strong>
         </div>
     %endif
         ## Header row for history items (name, state, action buttons)
@@ -28,7 +28,7 @@
     <div style="float: right;">
     <a href="${h.url_for( controller='dataset', dataset_id=data.id, action='display', filename='index')}" target="galaxy_main"><img src="${h.url_for('/static/images/eye_icon.png')}" rollover="${h.url_for('/static/images/eye_icon_dark.png')}" width='16' height='16' alt='display data' title='display data' class='displayButton' border='0'></a>
     <a href="${h.url_for( action='edit', id=data.id )}" target="galaxy_main"><img src="${h.url_for('/static/images/pencil_icon.png')}" rollover="${h.url_for('/static/images/pencil_icon_dark.png')}" width='16' height='16' alt='edit attributes' title='edit attributes' class='editButton' border='0'></a>
-    <a href="${h.url_for( action='delete', id=data.id, show_deleted_on_refresh=show_deleted )}" class="historyItemDelete" id="historyItemDelter-${data.id}"><img src="${h.url_for('/static/images/delete_icon.png')}" rollover="${h.url_for('/static/images/delete_icon_dark.png')}" width='16' height='16' alt='delete' class='deleteButton' border='0'></a>
+    <a href="${h.url_for( action='delete', id=data.id, show_deleted_on_refresh=show_deleted_on_refresh )}" class="historyItemDelete" id="historyItemDeleter-${data.id}"><img src="${h.url_for('/static/images/delete_icon.png')}" rollover="${h.url_for('/static/images/delete_icon_dark.png')}" width='16' height='16' alt='delete' class='deleteButton' border='0'></a>
     </div>
     <span class="historyItemTitle"><b>${hid}: ${data.display_name()}</b></span>
  </div>
@@ -44,6 +44,10 @@
                 <div>
                     An error occurred running this job: <i>${data.display_info().strip()}</i>,
                     <a href="${h.url_for( controller='dataset', action='errors', id=data.id )}" target="galaxy_main">report this error</a>
+                </div>
+            %elif data_state == "discarded":
+                <div>
+                    The job creating this dataset was cancelled before completion.
                 </div>
             %elif data_state == "empty":
                 <div>No data: <i>${data.display_info()}</i></div>
@@ -95,7 +99,7 @@
                     <div>
                         There are ${len( children )} secondary datasets.
                         %for idx, child in enumerate(children):
-                            ${render_dataset( child, idx + 1 )}
+                            ${render_dataset( child, idx + 1, show_deleted_on_refresh = show_deleted_on_refresh )}
                         %endfor
                     </div>
                 %endif
diff -r 45033114f82d -r 7e2ec07716b8 templates/root/history_item.mako
--- a/templates/root/history_item.mako Thu Oct 02 16:37:32 2008 -0400
+++ b/templates/root/history_item.mako Fri Oct 03 16:06:01 2008 -0400
@@ -1,8 +1,3 @@
 <%namespace file="history_common.mako" import="render_dataset" />
 
-## this is necessary because this dataset remains in history.active_datasets
-## after deletion, until the history is reloaded
-## FIXME: still necessary now that we don't re-pull finished datasets?  test.
-%if data.deleted is not True:
-    ${render_dataset( data, hid )}    
-%endif
\ No newline at end of file
+${render_dataset( data, hid )}