Edit attributes: HDA name, info, annotation: display 'None' values in inputs as empty strings; History panel: remove last modal/alert

This commit is contained in:
Carl Eberhard
2013-04-10 12:22:11 -04:00
parent 73a4e9ded6
commit b1c3cb55ff
6 changed files with 19 additions and 12 deletions
@@ -388,8 +388,8 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesHistoryMixin, Use
error = True
elif params.save:
# The user clicked the Save button on the 'Edit Attributes' form
data.name = params.name
data.info = params.info
data.name = params.name if params.name else ''
data.info = params.info if params.info else ''
message = ''
if __ok_to_edit_metadata( data.id ):
# The following for loop will save all metadata_spec items
@@ -1350,9 +1350,11 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI
@web.json
def get_display_application_links( self, trans, hda_ids=None ):
"""Returns external display application JSON data for all/given
"""
Returns external display application JSON data for all/given
HDAs within the current history.
"""
#TODO: fold into API and remove
try:
history = trans.get_history()
#TODO: allow id for more flexibility? (the following doesn't work if anonymous...)
@@ -1363,7 +1365,7 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI
hdas = self.get_history_datasets( trans, history, show_deleted=False, show_hidden=True, show_purged=False )
except Exception, exc:
log.error( 'Error get_display_application_links (%s): %s', hda_ids, str( exc ) )
log.error( 'Failed loading data for ids (%s): %s', hda_ids, str( exc ), exc_info=True )
trans.response.status = 500
return str( exc )
@@ -1384,10 +1386,12 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI
hda_link_data[ 'display_apps' ] = self.get_display_apps( trans, hda )
except Exception, exc:
log.error( 'Error getting display applications, hda (%s): %s', hda_link_data[ 'id' ], str( exc ) )
log.error( 'Failed getting links, hda (%s): %s', hda_link_data[ 'id' ], str( exc ), exc_info=True )
hda_link_data[ 'error' ] = str( exc )
hda_display_links.append( hda_link_data )
# send 'do not cache' headers to handle IE's caching of ajax get responses
trans.response.headers[ 'Cache-Control' ] = "max-age=0,no-cache,no-store"
trans.response.set_content_type( 'application/json' )
return hda_display_links
+4 -4
View File
@@ -284,10 +284,10 @@ var History = BaseModel.extend( LoggableMixin ).extend(
},
error : function( xhr, status, error ){
if( !( ( xhr.readyState === 0 ) && ( xhr.status === 0 ) ) ){
var msg = 'Error fetching display applications, ' + ids + ':' + ( xhr.responseText || error );
Galaxy.show_modal( 'History panel error',
msg, { 'Ok': function(){ Galaxy.hide_modal(); } });
this.log( msg );
history.log( 'Error fetching display applications:', ids, xhr, status, error );
var msg = _l( 'An error occurred while getting display applications from the server.' ) + ' '
+ _l( 'Please contact a Galaxy administrator if the problem persists.' );
history.trigger( 'error', msg, xhr, status, error );
}
}
});
@@ -1 +1 @@
var History=BaseModel.extend(LoggableMixin).extend({defaults:{id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:"api/histories/",url:function(){return this.urlRoot+this.get("id")},initialize:function(b,c,a){a=a||null;this.log(this+".initialize:",b,c);this.hdas=new HDACollection();if(c&&_.isArray(c)){this.hdas.reset(c);this.checkForUpdates();if(this.hdas.length>0){this.updateDisplayApplications()}}this.hdas.bind("state:ready",function(e,g,d){if(e.get("force_history_refresh")){var f=this;setTimeout(function(){f.stateUpdater()},History.UPDATE_DELAY)}},this);if(this.logger){this.bind("all",function(d){this.log(this+"",arguments)},this)}},hdaIdsFromStateIds:function(){return _.reduce(_.values(this.get("state_ids")),function(b,a){return b.concat(a)})},checkForUpdates:function(){if(this.hdas.running().length){this.stateUpdater()}else{this.trigger("ready")}return this},stateUpdater:function(){var c=this,a=this.get("state"),b=this.get("state_ids");jQuery.ajax("api/histories/"+this.get("id")).success(function(d){c.set(d);c.log("current history state:",c.get("state"),"(was)",a,"new size:",c.get("nice_size"));var e=[];_.each(_.keys(d.state_ids),function(g){var f=_.difference(d.state_ids[g],b[g]);e=e.concat(f)});if(e.length){c.fetchHdaUpdates(e)}if((c.get("state")===HistoryDatasetAssociation.STATES.RUNNING)||(c.get("state")===HistoryDatasetAssociation.STATES.QUEUED)){setTimeout(function(){c.stateUpdater()},History.UPDATE_DELAY)}else{c.trigger("ready")}}).error(function(g,d,e){if(g.status===502){setTimeout(function(){c.log("Bad Gateway error. Retrying...");c.stateUpdater()},History.UPDATE_DELAY)}else{if(!((g.readyState===0)&&(g.status===0))){c.log("stateUpdater error:",e,"responseText:",g.responseText);var f=_l("An error occurred while getting updates from the server.")+" "+_l("Please contact a Galaxy administrator if the problem persists.");c.trigger("error",f,g,d,e)}}})},fetchHdaUpdates:function(b){var a=this;jQuery.ajax({url:this.url()+"/contents?"+jQuery.param({ids:b.join(",")}),error:function(h,c,d){if((h.readyState===0)&&(h.status===0)){return}var f=JSON.parse(h.responseText);if(_.isArray(f)){var e=_.groupBy(f,function(i){if(_.has(i,"error")){return"errored"}return"ok"});a.log("fetched, errored datasets:",e.errored);a.updateHdas(f)}else{a.log("Error updating hdas from api history contents",b,h,c,d,f);var g=_l("An error occurred while getting dataset details from the server.")+" "+_l("Please contact a Galaxy administrator if the problem persists.");a.trigger("error",g,h,c,d)}},success:function(d,c,e){a.log(a+".fetchHdaUpdates, success:",c,e);a.updateHdas(d)}})},updateHdas:function(a){var c=this,b=[];c.log(c+".updateHdas:",a);_.each(a,function(e,f){var d=c.hdas.get(e.id);if(d){c.log("found existing model in list for id "+e.id+", updating...:");d.set(e)}else{c.log("NO existing model for id "+e.id+", creating...:");b.push(e)}});if(b.length){c.addHdas(b)}},addHdas:function(a){var b=this;_.each(a,function(c,d){var e=b.hdas.hidToCollectionIndex(c.hid);c.history_id=b.get("id");b.hdas.add(new HistoryDatasetAssociation(c),{at:e,silent:true})});b.hdas.trigger("add",a)},updateDisplayApplications:function(a){this.log(this+"updateDisplayApplications:",a);var c=this,b=(a&&_.isArray(a))?({hda_ids:a.join(",")}):({});c.log(this+": fetching display application data");jQuery.ajax("history/get_display_application_links",{data:b,success:function(e,d,f){c.hdas.set(e)},error:function(g,d,e){if(!((g.readyState===0)&&(g.status===0))){var f="Error fetching display applications, "+a+":"+(g.responseText||e);Galaxy.show_modal("History panel error",f,{Ok:function(){Galaxy.hide_modal()}});this.log(f)}}})},toString:function(){var a=(this.get("name"))?(","+this.get("name")):("");return"History("+this.get("id")+a+")"}});History.UPDATE_DELAY=4000;var HistoryCollection=Backbone.Collection.extend(LoggableMixin).extend({model:History,urlRoot:"api/histories"});
var History=BaseModel.extend(LoggableMixin).extend({defaults:{id:null,name:"Unnamed History",state:"new",diskSize:0,deleted:false},urlRoot:"api/histories/",url:function(){return this.urlRoot+this.get("id")},initialize:function(b,c,a){a=a||null;this.log(this+".initialize:",b,c);this.hdas=new HDACollection();if(c&&_.isArray(c)){this.hdas.reset(c);this.checkForUpdates();if(this.hdas.length>0){this.updateDisplayApplications()}}this.hdas.bind("state:ready",function(e,g,d){if(e.get("force_history_refresh")){var f=this;setTimeout(function(){f.stateUpdater()},History.UPDATE_DELAY)}},this);if(this.logger){this.bind("all",function(d){this.log(this+"",arguments)},this)}},hdaIdsFromStateIds:function(){return _.reduce(_.values(this.get("state_ids")),function(b,a){return b.concat(a)})},checkForUpdates:function(){if(this.hdas.running().length){this.stateUpdater()}else{this.trigger("ready")}return this},stateUpdater:function(){var c=this,a=this.get("state"),b=this.get("state_ids");jQuery.ajax("api/histories/"+this.get("id")).success(function(d){c.set(d);c.log("current history state:",c.get("state"),"(was)",a,"new size:",c.get("nice_size"));var e=[];_.each(_.keys(d.state_ids),function(g){var f=_.difference(d.state_ids[g],b[g]);e=e.concat(f)});if(e.length){c.fetchHdaUpdates(e)}if((c.get("state")===HistoryDatasetAssociation.STATES.RUNNING)||(c.get("state")===HistoryDatasetAssociation.STATES.QUEUED)){setTimeout(function(){c.stateUpdater()},History.UPDATE_DELAY)}else{c.trigger("ready")}}).error(function(g,d,e){if(g.status===502){setTimeout(function(){c.log("Bad Gateway error. Retrying...");c.stateUpdater()},History.UPDATE_DELAY)}else{if(!((g.readyState===0)&&(g.status===0))){c.log("stateUpdater error:",e,"responseText:",g.responseText);var f=_l("An error occurred while getting updates from the server.")+" "+_l("Please contact a Galaxy administrator if the problem persists.");c.trigger("error",f,g,d,e)}}})},fetchHdaUpdates:function(b){var a=this;jQuery.ajax({url:this.url()+"/contents?"+jQuery.param({ids:b.join(",")}),error:function(h,c,d){if((h.readyState===0)&&(h.status===0)){return}var f=JSON.parse(h.responseText);if(_.isArray(f)){var e=_.groupBy(f,function(i){if(_.has(i,"error")){return"errored"}return"ok"});a.log("fetched, errored datasets:",e.errored);a.updateHdas(f)}else{a.log("Error updating hdas from api history contents",b,h,c,d,f);var g=_l("An error occurred while getting dataset details from the server.")+" "+_l("Please contact a Galaxy administrator if the problem persists.");a.trigger("error",g,h,c,d)}},success:function(d,c,e){a.log(a+".fetchHdaUpdates, success:",c,e);a.updateHdas(d)}})},updateHdas:function(a){var c=this,b=[];c.log(c+".updateHdas:",a);_.each(a,function(e,f){var d=c.hdas.get(e.id);if(d){c.log("found existing model in list for id "+e.id+", updating...:");d.set(e)}else{c.log("NO existing model for id "+e.id+", creating...:");b.push(e)}});if(b.length){c.addHdas(b)}},addHdas:function(a){var b=this;_.each(a,function(c,d){var e=b.hdas.hidToCollectionIndex(c.hid);c.history_id=b.get("id");b.hdas.add(new HistoryDatasetAssociation(c),{at:e,silent:true})});b.hdas.trigger("add",a)},updateDisplayApplications:function(a){this.log(this+"updateDisplayApplications:",a);var c=this,b=(a&&_.isArray(a))?({hda_ids:a.join(",")}):({});c.log(this+": fetching display application data");jQuery.ajax("history/get_display_application_links",{data:b,success:function(e,d,f){c.hdas.set(e)},error:function(g,d,e){if(!((g.readyState===0)&&(g.status===0))){c.log("Error fetching display applications:",a,g,d,e);var f=_l("An error occurred while getting display applications from the server.")+" "+_l("Please contact a Galaxy administrator if the problem persists.");c.trigger("error",f,g,d,e)}}})},toString:function(){var a=(this.get("name"))?(","+this.get("name")):("");return"History("+this.get("id")+a+")"}});History.UPDATE_DELAY=4000;var HistoryCollection=Backbone.Collection.extend(LoggableMixin).extend({model:History,urlRoot:"api/histories"});
@@ -58,7 +58,8 @@
Info:
</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="info" cols="40" rows="2">${ util.unicodify( data.info ) | h}</textarea>
<% info = data.info if data.info else '' %>
<textarea name="info" cols="40" rows="2">${ util.unicodify( info ) | h}</textarea>
</div>
<div style="clear: both"></div>
</div>
@@ -68,7 +69,8 @@
Annotation / Notes:
</label>
<div style="float: left; width: 250px; margin-right: 10px;">
<textarea name="annotation" cols="40" rows="2">${data_annotation | h}</textarea>
<% annotation = data_annotation if data_annotation else '' %>
<textarea name="annotation" cols="40" rows="2">${annotation | h}</textarea>
</div>
<div style="clear: both"></div>
<div class="toolParamHelp">Add an annotation or notes to a dataset; annotations are available when a history is viewed.</div>
@@ -446,6 +446,7 @@ $(function(){
}
#message-container [class$="message"] {
margin: 8px 0 0 0;
cursor: pointer;
}
/*---- history level */