2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/79c884befb23/ changeset: 79c884befb23 user: carlfeberhard date: 2012-11-06 20:07:21 summary: quota meter: fix multiple api calls on first history render; controllers/root.py: set up to move show_deleted/hidden into client affected #: 5 files diff -r 5dcbbdfe1087e8d75f1df939d363b347e2764dd5 -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b lib/galaxy/webapps/galaxy/controllers/root.py --- a/lib/galaxy/webapps/galaxy/controllers/root.py +++ b/lib/galaxy/webapps/galaxy/controllers/root.py @@ -116,13 +116,23 @@ show_deleted=util.string_as_bool( show_deleted ), show_hidden=util.string_as_bool( show_hidden ) ) else: - show_deleted = show_purged = util.string_as_bool( show_deleted ) + show_deleted = util.string_as_bool( show_deleted ) show_hidden = util.string_as_bool( show_hidden ) - datasets = self.get_history_datasets( trans, history, show_deleted, show_hidden, show_purged ) + show_purged = util.string_as_bool( show_deleted ) + datasets = [] history_panel_template = "root/history.mako" - # history panel -> backbone - #history_panel_template = "root/alternate_history.mako" + + # history panel -> backbone (WIP - uncomment next to use) + #USE_ALTERNATE = True + if 'USE_ALTERNATE' in locals(): + datasets = self.get_history_datasets( trans, history, + show_deleted=True, show_hidden=True, show_purged=True ) + history_panel_template = "root/alternate_history.mako" + + else: + datasets = self.get_history_datasets( trans, history, show_deleted, show_hidden, show_purged ) + return trans.stream_template_mako( history_panel_template, history = history, annotation = self.get_item_annotation_str( trans.sa_session, trans.user, history ), diff -r 5dcbbdfe1087e8d75f1df939d363b347e2764dd5 -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b static/scripts/mvc/history.js --- a/static/scripts/mvc/history.js +++ b/static/scripts/mvc/history.js @@ -27,7 +27,7 @@ bug: quotaMeter bar rendering square in chrome BUG: quotaMsg not showing when 100% (on load) BUG: upload, history size, doesn't change - TODO: on hdas state:final, update ONLY the size...from what? histories.py? in js? + TODO: on hdas state:ready, update ONLY the size...from what? histories.py? in js? BUG: imported, shared history with unaccessible dataset errs in historycontents when getting history (entire history is inaccessible) ??: still happening? @@ -41,7 +41,7 @@ bug: loading hdas (alt_hist) FIXED: added anon user api request ( trans.user == None and trans.history.id == requested id ) bug: quota meter not updating on upload/tool run - FIXED: quotaMeter now listens for 'state:final' from glx_history in alternate_history.mako + FIXED: quotaMeter now listens for 'state:ready' from glx_history in alternate_history.mako bug: use of new HDACollection with event listener in init doesn't die...keeps reporting FIXED: change getVisible to return an array BUG: history, broken intial hist state (running, updater, etc.) @@ -134,6 +134,7 @@ // array of associated file types (eg. [ 'bam_index', ... ]) meta_files : [], + misc_blurb : '', misc_info : '', @@ -155,25 +156,32 @@ }, // (curr) only handles changing state of non-accessible hdas to STATES.NOT_VIEWABLE - //TODO: use initialize (or validate) to check purged AND deleted -> purged XOR deleted + //TODO:? use initialize (or validate) to check purged AND deleted -> purged XOR deleted initialize : function(){ this.log( this + '.initialize', this.attributes ); this.log( '\tparent history_id: ' + this.get( 'history_id' ) ); - //!! this state is not in trans.app.model.Dataset.states - set it here + //!! this state is not in trans.app.model.Dataset.states - set it here - + //TODO: change to server side. if( !this.get( 'accessible' ) ){ this.set( 'state', HistoryDatasetAssociation.STATES.NOT_VIEWABLE ); } + // if the state has changed and the new state is a ready state, fire an event + this.on( 'change:state', function( currModel, newState ){ + this.log( this + ' has changed state:', currModel, newState ); + if( this.inReadyState() ){ + this.trigger( 'state:ready', this.get( 'id' ), newState, this.previous( 'state' ), currModel ); + } + }); + + // debug on change events //this.on( 'change', function( currModel, changedList ){ // this.log( this + ' has changed:', currModel, changedList ); //}); - this.on( 'change:state', function( currModel, newState ){ - this.log( this + ' has changed state:', currModel, newState ); - if( this.inFinalState() ){ - this.trigger( 'state:final', currModel, newState, this.previous( 'state' ) ); - } - }); + //this.bind( 'all', function( event ){ + // this.log( this + '', arguments ); + //}); }, isDeletedOrPurged : function(){ @@ -195,8 +203,8 @@ return isVisible; }, - // 'final' states are states where no processing (for the ds) is left to do on the server - inFinalState : function(){ + // 'ready' states are states where no processing (for the ds) is left to do on the server + inReadyState : function(){ var state = this.get( 'state' ); return ( ( state === HistoryDatasetAssociation.STATES.NEW ) @@ -248,8 +256,8 @@ //logger : console, initialize : function(){ - //this.bind( 'all', function( x, y, z ){ - // console.info( this + '', x, y, z ); + //this.bind( 'all', function( event ){ + // this.log( this + '', arguments ); //}); }, @@ -276,11 +284,11 @@ return stateLists; }, - // returns the id of every hda still running (not in a final state) + // returns the id of every hda still running (not in a ready state) running : function(){ var idList = []; this.each( function( item ){ - if( !item.inFinalState() ){ + if( !item.inReadyState() ){ idList.push( item.get( 'id' ) ); } }); @@ -354,6 +362,9 @@ //this.on( 'change', function( currModel, changedList ){ // this.log( this + ' has changed:', currModel, changedList ); //}); + //this.bind( 'all', function( event ){ + // this.log( this + '', arguments ); + //}); }, // get data via the api (alternative to sending options,hdas to initialize) @@ -419,7 +430,9 @@ ).success( function( response ){ //this.log( 'historyApiRequest, response:', response ); history.set( response ); - history.log( 'current history state:', history.get( 'state' ), '(was)', oldState ); + history.log( 'current history state:', history.get( 'state' ), + '(was)', oldState, + 'new size:', history.get( 'nice_size' ) ); //TODO: revisit this - seems too elaborate, need something straightforward // for each state, check for the difference between old dataset states and new @@ -484,6 +497,9 @@ // re-render the entire view on any model change this.model.bind( 'change', this.render, this ); + //this.bind( 'all', function( event ){ + // this.log( event ); + //}, this ); }, // urlTemplates is a map (or nested map) of underscore templates (currently, anyhoo) @@ -525,7 +541,10 @@ var view = this, id = this.model.get( 'id' ), state = this.model.get( 'state' ), - itemWrapper = $( '<div/>' ).attr( 'id', 'historyItem-' + id ); + itemWrapper = $( '<div/>' ).attr( 'id', 'historyItem-' + id ), + initialRender = ( this.$el.children().size() === 0 ); + + //console.debug( this + '.render, initial?:', initialRender ); this._clearReferences(); this.$el.attr( 'id', 'historyItemContainer-' + id ); @@ -551,10 +570,14 @@ view.$el.children().remove(); view.$el.append( itemWrapper ).fadeIn( 'fast', function(){ view.log( view + ' rendered:', view.$el ); - view.trigger( 'rendered' ); - if( view.model.inFinalState() ){ - view.trigger( 'rendered:final' ); + var renderedEventName = 'rendered'; + + if( initialRender ){ + renderedEventName += ':initial'; + } else if( view.model.inReadyState() ){ + renderedEventName += ':ready'; } + view.trigger( renderedEventName ); }); }); return this; @@ -610,8 +633,8 @@ // icon-button to display this hda in the galaxy main iframe _render_displayButton : function(){ - // don't show display if not in final state, error'd, or not accessible - if( ( !this.model.inFinalState() ) + // don't show display if not in ready state, error'd, or not accessible + if( ( !this.model.inReadyState() ) || ( this.model.get( 'state' ) === HistoryDatasetAssociation.STATES.ERROR ) || ( this.model.get( 'state' ) === HistoryDatasetAssociation.STATES.NOT_VIEWABLE ) || ( !this.model.get( 'accessible' ) ) ){ @@ -1335,13 +1358,18 @@ { expandedHdas : {} } ); + // bind events from the model's hda collection //this.model.bind( 'change', this.render, this ); + this.model.bind( 'change:nice_size', this.updateHistoryDiskSize, this ); - // bind events from the model's hda collection this.model.hdas.bind( 'add', this.add, this ); this.model.hdas.bind( 'reset', this.addAll, this ); this.model.hdas.bind( 'all', this.all, this ); + //this.bind( 'all', function(){ + // this.log( arguments ); + //}, this ); + // set up instance vars this.hdaViews = {}; this.urls = {}; @@ -1379,7 +1407,10 @@ var historyView = this, setUpQueueName = historyView.toString() + '.set-up', newRender = $( '<div/>' ), - modelJson = this.model.toJSON(); + modelJson = this.model.toJSON(), + initialRender = ( this.$el.children().size() === 0 ); + + //console.debug( this + '.render, initialRender:', initialRender ); // render the urls and add them to the model json modelJson.urls = this.renderUrls( modelJson ); @@ -1389,7 +1420,7 @@ newRender.append( HistoryView.templates.historyPanel( modelJson ) ); newRender.find( '.tooltip' ).tooltip(); - // render hda views (if any) + // render hda views (if any and any shown (show_deleted/hidden) if( !this.model.hdas.length || !this.renderItems( newRender.find( '#' + this.model.get( 'id' ) + '-datasets' ) ) ){ // if history is empty or no hdas would be rendered, show the empty message @@ -1413,7 +1444,12 @@ //TODO: ideally, these would be set up before the fade in (can't because of async save text) historyView.setUpBehaviours(); - historyView.trigger( 'rendered' ); + if( initialRender ){ + historyView.trigger( 'rendered:initial' ); + + } else { + historyView.trigger( 'rendered' ); + } next(); }); $( historyView ).dequeue( setUpQueueName ); @@ -1459,8 +1495,7 @@ }); // rendering listeners - //hdaView.bind( 'rendered', function(){}); - hdaView.bind( 'rendered:final', function(){ historyView.trigger( 'hda:rendered:final' ); }); + hdaView.bind( 'rendered:ready', function(){ historyView.trigger( 'hda:rendered:ready' ); }); }, // set up js/widget behaviours: tooltips, @@ -1488,6 +1523,11 @@ async_save_text( "history-annotation-container", "history-annotation", this.urls.annotate, "new_annotation", 18, true, 4 ); }, + + // update the history size display (curr. upper right of panel) + updateHistoryDiskSize : function(){ + this.$el.find( '#history-size' ).text( this.model.get( 'nice_size' ) ); + }, //TODO: this seems more like a per user message than a history message; IOW, this doesn't belong here showQuotaMessage : function( userData ){ diff -r 5dcbbdfe1087e8d75f1df939d363b347e2764dd5 -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b static/scripts/mvc/user/user-model.js --- a/static/scripts/mvc/user/user-model.js +++ b/static/scripts/mvc/user/user-model.js @@ -22,9 +22,9 @@ options = options || {}; var model = this, userFn = options.success; - options.success = function( model, response ){ - model.trigger( 'loaded', model, response ); - if( userFn ){ userFn( model, response ); } + options.success = function( newModel, response ){ + model.trigger( 'loaded', newModel, response ); + if( userFn ){ userFn( newModel, response ); } }; if( idOrCurrent === User.CURRENT_ID_STR ){ options.url = this.urlRoot + '/' + User.CURRENT_ID_STR; @@ -41,14 +41,18 @@ return 'User(' + userInfo.join( ':' ) + ')'; } }); + +// string to send to tell server to return this transaction's user (see api/users.py) User.CURRENT_ID_STR = 'current'; +// class method to load the current user via the api and return that model User.getCurrentUserFromApi = function( options ){ var currentUser = new User(); currentUser.loadFromApi( User.CURRENT_ID_STR, options ); return currentUser; }; +// (stub) collection for users (shouldn't be common unless admin UI) var UserCollection = Backbone.Collection.extend( LoggableMixin ).extend({ model : User, logger : console, diff -r 5dcbbdfe1087e8d75f1df939d363b347e2764dd5 -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b static/scripts/mvc/user/user-quotameter.js --- a/static/scripts/mvc/user/user-quotameter.js +++ b/static/scripts/mvc/user/user-quotameter.js @@ -5,7 +5,7 @@ // for now, keep the view in the history panel (where the message is), but render ALSO to the masthead var UserQuotaMeter = BaseView.extend( LoggableMixin ).extend({ - logger : console, + //logger : console, options : { warnAtPercent : 85, diff -r 5dcbbdfe1087e8d75f1df939d363b347e2764dd5 -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b templates/root/alternate_history.mako --- a/templates/root/alternate_history.mako +++ b/templates/root/alternate_history.mako @@ -251,9 +251,9 @@ var user = ${ get_current_user() }, history = ${ get_history( history.id ) }, hdas = ${ get_hdas( history.id, datasets ) }; - console.debug( 'user:', user ); - console.debug( 'history:', history ); - console.debug( 'hdas:', hdas ); + //console.debug( 'user:', user ); + //console.debug( 'history:', history ); + //console.debug( 'hdas:', hdas ); // i don't like this relationship, but user authentication changes views/behaviour history.user = user; @@ -296,10 +296,12 @@ glx_history_view.showQuotaMessage(); } }); + //TODO: this _is_ sent to the page (over_quota)... - // update the quota meter when any hda reaches a 'final' state - //NOTE: use an anon function or update will be passed the hda and think it's the options param - glx_history_view.on( 'hda:rendered:final', function(){ window.quotaMeter.update({}) }, window.quotaMeter ) + // update the quota meter when current history changes size + glx_history.bind( 'change:nice_size', function(){ + window.quotaMeter.update() + }, window.quotaMeter ); if( console && console.debug ){ https://bitbucket.org/galaxy/galaxy-central/changeset/3d27b35e1c1f/ changeset: 3d27b35e1c1f user: carlfeberhard date: 2012-11-06 20:09:40 summary: pack scripts affected #: 7 files diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/mvc/history.js --- a/static/scripts/packed/mvc/history.js +++ b/static/scripts/packed/mvc/history.js @@ -1,1 +1,1 @@ -var HistoryDatasetAssociation=BaseModel.extend(LoggableMixin).extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",hid:0,id:null,name:"",state:"",data_type:null,file_size:0,meta_files:[],misc_blurb:"",misc_info:"",deleted:false,purged:false,visible:false,accessible:false,for_editing:true},url:function(){return"api/histories/"+this.get("history_id")+"/contents/"+this.get("id")},initialize:function(){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",HistoryDatasetAssociation.STATES.NOT_VIEWABLE)}this.on("change",function(b,a,d,c){this.log(this+" has changed:",b,a,d,c)})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},isEditable:function(){return(!this.isDeletedOrPurged())},isVisible:function(b,c){var a=true;if((!b)&&(this.get("deleted")||this.get("purged"))){a=false}if((!c)&&(!this.get("visible"))){a=false}return a},inFinalState:function(){return((this.get("state")===HistoryDatasetAssociation.STATES.OK)||(this.get("state")===HistoryDatasetAssociation.STATES.FAILED_METADATA)||(this.get("state")===HistoryDatasetAssociation.STATES.EMPTY)||(this.get("state")===HistoryDatasetAssociation.STATES.ERROR))},hasData:function(){return(this.get("file_size")>0)},toString:function(){var a=this.get("id")||"";if(this.get("name")){a+=':"'+this.get("name")+'"'}return"HistoryDatasetAssociation("+a+")"}});HistoryDatasetAssociation.STATES={NOT_VIEWABLE:"noPermission",NEW:"new",UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",OK:"ok",EMPTY:"empty",ERROR:"error",DISCARDED:"discarded",SETTING_METADATA:"setting_metadata",FAILED_METADATA:"failed_metadata"};var HDACollection=Backbone.Collection.extend(LoggableMixin).extend({model:HistoryDatasetAssociation,logger:console,ids:function(){return this.map(function(a){return a.id})},getVisible:function(a,b){return new HDACollection(this.filter(function(c){return c.isVisible(a,b)}))},getStateLists:function(){var a={};_.each(_.values(HistoryDatasetAssociation.STATES),function(b){a[b]=[]});this.each(function(b){a[b.get("state")].push(b.get("id"))});return a},update:function(a){this.log(this+"update:",a);if(!(a&&a.length)){return}var b=this;_.each(a,function(e,c){var d=b.get(e);d.fetch()})},toString:function(){return("HDACollection("+this.ids().join(",")+")")}});var History=BaseModel.extend(LoggableMixin).extend({defaults:{id:"",name:"",state:"",show_deleted:false,show_hidden:false,diskSize:0,deleted:false,tags:[],annotation:null,message:null,quotaMsg:false},url:function(){return"api/histories/"+this.get("id")},initialize:function(a,b){this.log(this+".initialize:",a,b);this.hdas=new HDACollection();if(b&&b.length){this.hdas.reset(b);this.checkForUpdates()}this.on("change",function(d,c,f,e){this.log(this+" has changed:",d,c,f,e)})},loadFromAPI:function(a,c){var b=this;b.attributes.id=a;jQuery.when(jQuery.ajax("api/users/current"),b.fetch()).then(function(e,d){b.attributes.user=e[0];b.log(b)}).then(function(){jQuery.ajax(b.url()+"/contents?"+jQuery.param({ids:b.itemIdsFromStateIds().join(",")})).success(function(d){b.hdas.reset(d);b.checkForUpdates();c()})})},hdaIdsFromStateIds:function(){return _.reduce(_.values(this.get("state_ids")),function(b,a){return b.concat(a)})},checkForUpdates:function(a){this.stateFromStateIds();if((this.get("state")===HistoryDatasetAssociation.STATES.RUNNING)||(this.get("state")===HistoryDatasetAssociation.STATES.QUEUED)){this.stateUpdater()}return this},stateFromStateIds:function(){var a=this.hdas.getStateLists();this.attributes.state_ids=a;if((a.running.length>0)||(a.upload.length>0)||(a.setting_metadata.length>0)){this.set("state",HistoryDatasetAssociation.STATES.RUNNING)}else{if(a.queued.length>0){this.set("state",HistoryDatasetAssociation.STATES.QUEUED)}else{if((a.error.length>0)||(a.failed_metadata.length>0)){this.set("state",HistoryDatasetAssociation.STATES.ERROR)}else{if(a.ok.length===this.hdas.length){this.set("state",HistoryDatasetAssociation.STATES.OK)}else{throw (this+".stateFromStateDetails: unable to determine history state from hda states: "+this.get("state_ids"))}}}}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);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.hdas.update(e)}if((c.get("state")===HistoryDatasetAssociation.STATES.RUNNING)||(c.get("state")===HistoryDatasetAssociation.STATES.QUEUED)){setTimeout(function(){c.stateUpdater()},4000)}}).error(function(f,d,e){if(console&&console.warn){console.warn("Error getting history updates from the server:",f,d,e)}alert("Error getting history updates from the server.\n"+e)})},toString:function(){var a=(this.get("name"))?(","+this.get("name")):("");return"History("+this.get("id")+a+")"}});var HDAView=BaseView.extend(LoggableMixin).extend({logger:console,tagName:"div",className:"historyItemContainer",initialize:function(a){this.log(this+".initialize:",a);if(!a.urlTemplates){throw ("HDAView needs urlTemplates on initialize")}this.urls=this.renderUrls(a.urlTemplates,this.model.toJSON());this.expanded=a.expanded||false;this.model.bind("change",this.render,this)},renderUrls:function(d,a){var b=this,c={};_.each(d,function(e,f){if(_.isObject(e)){c[f]=b.renderUrls(e,a)}else{if(f==="meta_download"){c[f]=b.renderMetaDownloadUrls(e,a)}else{c[f]=_.template(e,a)}}});return c},renderMetaDownloadUrls:function(b,a){return _.map(a.meta_files,function(c){return{url:_.template(b,{id:a.id,file_type:c.file_type}),file_type:c.file_type}})},render:function(){var b=this,d=this.model.get("id"),c=this.model.get("state"),a=$("<div/>").attr("id","historyItem-"+d);this._clearReferences();this.$el.attr("id","historyItemContainer-"+d);a.addClass("historyItemWrapper").addClass("historyItem").addClass("historyItem-"+c);a.append(this._render_warnings());a.append(this._render_titleBar());this.body=$(this._render_body());a.append(this.body);make_popup_menus(a);a.find(".tooltip").tooltip({placement:"bottom"});this.$el.fadeOut("fast",function(){b.$el.children().remove();b.$el.append(a).fadeIn("fast",function(){b.log(b+" rendered:",b.$el);b.trigger("rendered")})});return this},_clearReferences:function(){this.displayButton=null;this.editButton=null;this.deleteButton=null;this.errButton=null;this.showParamsButton=null;this.rerunButton=null;this.visualizationsButton=null;this.tagButton=null;this.annotateButton=null},_render_warnings:function(){return $(jQuery.trim(HDAView.templates.messages(_.extend(this.model.toJSON(),{urls:this.urls}))))},_render_titleBar:function(){var a=$('<div class="historyItemTitleBar" style="overflow: hidden"></div>');a.append(this._render_titleButtons());a.append('<span class="state-icon"></span>');a.append(this._render_titleLink());return a},_render_titleButtons:function(){var a=$('<div class="historyItemButtons"></div>');a.append(this._render_displayButton());a.append(this._render_editButton());a.append(this._render_deleteButton());return a},_render_displayButton:function(){if((!this.model.inFinalState())||(this.model.get("state")===HistoryDatasetAssociation.STATES.ERROR)||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var a={icon_class:"display"};if(this.model.get("purged")){a.enabled=false;a.title="Cannot display datasets removed from disk"}else{a.title="Display data in browser";a.href=this.urls.display}if(this.model.get("for_editing")){a.target="galaxy_main"}this.displayButton=new IconButtonView({model:new IconButton(a)});return this.displayButton.render().$el},_render_editButton:function(){if((this.model.get("state")===HistoryDatasetAssociation.STATES.UPLOAD)||(this.model.get("state")===HistoryDatasetAssociation.STATES.ERROR)||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))||(!this.model.get("for_editing"))){return null}var c=this.model.get("purged"),a=this.model.get("deleted"),b={title:"Edit attributes",href:this.urls.edit,target:"galaxy_main",icon_class:"edit"};if(a||c){b.enabled=false;if(c){b.title="Cannot edit attributes of datasets removed from disk"}else{if(a){b.title="Undelete dataset to edit attributes"}}}this.editButton=new IconButtonView({model:new IconButton(b)});return this.editButton.render().$el},_render_deleteButton:function(){if((!this.model.get("for_editing"))||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var a={title:"Delete",href:this.urls["delete"],id:"historyItemDeleter-"+this.model.get("id"),icon_class:"delete"};if(this.model.get("deleted")||this.model.get("purged")){a={title:"Dataset is already deleted",icon_class:"delete",enabled:false}}this.deleteButton=new IconButtonView({model:new IconButton(a)});return this.deleteButton.render().$el},_render_titleLink:function(){return $(jQuery.trim(HDAView.templates.titleLink(_.extend(this.model.toJSON(),{urls:this.urls}))))},_render_hdaSummary:function(){var a=_.extend(this.model.toJSON(),{urls:this.urls});if(this.model.get("metadata_dbkey")==="?"&&this.model.isEditable()){_.extend(a,{dbkey_unknown_and_editable:true})}return HDAView.templates.hdaSummary(a)},_render_primaryActionButtons:function(c){var b=$("<div/>").attr("id","primary-actions-"+this.model.get("id")),a=this;_.each(c,function(d){b.append(d.call(a))});return b},_render_downloadButton:function(){if(this.model.get("purged")){return null}var a=HDAView.templates.downloadLinks(_.extend(this.model.toJSON(),{urls:this.urls}));return $(a)},_render_errButton:function(){if((this.model.get("state")!==HistoryDatasetAssociation.STATES.ERROR)||(!this.model.get("for_editing"))){return null}this.errButton=new IconButtonView({model:new IconButton({title:"View or report this error",href:this.urls.report_error,target:"galaxy_main",icon_class:"bug"})});return this.errButton.render().$el},_render_showParamsButton:function(){this.showParamsButton=new IconButtonView({model:new IconButton({title:"View details",href:this.urls.show_params,target:"galaxy_main",icon_class:"information"})});return this.showParamsButton.render().$el},_render_rerunButton:function(){if(!this.model.get("for_editing")){return null}this.rerunButton=new IconButtonView({model:new IconButton({title:"Run this job again",href:this.urls.rerun,target:"galaxy_main",icon_class:"arrow-circle"})});return this.rerunButton.render().$el},_render_visualizationsButton:function(){var c=this.model.get("dbkey"),a=this.model.get("visualizations"),f=this.urls.visualization,d={},g={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(!(this.model.hasData())||!(this.model.get("for_editing"))||!(a&&a.length)||!(f)){return null}this.visualizationsButton=new IconButtonView({model:new IconButton({title:"Visualize",href:f,icon_class:"chart_curve"})});var b=this.visualizationsButton.render().$el;b.addClass("visualize-icon");if(c){g.dbkey=c}function e(h){switch(h){case"trackster":return create_trackster_action_fn(f,g,c);case"scatterplot":return create_scatterplot_action_fn(f,g);default:return function(){window.parent.location=f+"/"+h+"?"+$.param(g)}}}if(a.length===1){b.attr("title",a[0]);b.click(e(a[0]))}else{_.each(a,function(i){var h=i.charAt(0).toUpperCase()+i.slice(1);d[h]=e(i)});make_popupmenu(b,d)}return b},_render_secondaryActionButtons:function(b){var c=$("<div/>"),a=this;c.attr("style","float: right;").attr("id","secondary-actions-"+this.model.get("id"));_.each(b,function(d){c.append(d.call(a))});return c},_render_tagButton:function(){if(!(this.model.hasData())||!(this.model.get("for_editing"))||(!this.urls.tags.get)){return null}this.tagButton=new IconButtonView({model:new IconButton({title:"Edit dataset tags",target:"galaxy_main",href:this.urls.tags.get,icon_class:"tags"})});return this.tagButton.render().$el},_render_annotateButton:function(){if(!(this.model.hasData())||!(this.model.get("for_editing"))||(!this.urls.annotation.get)){return null}this.annotateButton=new IconButtonView({model:new IconButton({title:"Edit dataset annotation",target:"galaxy_main",icon_class:"annotate"})});return this.annotateButton.render().$el},_render_displayApps:function(){if(!this.model.hasData()){return null}var a=$("<div/>").addClass("display-apps");if(!_.isEmpty(this.model.get("display_types"))){a.append(HDAView.templates.displayApps({displayApps:this.model.get("display_types")}))}if(!_.isEmpty(this.model.get("display_apps"))){a.append(HDAView.templates.displayApps({displayApps:this.model.get("display_apps")}))}return a},_render_tagArea:function(){if(!this.urls.tags.set){return null}return $(HDAView.templates.tagArea(_.extend(this.model.toJSON(),{urls:this.urls})))},_render_annotationArea:function(){if(!this.urls.annotation.get){return null}return $(HDAView.templates.annotationArea(_.extend(this.model.toJSON(),{urls:this.urls})))},_render_peek:function(){if(!this.model.get("peek")){return null}return $("<div/>").append($("<pre/>").attr("id","peek"+this.model.get("id")).addClass("peek").append(this.model.get("peek")))},_render_body_not_viewable:function(a){a.append($("<div>You do not have permission to view dataset.</div>"))},_render_body_uploading:function(a){a.append($("<div>Dataset is uploading</div>"))},_render_body_queued:function(a){a.append($("<div>Job is waiting to run.</div>"));a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_running:function(a){a.append("<div>Job is currently running.</div>");a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_error:function(a){if(!this.model.get("purged")){a.append($("<div>"+this.model.get("misc_blurb")+"</div>"))}a.append(("An error occurred running this job: <i>"+$.trim(this.model.get("misc_info"))+"</i>"));a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_errButton,this._render_showParamsButton,this._render_rerunButton]))},_render_body_discarded:function(a){a.append("<div>The job creating this dataset was cancelled before completion.</div>");a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_setting_metadata:function(a){a.append($("<div>Metadata is being auto-detected.</div>"))},_render_body_empty:function(a){a.append($("<div>No data: <i>"+this.model.get("misc_blurb")+"</i></div>"));a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_failed_metadata:function(a){a.append($(HDAView.templates.failedMetadata(this.model.toJSON())));this._render_body_ok(a)},_render_body_ok:function(a){a.append(this._render_hdaSummary());if(this.model.isDeletedOrPurged()){a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_showParamsButton,this._render_rerunButton]));return}a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_errButton,this._render_showParamsButton,this._render_rerunButton,this._render_visualizationsButton]));a.append(this._render_secondaryActionButtons([this._render_tagButton,this._render_annotateButton]));a.append('<div class="clear"/>');a.append(this._render_tagArea());a.append(this._render_annotationArea());a.append(this._render_displayApps());a.append(this._render_peek())},_render_body:function(){var a=$("<div/>").attr("id","info-"+this.model.get("id")).addClass("historyItemBody").attr("style","display: block");switch(this.model.get("state")){case HistoryDatasetAssociation.STATES.NOT_VIEWABLE:this._render_body_not_viewable(a);break;case HistoryDatasetAssociation.STATES.UPLOAD:this._render_body_uploading(a);break;case HistoryDatasetAssociation.STATES.QUEUED:this._render_body_queued(a);break;case HistoryDatasetAssociation.STATES.RUNNING:this._render_body_running(a);break;case HistoryDatasetAssociation.STATES.ERROR:this._render_body_error(a);break;case HistoryDatasetAssociation.STATES.DISCARDED:this._render_body_discarded(a);break;case HistoryDatasetAssociation.STATES.SETTING_METADATA:this._render_body_setting_metadata(a);break;case HistoryDatasetAssociation.STATES.EMPTY:this._render_body_empty(a);break;case HistoryDatasetAssociation.STATES.FAILED_METADATA:this._render_body_failed_metadata(a);break;case HistoryDatasetAssociation.STATES.OK:this._render_body_ok(a);break;default:a.append($('<div>Error: unknown dataset state "'+state+'".</div>'))}a.append('<div style="clear: both"></div>');if(this.expanded){a.show()}else{a.hide()}return a},events:{"click .historyItemTitle":"toggleBodyVisibility","click a.icon-button.tags":"loadAndDisplayTags","click a.icon-button.annotate":"loadAndDisplayAnnotation"},loadAndDisplayTags:function(b){this.log(this+".loadAndDisplayTags",b);var c=this.$el.find(".tag-area"),a=c.find(".tag-elt");if(c.is(":hidden")){if(!jQuery.trim(a.html())){$.ajax({url:this.urls.tags.get,error:function(){alert("Tagging failed")},success:function(d){a.html(d);a.find(".tooltip").tooltip();c.slideDown("fast")}})}else{c.slideDown("fast")}}else{c.slideUp("fast")}return false},loadAndDisplayAnnotation:function(b){this.log(this+".loadAndDisplayAnnotation",b);var d=this.$el.find(".annotation-area"),c=d.find(".annotation-elt"),a=this.urls.annotation.set;if(d.is(":hidden")){if(!jQuery.trim(c.html())){$.ajax({url:this.urls.annotation.get,error:function(){alert("Annotations failed")},success:function(e){if(e===""){e="<em>Describe or add notes to dataset</em>"}c.html(e);d.find(".tooltip").tooltip();async_save_text(c.attr("id"),c.attr("id"),a,"new_annotation",18,true,4);d.slideDown("fast")}})}else{d.slideDown("fast")}}else{d.slideUp("fast")}return false},toggleBodyVisibility:function(b,a){var c=this.$el.find(".historyItemBody");a=(a===undefined)?(!c.is(":visible")):(a);if(a){c.slideDown("fast")}else{c.slideUp("fast")}this.trigger("toggleBodyVisibility",this.model.get("id"),a)},toString:function(){var a=(this.model)?(this.model+""):("(no model)");return"HDAView("+a+")"}});HDAView.templates={warningMsg:Handlebars.templates["template-warningmessagesmall"],messages:Handlebars.templates["template-history-warning-messages"],titleLink:Handlebars.templates["template-history-titleLink"],hdaSummary:Handlebars.templates["template-history-hdaSummary"],downloadLinks:Handlebars.templates["template-history-downloadLinks"],failedMetadata:Handlebars.templates["template-history-failedMetaData"],tagArea:Handlebars.templates["template-history-tagArea"],annotationArea:Handlebars.templates["template-history-annotationArea"],displayApps:Handlebars.templates["template-history-displayApps"]};function create_scatterplot_action_fn(a,b){action=function(){var d=$(window.parent.document).find("iframe#galaxy_main"),c=a+"/scatterplot?"+$.param(b);d.attr("src",c);$("div.popmenu-wrapper").remove();return false};return action}function create_trackster_action_fn(a,c,b){return function(){var d={};if(b){d.dbkey=b}$.ajax({url:a+"/list_tracks?f-"+$.param(d),dataType:"html",error:function(){alert("Could not add this dataset to browser.")},success:function(e){var f=window.parent;f.show_modal("View Data in a New or Saved Visualization","",{Cancel:function(){f.hide_modal()},"View in saved visualization":function(){f.show_modal("Add Data to Saved Visualization",e,{Cancel:function(){f.hide_modal()},"Add to visualization":function(){$(f.document).find("input[name=id]:checked").each(function(){var g=$(this).val();c.id=g;f.location=a+"/trackster?"+$.param(c)})}})},"View in new visualization":function(){f.location=a+"/trackster?"+$.param(c)}})}});return false}}var HistoryView=BaseView.extend(LoggableMixin).extend({logger:console,el:"body.historyPage",initialize:function(a){this.log(this+".initialize:",a);if(!a.urlTemplates){throw ("HDAView needs urlTemplates on initialize")}if(!a.urlTemplates.history){throw ("HDAView needs urlTemplates.history on initialize")}if(!a.urlTemplates.hda){throw ("HDAView needs urlTemplates.hda on initialize")}this.urlTemplates=a.urlTemplates.history;this.hdaUrlTemplates=a.urlTemplates.hda;this.storage=new PersistantStorage("HistoryView."+this.model.get("id"),{expandedHdas:{}});this.model.hdas.bind("add",this.add,this);this.model.hdas.bind("reset",this.addAll,this);this.model.hdas.bind("all",this.all,this);this.hdaViews={};this.urls={}},add:function(a){},addAll:function(){this.render()},all:function(a){},renderUrls:function(a){var b=this;b.urls={};_.each(this.urlTemplates,function(d,c){b.urls[c]=_.template(d,a)});return b.urls},render:function(){var b=this,d=b.toString()+".set-up",c=$("<div/>"),a=this.model.toJSON();a.urls=this.renderUrls(a);c.append(HistoryView.templates.historyPanel(a));b.$el.find(".tooltip").tooltip();if(!this.model.hdas.length||!this.renderItems(c.find("#"+this.model.get("id")+"-datasets"))){c.find("#emptyHistoryMessage").show()}$(b).queue(d,function(e){b.$el.fadeOut("fast",function(){e()})});$(b).queue(d,function(e){b.$el.html("");b.$el.append(c.children());b.$el.fadeIn("fast",function(){e()})});$(b).queue(d,function(e){this.log(b+" rendered:",b.$el);b.setUpBehaviours();b.trigger("rendered");e()});$(b).dequeue(d);return this},renderItems:function(c){this.hdaViews={};var b=this,a=this.model.get("show_deleted"),e=this.model.get("show_hidden"),d=this.model.hdas.getVisible(a,e);d.each(function(h){var g=h.get("id"),f=b.storage.get("expandedHdas").get(g);b.hdaViews[g]=new HDAView({model:h,expanded:f,urlTemplates:b.hdaUrlTemplates});b.setUpHdaListeners(b.hdaViews[g]);c.prepend(b.hdaViews[g].render().$el)});return d.length},setUpHdaListeners:function(a){var b=this;a.bind("toggleBodyVisibility",function(d,c){if(c){b.storage.get("expandedHdas").set(d,true)}else{b.storage.get("expandedHdas").deleteKey(d)}})},setUpBehaviours:function(){var a=this.$("#history-annotation-area");this.$("#history-annotate").click(function(){if(a.is(":hidden")){a.slideDown("fast")}else{a.slideUp("fast")}return false});async_save_text("history-name-container","history-name",this.urls.rename,"new_name",18);async_save_text("history-annotation-container","history-annotation",this.urls.annotate,"new_annotation",18,true,4)},events:{"click #history-collapse-all":"hideAllHdaBodies","click #history-tag":"loadAndDisplayTags"},hideAllHdaBodies:function(){_.each(this.itemViews,function(a){a.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{})},loadAndDisplayTags:function(c){this.log(this+".loadAndDisplayTags",c);var d=this.$el.find("#history-tag-area"),b=d.find(".tag-elt");this.log("\t tagArea",d," tagElt",b);if(d.is(":hidden")){if(!jQuery.trim(b.html())){var a=this;$.ajax({url:a.urls.tag,error:function(){alert("Tagging failed")},success:function(e){b.html(e);b.find(".tooltip").tooltip();d.slideDown("fast")}})}else{d.slideDown("fast")}}else{d.slideUp("fast")}return false},toString:function(){var a=this.model.get("name")||"";return"HistoryView("+a+")"}});HistoryView.templates={historyPanel:Handlebars.templates["template-history-historyPanel"]}; \ No newline at end of file +var HistoryDatasetAssociation=BaseModel.extend(LoggableMixin).extend({defaults:{history_id:null,model_class:"HistoryDatasetAssociation",hid:0,id:null,name:"",state:"",data_type:null,file_size:0,meta_files:[],misc_blurb:"",misc_info:"",deleted:false,purged:false,visible:false,accessible:false,for_editing:true},url:function(){return"api/histories/"+this.get("history_id")+"/contents/"+this.get("id")},initialize:function(){this.log(this+".initialize",this.attributes);this.log("\tparent history_id: "+this.get("history_id"));if(!this.get("accessible")){this.set("state",HistoryDatasetAssociation.STATES.NOT_VIEWABLE)}this.on("change:state",function(b,a){this.log(this+" has changed state:",b,a);if(this.inReadyState()){this.trigger("state:ready",this.get("id"),a,this.previous("state"),b)}})},isDeletedOrPurged:function(){return(this.get("deleted")||this.get("purged"))},isVisible:function(b,c){var a=true;if((!b)&&(this.get("deleted")||this.get("purged"))){a=false}if((!c)&&(!this.get("visible"))){a=false}return a},inReadyState:function(){var a=this.get("state");return((a===HistoryDatasetAssociation.STATES.NEW)||(a===HistoryDatasetAssociation.STATES.OK)||(a===HistoryDatasetAssociation.STATES.EMPTY)||(a===HistoryDatasetAssociation.STATES.FAILED_METADATA)||(a===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(a===HistoryDatasetAssociation.STATES.DISCARDED)||(a===HistoryDatasetAssociation.STATES.ERROR))},hasData:function(){return(this.get("file_size")>0)},toString:function(){var a=this.get("id")||"";if(this.get("name")){a+=':"'+this.get("name")+'"'}return"HistoryDatasetAssociation("+a+")"}});HistoryDatasetAssociation.STATES={UPLOAD:"upload",QUEUED:"queued",RUNNING:"running",SETTING_METADATA:"setting_metadata",NEW:"new",OK:"ok",EMPTY:"empty",FAILED_METADATA:"failed_metadata",NOT_VIEWABLE:"noPermission",DISCARDED:"discarded",ERROR:"error"};var HDACollection=Backbone.Collection.extend(LoggableMixin).extend({model:HistoryDatasetAssociation,initialize:function(){},ids:function(){return this.map(function(a){return a.id})},getVisible:function(a,b){return this.filter(function(c){return c.isVisible(a,b)})},getStateLists:function(){var a={};_.each(_.values(HistoryDatasetAssociation.STATES),function(b){a[b]=[]});this.each(function(b){a[b.get("state")].push(b.get("id"))});return a},running:function(){var a=[];this.each(function(b){if(!b.inReadyState()){a.push(b.get("id"))}});return a},update:function(a){this.log(this+"update:",a);if(!(a&&a.length)){return}var b=this;_.each(a,function(e,c){var d=b.get(e);d.fetch()})},toString:function(){return("HDACollection("+this.ids().join(",")+")")}});var History=BaseModel.extend(LoggableMixin).extend({defaults:{id:"",name:"",state:"",show_deleted:false,show_hidden:false,diskSize:0,deleted:false,tags:[],annotation:null,message:null,quotaMsg:false},url:function(){return"api/histories/"+this.get("id")},initialize:function(a,b){this.log(this+".initialize:",a,b);this.hdas=new HDACollection();if(b&&b.length){this.hdas.reset(b);this.checkForUpdates()}},loadFromApi:function(a,c){var b=this;b.attributes.id=a;jQuery.when(jQuery.ajax("api/users/current"),b.fetch()).then(function(e,d){b.attributes.user=e[0];b.log(b)}).then(function(){jQuery.ajax(b.url()+"/contents?"+jQuery.param({ids:b.itemIdsFromStateIds().join(",")})).success(function(d){b.hdas.reset(d);b.checkForUpdates();c()})})},hdaIdsFromStateIds:function(){return _.reduce(_.values(this.get("state_ids")),function(b,a){return b.concat(a)})},checkForUpdates:function(a){if(this.hdas.running().length){this.stateUpdater()}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.hdas.update(e)}if((c.get("state")===HistoryDatasetAssociation.STATES.RUNNING)||(c.get("state")===HistoryDatasetAssociation.STATES.QUEUED)){setTimeout(function(){c.stateUpdater()},4000)}}).error(function(f,d,e){if(console&&console.warn){console.warn("Error getting history updates from the server:",f,d,e)}alert("Error getting history updates from the server.\n"+e)})},toString:function(){var a=(this.get("name"))?(","+this.get("name")):("");return"History("+this.get("id")+a+")"}});var HDAView=BaseView.extend(LoggableMixin).extend({tagName:"div",className:"historyItemContainer",initialize:function(a){this.log(this+".initialize:",a);if(!a.urlTemplates){throw ("HDAView needs urlTemplates on initialize")}this.urls=this.renderUrls(a.urlTemplates,this.model.toJSON());this.expanded=a.expanded||false;this.model.bind("change",this.render,this)},renderUrls:function(d,a){var b=this,c={};_.each(d,function(e,f){if(_.isObject(e)){c[f]=b.renderUrls(e,a)}else{if(f==="meta_download"){c[f]=b.renderMetaDownloadUrls(e,a)}else{c[f]=_.template(e,a)}}});return c},renderMetaDownloadUrls:function(b,a){return _.map(a.meta_files,function(c){return{url:_.template(b,{id:a.id,file_type:c.file_type}),file_type:c.file_type}})},render:function(){var b=this,e=this.model.get("id"),c=this.model.get("state"),a=$("<div/>").attr("id","historyItem-"+e),d=(this.$el.children().size()===0);this._clearReferences();this.$el.attr("id","historyItemContainer-"+e);a.addClass("historyItemWrapper").addClass("historyItem").addClass("historyItem-"+c);a.append(this._render_warnings());a.append(this._render_titleBar());this.body=$(this._render_body());a.append(this.body);make_popup_menus(a);a.find(".tooltip").tooltip({placement:"bottom"});this.$el.fadeOut("fast",function(){b.$el.children().remove();b.$el.append(a).fadeIn("fast",function(){b.log(b+" rendered:",b.$el);var f="rendered";if(d){f+=":initial"}else{if(b.model.inReadyState()){f+=":ready"}}b.trigger(f)})});return this},_clearReferences:function(){this.displayButton=null;this.editButton=null;this.deleteButton=null;this.errButton=null;this.showParamsButton=null;this.rerunButton=null;this.visualizationsButton=null;this.tagButton=null;this.annotateButton=null},_render_warnings:function(){return $(jQuery.trim(HDAView.templates.messages(_.extend(this.model.toJSON(),{urls:this.urls}))))},_render_titleBar:function(){var a=$('<div class="historyItemTitleBar" style="overflow: hidden"></div>');a.append(this._render_titleButtons());a.append('<span class="state-icon"></span>');a.append(this._render_titleLink());return a},_render_titleButtons:function(){var a=$('<div class="historyItemButtons"></div>');a.append(this._render_displayButton());a.append(this._render_editButton());a.append(this._render_deleteButton());return a},_render_displayButton:function(){if((!this.model.inReadyState())||(this.model.get("state")===HistoryDatasetAssociation.STATES.ERROR)||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var a={icon_class:"display"};if(this.model.get("purged")){a.enabled=false;a.title="Cannot display datasets removed from disk"}else{a.title="Display data in browser";a.href=this.urls.display}if(this.model.get("for_editing")){a.target="galaxy_main"}this.displayButton=new IconButtonView({model:new IconButton(a)});return this.displayButton.render().$el},_render_editButton:function(){if((this.model.get("state")===HistoryDatasetAssociation.STATES.UPLOAD)||(this.model.get("state")===HistoryDatasetAssociation.STATES.ERROR)||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))||(!this.model.get("for_editing"))){return null}var c=this.model.get("purged"),a=this.model.get("deleted"),b={title:"Edit attributes",href:this.urls.edit,target:"galaxy_main",icon_class:"edit"};if(a||c){b.enabled=false;if(c){b.title="Cannot edit attributes of datasets removed from disk"}else{if(a){b.title="Undelete dataset to edit attributes"}}}this.editButton=new IconButtonView({model:new IconButton(b)});return this.editButton.render().$el},_render_deleteButton:function(){if((!this.model.get("for_editing"))||(this.model.get("state")===HistoryDatasetAssociation.STATES.NOT_VIEWABLE)||(!this.model.get("accessible"))){return null}var a={title:"Delete",href:this.urls["delete"],id:"historyItemDeleter-"+this.model.get("id"),icon_class:"delete"};if(this.model.get("deleted")||this.model.get("purged")){a={title:"Dataset is already deleted",icon_class:"delete",enabled:false}}this.deleteButton=new IconButtonView({model:new IconButton(a)});return this.deleteButton.render().$el},_render_titleLink:function(){return $(jQuery.trim(HDAView.templates.titleLink(_.extend(this.model.toJSON(),{urls:this.urls}))))},_render_hdaSummary:function(){var a=_.extend(this.model.toJSON(),{urls:this.urls});if(this.model.get("metadata_dbkey")==="?"&&!this.model.isDeletedOrPurged()){_.extend(a,{dbkey_unknown_and_editable:true})}return HDAView.templates.hdaSummary(a)},_render_primaryActionButtons:function(c){var b=$("<div/>").attr("id","primary-actions-"+this.model.get("id")),a=this;_.each(c,function(d){b.append(d.call(a))});return b},_render_downloadButton:function(){if(this.model.get("purged")){return null}var a=HDAView.templates.downloadLinks(_.extend(this.model.toJSON(),{urls:this.urls}));return $(a)},_render_errButton:function(){if((this.model.get("state")!==HistoryDatasetAssociation.STATES.ERROR)||(!this.model.get("for_editing"))){return null}this.errButton=new IconButtonView({model:new IconButton({title:"View or report this error",href:this.urls.report_error,target:"galaxy_main",icon_class:"bug"})});return this.errButton.render().$el},_render_showParamsButton:function(){this.showParamsButton=new IconButtonView({model:new IconButton({title:"View details",href:this.urls.show_params,target:"galaxy_main",icon_class:"information"})});return this.showParamsButton.render().$el},_render_rerunButton:function(){if(!this.model.get("for_editing")){return null}this.rerunButton=new IconButtonView({model:new IconButton({title:"Run this job again",href:this.urls.rerun,target:"galaxy_main",icon_class:"arrow-circle"})});return this.rerunButton.render().$el},_render_visualizationsButton:function(){var c=this.model.get("dbkey"),a=this.model.get("visualizations"),f=this.urls.visualization,d={},g={dataset_id:this.model.get("id"),hda_ldda:"hda"};if(!(this.model.hasData())||!(this.model.get("for_editing"))||!(a&&a.length)||!(f)){return null}this.visualizationsButton=new IconButtonView({model:new IconButton({title:"Visualize",href:f,icon_class:"chart_curve"})});var b=this.visualizationsButton.render().$el;b.addClass("visualize-icon");if(c){g.dbkey=c}function e(h){switch(h){case"trackster":return create_trackster_action_fn(f,g,c);case"scatterplot":return create_scatterplot_action_fn(f,g);default:return function(){window.parent.location=f+"/"+h+"?"+$.param(g)}}}if(a.length===1){b.attr("title",a[0]);b.click(e(a[0]))}else{_.each(a,function(i){var h=i.charAt(0).toUpperCase()+i.slice(1);d[h]=e(i)});make_popupmenu(b,d)}return b},_render_secondaryActionButtons:function(b){var c=$("<div/>"),a=this;c.attr("style","float: right;").attr("id","secondary-actions-"+this.model.get("id"));_.each(b,function(d){c.append(d.call(a))});return c},_render_tagButton:function(){if(!(this.model.hasData())||!(this.model.get("for_editing"))||(!this.urls.tags.get)){return null}this.tagButton=new IconButtonView({model:new IconButton({title:"Edit dataset tags",target:"galaxy_main",href:this.urls.tags.get,icon_class:"tags"})});return this.tagButton.render().$el},_render_annotateButton:function(){if(!(this.model.hasData())||!(this.model.get("for_editing"))||(!this.urls.annotation.get)){return null}this.annotateButton=new IconButtonView({model:new IconButton({title:"Edit dataset annotation",target:"galaxy_main",icon_class:"annotate"})});return this.annotateButton.render().$el},_render_displayApps:function(){if(!this.model.hasData()){return null}var a=$("<div/>").addClass("display-apps");if(!_.isEmpty(this.model.get("display_types"))){a.append(HDAView.templates.displayApps({displayApps:this.model.get("display_types")}))}if(!_.isEmpty(this.model.get("display_apps"))){a.append(HDAView.templates.displayApps({displayApps:this.model.get("display_apps")}))}return a},_render_tagArea:function(){if(!this.urls.tags.set){return null}return $(HDAView.templates.tagArea(_.extend(this.model.toJSON(),{urls:this.urls})))},_render_annotationArea:function(){if(!this.urls.annotation.get){return null}return $(HDAView.templates.annotationArea(_.extend(this.model.toJSON(),{urls:this.urls})))},_render_peek:function(){if(!this.model.get("peek")){return null}return $("<div/>").append($("<pre/>").attr("id","peek"+this.model.get("id")).addClass("peek").append(this.model.get("peek")))},_render_body_not_viewable:function(a){a.append($("<div>You do not have permission to view dataset.</div>"))},_render_body_uploading:function(a){a.append($("<div>Dataset is uploading</div>"))},_render_body_queued:function(a){a.append($("<div>Job is waiting to run.</div>"));a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_running:function(a){a.append("<div>Job is currently running.</div>");a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_error:function(a){if(!this.model.get("purged")){a.append($("<div>"+this.model.get("misc_blurb")+"</div>"))}a.append(("An error occurred running this job: <i>"+$.trim(this.model.get("misc_info"))+"</i>"));a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_errButton,this._render_showParamsButton,this._render_rerunButton]))},_render_body_discarded:function(a){a.append("<div>The job creating this dataset was cancelled before completion.</div>");a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_setting_metadata:function(a){a.append($("<div>Metadata is being auto-detected.</div>"))},_render_body_empty:function(a){a.append($("<div>No data: <i>"+this.model.get("misc_blurb")+"</i></div>"));a.append(this._render_primaryActionButtons([this._render_showParamsButton,this._render_rerunButton]))},_render_body_failed_metadata:function(a){a.append($(HDAView.templates.failedMetadata(this.model.toJSON())));this._render_body_ok(a)},_render_body_ok:function(a){a.append(this._render_hdaSummary());if(this.model.isDeletedOrPurged()){a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_showParamsButton,this._render_rerunButton]));return}a.append(this._render_primaryActionButtons([this._render_downloadButton,this._render_errButton,this._render_showParamsButton,this._render_rerunButton,this._render_visualizationsButton]));a.append(this._render_secondaryActionButtons([this._render_tagButton,this._render_annotateButton]));a.append('<div class="clear"/>');a.append(this._render_tagArea());a.append(this._render_annotationArea());a.append(this._render_displayApps());a.append(this._render_peek())},_render_body:function(){var a=$("<div/>").attr("id","info-"+this.model.get("id")).addClass("historyItemBody").attr("style","display: block");switch(this.model.get("state")){case HistoryDatasetAssociation.STATES.NOT_VIEWABLE:this._render_body_not_viewable(a);break;case HistoryDatasetAssociation.STATES.UPLOAD:this._render_body_uploading(a);break;case HistoryDatasetAssociation.STATES.QUEUED:this._render_body_queued(a);break;case HistoryDatasetAssociation.STATES.RUNNING:this._render_body_running(a);break;case HistoryDatasetAssociation.STATES.ERROR:this._render_body_error(a);break;case HistoryDatasetAssociation.STATES.DISCARDED:this._render_body_discarded(a);break;case HistoryDatasetAssociation.STATES.SETTING_METADATA:this._render_body_setting_metadata(a);break;case HistoryDatasetAssociation.STATES.EMPTY:this._render_body_empty(a);break;case HistoryDatasetAssociation.STATES.FAILED_METADATA:this._render_body_failed_metadata(a);break;case HistoryDatasetAssociation.STATES.OK:this._render_body_ok(a);break;default:a.append($('<div>Error: unknown dataset state "'+state+'".</div>'))}a.append('<div style="clear: both"></div>');if(this.expanded){a.show()}else{a.hide()}return a},events:{"click .historyItemTitle":"toggleBodyVisibility","click a.icon-button.tags":"loadAndDisplayTags","click a.icon-button.annotate":"loadAndDisplayAnnotation"},loadAndDisplayTags:function(b){this.log(this+".loadAndDisplayTags",b);var c=this.$el.find(".tag-area"),a=c.find(".tag-elt");if(c.is(":hidden")){if(!jQuery.trim(a.html())){$.ajax({url:this.urls.tags.get,error:function(){alert("Tagging failed")},success:function(d){a.html(d);a.find(".tooltip").tooltip();c.slideDown("fast")}})}else{c.slideDown("fast")}}else{c.slideUp("fast")}return false},loadAndDisplayAnnotation:function(b){this.log(this+".loadAndDisplayAnnotation",b);var d=this.$el.find(".annotation-area"),c=d.find(".annotation-elt"),a=this.urls.annotation.set;if(d.is(":hidden")){if(!jQuery.trim(c.html())){$.ajax({url:this.urls.annotation.get,error:function(){alert("Annotations failed")},success:function(e){if(e===""){e="<em>Describe or add notes to dataset</em>"}c.html(e);d.find(".tooltip").tooltip();async_save_text(c.attr("id"),c.attr("id"),a,"new_annotation",18,true,4);d.slideDown("fast")}})}else{d.slideDown("fast")}}else{d.slideUp("fast")}return false},toggleBodyVisibility:function(b,a){var c=this.$el.find(".historyItemBody");a=(a===undefined)?(!c.is(":visible")):(a);if(a){c.slideDown("fast")}else{c.slideUp("fast")}this.trigger("toggleBodyVisibility",this.model.get("id"),a)},toString:function(){var a=(this.model)?(this.model+""):("(no model)");return"HDAView("+a+")"}});HDAView.templates={warningMsg:Handlebars.templates["template-warningmessagesmall"],messages:Handlebars.templates["template-history-warning-messages"],titleLink:Handlebars.templates["template-history-titleLink"],hdaSummary:Handlebars.templates["template-history-hdaSummary"],downloadLinks:Handlebars.templates["template-history-downloadLinks"],failedMetadata:Handlebars.templates["template-history-failedMetaData"],tagArea:Handlebars.templates["template-history-tagArea"],annotationArea:Handlebars.templates["template-history-annotationArea"],displayApps:Handlebars.templates["template-history-displayApps"]};function create_scatterplot_action_fn(a,b){action=function(){var d=$(window.parent.document).find("iframe#galaxy_main"),c=a+"/scatterplot?"+$.param(b);d.attr("src",c);$("div.popmenu-wrapper").remove();return false};return action}function create_trackster_action_fn(a,c,b){return function(){var d={};if(b){d.dbkey=b}$.ajax({url:a+"/list_tracks?f-"+$.param(d),dataType:"html",error:function(){alert("Could not add this dataset to browser.")},success:function(e){var f=window.parent;f.show_modal("View Data in a New or Saved Visualization","",{Cancel:function(){f.hide_modal()},"View in saved visualization":function(){f.show_modal("Add Data to Saved Visualization",e,{Cancel:function(){f.hide_modal()},"Add to visualization":function(){$(f.document).find("input[name=id]:checked").each(function(){var g=$(this).val();c.id=g;f.location=a+"/trackster?"+$.param(c)})}})},"View in new visualization":function(){f.location=a+"/trackster?"+$.param(c)}})}});return false}}var HistoryView=BaseView.extend(LoggableMixin).extend({el:"body.historyPage",initialize:function(a){this.log(this+".initialize:",a);if(!a.urlTemplates){throw ("HDAView needs urlTemplates on initialize")}if(!a.urlTemplates.history){throw ("HDAView needs urlTemplates.history on initialize")}if(!a.urlTemplates.hda){throw ("HDAView needs urlTemplates.hda on initialize")}this.urlTemplates=a.urlTemplates.history;this.hdaUrlTemplates=a.urlTemplates.hda;this.storage=new PersistantStorage("HistoryView."+this.model.get("id"),{expandedHdas:{}});this.model.bind("change:nice_size",this.updateHistoryDiskSize,this);this.model.hdas.bind("add",this.add,this);this.model.hdas.bind("reset",this.addAll,this);this.model.hdas.bind("all",this.all,this);this.hdaViews={};this.urls={}},add:function(a){},addAll:function(){this.render()},all:function(a){},renderUrls:function(a){var b=this;b.urls={};_.each(this.urlTemplates,function(d,c){b.urls[c]=_.template(d,a)});return b.urls},render:function(){var b=this,d=b.toString()+".set-up",c=$("<div/>"),a=this.model.toJSON(),e=(this.$el.children().size()===0);a.urls=this.renderUrls(a);c.append(HistoryView.templates.historyPanel(a));c.find(".tooltip").tooltip();if(!this.model.hdas.length||!this.renderItems(c.find("#"+this.model.get("id")+"-datasets"))){c.find("#emptyHistoryMessage").show()}$(b).queue(d,function(f){b.$el.fadeOut("fast",function(){f()})});$(b).queue(d,function(f){b.$el.html("");b.$el.append(c.children());b.$el.fadeIn("fast",function(){f()})});$(b).queue(d,function(f){this.log(b+" rendered:",b.$el);b.setUpBehaviours();if(e){b.trigger("rendered:initial")}else{b.trigger("rendered")}f()});$(b).dequeue(d);return this},renderItems:function(c){this.hdaViews={};var b=this,a=this.model.get("show_deleted"),e=this.model.get("show_hidden"),d=this.model.hdas.getVisible(a,e);_.each(d,function(h){var g=h.get("id"),f=b.storage.get("expandedHdas").get(g);b.hdaViews[g]=new HDAView({model:h,expanded:f,urlTemplates:b.hdaUrlTemplates});b.setUpHdaListeners(b.hdaViews[g]);c.prepend(b.hdaViews[g].render().$el)});return d.length},setUpHdaListeners:function(b){var a=this;b.bind("toggleBodyVisibility",function(d,c){if(c){a.storage.get("expandedHdas").set(d,true)}else{a.storage.get("expandedHdas").deleteKey(d)}});b.bind("rendered:ready",function(){a.trigger("hda:rendered:ready")})},setUpBehaviours:function(){if(!(this.model.get("user")&&this.model.get("user").email)){return}var a=this.$("#history-annotation-area");this.$("#history-annotate").click(function(){if(a.is(":hidden")){a.slideDown("fast")}else{a.slideUp("fast")}return false});async_save_text("history-name-container","history-name",this.urls.rename,"new_name",18);async_save_text("history-annotation-container","history-annotation",this.urls.annotate,"new_annotation",18,true,4)},updateHistoryDiskSize:function(){this.$el.find("#history-size").text(this.model.get("nice_size"))},showQuotaMessage:function(a){var b=this.$el.find("#quota-message-container");if(b.is(":hidden")){b.slideDown("fast")}},hideQuotaMessage:function(a){var b=this.$el.find("#quota-message-container");if(!b.is(":hidden")){b.slideUp("fast")}},events:{"click #history-collapse-all":"hideAllHdaBodies","click #history-tag":"loadAndDisplayTags"},hideAllHdaBodies:function(){_.each(this.hdaViews,function(a){a.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{})},loadAndDisplayTags:function(c){this.log(this+".loadAndDisplayTags",c);var d=this.$el.find("#history-tag-area"),b=d.find(".tag-elt");this.log("\t tagArea",d," tagElt",b);if(d.is(":hidden")){if(!jQuery.trim(b.html())){var a=this;$.ajax({url:a.urls.tag,error:function(){alert("Tagging failed")},success:function(e){b.html(e);b.find(".tooltip").tooltip();d.slideDown("fast")}})}else{d.slideDown("fast")}}else{d.slideUp("fast")}return false},toString:function(){var a=this.model.get("name")||"";return"HistoryView("+a+")"}});HistoryView.templates={historyPanel:Handlebars.templates["template-history-historyPanel"]}; \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/mvc/user/user-model.js --- /dev/null +++ b/static/scripts/packed/mvc/user/user-model.js @@ -0,0 +1,1 @@ +var User=BaseModel.extend(LoggableMixin).extend({defaults:{id:null,username:"(anonymous user)",email:"",total_disk_usage:0,nice_total_disk_usage:"0 bytes"},initialize:function(a){this.log("User.initialize:",a);this.on("loaded",function(b,c){this.log(this+" has loaded:",b,c)});this.on("change",function(b,c){this.log(this+" has changed:",b,c.changes)})},urlRoot:"api/users",loadFromApi:function(d,b){d=d||User.CURRENT_ID_STR;b=b||{};var a=this,c=b.success;b.success=function(f,e){a.trigger("loaded",f,e);if(c){c(f,e)}};if(d===User.CURRENT_ID_STR){b.url=this.urlRoot+"/"+User.CURRENT_ID_STR}return BaseModel.prototype.fetch.call(this,b)},toString:function(){var a=[this.get("username")];if(this.get("id")){a.unshift(this.get("id"));a.push(this.get("email"))}return"User("+a.join(":")+")"}});User.CURRENT_ID_STR="current";User.getCurrentUserFromApi=function(b){var a=new User();a.loadFromApi(User.CURRENT_ID_STR,b);return a};var UserCollection=Backbone.Collection.extend(LoggableMixin).extend({model:User,logger:console,urlRoot:"api/users"}); \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/mvc/user/user-quotameter.js --- /dev/null +++ b/static/scripts/packed/mvc/user/user-quotameter.js @@ -0,0 +1,1 @@ +var UserQuotaMeter=BaseView.extend(LoggableMixin).extend({options:{warnAtPercent:85,errorAtPercent:100,meterDocument:window.top.document,containerSelector:".quota-meter-container",meterSelector:"#quota-meter",barSelector:"#quota-meter-bar",textSelector:"#quota-meter-text",msgDocument:(top.frames.galaxy_history)?(top.frames.galaxy_history.document):(top.document),msgSelector:"#quota-message-container",warnClass:"quota-meter-bar-warn",errorClass:"quota-meter-bar-error",usageTemplate:"Using <%= nice_total_disk_usage %>",quotaTemplate:"Using <%= quota_percent %>%",meterTemplate:"",animationSpeed:"fast"},initialize:function(a){this.log(this+".initialize:",a);_.extend(this.options,a);this.model.bind("change:quota_percent change:total_disk_usage",this.render,this)},update:function(a){this.log(this+" updating user data...",a);this.model.loadFromApi(this.model.get("id"),a);return this},isOverQuota:function(){return(this.model.get("quota_percent")!==null&&this.model.get("quota_percent")>=this.options.errorAtPercent)},_render_quota:function(){var a=this.model.toJSON(),b=a.quota_percent,c=$(UserQuotaMeter.templates.quota(a));if(this.isOverQuota()){c.addClass("progress-danger");c.find("#quota-meter-text").css("color","white");this.trigger("quota:over",a)}else{if(b>=this.options.warnAtPercent){c.addClass("progress-warning");this.trigger("quota:under quota:under:approaching",a)}else{c.addClass("progress-success");this.trigger("quota:under quota:under:ok",a)}}return c},_render_usage:function(){var a=$(UserQuotaMeter.templates.usage(this.model.toJSON()));this.log(this+".rendering usage:",a);return a},render:function(){var a=null;this.log(this+".model.quota_percent:",this.model.get("quota_percent"));if((this.model.get("quota_percent")===null)||(this.model.get("quota_percent")===undefined)){a=this._render_usage()}else{a=this._render_quota()}this.$el.html(a);return this},toString:function(){return"UserQuotaMeter("+this.model+")"}});UserQuotaMeter.templates={quota:Handlebars.templates["template-user-quotaMeter-quota"],usage:Handlebars.templates["template-user-quotaMeter-usage"]}; \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/templates/compiled/template-history-historyPanel.js --- a/static/scripts/packed/templates/compiled/template-history-historyPanel.js +++ b/static/scripts/packed/templates/compiled/template-history-historyPanel.js @@ -1,1 +1,1 @@ -(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-history-historyPanel"]=b(function(k,y,w,r,G){w=w||k.helpers;var x="",n,m,f="function",e=this.escapeExpression,u=this,c=w.blockHelperMissing;function t(L,K){var I="",J,H;I+='\n <div id="history-name" style="margin-right: 50px;" class="tooltip editable-text"\n title="Click to rename history">';H=w.name;if(H){J=H.call(L,{hash:{}})}else{J=L.name;J=typeof J===f?J():J}I+=e(J)+"</div>\n ";return I}function s(I,H){return"refresh"}function q(I,H){return"collapse all"}function p(L,K){var I="",J,H;I+='\n <a id="history-tag" title="';H=w.local;if(H){J=H.call(L,{hash:{},inverse:u.noop,fn:u.program(8,l,K)})}else{J=L.local;J=typeof J===f?J():J}if(!w.local){J=c.call(L,J,{hash:{},inverse:u.noop,fn:u.program(8,l,K)})}if(J||J===0){I+=J}I+='"\n class="icon-button tags tooltip" target="galaxy_main" href="javascript:void(0)"></a>\n <a id="history-annotate" title="';H=w.local;if(H){J=H.call(L,{hash:{},inverse:u.noop,fn:u.program(10,F,K)})}else{J=L.local;J=typeof J===f?J():J}if(!w.local){J=c.call(L,J,{hash:{},inverse:u.noop,fn:u.program(10,F,K)})}if(J||J===0){I+=J}I+='"\n class="icon-button annotate tooltip" target="galaxy_main" href="javascript:void(0)"></a>\n ';return I}function l(I,H){return"Edit history tags"}function F(I,H){return"Edit history annotation"}function E(L,K){var I="",J,H;I+='\n <a href="';J=L.urls;J=J==null||J===false?J:J.hide_deleted;J=typeof J===f?J():J;I+=e(J)+'">';H=w.local;if(H){J=H.call(L,{hash:{},inverse:u.noop,fn:u.program(13,D,K)})}else{J=L.local;J=typeof J===f?J():J}if(!w.local){J=c.call(L,J,{hash:{},inverse:u.noop,fn:u.program(13,D,K)})}if(J||J===0){I+=J}I+="</a>\n ";return I}function D(I,H){return"hide deleted"}function C(L,K){var I="",J,H;I+='\n <a href="';J=L.urls;J=J==null||J===false?J:J.hide_hidden;J=typeof J===f?J():J;I+=e(J)+'">';H=w.local;if(H){J=H.call(L,{hash:{},inverse:u.noop,fn:u.program(16,B,K)})}else{J=L.local;J=typeof J===f?J():J}if(!w.local){J=c.call(L,J,{hash:{},inverse:u.noop,fn:u.program(16,B,K)})}if(J||J===0){I+=J}I+="</a>\n ";return I}function B(I,H){return"hide hidden"}function A(L,K){var I="",J,H;I+="\n";H=w.warningmessagesmall;if(H){J=H.call(L,{hash:{},inverse:u.noop,fn:u.program(19,z,K)})}else{J=L.warningmessagesmall;J=typeof J===f?J():J}if(!w.warningmessagesmall){J=c.call(L,J,{hash:{},inverse:u.noop,fn:u.program(19,z,K)})}if(J||J===0){I+=J}I+="\n";return I}function z(K,J){var I,H;H=w.local;if(H){I=H.call(K,{hash:{},inverse:u.noop,fn:u.program(20,o,J)})}else{I=K.local;I=typeof I===f?I():I}if(!w.local){I=c.call(K,I,{hash:{},inverse:u.noop,fn:u.program(20,o,J)})}if(I||I===0){return I}else{return""}}function o(I,H){return"You are currently viewing a deleted history!"}function j(K,J){var H="",I;H+='\n <div id="history-tag-area" style="display: none">\n <strong>Tags:</strong>\n <div class="tag-elt"></div>\n </div>\n\n <div id="history-annotation-area" style="display: none">\n <strong>Annotation / Notes:</strong>\n <div id="history-annotation-container">\n <div id="history-annotation" class="tooltip editable-text" title="Click to edit annotation">\n ';I=K.annotation;I=w["if"].call(K,I,{hash:{},inverse:u.program(25,h,J),fn:u.program(23,i,J)});if(I||I===0){H+=I}H+="\n </div>\n </div>\n </div>\n ";return H}function i(L,K){var I="",J,H;I+="\n ";H=w.annotation;if(H){J=H.call(L,{hash:{}})}else{J=L.annotation;J=typeof J===f?J():J}I+=e(J)+"\n ";return I}function h(I,H){return"\n <em>Describe or add notes to history</em>\n "}function g(L,K){var I="",J,H;I+='\n<div id="message-container">\n <div class="';H=w.status;if(H){J=H.call(L,{hash:{}})}else{J=L.status;J=typeof J===f?J():J}I+=e(J)+'message">\n ';H=w.message;if(H){J=H.call(L,{hash:{}})}else{J=L.message;J=typeof J===f?J():J}I+=e(J)+"\n </div><br />\n</div>\n";return I}function d(I,H){return'\n <div id="quota-message" class="errormessage">\n You are over your disk quota. Tool execution is on hold until your disk usage drops below your allocated quota.\n </div>\n <br/>\n '}function v(I,H){return"Your history is empty. Click 'Get Data' on the left pane to start"}x+='\n<div id="history-name-area" class="historyLinks">\n <div id="history-name-container" style="position: relative;">\n ';x+='\n <div id="history-size" style="position: absolute; top: 3px; right: 0px;">';m=w.nice_size;if(m){n=m.call(y,{hash:{}})}else{n=y.nice_size;n=typeof n===f?n():n}x+=e(n)+"</div>\n ";n=y.user;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(1,t,G)});if(n||n===0){x+=n}x+='\n </div> \n</div>\n<div style="clear: both;"></div>\n\n<div id="top-links" class="historyLinks">\n <a title="';m=w.local;if(m){n=m.call(y,{hash:{},inverse:u.noop,fn:u.program(3,s,G)})}else{n=y.local;n=typeof n===f?n():n}if(!w.local){n=c.call(y,n,{hash:{},inverse:u.noop,fn:u.program(3,s,G)})}if(n||n===0){x+=n}x+='" class="icon-button arrow-circle tooltip" href="';n=y.urls;n=n==null||n===false?n:n.base;n=typeof n===f?n():n;x+=e(n)+"\"></a>\n <a title='";m=w.local;if(m){n=m.call(y,{hash:{},inverse:u.noop,fn:u.program(5,q,G)})}else{n=y.local;n=typeof n===f?n():n}if(!w.local){n=c.call(y,n,{hash:{},inverse:u.noop,fn:u.program(5,q,G)})}if(n||n===0){x+=n}x+="' id=\"history-collapse-all\"\n class='icon-button toggle tooltip' href='javascript:void(0);'></a>\n <div style=\"width: 40px; float: right; white-space: nowrap;\">\n ";n=y.user;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(7,p,G)});if(n||n===0){x+=n}x+='\n </div>\n</div>\n<div style="clear: both;"></div>\n\n';x+='\n<div class="historyLinks">\n ';n=y.show_deleted;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(12,E,G)});if(n||n===0){x+=n}x+="\n ";n=y.show_hidden;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(15,C,G)});if(n||n===0){x+=n}x+="\n</div>\n\n";n=y.deleted;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(18,A,G)});if(n||n===0){x+=n}x+="\n\n";x+="\n";x+='\n<div style="margin: 0px 5px 10px 5px">\n\n ';n=y.user;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(22,j,G)});if(n||n===0){x+=n}x+="\n</div>\n\n";n=y.message;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(27,g,G)});if(n||n===0){x+=n}x+='\n\n<div id="quota-message-container">\n ';n=y.over_quota;n=w["if"].call(y,n,{hash:{},inverse:u.noop,fn:u.program(29,d,G)});if(n||n===0){x+=n}x+='\n</div>\n\n<div id="';m=w.id;if(m){n=m.call(y,{hash:{}})}else{n=y.id;n=typeof n===f?n():n}x+=e(n)+'-datasets" class="history-datasets-list"></div>\n\n<div class="infomessagesmall" id="emptyHistoryMessage" style="display: none;">\n ';m=w.local;if(m){n=m.call(y,{hash:{},inverse:u.noop,fn:u.program(31,v,G)})}else{n=y.local;n=typeof n===f?n():n}if(!w.local){n=c.call(y,n,{hash:{},inverse:u.noop,fn:u.program(31,v,G)})}if(n||n===0){x+=n}x+="\n</div>";return x})})(); \ No newline at end of file +(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-history-historyPanel"]=b(function(l,z,x,s,G){x=x||l.helpers;var y="",o,n,f="function",e=this.escapeExpression,v=this,c=x.blockHelperMissing;function u(L,K){var I="",J,H;I+='\n <div id="history-name" style="margin-right: 50px;" class="tooltip editable-text"\n title="Click to rename history">';H=x.name;if(H){J=H.call(L,{hash:{}})}else{J=L.name;J=typeof J===f?J():J}I+=e(J)+"</div>\n ";return I}function t(L,K){var I="",J,H;I+='\n <div id="history-name" style="margin-right: 50px;" class="tooltip"\n title="You must be logged in to edit your history name">';H=x.name;if(H){J=H.call(L,{hash:{}})}else{J=L.name;J=typeof J===f?J():J}I+=e(J)+"</div>\n ";return I}function r(I,H){return"refresh"}function q(I,H){return"collapse all"}function k(L,K){var I="",J,H;I+='\n <a id="history-tag" title="';H=x.local;if(H){J=H.call(L,{hash:{},inverse:v.noop,fn:v.program(10,F,K)})}else{J=L.local;J=typeof J===f?J():J}if(!x.local){J=c.call(L,J,{hash:{},inverse:v.noop,fn:v.program(10,F,K)})}if(J||J===0){I+=J}I+='"\n class="icon-button tags tooltip" target="galaxy_main" href="javascript:void(0)"></a>\n <a id="history-annotate" title="';H=x.local;if(H){J=H.call(L,{hash:{},inverse:v.noop,fn:v.program(12,E,K)})}else{J=L.local;J=typeof J===f?J():J}if(!x.local){J=c.call(L,J,{hash:{},inverse:v.noop,fn:v.program(12,E,K)})}if(J||J===0){I+=J}I+='"\n class="icon-button annotate tooltip" target="galaxy_main" href="javascript:void(0)"></a>\n ';return I}function F(I,H){return"Edit history tags"}function E(I,H){return"Edit history annotation"}function D(L,K){var I="",J,H;I+='\n <a href="';J=L.urls;J=J==null||J===false?J:J.hide_deleted;J=typeof J===f?J():J;I+=e(J)+'">';H=x.local;if(H){J=H.call(L,{hash:{},inverse:v.noop,fn:v.program(15,C,K)})}else{J=L.local;J=typeof J===f?J():J}if(!x.local){J=c.call(L,J,{hash:{},inverse:v.noop,fn:v.program(15,C,K)})}if(J||J===0){I+=J}I+="</a>\n ";return I}function C(I,H){return"hide deleted"}function B(L,K){var I="",J,H;I+='\n <a href="';J=L.urls;J=J==null||J===false?J:J.hide_hidden;J=typeof J===f?J():J;I+=e(J)+'">';H=x.local;if(H){J=H.call(L,{hash:{},inverse:v.noop,fn:v.program(18,A,K)})}else{J=L.local;J=typeof J===f?J():J}if(!x.local){J=c.call(L,J,{hash:{},inverse:v.noop,fn:v.program(18,A,K)})}if(J||J===0){I+=J}I+="</a>\n ";return I}function A(I,H){return"hide hidden"}function p(L,K){var I="",J,H;I+="\n";H=x.warningmessagesmall;if(H){J=H.call(L,{hash:{},inverse:v.noop,fn:v.program(21,m,K)})}else{J=L.warningmessagesmall;J=typeof J===f?J():J}if(!x.warningmessagesmall){J=c.call(L,J,{hash:{},inverse:v.noop,fn:v.program(21,m,K)})}if(J||J===0){I+=J}I+="\n";return I}function m(K,J){var I,H;H=x.local;if(H){I=H.call(K,{hash:{},inverse:v.noop,fn:v.program(22,j,J)})}else{I=K.local;I=typeof I===f?I():I}if(!x.local){I=c.call(K,I,{hash:{},inverse:v.noop,fn:v.program(22,j,J)})}if(I||I===0){return I}else{return""}}function j(I,H){return"You are currently viewing a deleted history!"}function i(K,J){var H="",I;H+='\n <div id="history-tag-area" style="display: none">\n <strong>Tags:</strong>\n <div class="tag-elt"></div>\n </div>\n\n <div id="history-annotation-area" style="display: none">\n <strong>Annotation / Notes:</strong>\n <div id="history-annotation-container">\n <div id="history-annotation" class="tooltip editable-text" title="Click to edit annotation">\n ';I=K.annotation;I=x["if"].call(K,I,{hash:{},inverse:v.program(27,g,J),fn:v.program(25,h,J)});if(I||I===0){H+=I}H+="\n </div>\n </div>\n </div>\n ";return H}function h(L,K){var I="",J,H;I+="\n ";H=x.annotation;if(H){J=H.call(L,{hash:{}})}else{J=L.annotation;J=typeof J===f?J():J}I+=e(J)+"\n ";return I}function g(I,H){return"\n <em>Describe or add notes to history</em>\n "}function d(L,K){var I="",J,H;I+='\n<div id="message-container">\n <div class="';H=x.status;if(H){J=H.call(L,{hash:{}})}else{J=L.status;J=typeof J===f?J():J}I+=e(J)+'message">\n ';H=x.message;if(H){J=H.call(L,{hash:{}})}else{J=L.message;J=typeof J===f?J():J}I+=e(J)+"\n </div><br />\n</div>\n";return I}function w(I,H){return"Your history is empty. Click 'Get Data' on the left pane to start"}y+='\n<div id="history-name-area" class="historyLinks">\n <div id="history-name-container" style="position: relative;">\n ';y+='\n <div id="history-size" style="position: absolute; top: 3px; right: 0px;">';n=x.nice_size;if(n){o=n.call(z,{hash:{}})}else{o=z.nice_size;o=typeof o===f?o():o}y+=e(o)+"</div>\n ";o=z.user;o=o==null||o===false?o:o.email;o=x["if"].call(z,o,{hash:{},inverse:v.program(3,t,G),fn:v.program(1,u,G)});if(o||o===0){y+=o}y+='\n </div> \n</div>\n<div style="clear: both;"></div>\n\n<div id="top-links" class="historyLinks">\n <a title="';n=x.local;if(n){o=n.call(z,{hash:{},inverse:v.noop,fn:v.program(5,r,G)})}else{o=z.local;o=typeof o===f?o():o}if(!x.local){o=c.call(z,o,{hash:{},inverse:v.noop,fn:v.program(5,r,G)})}if(o||o===0){y+=o}y+='" class="icon-button arrow-circle tooltip" href="';o=z.urls;o=o==null||o===false?o:o.base;o=typeof o===f?o():o;y+=e(o)+"\"></a>\n <a title='";n=x.local;if(n){o=n.call(z,{hash:{},inverse:v.noop,fn:v.program(7,q,G)})}else{o=z.local;o=typeof o===f?o():o}if(!x.local){o=c.call(z,o,{hash:{},inverse:v.noop,fn:v.program(7,q,G)})}if(o||o===0){y+=o}y+="' id=\"history-collapse-all\"\n class='icon-button toggle tooltip' href='javascript:void(0);'></a>\n <div style=\"width: 40px; float: right; white-space: nowrap;\">\n ";o=z.user;o=o==null||o===false?o:o.email;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(9,k,G)});if(o||o===0){y+=o}y+='\n </div>\n</div>\n<div style="clear: both;"></div>\n\n';y+='\n<div class="historyLinks">\n ';o=z.show_deleted;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(14,D,G)});if(o||o===0){y+=o}y+="\n ";o=z.show_hidden;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(17,B,G)});if(o||o===0){y+=o}y+="\n</div>\n\n";o=z.deleted;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(20,p,G)});if(o||o===0){y+=o}y+="\n\n";y+="\n";y+='\n<div style="margin: 0px 5px 10px 5px">\n\n ';o=z.user;o=o==null||o===false?o:o.email;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(24,i,G)});if(o||o===0){y+=o}y+="\n</div>\n\n";o=z.message;o=x["if"].call(z,o,{hash:{},inverse:v.noop,fn:v.program(29,d,G)});if(o||o===0){y+=o}y+='\n\n<div id="quota-message-container" style="display: none">\n <div id="quota-message" class="errormessage">\n You are over your disk quota. Tool execution is on hold until your disk usage drops below your allocated quota.\n </div>\n</div>\n\n<div id="';n=x.id;if(n){o=n.call(z,{hash:{}})}else{o=z.id;o=typeof o===f?o():o}y+=e(o)+'-datasets" class="history-datasets-list"></div>\n\n<div class="infomessagesmall" id="emptyHistoryMessage" style="display: none;">\n ';n=x.local;if(n){o=n.call(z,{hash:{},inverse:v.noop,fn:v.program(31,w,G)})}else{o=z.local;o=typeof o===f?o():o}if(!x.local){o=c.call(z,o,{hash:{},inverse:v.noop,fn:v.program(31,w,G)})}if(o||o===0){y+=o}y+="\n</div>";return y})})(); \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/templates/compiled/template-user-quotaMeter-quota.js --- /dev/null +++ b/static/scripts/packed/templates/compiled/template-user-quotaMeter-quota.js @@ -0,0 +1,1 @@ +(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-user-quotaMeter-quota"]=b(function(e,l,d,k,j){d=d||e.helpers;var h="",c,g,f="function",i=this.escapeExpression;h+='<div id="quota-meter" class="quota-meter progress">\n <div id="quota-meter-bar" class="quota-meter-bar bar" style="width: ';g=d.quota_percent;if(g){c=g.call(l,{hash:{}})}else{c=l.quota_percent;c=typeof c===f?c():c}h+=i(c)+'%"></div>\n ';h+='\n <div id="quota-meter-text" class="quota-meter-text"style="top: 6px">\n Using ';g=d.quota_percent;if(g){c=g.call(l,{hash:{}})}else{c=l.quota_percent;c=typeof c===f?c():c}h+=i(c)+"%\n </div>\n</div>";return h})})(); \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/templates/compiled/template-user-quotaMeter-usage.js --- /dev/null +++ b/static/scripts/packed/templates/compiled/template-user-quotaMeter-usage.js @@ -0,0 +1,1 @@ +(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a["template-user-quotaMeter-usage"]=b(function(e,l,d,k,j){d=d||e.helpers;var h="",c,g,f="function",i=this.escapeExpression;h+='\n<div id="quota-meter" class="quota-meter" style="background-color: transparent">\n <div id="quota-meter-text" class="quota-meter-text" style="top: 6px; color: white">\n Using ';g=d.nice_total_disk_usage;if(g){c=g.call(l,{hash:{}})}else{c=l.nice_total_disk_usage;c=typeof c===f?c():c}h+=i(c)+"\n </div>\n</div>";return h})})(); \ No newline at end of file diff -r 79c884befb2333f79d1fd8a9af3e531c42a59d6b -r 3d27b35e1c1fa629ec4175f5e613b5a771152377 static/scripts/packed/viz/circster.js --- a/static/scripts/packed/viz/circster.js +++ b/static/scripts/packed/viz/circster.js @@ -1,1 +1,1 @@ -define(["libs/underscore","libs/d3","viz/visualization"],function(g,l,i){var m=Backbone.Model.extend({is_visible:function(q,n){var o=q.getBoundingClientRect(),p=$("svg")[0].getBoundingClientRect();if(o.right<0||o.left>p.right||o.bottom<0||o.top>p.bottom){return false}return true}});var h={drawTicks:function(r,q,v,p,n){var u=r.append("g").selectAll("g").data(q).enter().append("g").selectAll("g").data(v).enter().append("g").attr("class","tick").attr("transform",function(w){return"rotate("+(w.angle*180/Math.PI-90)+")translate("+w.radius+",0)"});var t=[],s=[],o=function(w){return w.angle>Math.PI?"end":null};if(n){t=[0,0,0,-4];s=[4,0,"",".35em"];o=null}else{t=[1,0,4,0];s=[0,4,".35em",""]}u.append("line").attr("x1",t[0]).attr("y1",t[1]).attr("x2",t[2]).attr("y1",t[3]).style("stroke","#000");u.append("text").attr("x",s[0]).attr("y",s[1]).attr("dx",s[2]).attr("dy",s[3]).attr("text-anchor",o).attr("transform",p).text(function(w){return w.label})},formatNum:function(o,n){var q=null;if(o<1){q=o.toPrecision(n)}else{var p=Math.round(o.toPrecision(n));if(o<1000){q=p}else{if(o<1000000){q=Math.round((p/1000).toPrecision(3)).toFixed(0)+"K"}else{if(o<1000000000){q=Math.round((p/1000000).toPrecision(3)).toFixed(0)+"M"}}}}return q}};var c=Backbone.Model.extend({});var a=Backbone.View.extend({className:"circster",initialize:function(n){this.total_gap=n.total_gap;this.genome=n.genome;this.dataset_arc_height=n.dataset_arc_height;this.track_gap=10;this.label_arc_height=50;this.scale=1;this.circular_views=null;this.chords_views=null;this.model.get("tracks").on("add",this.add_track,this);this.model.get("tracks").on("remove",this.remove_track,this);this.get_circular_tracks()},get_circular_tracks:function(){return this.model.get("tracks").filter(function(n){return n.get("track_type")!=="DiagonalHeatmapTrack"})},get_chord_tracks:function(){return this.model.get("tracks").filter(function(n){return n.get("track_type")==="DiagonalHeatmapTrack"})},get_tracks_bounds:function(){var o=this.get_circular_tracks();dataset_arc_height=this.dataset_arc_height,min_dimension=Math.min(this.$el.width(),this.$el.height()),radius_start=min_dimension/2-o.length*(this.dataset_arc_height+this.track_gap)-(this.label_arc_height+this.track_gap),tracks_start_radii=l.range(radius_start,min_dimension/2,this.dataset_arc_height+this.track_gap);var n=this;return g.map(tracks_start_radii,function(p){return[p,p+n.dataset_arc_height]})},render:function(){var w=this,q=this.dataset_arc_height,n=w.$el.width(),v=w.$el.height(),s=this.get_circular_tracks(),p=this.get_chord_tracks(),r=this.get_tracks_bounds(),o=l.select(w.$el[0]).append("svg").attr("width",n).attr("height",v).attr("pointer-events","all").append("svg:g").call(l.behavior.zoom().on("zoom",function(){var x=l.event.scale;o.attr("transform","translate("+l.event.translate+") scale("+x+")");if(w.scale!==x){if(w.zoom_drag_timeout){clearTimeout(w.zoom_drag_timeout)}w.zoom_drag_timeout=setTimeout(function(){},400)}})).attr("transform","translate("+n/2+","+v/2+")").append("svg:g").attr("class","tracks");this.circular_views=s.map(function(y,z){var A=(y.get("track_type")==="LineTrack"?d:e),x=new A({el:o.append("g")[0],track:y,radius_bounds:r[z],genome:w.genome,total_gap:w.total_gap});x.render();return x});this.chords_views=p.map(function(y){var x=new j({el:o.append("g")[0],track:y,radius_bounds:r[0],genome:w.genome,total_gap:w.total_gap});x.render();return x});var u=this.circular_views[this.circular_views.length-1].radius_bounds[1],t=[u,u+this.label_arc_height];this.label_track_view=new b({el:o.append("g")[0],track:new c(),radius_bounds:t,genome:w.genome,total_gap:w.total_gap});this.label_track_view.render()},add_track:function(t){if(t.get("track_type")==="DiagonalHeatmapTrack"){var p=this.circular_views[0].radius_bounds,s=new j({el:l.select("g.tracks").append("g")[0],track:t,radius_bounds:p,genome:this.genome,total_gap:this.total_gap});s.render();this.chords_views.push(s)}else{var r=this.get_tracks_bounds();g.each(this.circular_views,function(v,w){v.update_radius_bounds(r[w])});g.each(this.chords_views,function(v){v.update_radius_bounds(r[0])});var q=this.circular_views.length,u=(t.get("track_type")==="LineTrack"?d:e),n=new u({el:l.select("g.tracks").append("g")[0],track:t,radius_bounds:r[q],genome:this.genome,total_gap:this.total_gap});n.render();this.circular_views.push(n);var o=r[r.length-1];o[1]=o[0];this.label_track_view.update_radius_bounds(o)}},remove_track:function(o,q,p){var n=this.circular_views[p.index];this.circular_views.splice(p.index,1);n.$el.remove();var r=this.get_tracks_bounds();g.each(this.circular_views,function(s,t){s.update_radius_bounds(r[t])})}});var k=Backbone.View.extend({tagName:"g",initialize:function(n){this.bg_stroke="ccc";this.loading_bg_fill="000";this.bg_fill="ccc";this.total_gap=n.total_gap;this.track=n.track;this.radius_bounds=n.radius_bounds;this.genome=n.genome;this.chroms_layout=this._chroms_layout();this.data_bounds=[];this.scale=1;this.parent_elt=l.select(this.$el[0])},get_fill_color:function(){var n=this.track.get("config").get_value("block_color");if(!n){n=this.track.get("config").get_value("color")}return n},render:function(){var r=this.parent_elt;if(!r){console.log("no parent elt")}var q=this.chroms_layout,t=l.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]),n=r.selectAll("g").data(q).enter().append("svg:g"),p=n.append("path").attr("d",t).attr("class","chrom-background").style("stroke",this.bg_stroke).style("fill",this.loading_bg_fill);p.append("title").text(function(v){return v.data.chrom});var o=this,s=o.track.get("data_manager"),u=(s?s.data_is_ready():true);$.when(u).then(function(){$.when(o._render_data(r)).then(function(){p.style("fill",o.bg_fill);o.render_labels()})})},render_labels:function(){},update_radius_bounds:function(o){this.radius_bounds=o;var n=l.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]);this.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",n);this._transition_chrom_data();this._transition_labels()},update_scale:function(q){var p=this.scale;this.scale=q;if(q<=p){return}var o=this,n=new m();this.parent_elt.selectAll("path.chrom-data").filter(function(s,r){return n.is_visible(this)}).each(function(x,t){var w=l.select(this),s=w.attr("chrom"),v=o.genome.get_chrom_region(s),u=o.track.get("data_manager"),r;if(!u.can_get_more_detailed_data(v)){return}r=o.track.get("data_manager").get_more_detailed_data(v,"Coverage",0,q);$.when(r).then(function(A){w.remove();o._update_data_bounds();var z=g.find(o.chroms_layout,function(B){return B.data.chrom===s});var y=o.get_fill_color();o._render_chrom_data(o.parent_elt,z,A).style("stroke",y).style("fill",y)})});return o},_transition_chrom_data:function(){var o=this.track,q=this.chroms_layout,n=this.parent_elt.selectAll("g>path.chrom-data"),r=n[0].length;if(r>0){var p=this;$.when(o.get("data_manager").get_genome_wide_data(this.genome)).then(function(t){var s=g.reject(g.map(t,function(u,v){var w=null,x=p._get_path_function(q[v],u);if(x){w=x(u.data)}return w}),function(u){return u===null});n.each(function(v,u){l.select(this).transition().duration(1000).attr("d",s[u])})})}},_transition_labels:function(){},_update_data_bounds:function(){var n=this.data_bounds;this.data_bounds=this.get_data_bounds(this.track.get("data_manager").get_genome_wide_data(this.genome));if(this.data_bounds[0]<n[0]||this.data_bounds[1]>n[1]){this._transition_chrom_data()}},_render_data:function(q){var p=this,o=this.chroms_layout,n=this.track,r=$.Deferred();$.when(n.get("data_manager").get_genome_wide_data(this.genome)).then(function(t){p.data_bounds=p.get_data_bounds(t);layout_and_data=g.zip(o,t),chroms_data_layout=g.map(layout_and_data,function(u){var v=u[0],w=u[1];return p._render_chrom_data(q,v,w)});var s=p.get_fill_color();p.parent_elt.selectAll("path.chrom-data").style("stroke",s).style("fill",s);r.resolve(q)});return r},_render_chrom_data:function(n,o,p){},_get_path_function:function(o,n){},_chroms_layout:function(){var o=this.genome.get_chroms_info(),q=l.layout.pie().value(function(s){return s.len}).sort(null),r=q(o),n=this.total_gap/o.length,p=g.map(r,function(u,t){var s=u.endAngle-n;u.endAngle=(s>u.startAngle?s:u.startAngle);return u});return p}});var b=k.extend({initialize:function(n){k.prototype.initialize.call(this,n);this.innerRadius=this.radius_bounds[0];this.radius_bounds[0]=this.radius_bounds[1];this.bg_stroke="fff";this.bg_fill="fff";this.min_arc_len=0.08},_render_data:function(p){var o=this,n=p.selectAll("g");n.selectAll("path").attr("id",function(t){return"label-"+t.data.chrom});n.append("svg:text").filter(function(t){return t.endAngle-t.startAngle>o.min_arc_len}).attr("text-anchor","middle").append("svg:textPath").attr("xlink:href",function(t){return"#label-"+t.data.chrom}).attr("startOffset","25%").attr("font-weight","bold").text(function(t){return t.data.chrom});var q=function(v){var t=(v.endAngle-v.startAngle)/v.value,u=l.range(0,v.value,25000000).map(function(w,x){return{radius:o.innerRadius,angle:w*t+v.startAngle,label:x===0?0:(x%3?null:o.formatNum(w))}});if(u.length<4){u[u.length-1].label=o.formatNum(Math.round((u[u.length-1].angle-v.startAngle)/t))}return u};var s=function(t){return t.angle>Math.PI?"rotate(180)translate(-16)":null};var r=g.filter(this.chroms_layout,function(t){return t.endAngle-t.startAngle>o.min_arc_len});this.drawTicks(this.parent_elt,r,q,s)}});g.extend(b.prototype,h);var f=k.extend({_render_chrom_data:function(n,q,o){var r=this._get_path_function(q,o);if(!r){return null}var p=n.datum(o.data),s=p.append("path").attr("class","chrom-data").attr("chrom",q.data.chrom).attr("d",r);return s},_get_path_function:function(q,p){if(typeof p==="string"||!p.data||p.data.length===0){return null}var n=l.scale.linear().domain(this.data_bounds).range(this.radius_bounds);var r=l.scale.linear().domain([0,p.data.length]).range([q.startAngle,q.endAngle]);var o=l.svg.line.radial().interpolate("linear").radius(function(s){return n(s[1])}).angle(function(t,s){return r(s)});return l.svg.area.radial().interpolate(o.interpolate()).innerRadius(n(0)).outerRadius(o.radius()).angle(o.angle())},render_labels:function(){var n=this,q=function(){return"rotate(90)"};var p=g.filter(this.chroms_layout,function(r){return r.endAngle-r.startAngle>0.08}),o=g.filter(p,function(s,r){return r%3===0});this.drawTicks(this.parent_elt,o,this._data_bounds_ticks_fn(),q,true)},_transition_labels:function(){var o=this,q=g.filter(this.chroms_layout,function(r){return r.endAngle-r.startAngle>0.08}),p=g.filter(q,function(s,r){return r%3===0}),n=g.flatten(g.map(p,function(r){return o._data_bounds_ticks_fn()(r)}));this.parent_elt.selectAll("g.tick").data(n).transition().attr("transform",function(r){return"rotate("+(r.angle*180/Math.PI-90)+")translate("+r.radius+",0)"})},_data_bounds_ticks_fn:function(){var n=this;visibleChroms=0;return function(o){return[{radius:n.radius_bounds[0],angle:o.startAngle,label:n.formatNum(n.data_bounds[0])},{radius:n.radius_bounds[1],angle:o.startAngle,label:n.formatNum(n.data_bounds[1])}]}},get_data_bounds:function(n){}});g.extend(f.prototype,h);var e=f.extend({get_data_bounds:function(o){var n=g.map(o,function(p){if(typeof p==="string"||!p.max){return 0}return p.max});return[0,(n&&typeof n!=="string"?g.max(n):0)]}});var d=f.extend({get_data_bounds:function(o){var n=g.flatten(g.map(o,function(p){if(p){return g.map(p.data,function(q){return q[1]})}else{return 0}}));return[g.min(n),g.max(n)]}});var j=k.extend({render:function(){var n=this;$.when(n.track.get("data_manager").data_is_ready()).then(function(){$.when(n.track.get("data_manager").get_genome_wide_data(n.genome)).then(function(q){var p=[],o=n.genome.get_chroms_info();g.each(q,function(u,t){var r=o[t].chrom;var s=g.map(u.data,function(w){var v=n._get_region_angle(r,w[1]),x=n._get_region_angle(w[3],w[4]);return{source:{startAngle:v,endAngle:v+0.01},target:{startAngle:x,endAngle:x+0.01}}});p=p.concat(s)});n.parent_elt.append("g").attr("class","chord").selectAll("path").data(p).enter().append("path").style("fill",n.get_fill_color()).attr("d",l.svg.chord().radius(n.radius_bounds[0])).style("opacity",1)})})},update_radius_bounds:function(n){this.radius_bounds=n;this.parent_elt.selectAll("path").transition().attr("d",l.svg.chord().radius(this.radius_bounds[0]))},_get_region_angle:function(p,n){var o=g.find(this.chroms_layout,function(q){return q.data.chrom===p});return o.endAngle-((o.endAngle-o.startAngle)*(o.data.len-n)/o.data.len)}});return{CircsterView:a}}); \ No newline at end of file +define(["libs/underscore","libs/d3","viz/visualization"],function(g,l,i){var m=Backbone.Model.extend({is_visible:function(q,n){var o=q.getBoundingClientRect(),p=$("svg")[0].getBoundingClientRect();if(o.right<0||o.left>p.right||o.bottom<0||o.top>p.bottom){return false}return true}});var h={drawTicks:function(r,q,v,p,n){var u=r.append("g").selectAll("g").data(q).enter().append("g").selectAll("g").data(v).enter().append("g").attr("class","tick").attr("transform",function(w){return"rotate("+(w.angle*180/Math.PI-90)+")translate("+w.radius+",0)"});var t=[],s=[],o=function(w){return w.angle>Math.PI?"end":null};if(n){t=[0,0,0,-4];s=[4,0,"",".35em"];o=null}else{t=[1,0,4,0];s=[0,4,".35em",""]}u.append("line").attr("x1",t[0]).attr("y1",t[1]).attr("x2",t[2]).attr("y1",t[3]).style("stroke","#000");u.append("text").attr("x",s[0]).attr("y",s[1]).attr("dx",s[2]).attr("dy",s[3]).attr("text-anchor",o).attr("transform",p).text(function(w){return w.label})},formatNum:function(o,n){var q=null;if(o<1){q=o.toPrecision(n)}else{var p=Math.round(o.toPrecision(n));if(o<1000){q=p}else{if(o<1000000){q=Math.round((p/1000).toPrecision(3)).toFixed(0)+"K"}else{if(o<1000000000){q=Math.round((p/1000000).toPrecision(3)).toFixed(0)+"M"}}}}return q}};var c=Backbone.Model.extend({});var a=Backbone.View.extend({className:"circster",initialize:function(n){this.total_gap=n.total_gap;this.genome=n.genome;this.dataset_arc_height=n.dataset_arc_height;this.track_gap=10;this.label_arc_height=50;this.scale=1;this.circular_views=null;this.chords_views=null;this.model.get("tracks").on("add",this.add_track,this);this.model.get("tracks").on("remove",this.remove_track,this);this.get_circular_tracks()},get_circular_tracks:function(){return this.model.get("tracks").filter(function(n){return n.get("track_type")!=="DiagonalHeatmapTrack"})},get_chord_tracks:function(){return this.model.get("tracks").filter(function(n){return n.get("track_type")==="DiagonalHeatmapTrack"})},get_tracks_bounds:function(){var o=this.get_circular_tracks();dataset_arc_height=this.dataset_arc_height,min_dimension=Math.min(this.$el.width(),this.$el.height()),radius_start=min_dimension/2-o.length*(this.dataset_arc_height+this.track_gap)-(this.label_arc_height+this.track_gap),tracks_start_radii=l.range(radius_start,min_dimension/2,this.dataset_arc_height+this.track_gap);var n=this;return g.map(tracks_start_radii,function(p){return[p,p+n.dataset_arc_height]})},render:function(){var w=this,q=this.dataset_arc_height,n=w.$el.width(),v=w.$el.height(),s=this.get_circular_tracks(),p=this.get_chord_tracks(),r=this.get_tracks_bounds(),o=l.select(w.$el[0]).append("svg").attr("width",n).attr("height",v).attr("pointer-events","all").append("svg:g").call(l.behavior.zoom().on("zoom",function(){var x=l.event.scale;o.attr("transform","translate("+l.event.translate+") scale("+x+")");if(w.scale!==x){if(w.zoom_drag_timeout){clearTimeout(w.zoom_drag_timeout)}w.zoom_drag_timeout=setTimeout(function(){},400)}})).attr("transform","translate("+n/2+","+v/2+")").append("svg:g").attr("class","tracks");this.circular_views=s.map(function(y,z){var A=(y.get("track_type")==="LineTrack"?d:e),x=new A({el:o.append("g")[0],track:y,radius_bounds:r[z],genome:w.genome,total_gap:w.total_gap});x.render();return x});this.chords_views=p.map(function(y){var x=new j({el:o.append("g")[0],track:y,radius_bounds:r[0],genome:w.genome,total_gap:w.total_gap});x.render();return x});var u=this.circular_views[this.circular_views.length-1].radius_bounds[1],t=[u,u+this.label_arc_height];this.label_track_view=new b({el:o.append("g")[0],track:new c(),radius_bounds:t,genome:w.genome,total_gap:w.total_gap});this.label_track_view.render()},add_track:function(t){if(t.get("track_type")==="DiagonalHeatmapTrack"){var p=this.circular_views[0].radius_bounds,s=new j({el:l.select("g.tracks").append("g")[0],track:t,radius_bounds:p,genome:this.genome,total_gap:this.total_gap});s.render();this.chords_views.push(s)}else{var r=this.get_tracks_bounds();g.each(this.circular_views,function(v,w){v.update_radius_bounds(r[w])});g.each(this.chords_views,function(v){v.update_radius_bounds(r[0])});var q=this.circular_views.length,u=(t.get("track_type")==="LineTrack"?d:e),n=new u({el:l.select("g.tracks").append("g")[0],track:t,radius_bounds:r[q],genome:this.genome,total_gap:this.total_gap});n.render();this.circular_views.push(n);var o=r[r.length-1];o[1]=o[0];this.label_track_view.update_radius_bounds(o)}},remove_track:function(o,q,p){var n=this.circular_views[p.index];this.circular_views.splice(p.index,1);n.$el.remove();var r=this.get_tracks_bounds();g.each(this.circular_views,function(s,t){s.update_radius_bounds(r[t])})}});var k=Backbone.View.extend({tagName:"g",initialize:function(n){this.bg_stroke="ccc";this.loading_bg_fill="000";this.bg_fill="ccc";this.total_gap=n.total_gap;this.track=n.track;this.radius_bounds=n.radius_bounds;this.genome=n.genome;this.chroms_layout=this._chroms_layout();this.data_bounds=[];this.scale=1;this.parent_elt=l.select(this.$el[0])},get_fill_color:function(){var n=this.track.get("config").get_value("block_color");if(!n){n=this.track.get("config").get_value("color")}return n},render:function(){var r=this.parent_elt;if(!r){console.log("no parent elt")}var q=this.chroms_layout,t=l.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]),n=r.selectAll("g").data(q).enter().append("svg:g"),p=n.append("path").attr("d",t).attr("class","chrom-background").style("stroke",this.bg_stroke).style("fill",this.loading_bg_fill);p.append("title").text(function(v){return v.data.chrom});var o=this,s=o.track.get("data_manager"),u=(s?s.data_is_ready():true);$.when(u).then(function(){$.when(o._render_data(r)).then(function(){p.style("fill",o.bg_fill);o.render_labels()})})},render_labels:function(){},update_radius_bounds:function(o){this.radius_bounds=o;var n=l.svg.arc().innerRadius(this.radius_bounds[0]).outerRadius(this.radius_bounds[1]);this.parent_elt.selectAll("g>path.chrom-background").transition().duration(1000).attr("d",n);this._transition_chrom_data();this._transition_labels()},update_scale:function(q){var p=this.scale;this.scale=q;if(q<=p){return}var o=this,n=new m();this.parent_elt.selectAll("path.chrom-data").filter(function(s,r){return n.is_visible(this)}).each(function(x,t){var w=l.select(this),s=w.attr("chrom"),v=o.genome.get_chrom_region(s),u=o.track.get("data_manager"),r;if(!u.can_get_more_detailed_data(v)){return}r=o.track.get("data_manager").get_more_detailed_data(v,"Coverage",0,q);$.when(r).then(function(A){w.remove();o._update_data_bounds();var z=g.find(o.chroms_layout,function(B){return B.data.chrom===s});var y=o.get_fill_color();o._render_chrom_data(o.parent_elt,z,A).style("stroke",y).style("fill",y)})});return o},_transition_chrom_data:function(){var o=this.track,q=this.chroms_layout,n=this.parent_elt.selectAll("g>path.chrom-data"),r=n[0].length;if(r>0){var p=this;$.when(o.get("data_manager").get_genome_wide_data(this.genome)).then(function(t){var s=g.reject(g.map(t,function(u,v){var w=null,x=p._get_path_function(q[v],u);if(x){w=x(u.data)}return w}),function(u){return u===null});n.each(function(v,u){l.select(this).transition().duration(1000).attr("d",s[u])})})}},_transition_labels:function(){},_update_data_bounds:function(){var n=this.data_bounds;this.data_bounds=this.get_data_bounds(this.track.get("data_manager").get_genome_wide_data(this.genome));if(this.data_bounds[0]<n[0]||this.data_bounds[1]>n[1]){this._transition_chrom_data()}},_render_data:function(q){var p=this,o=this.chroms_layout,n=this.track,r=$.Deferred();$.when(n.get("data_manager").get_genome_wide_data(this.genome)).then(function(t){p.data_bounds=p.get_data_bounds(t);layout_and_data=g.zip(o,t),chroms_data_layout=g.map(layout_and_data,function(u){var v=u[0],w=u[1];return p._render_chrom_data(q,v,w)});var s=p.get_fill_color();p.parent_elt.selectAll("path.chrom-data").style("stroke",s).style("fill",s);r.resolve(q)});return r},_render_chrom_data:function(n,o,p){},_get_path_function:function(o,n){},_chroms_layout:function(){var o=this.genome.get_chroms_info(),q=l.layout.pie().value(function(s){return s.len}).sort(null),r=q(o),n=this.total_gap/o.length,p=g.map(r,function(u,t){var s=u.endAngle-n;u.endAngle=(s>u.startAngle?s:u.startAngle);return u});return p}});var b=k.extend({initialize:function(n){k.prototype.initialize.call(this,n);this.innerRadius=this.radius_bounds[0];this.radius_bounds[0]=this.radius_bounds[1];this.bg_stroke="fff";this.bg_fill="fff";this.min_arc_len=0.08},_render_data:function(p){var o=this,n=p.selectAll("g");n.selectAll("path").attr("id",function(t){return"label-"+t.data.chrom});n.append("svg:text").filter(function(t){return t.endAngle-t.startAngle>o.min_arc_len}).attr("text-anchor","middle").append("svg:textPath").attr("xlink:href",function(t){return"#label-"+t.data.chrom}).attr("startOffset","25%").attr("font-weight","bold").text(function(t){return t.data.chrom});var q=function(v){var t=(v.endAngle-v.startAngle)/v.value,u=l.range(0,v.value,25000000).map(function(w,x){return{radius:o.innerRadius,angle:w*t+v.startAngle,label:x===0?0:(x%3?null:o.formatNum(w))}});if(u.length<4){u[u.length-1].label=o.formatNum(Math.round((u[u.length-1].angle-v.startAngle)/t))}return u};var s=function(t){return t.angle>Math.PI?"rotate(180)translate(-16)":null};var r=g.filter(this.chroms_layout,function(t){return t.endAngle-t.startAngle>o.min_arc_len});this.drawTicks(this.parent_elt,r,q,s)}});g.extend(b.prototype,h);var f=k.extend({_quantile:function(o,n){o.sort(l.ascending);return l.quantile(o,n)},_render_chrom_data:function(n,q,o){var r=this._get_path_function(q,o);if(!r){return null}var p=n.datum(o.data),s=p.append("path").attr("class","chrom-data").attr("chrom",q.data.chrom).attr("d",r);return s},_get_path_function:function(q,p){if(typeof p==="string"||!p.data||p.data.length===0){return null}var n=l.scale.linear().domain(this.data_bounds).range(this.radius_bounds).clamp(true);var r=l.scale.linear().domain([0,p.data.length]).range([q.startAngle,q.endAngle]);var o=l.svg.line.radial().interpolate("linear").radius(function(s){return n(s[1])}).angle(function(t,s){return r(s)});return l.svg.area.radial().interpolate(o.interpolate()).innerRadius(n(0)).outerRadius(o.radius()).angle(o.angle())},render_labels:function(){var n=this,q=function(){return"rotate(90)"};var p=g.filter(this.chroms_layout,function(r){return r.endAngle-r.startAngle>0.08}),o=g.filter(p,function(s,r){return r%3===0});this.drawTicks(this.parent_elt,o,this._data_bounds_ticks_fn(),q,true)},_transition_labels:function(){var o=this,q=g.filter(this.chroms_layout,function(r){return r.endAngle-r.startAngle>0.08}),p=g.filter(q,function(s,r){return r%3===0}),n=g.flatten(g.map(p,function(r){return o._data_bounds_ticks_fn()(r)}));this.parent_elt.selectAll("g.tick").data(n).transition().attr("transform",function(r){return"rotate("+(r.angle*180/Math.PI-90)+")translate("+r.radius+",0)"})},_data_bounds_ticks_fn:function(){var n=this;visibleChroms=0;return function(o){return[{radius:n.radius_bounds[0],angle:o.startAngle,label:n.formatNum(n.data_bounds[0])},{radius:n.radius_bounds[1],angle:o.startAngle,label:n.formatNum(n.data_bounds[1])}]}},get_data_bounds:function(n){}});g.extend(f.prototype,h);var e=f.extend({get_data_bounds:function(o){var n=g.map(o,function(p){if(typeof p==="string"||!p.max){return 0}return p.max});return[0,(n&&typeof n!=="string"?this._quantile(values,0.98):0)]}});var d=f.extend({get_data_bounds:function(o){var n=g.flatten(g.map(o,function(p){if(p){return g.map(p.data,function(q){return q[1]})}else{return 0}}));return[g.min(n),this._quantile(n,0.98)]}});var j=k.extend({render:function(){var n=this;$.when(n.track.get("data_manager").data_is_ready()).then(function(){$.when(n.track.get("data_manager").get_genome_wide_data(n.genome)).then(function(q){var p=[],o=n.genome.get_chroms_info();g.each(q,function(u,t){var r=o[t].chrom;var s=g.map(u.data,function(w){var v=n._get_region_angle(r,w[1]),x=n._get_region_angle(w[3],w[4]);return{source:{startAngle:v,endAngle:v+0.01},target:{startAngle:x,endAngle:x+0.01}}});p=p.concat(s)});n.parent_elt.append("g").attr("class","chord").selectAll("path").data(p).enter().append("path").style("fill",n.get_fill_color()).attr("d",l.svg.chord().radius(n.radius_bounds[0])).style("opacity",1)})})},update_radius_bounds:function(n){this.radius_bounds=n;this.parent_elt.selectAll("path").transition().attr("d",l.svg.chord().radius(this.radius_bounds[0]))},_get_region_angle:function(p,n){var o=g.find(this.chroms_layout,function(q){return q.data.chrom===p});return o.endAngle-((o.endAngle-o.startAngle)*(o.data.len-n)/o.data.len)}});return{CircsterView:a}}); \ No newline at end of file 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.