commit/galaxy-central: carlfeberhard: Fix to 7155334: add user model to AMD chain for history panel
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/ec75df18a967/ Changeset: ec75df18a967 User: carlfeberhard Date: 2014-03-27 17:57:54 Summary: Fix to 7155334: add user model to AMD chain for history panel Affected #: 6 files diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 lib/galaxy/webapps/galaxy/api/histories.py --- a/lib/galaxy/webapps/galaxy/api/histories.py +++ b/lib/galaxy/webapps/galaxy/api/histories.py @@ -113,8 +113,6 @@ else: history = self.mgrs.histories.get( trans, self._decode_id( trans, history_id ), check_ownership=False, check_accessible=True, deleted=deleted ) - #history = self._get_history( trans, self._decode_id( trans, history_id ), - # check_ownership=False, check_accessible=True, deleted=deleted ) history_data = self.get_history_dict( trans, history ) history_data[ 'contents_url' ] = url_for( 'history_contents', history_id=history_id ) diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 static/scripts/mvc/history/current-history-panel.js --- a/static/scripts/mvc/history/current-history-panel.js +++ b/static/scripts/mvc/history/current-history-panel.js @@ -154,6 +154,7 @@ * @see Backbone.View#render */ render : function( speed, callback ){ + this.log( 'render:', speed, callback ); // send a speed of 0 to have no fade in/out performed speed = ( speed === undefined )?( this.fxSpeed ):( speed ); var panel = this, diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 static/scripts/mvc/history/readonly-history-panel.js --- a/static/scripts/mvc/history/readonly-history-panel.js +++ b/static/scripts/mvc/history/readonly-history-panel.js @@ -1,8 +1,9 @@ define([ "mvc/history/history-model", "mvc/dataset/hda-base", + "mvc/user/user-model", "mvc/base-mvc" -], function( historyModel, hdaBase, baseMVC ){ +], function( historyModel, hdaBase, userModel, baseMVC ){ // ============================================================================ /** session storage for individual history preferences */ var HistoryPrefs = baseMVC.SessionStorageModel.extend({ @@ -224,7 +225,7 @@ parsed = { message : this._bePolite( msg ), details : { - user : ( user instanceof User )?( user.toJSON() ):( user + '' ), + user : ( user instanceof userModel.User )?( user.toJSON() ):( user + '' ), source : ( model instanceof Backbone.Model )?( model.toJSON() ):( model + '' ), xhr : xhr, options : ( xhr )?( _.omit( options, 'xhr' ) ):( options ) @@ -485,7 +486,7 @@ // we'll always need the message container var $newRender = $( '<div/>' ), $msgContainer = $( '<div/>' ).addClass( 'message-container' ) - .css({ 'margin-left': '4px', 'margin-right': '4px' }); + .css({ 'margin': '4px' }); return $newRender.append( $msgContainer ); }, diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 static/scripts/packed/mvc/history/current-history-panel.js --- a/static/scripts/packed/mvc/history/current-history-panel.js +++ b/static/scripts/packed/mvc/history/current-history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/hda-edit","mvc/history/history-panel","mvc/base-mvc"],function(b,f,c){var d=c.SessionStorageModel.extend({defaults:{searching:false,tagsEditorShown:false,annotationEditorShown:false},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});d.storageKey=function e(){return("history-panel")};var a=f.HistoryPanel.extend({HDAViewClass:b.HDAEditView,emptyMsg:_l("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:_l("No matching datasets found"),initialize:function(g){g=g||{};this.preferences=new d(_.extend({id:d.storageKey()},_.pick(g,_.keys(d.prototype.defaults))));f.HistoryPanel.prototype.initialize.call(this,g)},loadCurrentHistory:function(h){var g=this;return this.loadHistoryWithHDADetails("current",h).then(function(j,i){g.trigger("current-history",g)})},switchToHistory:function(j,i){var g=this,h=function(){return jQuery.ajax({url:galaxy_config.root+"api/histories/"+j+"/set_as_current",method:"PUT"})};return this.loadHistoryWithHDADetails(j,i,h).then(function(l,k){g.trigger("switched-history",g)})},createNewHistory:function(i){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",_l("You must be logged in to create histories"));return $.when()}var g=this,h=function(){return jQuery.post(galaxy_config.root+"api/histories",{current:true})};return this.loadHistory(undefined,i,h).then(function(k,j){g.trigger("new-history",g)})},setModel:function(h,g,i){f.HistoryPanel.prototype.setModel.call(this,h,g,i);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpModelEventHandlers:function(){f.HistoryPanel.prototype._setUpModelEventHandlers.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}this.model.hdas.on("state:ready",function(h,i,g){if((!h.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeHdaView(this.hdaViews[h.id])}},this)},render:function(i,j){i=(i===undefined)?(this.fxSpeed):(i);var g=this,h;if(this.model){h=this.renderModel()}else{h=this.renderWithoutModel()}$(g).queue("fx",[function(k){if(i&&g.$el.is(":visible")){g.$el.fadeOut(i,k)}else{k()}},function(k){g.$el.empty();if(h){g.$el.append(h.children());g.renderBasedOnPrefs()}k()},function(k){if(i&&!g.$el.is(":visible")){g.$el.fadeIn(i,k)}else{k()}},function(k){if(j){j.call(this)}g.trigger("rendered",this);k()}]);return this},renderBasedOnPrefs:function(){if(this.preferences.get("searching")){this.toggleSearchControls(0,true)}},_renderEmptyMsg:function(i){var h=this,g=h.$emptyMessage(i),j=$(".toolMenuContainer");if((_.isEmpty(h.hdaViews)&&!h.searchFor)&&(Galaxy&&Galaxy.upload&&j.size())){g.empty();g.html([_l("This history is empty. "),_l("You can "),'<a class="uploader-link" href="javascript:void(0)">',_l("load your own data"),"</a>",_l(" or "),'<a class="get-data-link" href="javascript:void(0)">',_l("get data from an external source"),"</a>"].join(""));g.find(".uploader-link").click(function(k){Galaxy.upload._eventShow(k)});g.find(".get-data-link").click(function(k){j.parent().scrollTop(0);j.find('span:contains("Get Data")').click()});g.show()}else{f.HistoryPanel.prototype._renderEmptyMsg.call(this,i)}return this},toggleSearchControls:function(h,g){var i=f.HistoryPanel.prototype.toggleSearchControls.call(this,h,g);this.preferences.set("searching",i)},_renderTags:function(g){var h=this;f.HistoryPanel.prototype._renderTags.call(this,g);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("tagsEditorShown",i.hidden)})},_renderAnnotation:function(g){var h=this;f.HistoryPanel.prototype._renderAnnotation.call(this,g);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("annotationEditorShown",i.hidden)})},connectToQuotaMeter:function(g){if(!g){return this}this.listenTo(g,"quota:over",this.showQuotaMessage);this.listenTo(g,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(g&&g.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var g=this.$el.find(".quota-message");if(g.is(":hidden")){g.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var g=this.$el.find(".quota-message");if(!g.is(":hidden")){g.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(g){if(!g){return this}this.on("new-storage",function(i,h){if(g&&i){g.findItemByHtml(_l("Include Deleted Datasets")).checked=i.get("show_deleted");g.findItemByHtml(_l("Include Hidden Datasets")).checked=i.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{CurrentHistoryPanel:a}}); \ No newline at end of file +define(["mvc/dataset/hda-edit","mvc/history/history-panel","mvc/base-mvc"],function(b,f,c){var d=c.SessionStorageModel.extend({defaults:{searching:false,tagsEditorShown:false,annotationEditorShown:false},toString:function(){return"HistoryPanelPrefs("+JSON.stringify(this.toJSON())+")"}});d.storageKey=function e(){return("history-panel")};var a=f.HistoryPanel.extend({HDAViewClass:b.HDAEditView,emptyMsg:_l("This history is empty. Click 'Get Data' on the left tool menu to start"),noneFoundMsg:_l("No matching datasets found"),initialize:function(g){g=g||{};this.preferences=new d(_.extend({id:d.storageKey()},_.pick(g,_.keys(d.prototype.defaults))));f.HistoryPanel.prototype.initialize.call(this,g)},loadCurrentHistory:function(h){var g=this;return this.loadHistoryWithHDADetails("current",h).then(function(j,i){g.trigger("current-history",g)})},switchToHistory:function(j,i){var g=this,h=function(){return jQuery.ajax({url:galaxy_config.root+"api/histories/"+j+"/set_as_current",method:"PUT"})};return this.loadHistoryWithHDADetails(j,i,h).then(function(l,k){g.trigger("switched-history",g)})},createNewHistory:function(i){if(!Galaxy||!Galaxy.currUser||Galaxy.currUser.isAnonymous()){this.displayMessage("error",_l("You must be logged in to create histories"));return $.when()}var g=this,h=function(){return jQuery.post(galaxy_config.root+"api/histories",{current:true})};return this.loadHistory(undefined,i,h).then(function(k,j){g.trigger("new-history",g)})},setModel:function(h,g,i){f.HistoryPanel.prototype.setModel.call(this,h,g,i);if(this.model){this.log("checking for updates");this.model.checkForUpdates()}return this},_setUpModelEventHandlers:function(){f.HistoryPanel.prototype._setUpModelEventHandlers.call(this);if(Galaxy&&Galaxy.quotaMeter){this.listenTo(this.model,"change:nice_size",function(){Galaxy.quotaMeter.update()})}this.model.hdas.on("state:ready",function(h,i,g){if((!h.get("visible"))&&(!this.storage.get("show_hidden"))){this.removeHdaView(this.hdaViews[h.id])}},this)},render:function(i,j){this.log("render:",i,j);i=(i===undefined)?(this.fxSpeed):(i);var g=this,h;if(this.model){h=this.renderModel()}else{h=this.renderWithoutModel()}$(g).queue("fx",[function(k){if(i&&g.$el.is(":visible")){g.$el.fadeOut(i,k)}else{k()}},function(k){g.$el.empty();if(h){g.$el.append(h.children());g.renderBasedOnPrefs()}k()},function(k){if(i&&!g.$el.is(":visible")){g.$el.fadeIn(i,k)}else{k()}},function(k){if(j){j.call(this)}g.trigger("rendered",this);k()}]);return this},renderBasedOnPrefs:function(){if(this.preferences.get("searching")){this.toggleSearchControls(0,true)}},_renderEmptyMsg:function(i){var h=this,g=h.$emptyMessage(i),j=$(".toolMenuContainer");if((_.isEmpty(h.hdaViews)&&!h.searchFor)&&(Galaxy&&Galaxy.upload&&j.size())){g.empty();g.html([_l("This history is empty. "),_l("You can "),'<a class="uploader-link" href="javascript:void(0)">',_l("load your own data"),"</a>",_l(" or "),'<a class="get-data-link" href="javascript:void(0)">',_l("get data from an external source"),"</a>"].join(""));g.find(".uploader-link").click(function(k){Galaxy.upload._eventShow(k)});g.find(".get-data-link").click(function(k){j.parent().scrollTop(0);j.find('span:contains("Get Data")').click()});g.show()}else{f.HistoryPanel.prototype._renderEmptyMsg.call(this,i)}return this},toggleSearchControls:function(h,g){var i=f.HistoryPanel.prototype.toggleSearchControls.call(this,h,g);this.preferences.set("searching",i)},_renderTags:function(g){var h=this;f.HistoryPanel.prototype._renderTags.call(this,g);if(this.preferences.get("tagsEditorShown")){this.tagsEditor.toggle(true)}this.tagsEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("tagsEditorShown",i.hidden)})},_renderAnnotation:function(g){var h=this;f.HistoryPanel.prototype._renderAnnotation.call(this,g);if(this.preferences.get("annotationEditorShown")){this.annotationEditor.toggle(true)}this.annotationEditor.on("hiddenUntilActivated:shown hiddenUntilActivated:hidden",function(i){h.preferences.set("annotationEditorShown",i.hidden)})},connectToQuotaMeter:function(g){if(!g){return this}this.listenTo(g,"quota:over",this.showQuotaMessage);this.listenTo(g,"quota:under",this.hideQuotaMessage);this.on("rendered rendered:initial",function(){if(g&&g.isOverQuota()){this.showQuotaMessage()}});return this},showQuotaMessage:function(){var g=this.$el.find(".quota-message");if(g.is(":hidden")){g.slideDown(this.fxSpeed)}},hideQuotaMessage:function(){var g=this.$el.find(".quota-message");if(!g.is(":hidden")){g.slideUp(this.fxSpeed)}},connectToOptionsMenu:function(g){if(!g){return this}this.on("new-storage",function(i,h){if(g&&i){g.findItemByHtml(_l("Include Deleted Datasets")).checked=i.get("show_deleted");g.findItemByHtml(_l("Include Hidden Datasets")).checked=i.get("show_hidden")}});return this},toString:function(){return"CurrentHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});return{CurrentHistoryPanel:a}}); \ No newline at end of file diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 static/scripts/packed/mvc/history/readonly-history-panel.js --- a/static/scripts/packed/mvc/history/readonly-history-panel.js +++ b/static/scripts/packed/mvc/history/readonly-history-panel.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-model","mvc/dataset/hda-base","mvc/base-mvc"],function(e,a,d){var g=d.SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(k){var j="expandedHdas";this.save(j,_.extend(this.get(j),_.object([k],[true])))},removeExpandedHda:function(k){var j="expandedHdas";this.save(j,_.omit(this.get(j),k))},toString:function(){return"HistoryPrefs("+this.id+")"}});g.storageKeyPrefix="history:";g.historyStorageKey=function c(j){if(!j){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+j)}return(g.storageKeyPrefix+j)};g.get=function b(j){return new g({id:g.historyStorageKey(j)})};g.clearAll=function f(k){for(var j in sessionStorage){if(j.indexOf(g.storageKeyPrefix)===0){sessionStorage.removeItem(j)}}};var h=Backbone.View.extend(d.LoggableMixin).extend({HDAViewClass:a.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(j){j=j||{};if(j.logger){this.logger=j.logger}this.log(this+".initialize:",j);this.linkTarget=j.linkTarget||"_blank";this.fxSpeed=_.has(j,"fxSpeed")?(j.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=j.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var k=_.pick(j,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,k,false);if(j.onready){j.onready.call(this)}},_setUpListeners:function(){this.on("error",function(k,n,j,m,l){this.errorHandler(k,n,j,m,l)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(j){this.log(this+"",arguments)},this)}return this},errorHandler:function(l,o,k,n,m){console.error(l,o,k,n,m);if(o&&o.status===0&&o.readyState===0){}else{if(o&&o.status===502){}else{var j=this._parseErrorMessage(l,o,k,n,m);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",j.message,j.details)})}else{this.displayMessage("error",j.message,j.details)}}}},_parseErrorMessage:function(m,q,l,p,o){var k=Galaxy.currUser,j={message:this._bePolite(p),details:{user:(k instanceof User)?(k.toJSON()):(k+""),source:(m instanceof Backbone.Model)?(m.toJSON()):(m+""),xhr:q,options:(q)?(_.omit(l,"xhr")):(l)}};_.extend(j.details,o||{});if(q&&_.isFunction(q.getAllResponseHeaders)){var n=q.getAllResponseHeaders();n=_.compact(n.split("\n"));n=_.map(n,function(r){return r.split(": ")});j.details.xhr.responseHeaders=_.object(n)}return j},_bePolite:function(j){j=j||_l("An error occurred while getting updates from the server");return j+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(l,k,j,n){var m=function(o){return _.keys(g.get(o.id).get("expandedHdas"))};return this.loadHistory(l,k,j,n,m)},loadHistory:function(m,l,k,p,n){var j=this;l=l||{};j.trigger("loading-history",j);var o=e.History.getHistoryData(m,{historyFn:k,hdaFn:p,hdaDetailIds:l.initiallyExpanded||n});return j._loadHistoryFromXHR(o,l).fail(function(s,q,r){j.trigger("error",j,s,l,_l("An error was encountered while "+q),{historyId:m,history:r||{}})}).always(function(){j.trigger("loading-done",j)})},_loadHistoryFromXHR:function(l,k){var j=this;l.then(function(m,n){j.JSONToModel(m,n,k)});l.fail(function(n,m){j.render()});return l},JSONToModel:function(m,j,k){this.log("JSONToModel:",m,j,k);k=k||{};var l=new e.History(m,j,k);this.setModel(l);return this},setModel:function(k,j,l){j=j||{};l=(l!==undefined)?(l):(true);this.log("setModel:",k,j,l);this.freeModel();this.selectedHdaIds=[];if(k){this.model=k;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(j.initiallyExpanded,j.show_deleted,j.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(l){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(k,j,l){this.storage=new g({id:g.historyStorageKey(this.model.get("id"))});if(_.isObject(k)){this.storage.set("exandedHdas",k)}if(_.isBoolean(j)){this.storage.set("show_deleted",j)}if(_.isBoolean(l)){this.storage.set("show_hidden",l)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(k,m,j,l){this.errorHandler(k,m,j,l)},this);return this},render:function(l,m){this.log("render:",l,m);l=(l===undefined)?(this.fxSpeed):(l);var j=this,k;if(this.model){k=this.renderModel()}else{k=this.renderWithoutModel()}$(j).queue("fx",[function(n){if(l&&j.$el.is(":visible")){j.$el.fadeOut(l,n)}else{n()}},function(n){j.$el.empty();if(k){j.$el.append(k.children())}n()},function(n){if(l&&!j.$el.is(":visible")){j.$el.fadeIn(l,n)}else{n()}},function(n){if(m){m.call(this)}j.trigger("rendered",this);n()}]);return this},renderWithoutModel:function(){var j=$("<div/>"),k=$("<div/>").addClass("message-container").css({"margin-left":"4px","margin-right":"4px"});return j.append(k)},renderModel:function(){var j=$("<div/>");j.append(h.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(j).text(this.emptyMsg);j.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(j);this.renderHdas(j);return j},_renderEmptyMsg:function(l){var k=this,j=k.$emptyMessage(l);if(!_.isEmpty(k.hdaViews)){j.hide()}else{if(k.searchFor){j.text(k.noneFoundMsg).show()}else{j.text(k.emptyMsg).show()}}return this},_renderSearchButton:function(j){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(j){j=j||this.$el;j.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(j.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(j){return(j||this.$el).find(".datasets-list")},$messages:function(j){return(j||this.$el).find(".message-container")},$emptyMessage:function(j){return(j||this.$el).find(".empty-history-message")},renderHdas:function(k){k=k||this.$el;var j=this,m={},l=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(k).empty();if(l.length){l.each(function(o){var n=o.get("id"),p=j._createHdaView(o);m[n]=p;if(_.contains(j.selectedHdaIds,n)){p.selected=true}j.attachHdaView(p.render(),k)})}this.hdaViews=m;this._renderEmptyMsg(k);return this.hdaViews},_createHdaView:function(k){var j=k.get("id"),l=new this.HDAViewClass({model:k,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[j],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(l);return l},_setUpHdaListeners:function(k){var j=this;k.on("error",function(m,o,l,n){j.errorHandler(m,o,l,n)});k.on("body-expanded",function(l){j.storage.addExpandedHda(l)});k.on("body-collapsed",function(l){j.storage.removeExpandedHda(l)});return this},attachHdaView:function(l,k){k=k||this.$el;var j=this.$datasetsList(k);j.prepend(l.$el);return this},addHdaView:function(m){this.log("add."+this,m);var k=this;if(!m.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return k}$({}).queue([function l(o){var n=k.$emptyMessage();if(n.is(":visible")){n.fadeOut(k.fxSpeed,o)}else{o()}},function j(n){var o=k._createHdaView(m);k.hdaViews[m.id]=o;o.render().$el.hide();k.scrollToTop();k.attachHdaView(o);o.$el.slideDown(k.fxSpeed)}]);return k},refreshHdas:function(k,j){if(this.model){return this.model.refresh(k,j)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(j){j.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(j){j=(j!==undefined)?(j):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",j);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(j){j=(j!==undefined)?(j):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",j);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(k){var l=this,m=".history-search-input";function j(n){if(l.model.hdas.haveDetails()){l.searchHdas(n);return}l.$el.find(m).searchInput("toggle-loading");l.model.hdas.fetchAllDetails({silent:true}).always(function(){l.$el.find(m).searchInput("toggle-loading")}).done(function(){l.searchHdas(n)})}k.searchInput({initialVal:l.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:j,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return k},toggleSearchControls:function(l,j){var k=this.$el.find(".history-search-controls"),m=(jQuery.type(l)==="number")?(l):(this.fxSpeed);j=(j!==undefined)?(j):(!k.is(":visible"));if(j){k.slideDown(m,function(){$(this).find("input").focus()})}else{k.slideUp(m)}return j},searchHdas:function(j){var k=this;this.searchFor=j;this.filters=[function(l){return l.matchesAll(k.searchFor)}];this.trigger("search:searching",j,this);this.renderHdas();return this},clearHdaSearch:function(j){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(k,j,l){j=(j!==undefined)?(j):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,l)}else{this.$el.fadeOut(j);this.indicator.show(k,j,l)}},_hideLoadingIndicator:function(j,k){j=(j!==undefined)?(j):(this.fxSpeed);if(this.indicator){this.indicator.hide(j,k)}},displayMessage:function(o,p,n){var l=this;this.scrollToTop();var m=this.$messages(),j=$("<div/>").addClass(o+"message").html(p);if(!_.isEmpty(n)){var k=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(l._messageToModalOptions(o,p,n));return false});j.append(" ",k)}return m.html(j)},_messageToModalOptions:function(n,p,m){var j=this,o=$("<div/>"),l={title:"Details"};function k(q){q=_.omit(q,_.functions(q));return["<table>",_.map(q,function(s,r){s=(_.isObject(s))?(k(s)):(s);return'<tr><td style="vertical-align: top; color: grey">'+r+'</td><td style="padding-left: 8px">'+s+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(m)){l.body=o.append(k(m))}else{l.body=o.html(m)}l.buttons={Ok:function(){Galaxy.modal.hide();j.clearMessages()}};return l},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(j){this.$container().scrollTop(j);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(k){if((!k)||(!this.hdaViews[k])){return this}var j=this.hdaViews[k];this.scrollTo(j.el.offsetTop);return this},scrollToHid:function(j){var k=this.model.hdas.getByHid(j);if(!k){return this}return this.scrollToId(k.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var i=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',_l("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',_l("You are over your disk quota."),_l("Tool execution is on hold until your disk usage drops below your allocated quota."),"</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',_l("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',_l("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',_l("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',_l("Your history is empty. Click 'Get Data' on the left pane to start"),"</div>"].join("");h.templates={historyPanel:function(j){return _.template(i,j,{variable:"history"})}};return{ReadOnlyHistoryPanel:h}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/dataset/hda-base","mvc/user/user-model","mvc/base-mvc"],function(f,b,a,e){var h=e.SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(l){var k="expandedHdas";this.save(k,_.extend(this.get(k),_.object([l],[true])))},removeExpandedHda:function(l){var k="expandedHdas";this.save(k,_.omit(this.get(k),l))},toString:function(){return"HistoryPrefs("+this.id+")"}});h.storageKeyPrefix="history:";h.historyStorageKey=function d(k){if(!k){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+k)}return(h.storageKeyPrefix+k)};h.get=function c(k){return new h({id:h.historyStorageKey(k)})};h.clearAll=function g(l){for(var k in sessionStorage){if(k.indexOf(h.storageKeyPrefix)===0){sessionStorage.removeItem(k)}}};var i=Backbone.View.extend(e.LoggableMixin).extend({HDAViewClass:b.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(k){k=k||{};if(k.logger){this.logger=k.logger}this.log(this+".initialize:",k);this.linkTarget=k.linkTarget||"_blank";this.fxSpeed=_.has(k,"fxSpeed")?(k.fxSpeed):(this.fxSpeed);this.filters=[];this.searchFor="";this.findContainerFn=k.findContainerFn;this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this._setUpListeners();var l=_.pick(k,"initiallyExpanded","show_deleted","show_hidden");this.setModel(this.model,l,false);if(k.onready){k.onready.call(this)}},_setUpListeners:function(){this.on("error",function(l,o,k,n,m){this.errorHandler(l,o,k,n,m)});this.on("loading-history",function(){this._showLoadingIndicator("loading history...",40)});this.on("loading-done",function(){this._hideLoadingIndicator(40);if(_.isEmpty(this.hdaViews)){this.trigger("empty-history",this)}});this.once("rendered",function(){this.trigger("rendered:initial",this);return false});if(this.logger){this.on("all",function(k){this.log(this+"",arguments)},this)}return this},errorHandler:function(m,p,l,o,n){console.error(m,p,l,o,n);if(p&&p.status===0&&p.readyState===0){}else{if(p&&p.status===502){}else{var k=this._parseErrorMessage(m,p,l,o,n);if(!this.$messages().is(":visible")){this.once("rendered",function(){this.displayMessage("error",k.message,k.details)})}else{this.displayMessage("error",k.message,k.details)}}}},_parseErrorMessage:function(n,r,m,q,p){var l=Galaxy.currUser,k={message:this._bePolite(q),details:{user:(l instanceof a.User)?(l.toJSON()):(l+""),source:(n instanceof Backbone.Model)?(n.toJSON()):(n+""),xhr:r,options:(r)?(_.omit(m,"xhr")):(m)}};_.extend(k.details,p||{});if(r&&_.isFunction(r.getAllResponseHeaders)){var o=r.getAllResponseHeaders();o=_.compact(o.split("\n"));o=_.map(o,function(s){return s.split(": ")});k.details.xhr.responseHeaders=_.object(o)}return k},_bePolite:function(k){k=k||_l("An error occurred while getting updates from the server");return k+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(m,l,k,o){var n=function(p){return _.keys(h.get(p.id).get("expandedHdas"))};return this.loadHistory(m,l,k,o,n)},loadHistory:function(n,m,l,q,o){var k=this;m=m||{};k.trigger("loading-history",k);var p=f.History.getHistoryData(n,{historyFn:l,hdaFn:q,hdaDetailIds:m.initiallyExpanded||o});return k._loadHistoryFromXHR(p,m).fail(function(t,r,s){k.trigger("error",k,t,m,_l("An error was encountered while "+r),{historyId:n,history:s||{}})}).always(function(){k.trigger("loading-done",k)})},_loadHistoryFromXHR:function(m,l){var k=this;m.then(function(n,o){k.JSONToModel(n,o,l)});m.fail(function(o,n){k.render()});return m},JSONToModel:function(n,k,l){this.log("JSONToModel:",n,k,l);l=l||{};var m=new f.History(n,k,l);this.setModel(m);return this},setModel:function(l,k,m){k=k||{};m=(m!==undefined)?(m):(true);this.log("setModel:",l,k,m);this.freeModel();this.selectedHdaIds=[];if(l){this.model=l;if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(k.initiallyExpanded,k.show_deleted,k.show_hidden);this._setUpModelEventHandlers();this.trigger("new-model",this)}if(m){this.render()}return this},freeModel:function(){if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.freeHdaViews();return this},freeHdaViews:function(){this.hdaViews={};return this},_setUpWebStorage:function(l,k,m){this.storage=new h({id:h.historyStorageKey(this.model.get("id"))});if(_.isObject(l)){this.storage.set("exandedHdas",l)}if(_.isBoolean(k)){this.storage.set("show_deleted",k)}if(_.isBoolean(m)){this.storage.set("show_hidden",m)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get());return this},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(l,n,k,m){this.errorHandler(l,n,k,m)},this);return this},render:function(m,n){this.log("render:",m,n);m=(m===undefined)?(this.fxSpeed):(m);var k=this,l;if(this.model){l=this.renderModel()}else{l=this.renderWithoutModel()}$(k).queue("fx",[function(o){if(m&&k.$el.is(":visible")){k.$el.fadeOut(m,o)}else{o()}},function(o){k.$el.empty();if(l){k.$el.append(l.children())}o()},function(o){if(m&&!k.$el.is(":visible")){k.$el.fadeIn(m,o)}else{o()}},function(o){if(n){n.call(this)}k.trigger("rendered",this);o()}]);return this},renderWithoutModel:function(){var k=$("<div/>"),l=$("<div/>").addClass("message-container").css({margin:"4px"});return k.append(l)},renderModel:function(){var k=$("<div/>");k.append(i.templates.historyPanel(this.model.toJSON()));this.$emptyMessage(k).text(this.emptyMsg);k.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(k);this.renderHdas(k);return k},_renderEmptyMsg:function(m){var l=this,k=l.$emptyMessage(m);if(!_.isEmpty(l.hdaViews)){k.hide()}else{if(l.searchFor){k.text(l.noneFoundMsg).show()}else{k.text(l.emptyMsg).show()}}return this},_renderSearchButton:function(k){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(k){k=k||this.$el;k.find("[title]").tooltip({placement:"bottom"});this._setUpSearchInput(k.find(".history-search-controls .history-search-input"));return this},$container:function(){return(this.findContainerFn)?(this.findContainerFn.call(this)):(this.$el.parent())},$datasetsList:function(k){return(k||this.$el).find(".datasets-list")},$messages:function(k){return(k||this.$el).find(".message-container")},$emptyMessage:function(k){return(k||this.$el).find(".empty-history-message")},renderHdas:function(l){l=l||this.$el;var k=this,n={},m=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);this.$datasetsList(l).empty();if(m.length){m.each(function(p){var o=p.get("id"),q=k._createHdaView(p);n[o]=q;if(_.contains(k.selectedHdaIds,o)){q.selected=true}k.attachHdaView(q.render(),l)})}this.hdaViews=n;this._renderEmptyMsg(l);return this.hdaViews},_createHdaView:function(l){var k=l.get("id"),m=new this.HDAViewClass({model:l,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[k],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(m);return m},_setUpHdaListeners:function(l){var k=this;l.on("error",function(n,p,m,o){k.errorHandler(n,p,m,o)});l.on("body-expanded",function(m){k.storage.addExpandedHda(m)});l.on("body-collapsed",function(m){k.storage.removeExpandedHda(m)});return this},attachHdaView:function(m,l){l=l||this.$el;var k=this.$datasetsList(l);k.prepend(m.$el);return this},addHdaView:function(n){this.log("add."+this,n);var l=this;if(!n.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return l}$({}).queue([function m(p){var o=l.$emptyMessage();if(o.is(":visible")){o.fadeOut(l.fxSpeed,p)}else{p()}},function k(o){var p=l._createHdaView(n);l.hdaViews[n.id]=p;p.render().$el.hide();l.scrollToTop();l.attachHdaView(p);p.$el.slideDown(l.fxSpeed)}]);return l},refreshHdas:function(l,k){if(this.model){return this.model.refresh(l,k)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(k){k.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{});return this},toggleShowDeleted:function(k){k=(k!==undefined)?(k):(!this.storage.get("show_deleted"));this.storage.set("show_deleted",k);this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(k){k=(k!==undefined)?(k):(!this.storage.get("show_hidden"));this.storage.set("show_hidden",k);this.renderHdas();return this.storage.get("show_hidden")},_setUpSearchInput:function(l){var m=this,n=".history-search-input";function k(o){if(m.model.hdas.haveDetails()){m.searchHdas(o);return}m.$el.find(n).searchInput("toggle-loading");m.model.hdas.fetchAllDetails({silent:true}).always(function(){m.$el.find(n).searchInput("toggle-loading")}).done(function(){m.searchHdas(o)})}l.searchInput({initialVal:m.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:k,onsearch:_.bind(this.searchHdas,this),onclear:_.bind(this.clearHdaSearch,this)});return l},toggleSearchControls:function(m,k){var l=this.$el.find(".history-search-controls"),n=(jQuery.type(m)==="number")?(m):(this.fxSpeed);k=(k!==undefined)?(k):(!l.is(":visible"));if(k){l.slideDown(n,function(){$(this).find("input").focus()})}else{l.slideUp(n)}return k},searchHdas:function(k){var l=this;this.searchFor=k;this.filters=[function(m){return m.matchesAll(l.searchFor)}];this.trigger("search:searching",k,this);this.renderHdas();return this},clearHdaSearch:function(k){this.searchFor="";this.filters=[];this.trigger("search:clear",this);this.renderHdas();return this},_showLoadingIndicator:function(l,k,m){k=(k!==undefined)?(k):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,m)}else{this.$el.fadeOut(k);this.indicator.show(l,k,m)}},_hideLoadingIndicator:function(k,l){k=(k!==undefined)?(k):(this.fxSpeed);if(this.indicator){this.indicator.hide(k,l)}},displayMessage:function(p,q,o){var m=this;this.scrollToTop();var n=this.$messages(),k=$("<div/>").addClass(p+"message").html(q);if(!_.isEmpty(o)){var l=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(m._messageToModalOptions(p,q,o));return false});k.append(" ",l)}return n.html(k)},_messageToModalOptions:function(o,q,n){var k=this,p=$("<div/>"),m={title:"Details"};function l(r){r=_.omit(r,_.functions(r));return["<table>",_.map(r,function(t,s){t=(_.isObject(t))?(l(t)):(t);return'<tr><td style="vertical-align: top; color: grey">'+s+'</td><td style="padding-left: 8px">'+t+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(n)){m.body=p.append(l(n))}else{m.body=p.html(n)}m.buttons={Ok:function(){Galaxy.modal.hide();k.clearMessages()}};return m},clearMessages:function(){this.$messages().empty();return this},scrollPosition:function(){return this.$container().scrollTop()},scrollTo:function(k){this.$container().scrollTop(k);return this},scrollToTop:function(){this.$container().scrollTop(0);return this},scrollToId:function(l){if((!l)||(!this.hdaViews[l])){return this}var k=this.hdaViews[l];this.scrollTo(k.el.offsetTop);return this},scrollToHid:function(k){var l=this.model.hdas.getByHid(k);if(!l){return this}return this.scrollToId(l.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});var j=['<div class="history-controls">','<div class="history-search-controls">','<div class="history-search-input"></div>',"</div>",'<div class="history-title">',"<% if( history.name ){ %>",'<div class="history-name"><%= history.name %></div>',"<% } %>","</div>",'<div class="history-subtitle clear">',"<% if( history.nice_size ){ %>",'<div class="history-size"><%= history.nice_size %></div>',"<% } %>",'<div class="history-secondary-actions"></div>',"</div>","<% if( history.deleted ){ %>",'<div class="warningmessagesmall"><strong>',_l("You are currently viewing a deleted history!"),"</strong></div>","<% } %>",'<div class="message-container">',"<% if( history.message ){ %>",'<div class="<%= history.status %>message"><%= history.message %></div>',"<% } %>","</div>",'<div class="quota-message errormessage">',_l("You are over your disk quota."),_l("Tool execution is on hold until your disk usage drops below your allocated quota."),"</div>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="history-dataset-actions">','<div class="btn-group">','<button class="history-select-all-datasets-btn btn btn-default"','data-mode="select">',_l("All"),"</button>",'<button class="history-deselect-all-datasets-btn btn btn-default"','data-mode="select">',_l("None"),"</button>","</div>",'<button class="history-dataset-action-popup-btn btn btn-default">',_l("For all selected"),"...</button>","</div>","</div>",'<div class="datasets-list"></div>','<div class="empty-history-message infomessagesmall">',_l("Your history is empty. Click 'Get Data' on the left pane to start"),"</div>"].join("");i.templates={historyPanel:function(k){return _.template(j,k,{variable:"history"})}};return{ReadOnlyHistoryPanel:i}}); \ No newline at end of file diff -r 4d99cae3baac3d5c136541aaed5aa640881e6a5b -r ec75df18a967a60c8026b6a24ddfe37351ba22e5 templates/webapps/galaxy/history/history_panel.mako --- a/templates/webapps/galaxy/history/history_panel.mako +++ b/templates/webapps/galaxy/history/history_panel.mako @@ -15,14 +15,10 @@ el : $( "${selector_to_attach_to}" ), linkTarget : 'galaxy_main', onready : function loadAsCurrentHistoryPanel(){ - var panel = this; this.connectToQuotaMeter( Galaxy.quotaMeter ) .connectToOptionsMenu( Galaxy.historyOptionsMenu ); - this.loadCurrentHistory() - .fail( function(){ - panel.render(); - }); - } + this.loadCurrentHistory(); + } }); Galaxy.currHistoryPanel = currPanel; }); Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org