Skip to content

Commit

Permalink
UI, Histories: move unhide_datasets and delete_hidden_datasets to the…
Browse files Browse the repository at this point in the history
… client, remove them from the web controller
  • Loading branch information
carlfeberhard committed Jul 30, 2015
1 parent ed29f74 commit bf8d74d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 53 deletions.
18 changes: 15 additions & 3 deletions client/galaxy/scripts/mvc/history/history-contents.js
Expand Up @@ -134,13 +134,25 @@ var HistoryContents = Backbone.Collection.extend( BASE_MVC.LoggableMixin ).exten
return item.isVisible( show_deleted, show_hidden );
}));

_.each( filters, function( filter_fn ){
if( !_.isFunction( filter_fn ) ){ return; }
filteredHdas = new HistoryContents( filteredHdas.filter( filter_fn ) );
_.each( filters, function( filterFn ){
if( !_.isFunction( filterFn ) ){ return; }
filteredHdas = new HistoryContents( filteredHdas.filter( filterFn ) );
});
return filteredHdas;
},

/** return a new contents collection of only hidden items */
hidden : function(){
function filterFn( c ){ return c.hidden(); }
return new HistoryContents( this.filter( filterFn ) );
},

/** return a new contents collection of only hidden items */
deleted : function(){
function filterFn( c ){ return c.get( 'deleted' ); }
return new HistoryContents( this.filter( filterFn ) );
},

/** return true if any contents don't have details */
haveDetails : function(){
return this.all( function( content ){ return content.hasDetails(); });
Expand Down
36 changes: 30 additions & 6 deletions client/galaxy/scripts/mvc/history/options-menu.js
Expand Up @@ -66,15 +66,39 @@ var menu = [
},
{
html : _l( 'Unhide Hidden Datasets' ),
confirm : _l( 'Really unhide all hidden datasets?' ),
href : 'history/unhide_datasets?current=True',
anon : true
anon : true,
func : function() {
if( Galaxy && Galaxy.currHistoryPanel && confirm( _l( 'Really unhide all hidden datasets?' ) ) ){
var filtered = Galaxy.currHistoryPanel.model.contents.hidden();
//TODO: batch
filtered.ajaxQueue( Backbone.Model.prototype.save, { visible : true })
.done( function(){
Galaxy.currHistoryPanel.render();
})
.fail( function(){
alert( 'There was an error unhiding the datasets' );
console.error( arguments );
});
}
}
},
{
html : _l( 'Delete Hidden Datasets' ),
confirm : _l( 'Really delete all hidden datasets?' ),
href : 'history/delete_hidden_datasets',
anon : true
anon : true,
func : function() {
if( Galaxy && Galaxy.currHistoryPanel && confirm( _l( 'Really delete all hidden datasets?' ) ) ){
var filtered = Galaxy.currHistoryPanel.model.contents.hidden();
//TODO: batch
filtered.ajaxQueue( Backbone.Model.prototype.save, { deleted : true })
.done( function(){
Galaxy.currHistoryPanel.render();
})
.fail( function(){
alert( 'There was an error deleting the datasets' );
console.error( arguments );
});
}
}
},
{
html : _l( 'Purge Deleted Datasets' ),
Expand Down
46 changes: 6 additions & 40 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Expand Up @@ -1075,21 +1075,6 @@ def _share_histories( self, trans, user, send_to_err, histories=None ):
return self.sharing( trans, histories=shared_histories, msg=msg )

# ......................................................................... actions/orig. async
@web.expose
def delete_hidden_datasets( self, trans ):
"""
This method deletes all hidden datasets in the current history.
"""
count = 0
for hda in trans.history.datasets:
if not hda.visible and not hda.deleted and not hda.purged:
hda.mark_deleted()
count += 1
trans.sa_session.add( hda )
trans.log_event( "HDA id %s has been deleted" % hda.id )
trans.sa_session.flush()
return trans.show_ok_message( "%d hidden datasets have been deleted" % count, refresh_frames=['history'] )

@web.expose
def purge_deleted_datasets( self, trans ):
count = 0
Expand Down Expand Up @@ -1163,21 +1148,6 @@ def delete_current( self, trans, purge=False ):
trans.get_or_create_default_history()
return trans.show_ok_message( "History deleted, a new history is active", refresh_frames=['history'] )

@web.expose
def unhide_datasets( self, trans, current=False, ids=None ):
"""Unhide the datasets in the active history -- this does not require a logged in user."""
if not ids and galaxy.util.string_as_bool( current ):
histories = [ trans.get_history() ]
refresh_frames = ['history']
else:
raise NotImplementedError( "You can currently only unhide all the datasets of the current history." )
for history in histories:
history.unhide_datasets()
trans.sa_session.add( history )
trans.sa_session.flush()
return trans.show_ok_message( "Your datasets have been unhidden.", refresh_frames=refresh_frames )
# TODO: used in index.mako

@web.expose
def resume_paused_jobs( self, trans, current=False, ids=None ):
"""Resume paused jobs the active history -- this does not require a logged in user."""
Expand Down Expand Up @@ -1495,8 +1465,8 @@ def copy( self, trans, id=None, **kwd ):
@web.expose
@web.require_login( "switch to a history" )
def switch_to_history( self, trans, hist_id=None ):
"""
"""
"""Change the current user's current history to one with `hist_id`."""
# remains for backwards compat
self.set_as_current( trans, id=hist_id )
return trans.response.send_redirect( url_for( "/" ) )

Expand All @@ -1505,16 +1475,14 @@ def get_item( self, trans, id ):
# TODO: override of base ui controller?

def history_data( self, trans, history ):
"""
"""
"""Return the given history in a serialized, dictionary form."""
return self.history_serializer.serialize_to_view( history, view='detailed', user=trans.user, trans=trans )

# TODO: combine these next two - poss. with a redirect flag
# @web.require_login( "switch to a history" )
@web.json
def set_as_current( self, trans, id ):
"""
"""
"""Change the current user's current history to one with `id`."""
try:
history = self.history_manager.get_owned( self.decode_id( id ), trans.user, current_history=trans.history )
trans.set_history( history )
Expand All @@ -1525,15 +1493,13 @@ def set_as_current( self, trans, id ):

@web.json
def current_history_json( self, trans ):
"""
"""
"""Return the current user's current history in a serialized, dictionary form."""
history = trans.get_history( create=True )
return self.history_serializer.serialize_to_view( history, view='detailed', user=trans.user, trans=trans )

@web.json
def create_new_current( self, trans, name=None ):
"""
"""
"""Create a new, current history for the current user"""
new_history = trans.new_history( name )
return self.history_serializer.serialize_to_view( new_history, view='detailed', user=trans.user, trans=trans )
# TODO: /history/current to do all of the above: if ajax, return json; if post, read id and set to current
2 changes: 1 addition & 1 deletion static/maps/mvc/history/history-contents.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf8d74d

Please sign in to comment.