commit/galaxy-central: carlfeberhard: Embedded histories: refactor and clean up
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2403d6f67500/ Changeset: 2403d6f67500 User: carlfeberhard Date: 2014-02-21 23:19:19 Summary: Embedded histories: refactor and clean up Affected #: 10 files diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a lib/galaxy/webapps/galaxy/controllers/history.py --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -753,21 +753,7 @@ history.annotation = self.get_item_annotation_str( trans.sa_session, history.user, history ) for dataset in datasets: dataset.annotation = self.get_item_annotation_str( trans.sa_session, history.user, dataset ) - - user_is_owner = trans.user == history.user - history.annotation = self.get_item_annotation_str( trans.sa_session, history.user, history ) - - hda_dicts = [] - datasets = self.get_history_datasets( trans, history ) - for hda in datasets: - hda_dict = self.get_hda_dict( trans, hda ) - hda_dict[ 'annotation' ] = self.get_item_annotation_str( trans.sa_session, history.user, hda ) - hda_dicts.append( hda_dict ) - history_dict = self.get_history_dict( trans, history, hda_dictionaries=hda_dicts ) - history_dict[ 'annotation' ] = history.annotation - - return trans.fill_template( "history/item_content.mako", item=history, item_data=datasets, - user_is_owner=user_is_owner, history_dict=history_dict, hda_dicts=hda_dicts ) + return trans.stream_template_mako( "/history/item_content.mako", item = history, item_data = datasets ) @web.expose def name_autocomplete_data( self, trans, q=None, limit=None, timestamp=None ): diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a lib/galaxy/webapps/galaxy/controllers/page.py --- a/lib/galaxy/webapps/galaxy/controllers/page.py +++ b/lib/galaxy/webapps/galaxy/controllers/page.py @@ -721,27 +721,52 @@ def get_item( self, trans, id ): return self.get_page( trans, id ) + def _get_embedded_history_html( self, trans, id ): + """ + Returns html suitable for embedding in another page. + """ + history = self.get_history( trans, id, False, True ) + if not history: + return None + + # create ownership flag for template, dictify models + # note: adding original annotation since this is published - get_dict returns user-based annos + user_is_owner = trans.user == history.user + history.annotation = self.get_item_annotation_str( trans.sa_session, history.user, history ) + + hda_dicts = [] + datasets = self.get_history_datasets( trans, history ) + for hda in datasets: + hda_dict = self.get_hda_dict( trans, hda ) + hda_dict[ 'annotation' ] = self.get_item_annotation_str( trans.sa_session, history.user, hda ) + hda_dicts.append( hda_dict ) + history_dict = self.get_history_dict( trans, history, hda_dictionaries=hda_dicts ) + history_dict[ 'annotation' ] = history.annotation + + filled = trans.fill_template( "history/embed.mako", item=history, item_data=datasets, + user_is_owner=user_is_owner, history_dict=history_dict, hda_dicts=hda_dicts ) + return filled + def _get_embed_html( self, trans, item_class, item_id ): """ Returns HTML for embedding an item in a page. """ item_class = self.get_class( item_class ) if item_class == model.History: - history = self.get_history( trans, item_id, False, True ) - history.annotation = self.get_item_annotation_str( trans.sa_session, history.user, history ) - if history: - datasets = self.get_history_datasets( trans, history ) - return trans.fill_template( "history/embed.mako", item=history, item_data=datasets ) + return self._get_embedded_history_html( trans, item_id ) + elif item_class == model.HistoryDatasetAssociation: dataset = self.get_dataset( trans, item_id, False, True ) dataset.annotation = self.get_item_annotation_str( trans.sa_session, dataset.history.user, dataset ) if dataset: data = self.get_data( dataset ) return trans.fill_template( "dataset/embed.mako", item=dataset, item_data=data ) + elif item_class == model.StoredWorkflow: workflow = self.get_stored_workflow( trans, item_id, False, True ) workflow.annotation = self.get_item_annotation_str( trans.sa_session, workflow.user, workflow ) if workflow: self.get_stored_workflow_steps( trans, workflow ) return trans.fill_template( "workflow/embed.mako", item=workflow, item_data=workflow.latest_workflow.steps ) + elif item_class == model.Visualization: visualization = self.get_visualization( trans, item_id, False, True ) visualization.annotation = self.get_item_annotation_str( trans.sa_session, visualization.user, visualization ) diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a 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 @@ -107,6 +107,9 @@ // ---- handle models passed on init if( this.model ){ + if( this.logger ){ + this.model.logger = this.logger; + } this._setUpWebStorage( attributes.initiallyExpanded, attributes.show_deleted, attributes.show_hidden ); this._setUpModelEventHandlers(); } @@ -302,6 +305,9 @@ newHistoryJSON.user = Galaxy.currUser.toJSON(); } this.model = new historyModel.History( newHistoryJSON, newHdaJSON, attributes ); + if( this.logger ){ + this.model.logger = this.logger; + } this._setUpWebStorage( attributes.initiallyExpanded, attributes.show_deleted, attributes.show_hidden ); this._setUpModelEventHandlers(); this.selectedHdaIds = []; diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a 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"],function(e,a){var d=SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(f){this.save("expandedHdas",_.extend(this.get("expandedHdas"),_.object([f],[true])))},removeExpandedHda:function(f){this.save("expandedHdas",_.omit(this.get("expandedHdas"),f))},toString:function(){return"HistoryPrefs("+this.id+")"}});d.historyStorageKey=function c(f){if(!f){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+f)}return("history:"+f)};var b=Backbone.View.extend(LoggableMixin).extend({HDAViewClass:a.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",datasetsSelector:".datasets-list",msgsSelector:".message-container",emptyMsgSelector:".empty-history-message",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(f){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.linkTarget=f.linkTarget||"_blank";this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this.filters=[];this.searchFor="";this._setUpListeners();if(this.model){this._setUpWebStorage(f.initiallyExpanded,f.show_deleted,f.show_hidden);this._setUpModelEventHandlers()}if(f.onready){f.onready.call(this)}},_setUpListeners:function(){this.on("error",function(g,j,f,i,h){this.errorHandler(g,j,f,i,h)});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(f){this.log(this+"",arguments)},this)}},errorHandler:function(h,k,g,j,i){var f=this._parseErrorMessage(h,k,g,j,i);if(k&&k.status===0&&k.readyState===0){}else{if(k&&k.status===502){}else{if(!this.$el.find(this.msgsSelector).is(":visible")){this.once("rendered",function(){this.displayMessage("error",f.message,f.details)})}else{this.displayMessage("error",f.message,f.details)}}}},_parseErrorMessage:function(i,m,h,l,k){var g=Galaxy.currUser,f={message:this._bePolite(l),details:{user:(g instanceof User)?(g.toJSON()):(g+""),source:(i instanceof Backbone.Model)?(i.toJSON()):(i+""),xhr:m,options:(m)?(_.omit(h,"xhr")):(h)}};_.extend(f.details,k||{});if(m&&_.isFunction(m.getAllResponseHeaders)){var j=m.getAllResponseHeaders();j=_.compact(j.split("\n"));j=_.map(j,function(n){return n.split(": ")});f.details.xhr.responseHeaders=_.object(j)}return f},_bePolite:function(f){f=f||_l("An error occurred while getting updates from the server");return f+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(i,h,g,k){var f=this,j=function(l){return f.getExpandedHdaIds(l.id)};return this.loadHistory(i,h,g,k,j)},loadHistory:function(i,h,g,l,j){this.trigger("loading-history",this);h=h||{};var f=this;var k=e.History.getHistoryData(i,{historyFn:g,hdaFn:l,hdaDetailIds:h.initiallyExpanded||j});return this._loadHistoryFromXHR(k,h).fail(function(o,m,n){f.trigger("error",f,o,h,_l("An error was encountered while "+m),{historyId:i,history:n||{}})}).always(function(){f.trigger("loading-done",f)})},_loadHistoryFromXHR:function(h,g){var f=this;h.then(function(i,j){f.setModel(i,j,g)});h.fail(function(j,i){f.render()});return h},setModel:function(h,f,g){g=g||{};if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.hdaViews={};if(Galaxy&&Galaxy.currUser){h.user=Galaxy.currUser.toJSON()}this.model=new e.History(h,f,g);this._setUpWebStorage(g.initiallyExpanded,g.show_deleted,g.show_hidden);this._setUpModelEventHandlers();this.selectedHdaIds=[];this.trigger("new-model",this);this.render();return this},_setUpWebStorage:function(g,f,h){this.storage=new d({id:d.historyStorageKey(this.model.get("id"))});if(_.isObject(g)){this.storage.set("exandedHdas",g)}if(_.isBoolean(f)){this.storage.set("show_deleted",f)}if(_.isBoolean(h)){this.storage.set("show_hidden",h)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get())},clearWebStorage:function(){for(var f in sessionStorage){if(f.indexOf("history:")===0){sessionStorage.removeItem(f)}}},getStoredOptions:function(g){if(!g||g==="current"){return(this.storage)?(this.storage.get()):({})}var f=sessionStorage.getItem(d.historyStorageKey(g));return(f===null)?({}):(JSON.parse(f))},getExpandedHdaIds:function(f){var g=this.getStoredOptions(f).expandedHdas;return((_.isEmpty(g))?([]):(_.keys(g)))},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(g,i,f,h){this.errorHandler(g,i,f,h)},this)},render:function(h,i){h=(h===undefined)?(this.fxSpeed):(h);var f=this,g;if(this.model){g=this.renderModel()}else{g=this.renderWithoutModel()}$(f).queue("fx",[function(j){if(h&&f.$el.is(":visible")){f.$el.fadeOut(h,j)}else{j()}},function(j){f.$el.empty();if(g){f.$el.append(g.children())}j()},function(j){if(h&&!f.$el.is(":visible")){f.$el.fadeIn(h,j)}else{j()}},function(j){if(i){i.call(this)}f.trigger("rendered",this);j()}]);return this},renderWithoutModel:function(){var f=$("<div/>"),g=$("<div/>").addClass("message-container").css({"margin-left":"4px","margin-right":"4px"});return f.append(g)},renderModel:function(){var f=$("<div/>");f.append(b.templates.historyPanel(this.model.toJSON()));f.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(f);this.renderHdas(f);return f},_renderSearchButton:function(f){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},createHdaView:function(g){var f=g.get("id"),h=new this.HDAViewClass({model:g,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[f],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(h);return h},_setUpHdaListeners:function(g){var f=this;g.on("body-expanded",function(h){f.storage.addExpandedHda(h)});g.on("body-collapsed",function(h){f.storage.removeExpandedHda(h)});g.on("error",function(i,k,h,j){f.errorHandler(i,k,h,j)})},renderHdas:function(g){g=g||this.$el;var f=this,i={},h=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);g.find(this.datasetsSelector).empty();if(h.length){h.each(function(k){var j=k.get("id"),l=f.createHdaView(k);i[j]=l;if(_.contains(f.selectedHdaIds,j)){l.selected=true}f.attachHdaView(l.render(),g)});g.find(this.emptyMsgSelector).hide()}else{g.find(this.emptyMsgSelector).text((this.model.hdas.length&&this.searchFor)?(this.noneFoundMsg):(this.emptyMsg)).show()}this.hdaViews=i;return this.hdaViews},attachHdaView:function(h,g){g=g||this.$el;var f=g.find(this.datasetsSelector);f.prepend(h.$el)},addHdaView:function(i){this.log("add."+this,i);var g=this;if(!i.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return}$({}).queue([function h(k){var j=g.$el.find(g.emptyMsgSelector);if(j.is(":visible")){j.fadeOut(g.fxSpeed,k)}else{k()}},function f(k){g.scrollToTop();var j=g.$el.find(g.datasetsSelector),l=g.createHdaView(i);g.hdaViews[i.id]=l;l.render().$el.hide().prependTo(j).slideDown(g.fxSpeed)}])},refreshHdas:function(g,f){if(this.model){return this.model.refresh(g,f)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(f){f.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{})},toggleShowDeleted:function(){this.storage.set("show_deleted",!this.storage.get("show_deleted"));this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(){this.storage.set("show_hidden",!this.storage.get("show_hidden"));this.renderHdas();return this.storage.get("show_hidden")},setUpSearchInput:function(g){var h=this,k=".history-search-input";function j(l){h.searchFor=l;h.filters=[function(m){return m.matchesAll(h.searchFor)}];h.trigger("search:searching",l,h);h.renderHdas()}function f(l){if(h.model.hdas.haveDetails()){j(l);return}h.$el.find(k).searchInput("toggle-loading");h.model.hdas.fetchAllDetails({silent:true}).always(function(){h.$el.find(k).searchInput("toggle-loading")}).done(function(){j(l)})}function i(){h.searchFor="";h.filters=[];h.trigger("search:clear",h);h.renderHdas()}g.searchInput({initialVal:h.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:f,onsearch:j,onclear:i});return g},showSearchControls:function(g){g=(g===undefined)?(this.fxSpeed):(g);var f=this.$el.find(".history-search-controls"),h=f.find(".history-search-input");if(!h.children().size()){this.setUpSearchInput(h)}f.slideDown(g,function(){$(this).find("input").focus()})},hideSearchControls:function(f){f=(f===undefined)?(this.fxSpeed):(f);this.$el.find(".history-search-controls").slideUp(f)},toggleSearchControls:function(f){speed=(jQuery.type(f)==="number")?(f):(this.fxSpeed);if(this.$el.find(".history-search-controls").is(":visible")){this.hideSearchControls(speed)}else{this.showSearchControls(speed)}},showLoadingIndicator:function(g,f,h){f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},hideLoadingIndicator:function(f,g){f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},displayMessage:function(k,l,j){var h=this;this.scrollToTop();var i=this.$el.find(this.msgsSelector),f=$("<div/>").addClass(k+"message").html(l);if(!_.isEmpty(j)){var g=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(h._messageToModalOptions(k,l,j));return false});f.append(" ",g)}return i.html(f)},_messageToModalOptions:function(j,l,i){var f=this,k=$("<div/>"),h={title:"Details"};function g(m){m=_.omit(m,_.functions(m));return["<table>",_.map(m,function(o,n){o=(_.isObject(o))?(g(o)):(o);return'<tr><td style="vertical-align: top; color: grey">'+n+'</td><td style="padding-left: 8px">'+o+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(i)){h.body=k.append(g(i))}else{h.body=k.html(i)}h.buttons={Ok:function(){Galaxy.modal.hide();f.clearMessages()}};return h},clearMessages:function(){var f=this.$el.find(this.msgsSelector);f.empty()},scrollPosition:function(){return this.$el.scrollTop()},scrollTo:function(f){this.$el.scrollTop(f);return this},scrollToTop:function(){this.$el.scrollTop(0);return this},scrollIntoView:function(k,g){if(g===undefined){this.scrollTo(k);return this}var f=window,j=this.$el.parent(),i=$(f).innerHeight(),h=(i/2)-(g/2);this.scrollTo(k-h);return this},scrollToId:function(g){if((!g)||(!this.hdaViews[g])){return this}var f=this.hdaViews[g].$el;this.scrollIntoView(f.offset().top,f.outerHeight());return this},scrollToHid:function(f){var g=this.model.hdas.getByHid(f);if(!g){return this}return this.scrollToId(g.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});b.templates={historyPanel:Handlebars.templates["template-history-historyPanel"]};return{ReadOnlyHistoryPanel:b}}); \ No newline at end of file +define(["mvc/history/history-model","mvc/dataset/hda-base"],function(e,a){var d=SessionStorageModel.extend({defaults:{expandedHdas:{},show_deleted:false,show_hidden:false},addExpandedHda:function(f){this.save("expandedHdas",_.extend(this.get("expandedHdas"),_.object([f],[true])))},removeExpandedHda:function(f){this.save("expandedHdas",_.omit(this.get("expandedHdas"),f))},toString:function(){return"HistoryPrefs("+this.id+")"}});d.historyStorageKey=function c(f){if(!f){throw new Error("HistoryPrefs.historyStorageKey needs valid id: "+f)}return("history:"+f)};var b=Backbone.View.extend(LoggableMixin).extend({HDAViewClass:a.HDABaseView,tagName:"div",className:"history-panel",fxSpeed:"fast",datasetsSelector:".datasets-list",msgsSelector:".message-container",emptyMsgSelector:".empty-history-message",emptyMsg:_l("This history is empty"),noneFoundMsg:_l("No matching datasets found"),initialize:function(f){f=f||{};if(f.logger){this.logger=f.logger}this.log(this+".initialize:",f);this.linkTarget=f.linkTarget||"_blank";this.fxSpeed=_.has(f,"fxSpeed")?(f.fxSpeed):(this.fxSpeed);this.hdaViews={};this.indicator=new LoadingIndicator(this.$el);this.filters=[];this.searchFor="";this._setUpListeners();if(this.model){if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(f.initiallyExpanded,f.show_deleted,f.show_hidden);this._setUpModelEventHandlers()}if(f.onready){f.onready.call(this)}},_setUpListeners:function(){this.on("error",function(g,j,f,i,h){this.errorHandler(g,j,f,i,h)});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(f){this.log(this+"",arguments)},this)}},errorHandler:function(h,k,g,j,i){var f=this._parseErrorMessage(h,k,g,j,i);if(k&&k.status===0&&k.readyState===0){}else{if(k&&k.status===502){}else{if(!this.$el.find(this.msgsSelector).is(":visible")){this.once("rendered",function(){this.displayMessage("error",f.message,f.details)})}else{this.displayMessage("error",f.message,f.details)}}}},_parseErrorMessage:function(i,m,h,l,k){var g=Galaxy.currUser,f={message:this._bePolite(l),details:{user:(g instanceof User)?(g.toJSON()):(g+""),source:(i instanceof Backbone.Model)?(i.toJSON()):(i+""),xhr:m,options:(m)?(_.omit(h,"xhr")):(h)}};_.extend(f.details,k||{});if(m&&_.isFunction(m.getAllResponseHeaders)){var j=m.getAllResponseHeaders();j=_.compact(j.split("\n"));j=_.map(j,function(n){return n.split(": ")});f.details.xhr.responseHeaders=_.object(j)}return f},_bePolite:function(f){f=f||_l("An error occurred while getting updates from the server");return f+". "+_l("Please contact a Galaxy administrator if the problem persists.")},loadHistoryWithHDADetails:function(i,h,g,k){var f=this,j=function(l){return f.getExpandedHdaIds(l.id)};return this.loadHistory(i,h,g,k,j)},loadHistory:function(i,h,g,l,j){this.trigger("loading-history",this);h=h||{};var f=this;var k=e.History.getHistoryData(i,{historyFn:g,hdaFn:l,hdaDetailIds:h.initiallyExpanded||j});return this._loadHistoryFromXHR(k,h).fail(function(o,m,n){f.trigger("error",f,o,h,_l("An error was encountered while "+m),{historyId:i,history:n||{}})}).always(function(){f.trigger("loading-done",f)})},_loadHistoryFromXHR:function(h,g){var f=this;h.then(function(i,j){f.setModel(i,j,g)});h.fail(function(j,i){f.render()});return h},setModel:function(h,f,g){g=g||{};if(this.model){this.model.clearUpdateTimeout();this.stopListening(this.model);this.stopListening(this.model.hdas)}this.hdaViews={};if(Galaxy&&Galaxy.currUser){h.user=Galaxy.currUser.toJSON()}this.model=new e.History(h,f,g);if(this.logger){this.model.logger=this.logger}this._setUpWebStorage(g.initiallyExpanded,g.show_deleted,g.show_hidden);this._setUpModelEventHandlers();this.selectedHdaIds=[];this.trigger("new-model",this);this.render();return this},_setUpWebStorage:function(g,f,h){this.storage=new d({id:d.historyStorageKey(this.model.get("id"))});if(_.isObject(g)){this.storage.set("exandedHdas",g)}if(_.isBoolean(f)){this.storage.set("show_deleted",f)}if(_.isBoolean(h)){this.storage.set("show_hidden",h)}this.trigger("new-storage",this.storage,this);this.log(this+" (init'd) storage:",this.storage.get())},clearWebStorage:function(){for(var f in sessionStorage){if(f.indexOf("history:")===0){sessionStorage.removeItem(f)}}},getStoredOptions:function(g){if(!g||g==="current"){return(this.storage)?(this.storage.get()):({})}var f=sessionStorage.getItem(d.historyStorageKey(g));return(f===null)?({}):(JSON.parse(f))},getExpandedHdaIds:function(f){var g=this.getStoredOptions(f).expandedHdas;return((_.isEmpty(g))?([]):(_.keys(g)))},_setUpModelEventHandlers:function(){this.model.hdas.on("add",this.addHdaView,this);this.model.on("error error:hdas",function(g,i,f,h){this.errorHandler(g,i,f,h)},this)},render:function(h,i){h=(h===undefined)?(this.fxSpeed):(h);var f=this,g;if(this.model){g=this.renderModel()}else{g=this.renderWithoutModel()}$(f).queue("fx",[function(j){if(h&&f.$el.is(":visible")){f.$el.fadeOut(h,j)}else{j()}},function(j){f.$el.empty();if(g){f.$el.append(g.children())}j()},function(j){if(h&&!f.$el.is(":visible")){f.$el.fadeIn(h,j)}else{j()}},function(j){if(i){i.call(this)}f.trigger("rendered",this);j()}]);return this},renderWithoutModel:function(){var f=$("<div/>"),g=$("<div/>").addClass("message-container").css({"margin-left":"4px","margin-right":"4px"});return f.append(g)},renderModel:function(){var f=$("<div/>");f.append(b.templates.historyPanel(this.model.toJSON()));f.find(".history-secondary-actions").prepend(this._renderSearchButton());this._setUpBehaviours(f);this.renderHdas(f);return f},_renderSearchButton:function(f){return faIconButton({title:_l("Search datasets"),classes:"history-search-btn",faIcon:"fa-search"})},_setUpBehaviours:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},createHdaView:function(g){var f=g.get("id"),h=new this.HDAViewClass({model:g,linkTarget:this.linkTarget,expanded:this.storage.get("expandedHdas")[f],hasUser:this.model.ownedByCurrUser(),logger:this.logger});this._setUpHdaListeners(h);return h},_setUpHdaListeners:function(g){var f=this;g.on("body-expanded",function(h){f.storage.addExpandedHda(h)});g.on("body-collapsed",function(h){f.storage.removeExpandedHda(h)});g.on("error",function(i,k,h,j){f.errorHandler(i,k,h,j)})},renderHdas:function(g){g=g||this.$el;var f=this,i={},h=this.model.hdas.getVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"),this.filters);g.find(this.datasetsSelector).empty();if(h.length){h.each(function(k){var j=k.get("id"),l=f.createHdaView(k);i[j]=l;if(_.contains(f.selectedHdaIds,j)){l.selected=true}f.attachHdaView(l.render(),g)});g.find(this.emptyMsgSelector).hide()}else{g.find(this.emptyMsgSelector).text((this.model.hdas.length&&this.searchFor)?(this.noneFoundMsg):(this.emptyMsg)).show()}this.hdaViews=i;return this.hdaViews},attachHdaView:function(h,g){g=g||this.$el;var f=g.find(this.datasetsSelector);f.prepend(h.$el)},addHdaView:function(i){this.log("add."+this,i);var g=this;if(!i.isVisible(this.storage.get("show_deleted"),this.storage.get("show_hidden"))){return}$({}).queue([function h(k){var j=g.$el.find(g.emptyMsgSelector);if(j.is(":visible")){j.fadeOut(g.fxSpeed,k)}else{k()}},function f(k){g.scrollToTop();var j=g.$el.find(g.datasetsSelector),l=g.createHdaView(i);g.hdaViews[i.id]=l;l.render().$el.hide().prependTo(j).slideDown(g.fxSpeed)}])},refreshHdas:function(g,f){if(this.model){return this.model.refresh(g,f)}return $.when()},events:{"click .message-container":"clearMessages","click .history-search-btn":"toggleSearchControls"},collapseAllHdaBodies:function(){_.each(this.hdaViews,function(f){f.toggleBodyVisibility(null,false)});this.storage.set("expandedHdas",{})},toggleShowDeleted:function(){this.storage.set("show_deleted",!this.storage.get("show_deleted"));this.renderHdas();return this.storage.get("show_deleted")},toggleShowHidden:function(){this.storage.set("show_hidden",!this.storage.get("show_hidden"));this.renderHdas();return this.storage.get("show_hidden")},setUpSearchInput:function(g){var h=this,k=".history-search-input";function j(l){h.searchFor=l;h.filters=[function(m){return m.matchesAll(h.searchFor)}];h.trigger("search:searching",l,h);h.renderHdas()}function f(l){if(h.model.hdas.haveDetails()){j(l);return}h.$el.find(k).searchInput("toggle-loading");h.model.hdas.fetchAllDetails({silent:true}).always(function(){h.$el.find(k).searchInput("toggle-loading")}).done(function(){j(l)})}function i(){h.searchFor="";h.filters=[];h.trigger("search:clear",h);h.renderHdas()}g.searchInput({initialVal:h.searchFor,name:"history-search",placeholder:"search datasets",classes:"history-search",onfirstsearch:f,onsearch:j,onclear:i});return g},showSearchControls:function(g){g=(g===undefined)?(this.fxSpeed):(g);var f=this.$el.find(".history-search-controls"),h=f.find(".history-search-input");if(!h.children().size()){this.setUpSearchInput(h)}f.slideDown(g,function(){$(this).find("input").focus()})},hideSearchControls:function(f){f=(f===undefined)?(this.fxSpeed):(f);this.$el.find(".history-search-controls").slideUp(f)},toggleSearchControls:function(f){speed=(jQuery.type(f)==="number")?(f):(this.fxSpeed);if(this.$el.find(".history-search-controls").is(":visible")){this.hideSearchControls(speed)}else{this.showSearchControls(speed)}},showLoadingIndicator:function(g,f,h){f=(f!==undefined)?(f):(this.fxSpeed);if(!this.indicator){this.indicator=new LoadingIndicator(this.$el,this.$el.parent())}if(!this.$el.is(":visible")){this.indicator.show(0,h)}else{this.$el.fadeOut(f);this.indicator.show(g,f,h)}},hideLoadingIndicator:function(f,g){f=(f!==undefined)?(f):(this.fxSpeed);if(this.indicator){this.indicator.hide(f,g)}},displayMessage:function(k,l,j){var h=this;this.scrollToTop();var i=this.$el.find(this.msgsSelector),f=$("<div/>").addClass(k+"message").html(l);if(!_.isEmpty(j)){var g=$('<a href="javascript:void(0)">Details</a>').click(function(){Galaxy.modal.show(h._messageToModalOptions(k,l,j));return false});f.append(" ",g)}return i.html(f)},_messageToModalOptions:function(j,l,i){var f=this,k=$("<div/>"),h={title:"Details"};function g(m){m=_.omit(m,_.functions(m));return["<table>",_.map(m,function(o,n){o=(_.isObject(o))?(g(o)):(o);return'<tr><td style="vertical-align: top; color: grey">'+n+'</td><td style="padding-left: 8px">'+o+"</td></tr>"}).join(""),"</table>"].join("")}if(_.isObject(i)){h.body=k.append(g(i))}else{h.body=k.html(i)}h.buttons={Ok:function(){Galaxy.modal.hide();f.clearMessages()}};return h},clearMessages:function(){var f=this.$el.find(this.msgsSelector);f.empty()},scrollPosition:function(){return this.$el.scrollTop()},scrollTo:function(f){this.$el.scrollTop(f);return this},scrollToTop:function(){this.$el.scrollTop(0);return this},scrollIntoView:function(k,g){if(g===undefined){this.scrollTo(k);return this}var f=window,j=this.$el.parent(),i=$(f).innerHeight(),h=(i/2)-(g/2);this.scrollTo(k-h);return this},scrollToId:function(g){if((!g)||(!this.hdaViews[g])){return this}var f=this.hdaViews[g].$el;this.scrollIntoView(f.offset().top,f.outerHeight());return this},scrollToHid:function(f){var g=this.model.hdas.getByHid(f);if(!g){return this}return this.scrollToId(g.id)},toString:function(){return"ReadOnlyHistoryPanel("+((this.model)?(this.model.get("name")):(""))+")"}});b.templates={historyPanel:Handlebars.templates["template-history-historyPanel"]};return{ReadOnlyHistoryPanel:b}}); \ No newline at end of file diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1652,7 +1652,7 @@ .history-panel .message-container{cursor:pointer} .history-panel .message-container [class$=message]{margin:0px;margin-bottom:8px} .history-panel .history-controls{margin:10px;padding:0px}.history-panel .history-controls .history-search-controls{display:none;padding:0px 0px 8px 0px} -.history-panel .history-controls .history-title{margin-bottom:4px} +.history-panel .history-controls .history-title{margin-bottom:8px} .history-panel .history-controls .history-name{word-wrap:break-word;font-weight:bold} .history-panel .history-controls .history-title input{width:100%;margin:-2px 0 -2px -4px;font-weight:bold} .history-panel .history-controls .history-subtitle{margin-bottom:8px} @@ -1688,8 +1688,8 @@ .dataset.state-discarded{background:#eee}.dataset.state-discarded .state-icon:before{content:"\f014"} .dataset.state-noPermission{background:#eee;filter:alpha(opacity=60);-moz-opacity:.60;opacity:.60}.dataset.state-noPermission .state-icon{font-size:20px}.dataset.state-noPermission .state-icon:before{content:"\f023"} .dataset.state-new{background:#eee}.dataset.state-new .state-icon:before{content:"\f06a"} -.annotated-history-panel{padding-top:10px}.annotated-history-panel [class$=messagesmall]{margin:8px 0px 8px 0px} -.annotated-history-panel .history-controls{margin:0px 0px 16px 4px;padding:0px}.annotated-history-panel .history-controls .history-name{font-size:150%} +.annotated-history-panel [class$=messagesmall]{margin:8px 0px 8px 0px} +.annotated-history-panel .history-controls{margin:0px 0px 16px 4px;padding:0px}.annotated-history-panel .history-controls .history-name{font-size:150%;margin-bottom:4px} .annotated-history-panel .history-controls .history-subtitle{margin:0px;padding:0px 0px 0px 4px;padding-left:4px} .annotated-history-panel .history-controls .history-annotation{border:1px solid lightgrey;border-width:1px 0px 0px 0px;padding:4px 0px 4px 0px;margin:4px;white-space:pre-wrap} .annotated-history-panel .history-controls .history-annotation:empty{display:none} diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a static/style/src/less/history.less --- a/static/style/src/less/history.less +++ b/static/style/src/less/history.less @@ -411,7 +411,7 @@ } .history-title { - margin-bottom: 4px; + margin-bottom: 8px; } .history-name { word-wrap: break-word; @@ -692,7 +692,6 @@ .annotated-history-panel { //TODO: most of these styles are specific to history/display.mako and not to this type of panel in general //TODO: some of these styles are also overrides of history-panel - remove those from hpanel and revisit this - padding-top: 10px; [class$=messagesmall] { margin: 8px 0px 8px 0px; @@ -704,6 +703,7 @@ .history-name { font-size: 150%; + margin-bottom: 4px; } .history-subtitle { margin: 0px; diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a templates/display_base.mako --- a/templates/display_base.mako +++ b/templates/display_base.mako @@ -36,7 +36,8 @@ ${h.js( "libs/jquery/jstorage", "libs/jquery/jquery.autocomplete", "libs/jquery/jquery.rating", "galaxy.autocom_tagging" )} ${history_panel_javascripts()} - ${h.js( "galaxy.panels", "libs/jquery/jstorage", "libs/jquery/jquery.event.drag", "libs/jquery/jquery.event.hover","libs/jquery/jquery.mousewheel", "libs/jquery/jquery-ui", "libs/require", "libs/farbtastic" )} + ${h.js( "galaxy.panels", "libs/jquery/jstorage", "libs/jquery/jquery.event.drag", "libs/jquery/jquery.event.hover", + "libs/jquery/jquery.mousewheel", "libs/jquery/jquery-ui", "libs/require", "libs/farbtastic" )} <script type="text/javascript"> @@ -152,18 +153,6 @@ border-right-style: solid; border-right-color: #66AA66; } - - .embedded-item.history .item-content { - padding: 8px; - background-color: white; - border-radius: 0px 0px 4px 4px; - } - .embedded-item.history hr { - margin-bottom: 2px; - } - .embedded-item.history .history-panel { - padding: 2px 0px 8px 0px; - } </style></%def> diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a templates/webapps/galaxy/history/display.mako --- a/templates/webapps/galaxy/history/display.mako +++ b/templates/webapps/galaxy/history/display.mako @@ -15,6 +15,9 @@ <%def name="stylesheets()"> ${parent.stylesheets()} <style type="text/css"> + .history-panel { + margin-top: 8px; + } </style></%def> @@ -48,7 +51,7 @@ historyJSON = ${h.to_json_string( history_dict )}, hdaJSON = ${h.to_json_string( hda_dicts )}; //window.historyJSON = historyJSON; - window.hdaJSON = hdaJSON; + //window.hdaJSON = hdaJSON; require.config({ baseUrl : "${h.url_for( '/static/scripts' )}" diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a templates/webapps/galaxy/history/embed.mako --- a/templates/webapps/galaxy/history/embed.mako +++ b/templates/webapps/galaxy/history/embed.mako @@ -1,13 +1,73 @@ -<%inherit file="/embed_base.mako"/> -<%! - from galaxy.web.framework.helpers import iff +##<%inherit file="/embed_base.mako"/> +<%namespace file="/display_common.mako" import="*" /> + +## Some duplication with embed_base here, needed a way to override the main embedded-item html for histories +<% + encoded_history_id = trans.security.encode_id( item.id ) + import_href = h.url_for( controller='history', action='imp', id=encoded_history_id ) + display_href = h.url_for( controller='history', action='display_by_username_and_slug', + username=item.user.username, slug=item.slug ) %> +<div id="history-${encoded_history_id}" class='embedded-item display history'> + <div class='title'> + <div style="float: left"> + <a class="expand-content-btn icon-button toggle-expand" href="${display_href}" + title="Show or hide history contents"></a> + </div> + <div style="float: right;"> + <a title="Import history" class="icon-button import" href="${import_href}"></a> + <a title="View history" class="icon-button go-to-full-screen" href="${display_href}"></a> + </div> + <h4> + <a class="toggle-embed" href="${display_href}" title="Show or hide history contents"> + Galaxy History | ${get_item_name( item )} + </a> + </h4> + %if hasattr( item, "annotation") and item.annotation: + <div class="annotation">${item.annotation}</div> + %endif + </div> + <div class='summary-content'> + ## currently, no summary content for history + </div> + <div class='expanded-content'> + <div class='item-content'> + <div class='history-panel'></div> + </div> + </div> +</div> -<%def name="render_summary_content( history, datasets )"> +<script type="text/javascript"> -## <ul> -## <% num_datasets = len ( datasets ) %> -## <li>${num_datasets} dataset${iff( num_datasets != 1, "s", "" )} -## <li>Operations: ... -## </ul> -</%def> +require.config({ + baseUrl : "${h.url_for( '/static/scripts' )}" +}); +require([ 'mvc/history/annotated-history-panel' ], function( panelMod ){ + + function toggleExpanded( ev ){ + var $embeddedHistory = $( "#history-${encoded_history_id}" ); + $embeddedHistory.find( '.expand-content-btn' ).toggleClass( 'toggle-expand' ).toggleClass( 'toggle' ); + $embeddedHistory.find( ".summary-content" ).slideToggle( "fast" ); + $embeddedHistory.find( ".annotation" ).slideToggle( "fast" ); + $embeddedHistory.find( ".expanded-content" ).slideToggle( "fast" ); + ev.preventDefault(); + } + + $(function(){ + var debugging = JSON.parse( sessionStorage.getItem( 'debugging' ) ) || false, + historyModel = require( 'mvc/history/history-model' ), + $embeddedHistory = $( "#history-${encoded_history_id}" ), + panel = new panelMod.AnnotatedHistoryPanel({ + el : $embeddedHistory.find( ".history-panel" ), + model : new historyModel.History( + ${h.to_json_string( history_dict )}, + ${h.to_json_string( hda_dicts )}, + { logger: ( debugging )?( console ):( null ) } + ) + }).render(); + + $embeddedHistory.find( '.expand-content-btn' ).click( toggleExpanded ); + $embeddedHistory.find( '.toggle-embed' ).click( toggleExpanded ); + }); +}); +</script> diff -r 6b6c7de6bbe10721674f50ebb5e8a600d8586416 -r 2403d6f67500ec35b16ce604142d98766286b65a templates/webapps/galaxy/page/display.mako --- a/templates/webapps/galaxy/page/display.mako +++ b/templates/webapps/galaxy/page/display.mako @@ -5,12 +5,12 @@ <script type="text/javascript"> $(function() { - // Setup embedded content: // (a) toggles for showing/hiding embedded content; // (b) ... $('.embedded-item').each( function() { var container = $(this); + if( container.hasClass( 'history' ) ){ return; } // Show embedded item. var show_embedded_item = function() { @@ -88,9 +88,12 @@ <%def name="stylesheets()"> ${parent.stylesheets()} - ${h.css( "base", "history", "autocomplete_tagging" )} + ${h.css( "base", "autocomplete_tagging" )} <style type="text/css"> .toggle { display: none; } + .embedded-item .title { + padding-top: 1px; + } .embedded-item h4 { margin: 0px; } @@ -119,6 +122,30 @@ .embedded-item .trackster-nav { position: inherit; } + + /* ---------------------------- histories */ + .embedded-item.history .toggle { + display: inline; + } + .embedded-item.history .expanded-content { + /* generates a fake wide border */ + padding: 4px; + } + /** wraps around the history */ + .embedded-item.history .item-content { + background-color: white; + padding: 8px; + border-radius: 0px 0px 4px 4px; + } + .embedded-item.history .history-panel .datasets-list { + margin-bottom: 8px; + } + .embedded-item.history .history-panel .errormessage { + margin-top: 8px; + } + .annotated-history-panel .history-controls { + margin: 0px 0px 16px 0px; + } </style></%def> @@ -131,4 +158,4 @@ <%def name="render_item( page, page_data=None )"> ${page_data} -</%def> \ No newline at end of file +</%def> 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