commit/galaxy-central: dannon: Pack scripts.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/188aa379bd9b/ Changeset: 188aa379bd9b User: dannon Date: 2014-09-02 15:29:50 Summary: Pack scripts. Affected #: 8 files diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/data.js --- a/static/scripts/packed/mvc/data.js +++ b/static/scripts/packed/mvc/data.js @@ -1,1 +1,1 @@ -define(["mvc/ui/ui-modal","mvc/ui/ui-frames"],function(j,i){var g=Backbone.Model.extend({});var b=Backbone.Model.extend({defaults:{id:"",type:"",name:"",hda_ldda:"hda",metadata:null},initialize:function(){this._set_metadata();this.on("change",this._set_metadata,this)},_set_metadata:function(){var m=new g();_.each(_.keys(this.attributes),function(n){if(n.indexOf("metadata_")===0){var o=n.split("metadata_")[1];m.set(o,this.attributes[n]);delete this.attributes[n]}},this);this.set("metadata",m,{silent:true})},get_metadata:function(m){return this.attributes.metadata.get(m)},urlRoot:galaxy_config.root+"api/datasets"});var h=b.extend({defaults:_.extend({},b.prototype.defaults,{chunk_url:null,first_data_chunk:null,chunk_index:-1,at_eof:false}),initialize:function(m){b.prototype.initialize.call(this);this.attributes.chunk_index=(this.attributes.first_data_chunk?1:0);this.attributes.chunk_url=galaxy_config.root+"dataset/display?dataset_id="+this.id;this.attributes.url_viz=galaxy_config.root+"visualization"},get_next_chunk:function(){if(this.attributes.at_eof){return null}var m=this,n=$.Deferred();$.getJSON(this.attributes.chunk_url,{chunk:m.attributes.chunk_index++}).success(function(o){var p;if(o.ck_data!==""){p=o}else{m.attributes.at_eof=true;p=null}n.resolve(p)});return n}});var e=Backbone.Collection.extend({model:b});var a=Backbone.View.extend({initialize:function(m){this.row_count=0;this.loading_chunk=false;this.header_color="#AAA";this.dark_row_color="#DDD";new d({model:m.model,$el:this.$el})},expand_to_container:function(){if(this.$el.height()<this.scroll_elt.height()){this.attempt_to_fetch()}},attempt_to_fetch:function(n){var m=this;if(!this.loading_chunk&&this.scrolled_to_bottom()){this.loading_chunk=true;this.loading_indicator.show();$.when(m.model.get_next_chunk()).then(function(o){if(o){m._renderChunk(o);m.loading_chunk=false}m.loading_indicator.hide();m.expand_to_container()})}},render:function(){this.loading_indicator=$("<div/>").attr("id","loading_indicator");this.$el.append(this.loading_indicator);var p=$("<table/>").attr({id:"content_table",cellpadding:0});this.$el.append(p);var m=this.model.get_metadata("column_names"),q=$("<tr/>").css("background-color",this.header_color).appendTo(p);if(m){q.append("<th>"+m.join("</th><th>")+"</th>")}var o=this,n=this.model.get("first_data_chunk");if(n){this._renderChunk(n)}else{$.when(o.model.get_next_chunk()).then(function(r){o._renderChunk(r)})}this.scroll_elt.scroll(function(){o.attempt_to_fetch()})},scrolled_to_bottom:function(){return false},_renderCell:function(p,m,q){var n=$("<td>").text(p);var o=this.model.get_metadata("column_types");if(q!==undefined){n.attr("colspan",q).addClass("stringalign")}else{if(o){if(m<o.length){if(o[m]==="str"||o[m]==="list"){n.addClass("stringalign")}}}}return n},_renderRow:function(m){var n=m.split("\t"),p=$("<tr>"),o=this.model.get_metadata("columns");if(this.row_count%2!==0){p.css("background-color",this.dark_row_color)}if(n.length===o){_.each(n,function(r,q){p.append(this._renderCell(r,q))},this)}else{if(n.length>o){_.each(n.slice(0,o-1),function(r,q){p.append(this._renderCell(r,q))},this);p.append(this._renderCell(n.slice(o-1).join("\t"),o-1))}else{if(o>5&&n.length===o-1){_.each(n,function(r,q){p.append(this._renderCell(r,q))},this);p.append($("<td>"))}else{p.append(this._renderCell(m,0,o))}}}this.row_count++;return p},_renderChunk:function(m){var n=this.$el.find("table");_.each(m.ck_data.split("\n"),function(o,p){if(o!==""){n.append(this._renderRow(o))}},this)}});var f=a.extend({initialize:function(m){a.prototype.initialize.call(this,m);scroll_elt=_.find(this.$el.parents(),function(n){return $(n).css("overflow")==="auto"});if(!scroll_elt){scroll_elt=window}this.scroll_elt=$(scroll_elt)},scrolled_to_bottom:function(){return(this.$el.height()-this.scroll_elt.scrollTop()-this.scroll_elt.height()<=0)}});var l=a.extend({initialize:function(m){a.prototype.initialize.call(this,m);this.scroll_elt=this.$el.css({position:"relative",overflow:"scroll",height:this.options.height||"500px"})},scrolled_to_bottom:function(){return this.$el.scrollTop()+this.$el.innerHeight()>=this.el.scrollHeight}});var d=Backbone.View.extend({col:{chrom:null,start:null,end:null},url_viz:null,dataset_id:null,genome_build:null,data_type:null,initialize:function(o){var r=parent.Galaxy;if(r&&r.modal){this.modal=r.modal}if(r&&r.frame){this.frame=r.frame}if(!this.modal||!this.frame){return}var n=o.model;var q=n.get("metadata");if(!n.get("data_type")){return}this.data_type=n.get("data_type");if(this.data_type=="bed"){if(q.get("chromCol")&&q.get("startCol")&&q.get("endCol")){this.col.chrom=q.get("chromCol")-1;this.col.start=q.get("startCol")-1;this.col.end=q.get("endCol")-1}else{console.log("TabularButtonTrackster : Bed-file metadata incomplete.");return}}if(this.data_type=="vcf"){function p(t,u){for(var s=0;s<u.length;s++){if(u[s].match(t)){return s}}return -1}this.col.chrom=p("Chrom",q.get("column_names"));this.col.start=p("Pos",q.get("column_names"));this.col.end=null;if(this.col.chrom==-1||this.col.start==-1){console.log("TabularButtonTrackster : VCF-file metadata incomplete.");return}}if(this.col.chrom===undefined){return}if(n.id){this.dataset_id=n.id}else{console.log("TabularButtonTrackster : Dataset identification is missing.");return}if(n.get("url_viz")){this.url_viz=n.get("url_viz")}else{console.log("TabularButtonTrackster : Url for visualization controller is missing.");return}if(n.get("genome_build")){this.genome_build=n.get("genome_build")}var m=new IconButtonView({model:new IconButton({title:"Visualize",icon_class:"chart_curve",id:"btn_viz"})});this.setElement(o.$el);this.$el.append(m.render().$el);this.hide()},events:{"mouseover tr":"show",mouseleave:"hide"},show:function(r){function q(w){return !isNaN(parseFloat(w))&&isFinite(w)}if(this.col.chrom===null){return}var v=$(r.target).parent();var s=v.children().eq(this.col.chrom).html();var m=v.children().eq(this.col.start).html();var o=this.col.end?v.children().eq(this.col.end).html():m;if(!s.match("^#")&&s!==""&&q(m)){var u={dataset_id:this.dataset_id,gene_region:s+":"+m+"-"+o};var p=v.offset();var n=p.left-10;var t=p.top-$(window).scrollTop()+3;$("#btn_viz").css({position:"fixed",top:t+"px",left:n+"px"});$("#btn_viz").off("click");$("#btn_viz").click(this.create_trackster_action(this.url_viz,u,this.genome_build));$("#btn_viz").show()}else{$("#btn_viz").hide()}},hide:function(){this.$el.find("#btn_viz").hide()},create_trackster_action:function(m,p,o){var n=this;return function(){var q={};if(o){q["f-dbkey"]=o}$.ajax({url:m+"/list_tracks?"+$.param(q),dataType:"html",error:function(){n.modal.show({title:"Something went wrong!",body:"Unfortunately we could not add this dataset to the track browser. Please try again or contact us.",buttons:{Cancel:function(){n.modal.hide()}}})},success:function(r){n.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){n.modal.hide()},"View in saved visualization":function(){n.modal.show({title:"Add Data to Saved Visualization",body:r,buttons:{Cancel:function(){n.modal.hide()},"Add to visualization":function(){n.modal.hide();n.modal.$el.find("input[name=id]:checked").each(function(){var s=$(this).val();p.id=s;n.frame.add({title:"Trackster",type:"url",content:m+"/trackster?"+$.param(p)})})}}})},"View in new visualization":function(){n.modal.hide();n.frame.add({title:"Trackster",type:"url",content:m+"/trackster?"+$.param(p)})}}})}});return false}}});var k=function(p,n,q,m){var o=new n({model:new p(q)});o.render();if(m){m.append(o.$el)}return o};var c=function(o){if(!o.model){o.model=new h(o.dataset_config)}var n=o.parent_elt;var p=o.embedded;delete o.embedded;delete o.parent_elt;delete o.dataset_config;var m=(p?new l(o):new f(o));m.render();if(n){n.append(m.$el);m.expand_to_container()}return m};return{Dataset:b,TabularDataset:h,DatasetCollection:e,TabularDatasetChunkedView:a,createTabularDatasetChunkedView:c}}); \ No newline at end of file +define(["mvc/ui/ui-modal","mvc/ui/ui-frames"],function(j,i){var g=Backbone.Model.extend({});var b=Backbone.Model.extend({defaults:{id:"",type:"",name:"",hda_ldda:"hda",metadata:null},initialize:function(){this._set_metadata();this.on("change",this._set_metadata,this)},_set_metadata:function(){var m=new g();_.each(_.keys(this.attributes),function(n){if(n.indexOf("metadata_")===0){var o=n.split("metadata_")[1];m.set(o,this.attributes[n]);delete this.attributes[n]}},this);this.set("metadata",m,{silent:true})},get_metadata:function(m){return this.attributes.metadata.get(m)},urlRoot:galaxy_config.root+"api/datasets"});var h=b.extend({defaults:_.extend({},b.prototype.defaults,{chunk_url:null,first_data_chunk:null,chunk_index:-1,at_eof:false}),initialize:function(m){b.prototype.initialize.call(this);this.attributes.chunk_index=(this.attributes.first_data_chunk?1:0);this.attributes.chunk_url=galaxy_config.root+"dataset/display?dataset_id="+this.id;this.attributes.url_viz=galaxy_config.root+"visualization"},get_next_chunk:function(){if(this.attributes.at_eof){return null}var m=this,n=$.Deferred();$.getJSON(this.attributes.chunk_url,{chunk:m.attributes.chunk_index++}).success(function(o){var p;if(o.ck_data!==""){p=o}else{m.attributes.at_eof=true;p=null}n.resolve(p)});return n}});var e=Backbone.Collection.extend({model:b});var a=Backbone.View.extend({initialize:function(m){this.row_count=0;this.loading_chunk=false;this.header_color="#AAA";this.dark_row_color="#DDD";new d({model:m.model,$el:this.$el})},expand_to_container:function(){if(this.$el.height()<this.scroll_elt.height()){this.attempt_to_fetch()}},attempt_to_fetch:function(n){var m=this;if(!this.loading_chunk&&this.scrolled_to_bottom()){this.loading_chunk=true;this.loading_indicator.show();$.when(m.model.get_next_chunk()).then(function(o){if(o){m._renderChunk(o);m.loading_chunk=false}m.loading_indicator.hide();m.expand_to_container()})}},render:function(){this.loading_indicator=$("<div/>").attr("id","loading_indicator");this.$el.append(this.loading_indicator);var p=$("<table/>").attr({id:"content_table",cellpadding:0});this.$el.append(p);var m=this.model.get_metadata("column_names"),q=$("<tr/>").css("background-color",this.header_color).appendTo(p);if(m){q.append("<th>"+m.join("</th><th>")+"</th>")}var o=this,n=this.model.get("first_data_chunk");if(n){this._renderChunk(n)}else{$.when(o.model.get_next_chunk()).then(function(r){o._renderChunk(r)})}this.scroll_elt.scroll(function(){o.attempt_to_fetch()})},scrolled_to_bottom:function(){return false},_renderCell:function(p,m,q){var n=$("<td>").text(p);var o=this.model.get_metadata("column_types");if(q!==undefined){n.attr("colspan",q).addClass("stringalign")}else{if(o){if(m<o.length){if(o[m]==="str"||o[m]==="list"){n.addClass("stringalign")}}}}return n},_renderRow:function(m){var n=m.split("\t"),p=$("<tr>"),o=this.model.get_metadata("columns");if(this.row_count%2!==0){p.css("background-color",this.dark_row_color)}if(n.length===o){_.each(n,function(r,q){p.append(this._renderCell(r,q))},this)}else{if(n.length>o){_.each(n.slice(0,o-1),function(r,q){p.append(this._renderCell(r,q))},this);p.append(this._renderCell(n.slice(o-1).join("\t"),o-1))}else{if(o>5&&n.length===o-1){_.each(n,function(r,q){p.append(this._renderCell(r,q))},this);p.append($("<td>"))}else{p.append(this._renderCell(m,0,o))}}}this.row_count++;return p},_renderChunk:function(m){var n=this.$el.find("table");_.each(m.ck_data.split("\n"),function(o,p){if(o!==""){n.append(this._renderRow(o))}},this)}});var f=a.extend({initialize:function(m){a.prototype.initialize.call(this,m);scroll_elt=_.find(this.$el.parents(),function(n){return $(n).css("overflow")==="auto"});if(!scroll_elt){scroll_elt=window}this.scroll_elt=$(scroll_elt)},scrolled_to_bottom:function(){return(this.$el.height()-this.scroll_elt.scrollTop()-this.scroll_elt.height()<=0)}});var l=a.extend({initialize:function(m){a.prototype.initialize.call(this,m);this.scroll_elt=this.$el.css({position:"relative",overflow:"scroll",height:this.options.height||"500px"})},scrolled_to_bottom:function(){return this.$el.scrollTop()+this.$el.innerHeight()>=this.el.scrollHeight}});var d=Backbone.View.extend({col:{chrom:null,start:null,end:null},url_viz:null,dataset_id:null,genome_build:null,file_ext:null,initialize:function(o){var r=parent.Galaxy;if(r&&r.modal){this.modal=r.modal}if(r&&r.frame){this.frame=r.frame}if(!this.modal||!this.frame){return}var n=o.model;var q=n.get("metadata");if(!n.get("file_ext")){return}this.file_ext=n.get("file_ext");if(this.file_ext=="bed"){if(q.get("chromCol")&&q.get("startCol")&&q.get("endCol")){this.col.chrom=q.get("chromCol")-1;this.col.start=q.get("startCol")-1;this.col.end=q.get("endCol")-1}else{console.log("TabularButtonTrackster : Bed-file metadata incomplete.");return}}if(this.file_ext=="vcf"){function p(t,u){for(var s=0;s<u.length;s++){if(u[s].match(t)){return s}}return -1}this.col.chrom=p("Chrom",q.get("column_names"));this.col.start=p("Pos",q.get("column_names"));this.col.end=null;if(this.col.chrom==-1||this.col.start==-1){console.log("TabularButtonTrackster : VCF-file metadata incomplete.");return}}if(this.col.chrom===undefined){return}if(n.id){this.dataset_id=n.id}else{console.log("TabularButtonTrackster : Dataset identification is missing.");return}if(n.get("url_viz")){this.url_viz=n.get("url_viz")}else{console.log("TabularButtonTrackster : Url for visualization controller is missing.");return}if(n.get("genome_build")){this.genome_build=n.get("genome_build")}var m=new IconButtonView({model:new IconButton({title:"Visualize",icon_class:"chart_curve",id:"btn_viz"})});this.setElement(o.$el);this.$el.append(m.render().$el);this.hide()},events:{"mouseover tr":"show",mouseleave:"hide"},show:function(r){function q(w){return !isNaN(parseFloat(w))&&isFinite(w)}if(this.col.chrom===null){return}var v=$(r.target).parent();var s=v.children().eq(this.col.chrom).html();var m=v.children().eq(this.col.start).html();var o=this.col.end?v.children().eq(this.col.end).html():m;if(!s.match("^#")&&s!==""&&q(m)){var u={dataset_id:this.dataset_id,gene_region:s+":"+m+"-"+o};var p=v.offset();var n=p.left-10;var t=p.top-$(window).scrollTop()+3;$("#btn_viz").css({position:"fixed",top:t+"px",left:n+"px"});$("#btn_viz").off("click");$("#btn_viz").click(this.create_trackster_action(this.url_viz,u,this.genome_build));$("#btn_viz").show()}else{$("#btn_viz").hide()}},hide:function(){this.$el.find("#btn_viz").hide()},create_trackster_action:function(m,p,o){var n=this;return function(){var q={};if(o){q["f-dbkey"]=o}$.ajax({url:m+"/list_tracks?"+$.param(q),dataType:"html",error:function(){n.modal.show({title:"Something went wrong!",body:"Unfortunately we could not add this dataset to the track browser. Please try again or contact us.",buttons:{Cancel:function(){n.modal.hide()}}})},success:function(r){n.modal.show({title:"View Data in a New or Saved Visualization",buttons:{Cancel:function(){n.modal.hide()},"View in saved visualization":function(){n.modal.show({title:"Add Data to Saved Visualization",body:r,buttons:{Cancel:function(){n.modal.hide()},"Add to visualization":function(){n.modal.hide();n.modal.$el.find("input[name=id]:checked").each(function(){var s=$(this).val();p.id=s;n.frame.add({title:"Trackster",type:"url",content:m+"/trackster?"+$.param(p)})})}}})},"View in new visualization":function(){n.modal.hide();n.frame.add({title:"Trackster",type:"url",content:m+"/trackster?"+$.param(p)})}}})}});return false}}});var k=function(p,n,q,m){var o=new n({model:new p(q)});o.render();if(m){m.append(o.$el)}return o};var c=function(o){if(!o.model){o.model=new h(o.dataset_config)}var n=o.parent_elt;var p=o.embedded;delete o.embedded;delete o.parent_elt;delete o.dataset_config;var m=(p?new l(o):new f(o));m.render();if(n){n.append(m.$el);m.expand_to_container()}return m};return{Dataset:b,TabularDataset:h,DatasetCollection:e,TabularDatasetChunkedView:a,createTabularDatasetChunkedView:c}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/dataset/dataset-choice.js --- a/static/scripts/packed/mvc/dataset/dataset-choice.js +++ b/static/scripts/packed/mvc/dataset/dataset-choice.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/dataset-model","mvc/dataset/dataset-list","mvc/ui/ui-modal","mvc/base-mvc","utils/localization"],function(a,d,f,i,c){function g(k,j,m){function l(p,o){for(var n in o){if(o.hasOwnProperty(n)){if(p[n]!==o[n]){return false}}}return true}return k.filter(function(n){return(!n.deleted&&n.visible)&&(!m||n.collection_type===undefined)&&(l(n,j))})}var b=function(n,j){j=_.defaults(j||{},{datasetsOnly:true,where:{state:"ok"},multiselect:false,selected:[]});j.title=j.title||(j.multiselect?c("Choose datasets:"):c("Choose a dataset:"));var m,o,l,q=jQuery.Deferred(),p=j.filter||g;n=p(n,j.where,j.datasetsOnly);if(!n.length){return q.reject("No matches found")}function k(){q.resolve(o.getSelectedModels().map(function(r){return r.toJSON()}))}if(j.multiselect){l={};l[c("Ok")]=k}m=new f.View({height:"auto",buttons:l,closing_events:true,closing_callback:function(){q.resolve(null)},body:['<div class="list-panel"></div>'].join("")});m.$(".modal-header").remove();m.$(".modal-footer").css("margin-top","0px");o=new d.DatasetList({title:j.title,subtitle:j.subtitle||c(["Click the checkboxes on the right to select datasets. ","Click the datasets names to see their details. "].join("")),el:m.$body.find(".list-panel"),selecting:true,selected:j.selected,collection:new a.DatasetAssociationCollection(n)});o.once("rendered:initial",function(){m.show();m.$el.addClass("dataset-choice-modal")});if(!j.multiselect){o.on("rendered",function(){o.$(".list-actions").hide()});o.on("view:selected",function(r){q.resolve([r.model.toJSON()])})}o.render(0);return q.always(function(){m.hide()})};var e=Backbone.View.extend(i.LoggableMixin).extend({className:"dataset-choice",initialize:function(j){this.debug(this+"(DatasetChoice).initialize:",j);this.label=j.label!==undefined?c(j.label):"";this.where=j.where;this.datasetsOnly=j.datasetsOnly!==undefined?j.datasetsOnly:true;this.datasetJSON=j.datasetJSON||[];this.selected=j.selected||[];this._setUpListeners()},_setUpListeners:function(){},render:function(){var j=this.toJSON();this.$el.html(this._template(j));this.$(".selected").replaceWith(this._renderSelected(j));return this},_template:function(j){return _.template(["<label>",'<span class="prompt"><%= json.label %></span>','<div class="selected"></div>',"</label>"].join(""),{json:j})},_renderSelected:function(j){if(j.selected.length){return $(_.template(['<div class="selected">','<span class="title"><%= selected.hid %>: <%= selected.name %></span>','<span class="subtitle">',"<i><%= selected.misc_blurb %></i>","<i>",c("format")+": ","<%= selected.data_type %></i>","<i><%= selected.misc_info %></i>","</span>","</div>"].join(""),{selected:j.selected[0]}))}return $(['<span class="none-selected-msg">(',c("click to select a dataset"),")</span>"].join(""))},toJSON:function(){var j=this;return{label:j.label,datasets:j.datasetJSON,selected:_.compact(_.map(j.selected,function(k){return _.findWhere(j.datasetJSON,{id:k})}))}},events:{click:"chooseWithModal"},chooseWithModal:function(){var j=this;return this._createModal().done(function(k){if(k){j.selected=_.pluck(k,"id");j.trigger("selected",j,k);j.render()}else{j.trigger("cancelled",j)}}).fail(function(){j.trigger("error",j,arguments)})},_createModal:function(){return new b(this.datasetJSON,this._getModalOptions())},_getModalOptions:function(){return{title:this.label,multiselect:false,selected:this.selected,where:this.where,datasetsOnly:this.datasetsOnly}},toString:function(){return"DatasetChoice("+this.selected+")"}});var h=e.extend({className:e.prototype.className+" multi",cells:{hid:c("History #"),name:c("Name"),misc_blurb:c("Summary"),data_type:c("Format"),genome_build:c("Genome"),tags:c("Tags"),annotation:c("Annotation")},initialize:function(j){this.showHeaders=j.showHeaders!==undefined?j.showHeaders:true;this.cells=j.cells||this.cells;e.prototype.initialize.call(this,j)},_renderSelected:function(j){if(j.selected.length){return $(_.template(['<table class="selected">',"<% if( json.showHeaders ){ %>","<thead><tr>","<% _.map( json.cells, function( val, key ){ %>","<th><%= val %></th>","<% }); %>","</tr></thead>","<% } %>","<tbody>","<% _.map( json.selected, function( selected ){ %>","<tr>","<% _.map( json.cells, function( val, key ){ %>",'<td class="cell-<%= key %>"><%= selected[ key ] %></td>',"<% }) %>","</tr>","<% }); %>","</tbody>","</table>"].join(""),{json:j}))}return $(['<span class="none-selected-msg">(',c("click to select a dataset"),")</span>"].join(""))},toJSON:function(){return _.extend(e.prototype.toJSON.call(this),{showHeaders:this.showHeaders,cells:this.cells})},_getModalOptions:function(){return _.extend(e.prototype._getModalOptions.call(this),{multiselect:true})},toString:function(){return"DatasetChoice("+this.selected+")"}});return{DatasetChoiceModal:b,DatasetChoice:e,MultiDatasetChoice:h}}); \ No newline at end of file +define(["mvc/dataset/dataset-model","mvc/dataset/dataset-list","mvc/ui/ui-modal","mvc/base-mvc","utils/localization"],function(a,d,f,i,c){function g(k,j,m){function l(p,o){for(var n in o){if(o.hasOwnProperty(n)){if(p[n]!==o[n]){return false}}}return true}return k.filter(function(n){return(!n.deleted&&n.visible)&&(!m||n.collection_type===undefined)&&(l(n,j))})}var b=function(n,j){j=_.defaults(j||{},{datasetsOnly:true,where:{state:"ok"},multiselect:false,selected:[]});j.title=j.title||(j.multiselect?c("Choose datasets:"):c("Choose a dataset:"));var m,o,l,q=jQuery.Deferred(),p=j.filter||g;n=p(n,j.where,j.datasetsOnly);if(!n.length){return q.reject("No matches found")}function k(){q.resolve(o.getSelectedModels().map(function(r){return r.toJSON()}))}if(j.multiselect){l={};l[c("Ok")]=k}m=new f.View({height:"auto",buttons:l,closing_events:true,closing_callback:function(){q.resolve(null)},body:['<div class="list-panel"></div>'].join("")});m.$(".modal-header").remove();m.$(".modal-footer").css("margin-top","0px");o=new d.DatasetList({title:j.title,subtitle:j.subtitle||c(["Click the checkboxes on the right to select datasets. ","Click the datasets names to see their details. "].join("")),el:m.$body.find(".list-panel"),selecting:true,selected:j.selected,collection:new a.DatasetAssociationCollection(n)});o.once("rendered:initial",function(){m.show();m.$el.addClass("dataset-choice-modal")});if(!j.multiselect){o.on("rendered",function(){o.$(".list-actions").hide()});o.on("view:selected",function(r){q.resolve([r.model.toJSON()])})}o.render(0);return q.always(function(){m.hide()})};var e=Backbone.View.extend(i.LoggableMixin).extend({className:"dataset-choice",initialize:function(j){this.debug(this+"(DatasetChoice).initialize:",j);this.label=j.label!==undefined?c(j.label):"";this.where=j.where;this.datasetsOnly=j.datasetsOnly!==undefined?j.datasetsOnly:true;this.datasetJSON=j.datasetJSON||[];this.selected=j.selected||[];this._setUpListeners()},_setUpListeners:function(){},render:function(){var j=this.toJSON();this.$el.html(this._template(j));this.$(".selected").replaceWith(this._renderSelected(j));return this},_template:function(j){return _.template(["<label>",'<span class="prompt"><%= json.label %></span>','<div class="selected"></div>',"</label>"].join(""),{json:j})},_renderSelected:function(j){if(j.selected.length){return $(_.template(['<div class="selected">','<span class="title"><%= selected.hid %>: <%= selected.name %></span>','<span class="subtitle">',"<i><%= selected.misc_blurb %></i>","<i>",c("format")+": ","<%= selected.file_ext %></i>","<i><%= selected.misc_info %></i>","</span>","</div>"].join(""),{selected:j.selected[0]}))}return $(['<span class="none-selected-msg">(',c("click to select a dataset"),")</span>"].join(""))},toJSON:function(){var j=this;return{label:j.label,datasets:j.datasetJSON,selected:_.compact(_.map(j.selected,function(k){return _.findWhere(j.datasetJSON,{id:k})}))}},events:{click:"chooseWithModal"},chooseWithModal:function(){var j=this;return this._createModal().done(function(k){if(k){j.selected=_.pluck(k,"id");j.trigger("selected",j,k);j.render()}else{j.trigger("cancelled",j)}}).fail(function(){j.trigger("error",j,arguments)})},_createModal:function(){return new b(this.datasetJSON,this._getModalOptions())},_getModalOptions:function(){return{title:this.label,multiselect:false,selected:this.selected,where:this.where,datasetsOnly:this.datasetsOnly}},toString:function(){return"DatasetChoice("+this.selected+")"}});var h=e.extend({className:e.prototype.className+" multi",cells:{hid:c("History #"),name:c("Name"),misc_blurb:c("Summary"),file_ext:c("Format"),genome_build:c("Genome"),tags:c("Tags"),annotation:c("Annotation")},initialize:function(j){this.showHeaders=j.showHeaders!==undefined?j.showHeaders:true;this.cells=j.cells||this.cells;e.prototype.initialize.call(this,j)},_renderSelected:function(j){if(j.selected.length){return $(_.template(['<table class="selected">',"<% if( json.showHeaders ){ %>","<thead><tr>","<% _.map( json.cells, function( val, key ){ %>","<th><%= val %></th>","<% }); %>","</tr></thead>","<% } %>","<tbody>","<% _.map( json.selected, function( selected ){ %>","<tr>","<% _.map( json.cells, function( val, key ){ %>",'<td class="cell-<%= key %>"><%= selected[ key ] %></td>',"<% }) %>","</tr>","<% }); %>","</tbody>","</table>"].join(""),{json:j}))}return $(['<span class="none-selected-msg">(',c("click to select a dataset"),")</span>"].join(""))},toJSON:function(){return _.extend(e.prototype.toJSON.call(this),{showHeaders:this.showHeaders,cells:this.cells})},_getModalOptions:function(){return _.extend(e.prototype._getModalOptions.call(this),{multiselect:true})},toString:function(){return"DatasetChoice("+this.selected+")"}});return{DatasetChoiceModal:b,DatasetChoice:e,MultiDatasetChoice:h}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/dataset/dataset-li.js --- a/static/scripts/packed/mvc/dataset/dataset-li.js +++ b/static/scripts/packed/mvc/dataset/dataset-li.js @@ -1,1 +1,1 @@ -define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b,c){var e=b.ListItemView;var d=e.extend({className:e.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(f){if(f.logger){this.logger=this.model.logger=f.logger}this.log(this+".initialize:",f);e.prototype.initialize.call(this,f);this.linkTarget=f.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);this.model.on("change",function(g,f){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this);this.on("all",function(f){this.log(f)},this)},_fetchModelDetails:function(){var f=this;if(f.model.inReadyState()&&!f.model.hasDetails()){return f.model.fetch({silent:true})}return jQuery.when()},remove:function(g,h){var f=this;g=g||this.fxSpeed;this.$el.fadeOut(g,function(){Backbone.View.prototype.remove.call(f);if(h){h.call(f)}})},render:function(f){return e.prototype.render.call(this,f)},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var h=this.model.get("state");if((h===a.NOT_VIEWABLE)||(h===a.DISCARDED)||(!this.model.get("accessible"))){return null}var g={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){g.disabled=true;g.title=c("Cannot display datasets removed from disk")}else{if(h===a.UPLOAD){g.disabled=true;g.title=c("This dataset must finish uploading before it can be viewed")}else{if(h===a.NEW){g.disabled=true;g.title=c("This dataset is not yet viewable")}else{g.title=c("View data");g.href=this.model.urls.display;var f=this;g.onclick=function(i){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+f.model.get("name"),type:"other",content:function(j){require(["mvc/data"],function(k){var l=new k.TabularDataset({id:f.model.get("id")});$.when(l.fetch()).then(function(){k.createTabularDatasetChunkedView({model:l,parent_elt:j,embedded:true,height:"100%"})})})}});i.preventDefault()}}}}}g.faIcon="fa-eye";return faIconButton(g)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var f=e.prototype._renderDetails.call(this);f.find(".actions .left").empty().append(this._renderSecondaryActions());f.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());f.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(f);return f},_renderSummary:function(){var f=this.model.toJSON(),g=this.templates.summaries[f.state];g=g||this.templates.summaries.unknown;return g(f,this)},_renderDetailMessages:function(){var f=this,h=$('<div class="detail-messages"></div>'),g=f.model.toJSON();_.each(f.templates.detailMessages,function(i){h.append($(i(g,f)))});return h},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return faIconButton({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var f=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+f.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(g){return['<li><a href="',f.meta_download+g.file_type,'">',c("Download")," ",g.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+f+")"}});d.prototype.templates=(function(){var h=_.extend({},e.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var i=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var g=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var j={};j[a.OK]=j[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.data_type ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.data_type %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");j[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");j[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");j[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");j[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");j[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");j[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");j[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");j[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");j[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");j[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");j.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var k={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var f=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},e.prototype.templates,{warnings:h,details:i,noAccess:g,summaries:j,detailMessages:k,displayApplications:f})}());return{DatasetListItemView:d}}); \ No newline at end of file +define(["mvc/dataset/states","mvc/base-mvc","utils/localization"],function(a,b,c){var e=b.ListItemView;var d=e.extend({className:e.prototype.className+" dataset",id:function(){return["dataset",this.model.get("id")].join("-")},initialize:function(f){if(f.logger){this.logger=this.model.logger=f.logger}this.log(this+".initialize:",f);e.prototype.initialize.call(this,f);this.linkTarget=f.linkTarget||"_blank";this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);this.model.on("change",function(g,f){if(this.model.changedAttributes().state&&this.model.inReadyState()&&this.expanded&&!this.model.hasDetails()){this.model.fetch()}else{this.render()}},this);this.on("all",function(f){this.log(f)},this)},_fetchModelDetails:function(){var f=this;if(f.model.inReadyState()&&!f.model.hasDetails()){return f.model.fetch({silent:true})}return jQuery.when()},remove:function(g,h){var f=this;g=g||this.fxSpeed;this.$el.fadeOut(g,function(){Backbone.View.prototype.remove.call(f);if(h){h.call(f)}})},render:function(f){return e.prototype.render.call(this,f)},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_renderPrimaryActions:function(){return[this._renderDisplayButton()]},_renderDisplayButton:function(){var h=this.model.get("state");if((h===a.NOT_VIEWABLE)||(h===a.DISCARDED)||(!this.model.get("accessible"))){return null}var g={target:this.linkTarget,classes:"display-btn"};if(this.model.get("purged")){g.disabled=true;g.title=c("Cannot display datasets removed from disk")}else{if(h===a.UPLOAD){g.disabled=true;g.title=c("This dataset must finish uploading before it can be viewed")}else{if(h===a.NEW){g.disabled=true;g.title=c("This dataset is not yet viewable")}else{g.title=c("View data");g.href=this.model.urls.display;var f=this;g.onclick=function(i){if(Galaxy.frame&&Galaxy.frame.active){Galaxy.frame.add({title:"Data Viewer: "+f.model.get("name"),type:"other",content:function(j){require(["mvc/data"],function(k){var l=new k.TabularDataset({id:f.model.get("id")});$.when(l.fetch()).then(function(){k.createTabularDatasetChunkedView({model:l,parent_elt:j,embedded:true,height:"100%"})})})}});i.preventDefault()}}}}}g.faIcon="fa-eye";return faIconButton(g)},_renderDetails:function(){if(this.model.get("state")===a.NOT_VIEWABLE){return $(this.templates.noAccess(this.model.toJSON(),this))}var f=e.prototype._renderDetails.call(this);f.find(".actions .left").empty().append(this._renderSecondaryActions());f.find(".summary").html(this._renderSummary()).prepend(this._renderDetailMessages());f.find(".display-applications").html(this._renderDisplayApplications());this._setUpBehaviors(f);return f},_renderSummary:function(){var f=this.model.toJSON(),g=this.templates.summaries[f.state];g=g||this.templates.summaries.unknown;return g(f,this)},_renderDetailMessages:function(){var f=this,h=$('<div class="detail-messages"></div>'),g=f.model.toJSON();_.each(f.templates.detailMessages,function(i){h.append($(i(g,f)))});return h},_renderDisplayApplications:function(){if(this.model.isDeletedOrPurged()){return""}return[this.templates.displayApplications(this.model.get("display_apps"),this),this.templates.displayApplications(this.model.get("display_types"),this)].join("")},_renderSecondaryActions:function(){this.debug("_renderSecondaryActions");switch(this.model.get("state")){case a.NOT_VIEWABLE:return[];case a.OK:case a.FAILED_METADATA:case a.ERROR:return[this._renderDownloadButton(),this._renderShowParamsButton()]}return[this._renderShowParamsButton()]},_renderShowParamsButton:function(){return faIconButton({title:c("View details"),classes:"params-btn",href:this.model.urls.show_params,target:this.linkTarget,faIcon:"fa-info-circle"})},_renderDownloadButton:function(){if(this.model.get("purged")||!this.model.hasData()){return null}if(!_.isEmpty(this.model.get("meta_files"))){return this._renderMetaFileDownloadButton()}return $(['<a class="download-btn icon-btn" href="',this.model.urls.download,'" title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>"].join(""))},_renderMetaFileDownloadButton:function(){var f=this.model.urls;return $(['<div class="metafile-dropdown dropdown">','<a class="download-btn icon-btn" href="javascript:void(0)" data-toggle="dropdown"',' title="'+c("Download")+'">','<span class="fa fa-floppy-o"></span>',"</a>",'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">','<li><a href="'+f.download+'">',c("Download dataset"),"</a></li>",_.map(this.model.get("meta_files"),function(g){return['<li><a href="',f.meta_download+g.file_type,'">',c("Download")," ",g.file_type,"</a></li>"].join("")}).join("\n"),"</ul>","</div>"].join("\n"))},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"DatasetListItemView("+f+")"}});d.prototype.templates=(function(){var h=_.extend({},e.prototype.templates.warnings,{failed_metadata:b.wrapTemplate(['<% if( model.state === "failed_metadata" ){ %>','<div class="warningmessagesmall">',c("An error occurred setting the metadata for this dataset"),"</div>","<% } %>"]),error:b.wrapTemplate(["<% if( model.error ){ %>",'<div class="errormessagesmall">',c("There was an error getting the data for this dataset"),": <%- model.error %>","</div>","<% } %>"]),purged:b.wrapTemplate(["<% if( model.purged ){ %>",'<div class="purged-msg warningmessagesmall">',c("This dataset has been deleted and removed from disk"),"</div>","<% } %>"]),deleted:b.wrapTemplate(["<% if( model.deleted && !model.purged ){ %>",'<div class="deleted-msg warningmessagesmall">',c("This dataset has been deleted"),"</div>","<% } %>"])});var i=b.wrapTemplate(['<div class="details">','<div class="summary"></div>','<div class="actions clear">','<div class="left"></div>','<div class="right"></div>',"</div>","<% if( !dataset.deleted && !dataset.purged ){ %>",'<div class="tags-display"></div>','<div class="annotation-display"></div>','<div class="display-applications"></div>',"<% if( dataset.peek ){ %>",'<pre class="dataset-peek"><%= dataset.peek %></pre>',"<% } %>","<% } %>","</div>"],"dataset");var g=b.wrapTemplate(['<div class="details">','<div class="summary">',c("You do not have permission to view this dataset"),"</div>","</div>"],"dataset");var j={};j[a.OK]=j[a.FAILED_METADATA]=b.wrapTemplate(["<% if( dataset.misc_blurb ){ %>",'<div class="blurb">','<span class="value"><%- dataset.misc_blurb %></span>',"</div>","<% } %>","<% if( dataset.file_ext ){ %>",'<div class="datatype">','<label class="prompt">',c("format"),"</label>",'<span class="value"><%- dataset.file_ext %></span>',"</div>","<% } %>","<% if( dataset.metadata_dbkey ){ %>",'<div class="dbkey">','<label class="prompt">',c("database"),"</label>",'<span class="value">',"<%- dataset.metadata_dbkey %>","</span>","</div>","<% } %>","<% if( dataset.misc_info ){ %>",'<div class="info">','<span class="value"><%- dataset.misc_info %></span>',"</div>","<% } %>"],"dataset");j[a.NEW]=b.wrapTemplate(["<div>",c("This is a new dataset and not all of its data are available yet"),"</div>"],"dataset");j[a.NOT_VIEWABLE]=b.wrapTemplate(["<div>",c("You do not have permission to view this dataset"),"</div>"],"dataset");j[a.DISCARDED]=b.wrapTemplate(["<div>",c("The job creating this dataset was cancelled before completion"),"</div>"],"dataset");j[a.QUEUED]=b.wrapTemplate(["<div>",c("This job is waiting to run"),"</div>"],"dataset");j[a.RUNNING]=b.wrapTemplate(["<div>",c("This job is currently running"),"</div>"],"dataset");j[a.UPLOAD]=b.wrapTemplate(["<div>",c("This dataset is currently uploading"),"</div>"],"dataset");j[a.SETTING_METADATA]=b.wrapTemplate(["<div>",c("Metadata is being auto-detected"),"</div>"],"dataset");j[a.PAUSED]=b.wrapTemplate(["<div>",c('This job is paused. Use the "Resume Paused Jobs" in the history menu to resume'),"</div>"],"dataset");j[a.ERROR]=b.wrapTemplate(["<% if( !dataset.purged ){ %>","<div><%- dataset.misc_blurb %></div>","<% } %>",'<span class="help-text">',c("An error occurred with this dataset"),":</span>",'<div class="job-error-text"><%- dataset.misc_info %></div>'],"dataset");j[a.EMPTY]=b.wrapTemplate(["<div>",c("No data"),": <i><%- dataset.misc_blurb %></i></div>"],"dataset");j.unknown=b.wrapTemplate(['<div>Error: unknown dataset state: "<%- dataset.state %>"</div>'],"dataset");var k={resubmitted:b.wrapTemplate(["<% if( model.resubmitted ){ %>",'<div class="resubmitted-msg infomessagesmall">',c("The job creating this dataset has been resubmitted"),"</div>","<% } %>"])};var f=b.wrapTemplate(["<% _.each( apps, function( app ){ %>",'<div class="display-application">','<span class="display-application-location"><%- app.label %></span> ','<span class="display-application-links">',"<% _.each( app.links, function( link ){ %>",'<a target="<%= link.target %>" href="<%= link.href %>">',"<% print( _l( link.text ) ); %>","</a> ","<% }); %>","</span>","</div>","<% }); %>"],"apps");return _.extend({},e.prototype.templates,{warnings:h,details:i,noAccess:g,summaries:j,detailMessages:k,displayApplications:f})}());return{DatasetListItemView:d}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/library/library-dataset-view.js --- a/static/scripts/packed/mvc/library/library-dataset-view.js +++ b/static/scripts/packed/mvc/library/library-dataset-view.js @@ -1,1 +1,1 @@ -define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,b){var a=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_modify_dataset":"enableModification","click .toolbtn_cancel_modifications":"render","click .toolbtn-download-dataset":"downloadDataset","click .toolbtn-import-dataset":"importIntoHistory","click .toolbtn-share-dataset":"shareDataset","click .btn-copy-link-to-clipboard":"copyToClipboard","click .btn-make-private":"makeDatasetPrivate","click .btn-remove-restrictions":"removeDatasetRestrictions","click .toolbtn_save_permissions":"savePermissions","click .toolbtn_save_modifications":"comingSoon",},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchDataset()}},fetchDataset:function(e){this.options=_.extend(this.options,e);this.model=new c.Item({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{if(f.options.show_version){f.fetchVersion()}else{f.render()}}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){this.options=_.extend(this.options,e);$(".tooltip").remove();var f=this.templateDataset();this.$el.html(f({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},fetchVersion:function(e){this.options=_.extend(this.options,e);that=this;if(!this.options.ldda_id){this.render();d.error("Library dataset version requested but no id provided.")}else{this.ldda=new c.Ldda({id:this.options.ldda_id});this.ldda.url=this.ldda.urlRoot+this.model.id+"/versions/"+this.ldda.id;this.ldda.fetch({success:function(){that.renderVersion()},error:function(g,f){if(typeof f.responseJSON!=="undefined"){d.error(f.responseJSON.err_msg)}else{d.error("An error ocurred :(")}}})}},renderVersion:function(){$(".tooltip").remove();var e=this.templateVersion();this.$el.html(e({item:this.model,ldda:this.ldda}));$(".peek").html(this.ldda.get("peek"))},enableModification:function(){$(".tooltip").remove();var e=this.templateModifyDataset();this.$el.html(e({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},downloadDataset:function(){var e="/api/libraries/datasets/download/uncompressed";var f={ldda_ids:this.id};this.processDownload(e,f)},processDownload:function(f,g,h){if(f&&g){g=typeof g=="string"?g:$.param(g);var e="";$.each(g.split("&"),function(){var i=this.split("=");e+='<input type="hidden" name="'+i[0]+'" value="'+i[1]+'" />'});$('<form action="'+f+'" method="'+(h||"post")+'">'+e+"</form>").appendTo("body").submit().remove();d.info("Your download will begin soon")}},importIntoHistory:function(){this.refreshUserHistoriesList(function(e){var f=e.templateBulkImportInModal();e.modal=Galaxy.modal;e.modal.show({closing_events:true,title:"Import into History",body:f({histories:e.histories.models}),buttons:{Import:function(){e.importCurrentIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})},refreshUserHistoriesList:function(f){var e=this;this.histories=new c.GalaxyHistories();this.histories.fetch({success:function(g){if(g.length===0){d.warning("You have to create history first. Click this to do so.","",{onclick:function(){window.location="/"}})}else{f(e)}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg)}else{d.error("An error ocurred :(")}}})},importCurrentIntoHistory:function(){var f=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();var g=new c.HistoryItem();g.url=g.urlRoot+f+"/contents";var e="/api/histories/"+f+"/set_as_current";$.ajax({url:e,type:"PUT"});g.save({content:this.id,source:"library"},{success:function(){Galaxy.modal.hide();d.success("Dataset imported. Click this to start analysing it.","",{onclick:function(){window.location="/"}})},error:function(i,h){if(typeof h.responseJSON!=="undefined"){d.error("Dataset not imported. "+h.responseJSON.err_msg)}else{d.error("An error occured! Dataset not imported. Please try again.")}}})},shareDataset:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();if(this.options.fetched_permissions!==undefined){if(this.options.fetched_permissions.access_dataset_roles.length===0){this.model.set({is_unrestricted:true})}else{this.model.set({is_unrestricted:false})}}var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateDatasetPermissions();this.$el.html(g({item:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/libraries/datasets/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i,is_admin:h})}).fail(function(){d.error("An error occurred while fetching dataset permissions. :(")})}else{this.prepareSelectBoxes({is_admin:h})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},prepareSelectBoxes:function(r){this.options=_.extend(this.options,r);var s=this.options.fetched_permissions;var k=this.options.is_admin;var q=this;var m=[];for(var h=0;h<s.access_dataset_roles.length;h++){m.push(s.access_dataset_roles[h]+":"+s.access_dataset_roles[h])}var f=[];for(var h=0;h<s.modify_item_roles.length;h++){f.push(s.modify_item_roles[h]+":"+s.modify_item_roles[h])}var g=[];for(var h=0;h<s.manage_dataset_roles.length;h++){g.push(s.manage_dataset_roles[h]+":"+s.manage_dataset_roles[h])}if(k){var o={minimumInputLength:0,css:"access_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#access_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:m.join(","),dropdownCssClass:"bigdrop"};var l={minimumInputLength:0,css:"modify_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#modify_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:f.join(","),dropdownCssClass:"bigdrop"};var p={minimumInputLength:0,css:"manage_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#manage_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:g.join(","),dropdownCssClass:"bigdrop"};q.accessSelectObject=new b.View(o);q.modifySelectObject=new b.View(l);q.manageSelectObject=new b.View(p)}else{var n=q.templateAccessSelect();$.get("/api/libraries/datasets/"+q.id+"/permissions?scope=available",function(i){$(".access_perm").html(n({options:i.roles}));q.accessSelectObject=$("#access_select").select2()}).fail(function(){d.error("An error occurred while fetching data with permissions. :(")})}},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},makeDatasetPrivate:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=make_private").done(function(f){e.model.set({is_unrestricted:false});e.showPermissions({fetched_permissions:f});d.success("The dataset is now private to you")}).fail(function(){d.error("An error occurred while making dataset private :(")})},removeDatasetRestrictions:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=remove_restrictions").done(function(f){e.model.set({is_unrestricted:true});e.showPermissions({fetched_permissions:f});d.success("Access to this dataset is now unrestricted")}).fail(function(){d.error("An error occurred while making dataset unrestricted :(")})},savePermissions:function(e){var n=this;var k=this.accessSelectObject.$el.select2("data");var f=this.manageSelectObject.$el.select2("data");var m=this.modifySelectObject.$el.select2("data");var g=[];var j=[];var l=[];for(var h=k.length-1;h>=0;h--){g.push(k[h].id)}for(var h=f.length-1;h>=0;h--){j.push(f[h].id)}for(var h=m.length-1;h>=0;h--){l.push(m[h].id)}$.post("/api/libraries/datasets/"+n.id+"/permissions?action=set_permissions",{"access_ids[]":g,"manage_ids[]":j,"modify_ids[]":l,}).done(function(i){n.showPermissions({fetched_permissions:i});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting dataset permissions :(")})},templateDataset:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Download dataset" class="btn btn-default toolbtn-download-dataset primary-button" type="button"><span class="fa fa-download"></span> Download</span></button>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Import dataset into history" class="btn btn-default toolbtn-import-dataset primary-button" type="button"><span class="fa fa-book"></span> to History</span></button>');e.push(' <% if (item.get("can_user_modify")) { %>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(" <% } %>");e.push(' <% if (item.get("can_user_manage")) { %>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" <% } %>");e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<% if (item.get("is_unrestricted")) { %>');e.push(' <div class="alert alert-info">');e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </div>");e.push("<% } %>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("data_type")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("data_type")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("genome_build")) { %>');e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(item.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("file_size")) { %>');e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(item.get("file_size")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("date_uploaded")) { %>');e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("uploaded_by")) { %>');e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_data_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_comment_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_columns")) { %>');e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_column_types")) { %>');e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("message")) { %>');e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(item.get("message")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("misc_blurb")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("misc_info")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push(" <div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push(" </div>");e.push(' <% if (item.get("has_versions")) { %>');e.push(" <div>");e.push(" <h3>Expired versions:</h3>");e.push(" <ul>");e.push(' <% _.each(item.get("expired_versions"), function(version) { %>');e.push(' <li><a title="See details of this version" href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/versions/<%- version[0] %>"><%- version[1] %></a></li>');e.push(" <% }) %>");e.push(" <ul>");e.push(" </div>");e.push(" <% } %>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateVersion:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>"><button data-toggle="tooltip" data-placement="top" title="Go to latest dataset" class="btn btn-default primary-button" type="button"><span class="fa fa-caret-left fa-lg"></span> Latest dataset</span></button><a>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push(' <div class="alert alert-warning">This is an expired version of the library dataset: <%= _.escape(item.get("name")) %></div>');e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(ldda.id) %>">Name</th>');e.push(' <td><%= _.escape(ldda.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (ldda.get("data_type")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(ldda.get("data_type")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("genome_build")) { %>');e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(ldda.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("file_size")) { %>');e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(ldda.get("file_size")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("date_uploaded")) { %>');e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(ldda.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("uploaded_by")) { %>');e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(ldda.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_data_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_comment_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_comment_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_columns")) { %>');e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_column_types")) { %>');e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("message")) { %>');e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("message")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("misc_blurb")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("misc_info")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push(" <div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push(" </div>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateModifyDataset:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Cancel modifications" class="btn btn-default toolbtn_cancel_modifications primary-button" type="button"><span class="fa fa-times"></span> Cancel</span></button>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Save modifications" class="btn btn-default toolbtn_save_modifications primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<div class="dataset_table">');e.push('<p>For more editing options please import the dataset to history and use "Edit attributes" on it.</p>');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><input class="input_dataset_name form-control" type="text" placeholder="name" value="<%= _.escape(item.get("name")) %>"></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("data_type")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(item.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(item.get("file_size")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(' <tr scope="row">');e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <% if (item.get("metadata_comment_lines") === "") { %>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');e.push(" <% } else { %>");e.push(' <td scope="row">unknown</td>');e.push(" <% } %>");e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(item.get("message")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" </table>");e.push("<div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push("</div>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateDatasetPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#folders/<%- item.get("folder_id") %>"><button data-toggle="tooltip" data-placement="top" title="Go back to containing folder" class="btn btn-default primary-button" type="button"><span class="fa fa-folder-open-o"></span> Containing Folder</span></button></a>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>"><button data-toggle="tooltip" data-placement="top" title="Go back to dataset" class="btn btn-default primary-button" type="button"><span class="fa fa-file-o"></span> Dataset Details</span></button><a>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<h1>Dataset: <%= _.escape(item.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any dataset on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% } %>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Library-related permissions</h2>");e.push("<h4>Roles that can modify the library item</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify name, metadata, and other information about this library item.</div>');e.push("<hr/>");e.push("<h2>Dataset-related permissions</h2>");e.push('<div class="alert alert-warning">Changes made below will affect <strong>every</strong> library item that was created from this dataset and also every history this dataset is part of.</div>');e.push('<% if (!item.get("is_unrestricted")) { %>');e.push(" <p>You can remove all access restrictions on this dataset. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Everybody will be able to access the dataset." class="btn btn-default btn-remove-restrictions primary-button" type="button">');e.push(' <span class="fa fa-globe"> Remove restrictions</span>');e.push(" </button>");e.push(" </p>");e.push("<% } else { %>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page.");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"> To Clipboard</span></button> ');e.push(" <p>You can make this dataset private to you. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Only you will be able to access the dataset." class="btn btn-default btn-make-private primary-button" type="button"><span class="fa fa-key"> Make Private</span></button>');e.push(" </p>");e.push("<% } %>");e.push("<h4>Roles that can access the dataset</h4>");e.push('<div id="access_perm" class="access_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User has to have <strong>all these roles</strong> in order to access this dataset. Users without access permission <strong>cannot</strong> have other permissions on this dataset. If there are no access roles set on the dataset it is considered <strong>unrestricted</strong>.</div>');e.push("<h4>Roles that can manage permissions on the dataset</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions of this dataset. If you remove yourself you will loose the ability manage this dataset unless you are an admin.</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications made on this page" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateBulkImportInModal:function(){var e=[];e.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');e.push("Select history: ");e.push('<select id="dataset_import_single" name="dataset_import_single" style="width:50%; margin-bottom: 1em; "> ');e.push(" <% _.each(histories, function(history) { %>");e.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');e.push(" <% }); %>");e.push("</select>");e.push("</span>");return _.template(e.join(""))},templateAccessSelect:function(){var e=[];e.push('<select id="access_select" multiple>');e.push(" <% _.each(options, function(option) { %>");e.push(' <option value="<%- option.name %>"><%- option.name %></option>');e.push(" <% }); %>");e.push("</select>");return _.template(e.join(""))}});return{LibraryDatasetView:a}}); \ No newline at end of file +define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,b){var a=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_modify_dataset":"enableModification","click .toolbtn_cancel_modifications":"render","click .toolbtn-download-dataset":"downloadDataset","click .toolbtn-import-dataset":"importIntoHistory","click .toolbtn-share-dataset":"shareDataset","click .btn-copy-link-to-clipboard":"copyToClipboard","click .btn-make-private":"makeDatasetPrivate","click .btn-remove-restrictions":"removeDatasetRestrictions","click .toolbtn_save_permissions":"savePermissions","click .toolbtn_save_modifications":"comingSoon",},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchDataset()}},fetchDataset:function(e){this.options=_.extend(this.options,e);this.model=new c.Item({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{if(f.options.show_version){f.fetchVersion()}else{f.render()}}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){this.options=_.extend(this.options,e);$(".tooltip").remove();var f=this.templateDataset();this.$el.html(f({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},fetchVersion:function(e){this.options=_.extend(this.options,e);that=this;if(!this.options.ldda_id){this.render();d.error("Library dataset version requested but no id provided.")}else{this.ldda=new c.Ldda({id:this.options.ldda_id});this.ldda.url=this.ldda.urlRoot+this.model.id+"/versions/"+this.ldda.id;this.ldda.fetch({success:function(){that.renderVersion()},error:function(g,f){if(typeof f.responseJSON!=="undefined"){d.error(f.responseJSON.err_msg)}else{d.error("An error ocurred :(")}}})}},renderVersion:function(){$(".tooltip").remove();var e=this.templateVersion();this.$el.html(e({item:this.model,ldda:this.ldda}));$(".peek").html(this.ldda.get("peek"))},enableModification:function(){$(".tooltip").remove();var e=this.templateModifyDataset();this.$el.html(e({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},downloadDataset:function(){var e="/api/libraries/datasets/download/uncompressed";var f={ldda_ids:this.id};this.processDownload(e,f)},processDownload:function(f,g,h){if(f&&g){g=typeof g=="string"?g:$.param(g);var e="";$.each(g.split("&"),function(){var i=this.split("=");e+='<input type="hidden" name="'+i[0]+'" value="'+i[1]+'" />'});$('<form action="'+f+'" method="'+(h||"post")+'">'+e+"</form>").appendTo("body").submit().remove();d.info("Your download will begin soon")}},importIntoHistory:function(){this.refreshUserHistoriesList(function(e){var f=e.templateBulkImportInModal();e.modal=Galaxy.modal;e.modal.show({closing_events:true,title:"Import into History",body:f({histories:e.histories.models}),buttons:{Import:function(){e.importCurrentIntoHistory()},Close:function(){Galaxy.modal.hide()}}})})},refreshUserHistoriesList:function(f){var e=this;this.histories=new c.GalaxyHistories();this.histories.fetch({success:function(g){if(g.length===0){d.warning("You have to create history first. Click this to do so.","",{onclick:function(){window.location="/"}})}else{f(e)}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg)}else{d.error("An error ocurred :(")}}})},importCurrentIntoHistory:function(){var f=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();var g=new c.HistoryItem();g.url=g.urlRoot+f+"/contents";var e="/api/histories/"+f+"/set_as_current";$.ajax({url:e,type:"PUT"});g.save({content:this.id,source:"library"},{success:function(){Galaxy.modal.hide();d.success("Dataset imported. Click this to start analysing it.","",{onclick:function(){window.location="/"}})},error:function(i,h){if(typeof h.responseJSON!=="undefined"){d.error("Dataset not imported. "+h.responseJSON.err_msg)}else{d.error("An error occured! Dataset not imported. Please try again.")}}})},shareDataset:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();if(this.options.fetched_permissions!==undefined){if(this.options.fetched_permissions.access_dataset_roles.length===0){this.model.set({is_unrestricted:true})}else{this.model.set({is_unrestricted:false})}}var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateDatasetPermissions();this.$el.html(g({item:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/libraries/datasets/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i,is_admin:h})}).fail(function(){d.error("An error occurred while fetching dataset permissions. :(")})}else{this.prepareSelectBoxes({is_admin:h})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},prepareSelectBoxes:function(r){this.options=_.extend(this.options,r);var s=this.options.fetched_permissions;var k=this.options.is_admin;var q=this;var m=[];for(var h=0;h<s.access_dataset_roles.length;h++){m.push(s.access_dataset_roles[h]+":"+s.access_dataset_roles[h])}var f=[];for(var h=0;h<s.modify_item_roles.length;h++){f.push(s.modify_item_roles[h]+":"+s.modify_item_roles[h])}var g=[];for(var h=0;h<s.manage_dataset_roles.length;h++){g.push(s.manage_dataset_roles[h]+":"+s.manage_dataset_roles[h])}if(k){var o={minimumInputLength:0,css:"access_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#access_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:m.join(","),dropdownCssClass:"bigdrop"};var l={minimumInputLength:0,css:"modify_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#modify_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:f.join(","),dropdownCssClass:"bigdrop"};var p={minimumInputLength:0,css:"manage_perm",multiple:true,placeholder:"Click to select a role",container:q.$el.find("#manage_perm"),ajax:{url:"/api/libraries/datasets/"+q.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(i,t){return{q:i,page_limit:10,page:t}},results:function(u,t){var i=(t*10)<u.total;return{results:u.roles,more:i}}},formatResult:function j(i){return i.name+" type: "+i.type},formatSelection:function e(i){return i.name},initSelection:function(i,u){var t=[];$(i.val().split(",")).each(function(){var v=this.split(":");t.push({id:v[1],name:v[1]})});u(t)},initialData:g.join(","),dropdownCssClass:"bigdrop"};q.accessSelectObject=new b.View(o);q.modifySelectObject=new b.View(l);q.manageSelectObject=new b.View(p)}else{var n=q.templateAccessSelect();$.get("/api/libraries/datasets/"+q.id+"/permissions?scope=available",function(i){$(".access_perm").html(n({options:i.roles}));q.accessSelectObject=$("#access_select").select2()}).fail(function(){d.error("An error occurred while fetching data with permissions. :(")})}},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},makeDatasetPrivate:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=make_private").done(function(f){e.model.set({is_unrestricted:false});e.showPermissions({fetched_permissions:f});d.success("The dataset is now private to you")}).fail(function(){d.error("An error occurred while making dataset private :(")})},removeDatasetRestrictions:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=remove_restrictions").done(function(f){e.model.set({is_unrestricted:true});e.showPermissions({fetched_permissions:f});d.success("Access to this dataset is now unrestricted")}).fail(function(){d.error("An error occurred while making dataset unrestricted :(")})},savePermissions:function(e){var n=this;var k=this.accessSelectObject.$el.select2("data");var f=this.manageSelectObject.$el.select2("data");var m=this.modifySelectObject.$el.select2("data");var g=[];var j=[];var l=[];for(var h=k.length-1;h>=0;h--){g.push(k[h].id)}for(var h=f.length-1;h>=0;h--){j.push(f[h].id)}for(var h=m.length-1;h>=0;h--){l.push(m[h].id)}$.post("/api/libraries/datasets/"+n.id+"/permissions?action=set_permissions",{"access_ids[]":g,"manage_ids[]":j,"modify_ids[]":l,}).done(function(i){n.showPermissions({fetched_permissions:i});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting dataset permissions :(")})},templateDataset:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Download dataset" class="btn btn-default toolbtn-download-dataset primary-button" type="button"><span class="fa fa-download"></span> Download</span></button>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Import dataset into history" class="btn btn-default toolbtn-import-dataset primary-button" type="button"><span class="fa fa-book"></span> to History</span></button>');e.push(' <% if (item.get("can_user_modify")) { %>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(" <% } %>");e.push(' <% if (item.get("can_user_manage")) { %>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" <% } %>");e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<% if (item.get("is_unrestricted")) { %>');e.push(' <div class="alert alert-info">');e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </div>");e.push("<% } %>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("file_ext")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("file_ext")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("genome_build")) { %>');e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(item.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("file_size")) { %>');e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(item.get("file_size")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("date_uploaded")) { %>');e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("uploaded_by")) { %>');e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_data_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_comment_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_columns")) { %>');e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("metadata_column_types")) { %>');e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("message")) { %>');e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(item.get("message")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("misc_blurb")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (item.get("misc_info")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push(" <div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push(" </div>");e.push(' <% if (item.get("has_versions")) { %>');e.push(" <div>");e.push(" <h3>Expired versions:</h3>");e.push(" <ul>");e.push(' <% _.each(item.get("expired_versions"), function(version) { %>');e.push(' <li><a title="See details of this version" href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/versions/<%- version[0] %>"><%- version[1] %></a></li>');e.push(" <% }) %>");e.push(" <ul>");e.push(" </div>");e.push(" <% } %>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateVersion:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>"><button data-toggle="tooltip" data-placement="top" title="Go to latest dataset" class="btn btn-default primary-button" type="button"><span class="fa fa-caret-left fa-lg"></span> Latest dataset</span></button><a>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push(' <div class="alert alert-warning">This is an expired version of the library dataset: <%= _.escape(item.get("name")) %></div>');e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(ldda.id) %>">Name</th>');e.push(' <td><%= _.escape(ldda.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (ldda.get("file_ext")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(ldda.get("file_ext")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("genome_build")) { %>');e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(ldda.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("file_size")) { %>');e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(ldda.get("file_size")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("date_uploaded")) { %>');e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(ldda.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("uploaded_by")) { %>');e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(ldda.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_data_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_comment_lines")) { %>');e.push(" <tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_comment_lines")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_columns")) { %>');e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("metadata_column_types")) { %>');e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("message")) { %>');e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("message")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("misc_blurb")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(' <% if (ldda.get("misc_info")) { %>');e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(ldda.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push(" <div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push(" </div>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateModifyDataset:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Cancel modifications" class="btn btn-default toolbtn_cancel_modifications primary-button" type="button"><span class="fa fa-times"></span> Cancel</span></button>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Save modifications" class="btn btn-default toolbtn_save_modifications primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<div class="dataset_table">');e.push('<p>For more editing options please import the dataset to history and use "Edit attributes" on it.</p>');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><input class="input_dataset_name form-control" type="text" placeholder="name" value="<%= _.escape(item.get("name")) %>"></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("file_ext")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Genome build</th>');e.push(' <td><%= _.escape(item.get("genome_build")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Size</th>');e.push(' <td><%= _.escape(item.get("file_size")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Date uploaded (UTC)</th>');e.push(' <td><%= _.escape(item.get("date_uploaded")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Uploaded by</th>');e.push(' <td><%= _.escape(item.get("uploaded_by")) %></td>');e.push(" </tr>");e.push(' <tr scope="row">');e.push(' <th scope="row">Data Lines</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_data_lines")) %></td>');e.push(" </tr>");e.push(' <th scope="row">Comment Lines</th>');e.push(' <% if (item.get("metadata_comment_lines") === "") { %>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_comment_lines")) %></td>');e.push(" <% } else { %>");e.push(' <td scope="row">unknown</td>');e.push(" <% } %>");e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Number of Columns</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_columns")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Column Types</th>');e.push(' <td scope="row"><%= _.escape(item.get("metadata_column_types")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Message</th>');e.push(' <td scope="row"><%= _.escape(item.get("message")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Miscellaneous information</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_info")) %></td>');e.push(" </tr>");e.push(" <tr>");e.push(' <th scope="row">Miscellaneous blurb</th>');e.push(' <td scope="row"><%= _.escape(item.get("misc_blurb")) %></td>');e.push(" </tr>");e.push(" </table>");e.push("<div>");e.push(' <pre class="peek">');e.push(" </pre>");e.push("</div>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateDatasetPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#folders/<%- item.get("folder_id") %>"><button data-toggle="tooltip" data-placement="top" title="Go back to containing folder" class="btn btn-default primary-button" type="button"><span class="fa fa-folder-open-o"></span> Containing Folder</span></button></a>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>"><button data-toggle="tooltip" data-placement="top" title="Go back to dataset" class="btn btn-default primary-button" type="button"><span class="fa fa-file-o"></span> Dataset Details</span></button><a>');e.push(" </div>");e.push('<ol class="breadcrumb">');e.push(' <li><a title="Return to the list of libraries" href="#">Libraries</a></li>');e.push(' <% _.each(item.get("full_path"), function(path_item) { %>');e.push(" <% if (path_item[0] != item.id) { %>");e.push(' <li><a title="Return to this folder" href="#/folders/<%- path_item[0] %>"><%- path_item[1] %></a></li> ');e.push("<% } else { %>");e.push(' <li class="active"><span title="You are here"><%- path_item[1] %></span></li>');e.push(" <% } %>");e.push(" <% }); %>");e.push("</ol>");e.push('<h1>Dataset: <%= _.escape(item.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any dataset on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% } %>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Library-related permissions</h2>");e.push("<h4>Roles that can modify the library item</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify name, metadata, and other information about this library item.</div>');e.push("<hr/>");e.push("<h2>Dataset-related permissions</h2>");e.push('<div class="alert alert-warning">Changes made below will affect <strong>every</strong> library item that was created from this dataset and also every history this dataset is part of.</div>');e.push('<% if (!item.get("is_unrestricted")) { %>');e.push(" <p>You can remove all access restrictions on this dataset. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Everybody will be able to access the dataset." class="btn btn-default btn-remove-restrictions primary-button" type="button">');e.push(' <span class="fa fa-globe"> Remove restrictions</span>');e.push(" </button>");e.push(" </p>");e.push("<% } else { %>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page.");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"> To Clipboard</span></button> ');e.push(" <p>You can make this dataset private to you. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Only you will be able to access the dataset." class="btn btn-default btn-make-private primary-button" type="button"><span class="fa fa-key"> Make Private</span></button>');e.push(" </p>");e.push("<% } %>");e.push("<h4>Roles that can access the dataset</h4>");e.push('<div id="access_perm" class="access_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User has to have <strong>all these roles</strong> in order to access this dataset. Users without access permission <strong>cannot</strong> have other permissions on this dataset. If there are no access roles set on the dataset it is considered <strong>unrestricted</strong>.</div>');e.push("<h4>Roles that can manage permissions on the dataset</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions of this dataset. If you remove yourself you will loose the ability manage this dataset unless you are an admin.</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications made on this page" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateBulkImportInModal:function(){var e=[];e.push('<span id="history_modal_combo_bulk" style="width:90%; margin-left: 1em; margin-right: 1em; ">');e.push("Select history: ");e.push('<select id="dataset_import_single" name="dataset_import_single" style="width:50%; margin-bottom: 1em; "> ');e.push(" <% _.each(histories, function(history) { %>");e.push(' <option value="<%= _.escape(history.get("id")) %>"><%= _.escape(history.get("name")) %></option>');e.push(" <% }); %>");e.push("</select>");e.push("</span>");return _.template(e.join(""))},templateAccessSelect:function(){var e=[];e.push('<select id="access_select" multiple>');e.push(" <% _.each(options, function(option) { %>");e.push(' <option value="<%- option.name %>"><%- option.name %></option>');e.push(" <% }); %>");e.push("</select>");return _.template(e.join(""))}});return{LibraryDatasetView:a}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/library/library-folder-view.js --- a/static/scripts/packed/mvc/library/library-folder-view.js +++ b/static/scripts/packed/mvc/library/library-folder-view.js @@ -1,1 +1,1 @@ -define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,a){var b=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_save_permissions":"savePermissions"},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchFolder()}},fetchFolder:function(e){this.options=_.extend(this.options,e);this.model=new c.FolderAsModel({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{f.render()}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){$(".tooltip").remove();this.options=_.extend(this.options,e);var f=this.templateFolder();this.$el.html(f({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},shareFolder:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateFolderPermissions();this.$el.html(g({folder:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/folders/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i})}).fail(function(){d.error("An error occurred while fetching folder permissions. :(")})}else{this.prepareSelectBoxes({})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},_serializeRoles:function(g){var e=[];for(var f=0;f<g.length;f++){e.push(g[f]+":"+g[f])}return e},prepareSelectBoxes:function(h){this.options=_.extend(this.options,h);var f=this.options.fetched_permissions;var g=this;var i=this._serializeRoles(f.add_library_item_role_list);var j=this._serializeRoles(f.manage_folder_role_list);var e=this._serializeRoles(f.modify_folder_role_list);g.addSelectObject=new a.View(this._createSelectOptions(this,"add_perm",i,false));g.manageSelectObject=new a.View(this._createSelectOptions(this,"manage_perm",j,false));g.modifySelectObject=new a.View(this._createSelectOptions(this,"modify_perm",e,false))},_createSelectOptions:function(e,j,h){var i={minimumInputLength:0,css:j,multiple:true,placeholder:"Click to select a role",container:e.$el.find("#"+j),ajax:{url:"/api/folders/"+e.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(k,l){return{q:k,page_limit:10,page:l}},results:function(m,l){var k=(l*10)<m.total;return{results:m.roles,more:k}}},formatResult:function f(k){return k.name+" type: "+k.type},formatSelection:function g(k){return k.name},initSelection:function(k,m){var l=[];$(k.val().split(",")).each(function(){var n=this.split(":");l.push({id:n[1],name:n[1]})});m(l)},initialData:h.join(","),dropdownCssClass:"bigdrop"};return i},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},_extractIds:function(e){ids_list=[];for(var f=e.length-1;f>=0;f--){ids_list.push(e[f].id)}return ids_list},savePermissions:function(h){var g=this;var e=this._extractIds(this.addSelectObject.$el.select2("data"));var i=this._extractIds(this.manageSelectObject.$el.select2("data"));var f=this._extractIds(this.modifySelectObject.$el.select2("data"));$.post("/api/folders/"+g.id+"/permissions?action=set_permissions",{"add_ids[]":e,"manage_ids[]":i,"modify_ids[]":f,}).done(function(j){g.showPermissions({fetched_permissions:j});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting folder permissions :(")})},templateFolder:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" </div>");e.push(" <p>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </p>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("data_type")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("data_type")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateFolderPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#/folders/<%= folder.get("parent_id") %>"><button data-toggle="tooltip" data-placement="top" title="Go back to the parent folder" class="btn btn-default primary-button" type="button"><span class="fa fa-caret-left fa-lg"></span> Parent folder</span></button></a>');e.push(" </div>");e.push('<h1>Folder: <%= _.escape(folder.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any folder on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% }%>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Folder permissions</h2>");e.push("<h4>Roles that can manage permissions on this folder</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions on this folder.</div>');e.push("<h4>Roles that can add items to this folder</h4>");e.push('<div id="add_perm" class="add_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can add items to this folder (folders and datasets).</div>');e.push("<h4>Roles that can modify this folder</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify this folder (name, etc.).</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))}});return{FolderView:b}}); \ No newline at end of file +define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,a){var b=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_save_permissions":"savePermissions"},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchFolder()}},fetchFolder:function(e){this.options=_.extend(this.options,e);this.model=new c.FolderAsModel({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{f.render()}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){$(".tooltip").remove();this.options=_.extend(this.options,e);var f=this.templateFolder();this.$el.html(f({item:this.model}));$(".peek").html(this.model.get("peek"));$("#center [data-toggle]").tooltip()},shareFolder:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateFolderPermissions();this.$el.html(g({folder:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/folders/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i})}).fail(function(){d.error("An error occurred while fetching folder permissions. :(")})}else{this.prepareSelectBoxes({})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},_serializeRoles:function(g){var e=[];for(var f=0;f<g.length;f++){e.push(g[f]+":"+g[f])}return e},prepareSelectBoxes:function(h){this.options=_.extend(this.options,h);var f=this.options.fetched_permissions;var g=this;var i=this._serializeRoles(f.add_library_item_role_list);var j=this._serializeRoles(f.manage_folder_role_list);var e=this._serializeRoles(f.modify_folder_role_list);g.addSelectObject=new a.View(this._createSelectOptions(this,"add_perm",i,false));g.manageSelectObject=new a.View(this._createSelectOptions(this,"manage_perm",j,false));g.modifySelectObject=new a.View(this._createSelectOptions(this,"modify_perm",e,false))},_createSelectOptions:function(e,j,h){var i={minimumInputLength:0,css:j,multiple:true,placeholder:"Click to select a role",container:e.$el.find("#"+j),ajax:{url:"/api/folders/"+e.id+"/permissions?scope=available",dataType:"json",quietMillis:100,data:function(k,l){return{q:k,page_limit:10,page:l}},results:function(m,l){var k=(l*10)<m.total;return{results:m.roles,more:k}}},formatResult:function f(k){return k.name+" type: "+k.type},formatSelection:function g(k){return k.name},initSelection:function(k,m){var l=[];$(k.val().split(",")).each(function(){var n=this.split(":");l.push({id:n[1],name:n[1]})});m(l)},initialData:h.join(","),dropdownCssClass:"bigdrop"};return i},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},_extractIds:function(e){ids_list=[];for(var f=e.length-1;f>=0;f--){ids_list.push(e[f].id)}return ids_list},savePermissions:function(h){var g=this;var e=this._extractIds(this.addSelectObject.$el.select2("data"));var i=this._extractIds(this.manageSelectObject.$el.select2("data"));var f=this._extractIds(this.modifySelectObject.$el.select2("data"));$.post("/api/folders/"+g.id+"/permissions?action=set_permissions",{"add_ids[]":e,"manage_ids[]":i,"modify_ids[]":f,}).done(function(j){g.showPermissions({fetched_permissions:j});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting folder permissions :(")})},templateFolder:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" </div>");e.push(" <p>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </p>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("file_ext")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("file_ext")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateFolderPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#/folders/<%= folder.get("parent_id") %>"><button data-toggle="tooltip" data-placement="top" title="Go back to the parent folder" class="btn btn-default primary-button" type="button"><span class="fa fa-caret-left fa-lg"></span> Parent folder</span></button></a>');e.push(" </div>");e.push('<h1>Folder: <%= _.escape(folder.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any folder on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% }%>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Folder permissions</h2>");e.push("<h4>Roles that can manage permissions on this folder</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions on this folder.</div>');e.push("<h4>Roles that can add items to this folder</h4>");e.push('<div id="add_perm" class="add_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can add items to this folder (folders and datasets).</div>');e.push("<h4>Roles that can modify this folder</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify this folder (name, etc.).</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))}});return{FolderView:b}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/library/library-folderrow-view.js --- a/static/scripts/packed/mvc/library/library-folderrow-view.js +++ b/static/scripts/packed/mvc/library/library-folderrow-view.js @@ -1,1 +1,1 @@ -define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-dataset-view"],function(c,e,f,d,b){var a=Backbone.View.extend({lastSelectedHistory:"",events:{"click .undelete_dataset_btn":"undelete_dataset"},options:{type:null},initialize:function(g){this.render(g)},render:function(g){var h=null;if(g.get("type")==="folder"){this.options.type="folder";h=this.templateRowFolder()}else{this.options.type="file";if(g.get("deleted")){h=this.templateRowDeletedFile()}else{h=this.templateRowFile()}}this.setElement(h({content_item:g}));this.$el.show();return this},showDatasetDetails:function(){Galaxy.libraries.datasetView=new b.LibraryDatasetView({id:this.id})},undelete_dataset:function(i){$(".tooltip").hide();var h=this;var g=$(i.target).closest("tr")[0].id;var j=Galaxy.libraries.folderListView.collection.get(g);j.url=j.urlRoot+j.id+"?undelete=true";j.destroy({success:function(l,k){Galaxy.libraries.folderListView.collection.remove(g);var m=new d.Item(k);Galaxy.libraries.folderListView.collection.add(m);f.success("Dataset undeleted. Click this to see it.","",{onclick:function(){h.showDatasetDetails()}})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error("Dataset was not undeleted. "+k.responseJSON.err_msg)}else{f.error("An error occured! Dataset was not undeleted. Please try again.")}}})},templateRowFolder:function(){tmpl_array=[];tmpl_array.push('<tr class="folder_row light library-row" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Folder" class="fa fa-folder-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(" <td></td>");tmpl_array.push(" <td>");tmpl_array.push(' <a href="#folders/<%- content_item.id %>"><%- content_item.get("name") %></a>');tmpl_array.push(" </td>");tmpl_array.push(" <td>folder</td>");tmpl_array.push(" <td></td>");tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(" <td>");tmpl_array.push(' <% if (content_item.get("can_manage")) { %><a href="#/folders/<%- content_item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" class="primary-button btn-xs permissions-folder-btn show_on_hover" title="Manage permissions" style="display:none;"><span class="fa fa-group"></span></button></a><% } %>');tmpl_array.push(" </td>");tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))},templateRowFile:function(){tmpl_array=[];tmpl_array.push('<tr class="dataset_row light library-row" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Dataset" class="fa fa-file-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(' <td style="text-align: center; "><input style="margin: 0;" type="checkbox"></td>');tmpl_array.push(' <td><a href="#folders/<%- content_item.get("folder_id") %>/datasets/<%- content_item.id %>" class="library-dataset"><%- content_item.get("name") %><a></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("data_type")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_size")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(" <td>");tmpl_array.push(' <% if (content_item.get("is_unrestricted")) { %><span data-toggle="tooltip" data-placement="top" title="Unrestricted dataset" style="color:grey;" class="fa fa-globe fa-lg"></span><% } %>');tmpl_array.push(' <% if (content_item.get("is_private")) { %><span data-toggle="tooltip" data-placement="top" title="Private dataset" style="color:grey;" class="fa fa-key fa-lg"></span><% } %>');tmpl_array.push(' <% if ((content_item.get("is_unrestricted") === false) && (content_item.get("is_private") === false)) { %><span data-toggle="tooltip" data-placement="top" title="Restricted dataset" style="color:grey;" class="fa fa-shield fa-lg"></span><% } %>');tmpl_array.push(' <% if (content_item.get("can_manage")) { %><a href="#folders/<%- content_item.get("folder_id") %>/datasets/<%- content_item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" class="primary-button btn-xs permissions-dataset-btn show_on_hover" title="Manage permissions" style="display:none;"><span class="fa fa-group"></span></button></a><% } %>');tmpl_array.push(" </td>");tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))},templateRowDeletedFile:function(){tmpl_array=[];tmpl_array.push('<tr class="active deleted_dataset" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Dataset" class="fa fa-file-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(" <td></td>");tmpl_array.push(' <td style="color:grey;"><%- content_item.get("name") %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("data_type")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_size")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(' <td><span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg"></span><button data-toggle="tooltip" data-placement="top" title="Undelete <%- content_item.get("name") %>" class="primary-button btn-xs undelete_dataset_btn show_on_hover" type="button" style="display:none; margin-left:1em;"><span class="fa fa-unlock"> Undelete</span></button></td>');tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))}});return{FolderRowView:a}}); \ No newline at end of file +define(["galaxy.masthead","utils/utils","libs/toastr","mvc/library/library-model","mvc/library/library-dataset-view"],function(c,e,f,d,b){var a=Backbone.View.extend({lastSelectedHistory:"",events:{"click .undelete_dataset_btn":"undelete_dataset"},options:{type:null},initialize:function(g){this.render(g)},render:function(g){var h=null;if(g.get("type")==="folder"){this.options.type="folder";h=this.templateRowFolder()}else{this.options.type="file";if(g.get("deleted")){h=this.templateRowDeletedFile()}else{h=this.templateRowFile()}}this.setElement(h({content_item:g}));this.$el.show();return this},showDatasetDetails:function(){Galaxy.libraries.datasetView=new b.LibraryDatasetView({id:this.id})},undelete_dataset:function(i){$(".tooltip").hide();var h=this;var g=$(i.target).closest("tr")[0].id;var j=Galaxy.libraries.folderListView.collection.get(g);j.url=j.urlRoot+j.id+"?undelete=true";j.destroy({success:function(l,k){Galaxy.libraries.folderListView.collection.remove(g);var m=new d.Item(k);Galaxy.libraries.folderListView.collection.add(m);f.success("Dataset undeleted. Click this to see it.","",{onclick:function(){h.showDatasetDetails()}})},error:function(l,k){if(typeof k.responseJSON!=="undefined"){f.error("Dataset was not undeleted. "+k.responseJSON.err_msg)}else{f.error("An error occured! Dataset was not undeleted. Please try again.")}}})},templateRowFolder:function(){tmpl_array=[];tmpl_array.push('<tr class="folder_row light library-row" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Folder" class="fa fa-folder-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(" <td></td>");tmpl_array.push(" <td>");tmpl_array.push(' <a href="#folders/<%- content_item.id %>"><%- content_item.get("name") %></a>');tmpl_array.push(" </td>");tmpl_array.push(" <td>folder</td>");tmpl_array.push(" <td></td>");tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(" <td>");tmpl_array.push(' <% if (content_item.get("can_manage")) { %><a href="#/folders/<%- content_item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" class="primary-button btn-xs permissions-folder-btn show_on_hover" title="Manage permissions" style="display:none;"><span class="fa fa-group"></span></button></a><% } %>');tmpl_array.push(" </td>");tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))},templateRowFile:function(){tmpl_array=[];tmpl_array.push('<tr class="dataset_row light library-row" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Dataset" class="fa fa-file-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(' <td style="text-align: center; "><input style="margin: 0;" type="checkbox"></td>');tmpl_array.push(' <td><a href="#folders/<%- content_item.get("folder_id") %>/datasets/<%- content_item.id %>" class="library-dataset"><%- content_item.get("name") %><a></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_ext")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_size")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(" <td>");tmpl_array.push(' <% if (content_item.get("is_unrestricted")) { %><span data-toggle="tooltip" data-placement="top" title="Unrestricted dataset" style="color:grey;" class="fa fa-globe fa-lg"></span><% } %>');tmpl_array.push(' <% if (content_item.get("is_private")) { %><span data-toggle="tooltip" data-placement="top" title="Private dataset" style="color:grey;" class="fa fa-key fa-lg"></span><% } %>');tmpl_array.push(' <% if ((content_item.get("is_unrestricted") === false) && (content_item.get("is_private") === false)) { %><span data-toggle="tooltip" data-placement="top" title="Restricted dataset" style="color:grey;" class="fa fa-shield fa-lg"></span><% } %>');tmpl_array.push(' <% if (content_item.get("can_manage")) { %><a href="#folders/<%- content_item.get("folder_id") %>/datasets/<%- content_item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" class="primary-button btn-xs permissions-dataset-btn show_on_hover" title="Manage permissions" style="display:none;"><span class="fa fa-group"></span></button></a><% } %>');tmpl_array.push(" </td>");tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))},templateRowDeletedFile:function(){tmpl_array=[];tmpl_array.push('<tr class="active deleted_dataset" id="<%- content_item.id %>">');tmpl_array.push(" <td>");tmpl_array.push(' <span title="Dataset" class="fa fa-file-o"></span>');tmpl_array.push(" </td>");tmpl_array.push(" <td></td>");tmpl_array.push(' <td style="color:grey;"><%- content_item.get("name") %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_ext")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("file_size")) %></td>');tmpl_array.push(' <td><%= _.escape(content_item.get("update_time")) %></td>');tmpl_array.push(' <td><span data-toggle="tooltip" data-placement="top" title="Marked deleted" style="color:grey;" class="fa fa-ban fa-lg"></span><button data-toggle="tooltip" data-placement="top" title="Undelete <%- content_item.get("name") %>" class="primary-button btn-xs undelete_dataset_btn show_on_hover" type="button" style="display:none; margin-left:1em;"><span class="fa fa-unlock"> Undelete</span></button></td>');tmpl_array.push("</tr>");return _.template(tmpl_array.join(""))}});return{FolderRowView:a}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/library/library-library-view.js --- a/static/scripts/packed/mvc/library/library-library-view.js +++ b/static/scripts/packed/mvc/library/library-library-view.js @@ -1,1 +1,1 @@ -define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,a){var b=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_save_permissions":"savePermissions"},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchLibrary()}},fetchLibrary:function(e){this.options=_.extend(this.options,e);this.model=new c.Library({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{f.render()}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){$(".tooltip").remove();this.options=_.extend(this.options,e);var f=this.templateLibrary();this.$el.html(f({item:this.model}));$("#center [data-toggle]").tooltip()},shareDataset:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();if(this.options.fetched_permissions!==undefined){if(this.options.fetched_permissions.access_library_role_list.length===0){this.model.set({is_unrestricted:true})}else{this.model.set({is_unrestricted:false})}}var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateLibraryPermissions();this.$el.html(g({library:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/libraries/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i})}).fail(function(){d.error("An error occurred while fetching library permissions. :(")})}else{this.prepareSelectBoxes({})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},_serializeRoles:function(g){var e=[];for(var f=0;f<g.length;f++){e.push(g[f]+":"+g[f])}return e},prepareSelectBoxes:function(i){this.options=_.extend(this.options,i);var e=this.options.fetched_permissions;var g=this;var f=this._serializeRoles(e.access_library_role_list);var j=this._serializeRoles(e.add_library_item_role_list);var h=this._serializeRoles(e.manage_library_role_list);var k=this._serializeRoles(e.modify_library_role_list);g.accessSelectObject=new a.View(this._createSelectOptions(this,"access_perm",f,true));g.addSelectObject=new a.View(this._createSelectOptions(this,"add_perm",j,false));g.manageSelectObject=new a.View(this._createSelectOptions(this,"manage_perm",h,false));g.modifySelectObject=new a.View(this._createSelectOptions(this,"modify_perm",k,false))},_createSelectOptions:function(f,k,i,e){e=e===true?e:false;var j={minimumInputLength:0,css:k,multiple:true,placeholder:"Click to select a role",container:f.$el.find("#"+k),ajax:{url:"/api/libraries/"+f.id+"/permissions?scope=available&is_library_access="+e,dataType:"json",quietMillis:100,data:function(l,m){return{q:l,page_limit:10,page:m}},results:function(n,m){var l=(m*10)<n.total;return{results:n.roles,more:l}}},formatResult:function g(l){return l.name+" type: "+l.type},formatSelection:function h(l){return l.name},initSelection:function(l,n){var m=[];$(l.val().split(",")).each(function(){var o=this.split(":");m.push({id:o[1],name:o[1]})});n(m)},initialData:i.join(","),dropdownCssClass:"bigdrop"};return j},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},makeDatasetPrivate:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=make_private").done(function(f){e.model.set({is_unrestricted:false});e.showPermissions({fetched_permissions:f});d.success("The dataset is now private to you")}).fail(function(){d.error("An error occurred while making dataset private :(")})},removeDatasetRestrictions:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=remove_restrictions").done(function(f){e.model.set({is_unrestricted:true});e.showPermissions({fetched_permissions:f});d.success("Access to this dataset is now unrestricted")}).fail(function(){d.error("An error occurred while making dataset unrestricted :(")})},_extractIds:function(e){ids_list=[];for(var f=e.length-1;f>=0;f--){ids_list.push(e[f].id)}return ids_list},savePermissions:function(h){var g=this;var i=this._extractIds(this.accessSelectObject.$el.select2("data"));var e=this._extractIds(this.addSelectObject.$el.select2("data"));var j=this._extractIds(this.manageSelectObject.$el.select2("data"));var f=this._extractIds(this.modifySelectObject.$el.select2("data"));$.post("/api/libraries/"+g.id+"/permissions?action=set_permissions",{"access_ids[]":i,"add_ids[]":e,"manage_ids[]":j,"modify_ids[]":f,}).done(function(k){g.showPermissions({fetched_permissions:k});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting library permissions :(")})},templateLibrary:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" </div>");e.push(" <p>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </p>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("data_type")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("data_type")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateLibraryPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#"><button data-toggle="tooltip" data-placement="top" title="Go back to the list of Libraries" class="btn btn-default primary-button" type="button"><span class="fa fa-list"></span> Libraries</span></button></a>');e.push(" </div>");e.push('<h1>Library: <%= _.escape(library.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any library on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% }%>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Library permissions</h2>");e.push("<h4>Roles that can access the library</h4>");e.push('<div id="access_perm" class="access_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can access this library. If there are no access roles set on the library it is considered <strong>unrestricted</strong>.</div>');e.push("<h4>Roles that can manage permissions on this library</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions on this library (includes giving access).</div>');e.push("<h4>Roles that can add items to this library</h4>");e.push('<div id="add_perm" class="add_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can add items to this library (folders and datasets).</div>');e.push("<h4>Roles that can modify this library</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify this library (name, synopsis, etc.).</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications made on this page" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))}});return{LibraryView:b}}); \ No newline at end of file +define(["libs/toastr","mvc/library/library-model","mvc/ui/ui-select"],function(d,c,a){var b=Backbone.View.extend({el:"#center",model:null,options:{},events:{"click .toolbtn_save_permissions":"savePermissions"},initialize:function(e){this.options=_.extend(this.options,e);if(this.options.id){this.fetchLibrary()}},fetchLibrary:function(e){this.options=_.extend(this.options,e);this.model=new c.Library({id:this.options.id});var f=this;this.model.fetch({success:function(){if(f.options.show_permissions){f.showPermissions()}else{f.render()}},error:function(h,g){if(typeof g.responseJSON!=="undefined"){d.error(g.responseJSON.err_msg+" Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}else{d.error("An error ocurred :(. Click this to go back.","",{onclick:function(){Galaxy.libraries.library_router.back()}})}}})},render:function(e){$(".tooltip").remove();this.options=_.extend(this.options,e);var f=this.templateLibrary();this.$el.html(f({item:this.model}));$("#center [data-toggle]").tooltip()},shareDataset:function(){d.info("Feature coming soon.")},goBack:function(){Galaxy.libraries.library_router.back()},showPermissions:function(f){this.options=_.extend(this.options,f);$(".tooltip").remove();if(this.options.fetched_permissions!==undefined){if(this.options.fetched_permissions.access_library_role_list.length===0){this.model.set({is_unrestricted:true})}else{this.model.set({is_unrestricted:false})}}var h=false;if(Galaxy.currUser){h=Galaxy.currUser.isAdmin()}var g=this.templateLibraryPermissions();this.$el.html(g({library:this.model,is_admin:h}));var e=this;if(this.options.fetched_permissions===undefined){$.get("/api/libraries/"+e.id+"/permissions?scope=current").done(function(i){e.prepareSelectBoxes({fetched_permissions:i})}).fail(function(){d.error("An error occurred while fetching library permissions. :(")})}else{this.prepareSelectBoxes({})}$("#center [data-toggle]").tooltip();$("#center").css("overflow","auto")},_serializeRoles:function(g){var e=[];for(var f=0;f<g.length;f++){e.push(g[f]+":"+g[f])}return e},prepareSelectBoxes:function(i){this.options=_.extend(this.options,i);var e=this.options.fetched_permissions;var g=this;var f=this._serializeRoles(e.access_library_role_list);var j=this._serializeRoles(e.add_library_item_role_list);var h=this._serializeRoles(e.manage_library_role_list);var k=this._serializeRoles(e.modify_library_role_list);g.accessSelectObject=new a.View(this._createSelectOptions(this,"access_perm",f,true));g.addSelectObject=new a.View(this._createSelectOptions(this,"add_perm",j,false));g.manageSelectObject=new a.View(this._createSelectOptions(this,"manage_perm",h,false));g.modifySelectObject=new a.View(this._createSelectOptions(this,"modify_perm",k,false))},_createSelectOptions:function(f,k,i,e){e=e===true?e:false;var j={minimumInputLength:0,css:k,multiple:true,placeholder:"Click to select a role",container:f.$el.find("#"+k),ajax:{url:"/api/libraries/"+f.id+"/permissions?scope=available&is_library_access="+e,dataType:"json",quietMillis:100,data:function(l,m){return{q:l,page_limit:10,page:m}},results:function(n,m){var l=(m*10)<n.total;return{results:n.roles,more:l}}},formatResult:function g(l){return l.name+" type: "+l.type},formatSelection:function h(l){return l.name},initSelection:function(l,n){var m=[];$(l.val().split(",")).each(function(){var o=this.split(":");m.push({id:o[1],name:o[1]})});n(m)},initialData:i.join(","),dropdownCssClass:"bigdrop"};return j},comingSoon:function(){d.warning("Feature coming soon")},copyToClipboard:function(){var e=Backbone.history.location.href;if(e.lastIndexOf("/permissions")!==-1){e=e.substr(0,e.lastIndexOf("/permissions"))}window.prompt("Copy to clipboard: Ctrl+C, Enter",e)},makeDatasetPrivate:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=make_private").done(function(f){e.model.set({is_unrestricted:false});e.showPermissions({fetched_permissions:f});d.success("The dataset is now private to you")}).fail(function(){d.error("An error occurred while making dataset private :(")})},removeDatasetRestrictions:function(){var e=this;$.post("/api/libraries/datasets/"+e.id+"/permissions?action=remove_restrictions").done(function(f){e.model.set({is_unrestricted:true});e.showPermissions({fetched_permissions:f});d.success("Access to this dataset is now unrestricted")}).fail(function(){d.error("An error occurred while making dataset unrestricted :(")})},_extractIds:function(e){ids_list=[];for(var f=e.length-1;f>=0;f--){ids_list.push(e[f].id)}return ids_list},savePermissions:function(h){var g=this;var i=this._extractIds(this.accessSelectObject.$el.select2("data"));var e=this._extractIds(this.addSelectObject.$el.select2("data"));var j=this._extractIds(this.manageSelectObject.$el.select2("data"));var f=this._extractIds(this.modifySelectObject.$el.select2("data"));$.post("/api/libraries/"+g.id+"/permissions?action=set_permissions",{"access_ids[]":i,"add_ids[]":e,"manage_ids[]":j,"modify_ids[]":f,}).done(function(k){g.showPermissions({fetched_permissions:k});d.success("Permissions saved")}).fail(function(){d.error("An error occurred while setting library permissions :(")})},templateLibrary:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <button data-toggle="tooltip" data-placement="top" title="Modify library item" class="btn btn-default toolbtn_modify_dataset primary-button" type="button"><span class="fa fa-pencil"></span> Modify</span></button>');e.push(' <a href="#folders/<%- item.get("folder_id") %>/datasets/<%- item.id %>/permissions"><button data-toggle="tooltip" data-placement="top" title="Manage permissions" class="btn btn-default toolbtn_change_permissions primary-button" type="button"><span class="fa fa-group"></span> Permissions</span></button></a>');e.push(' <button data-toggle="tooltip" data-placement="top" title="Share dataset" class="btn btn-default toolbtn-share-dataset primary-button" type="button"><span class="fa fa-share"></span> Share</span></button>');e.push(" </div>");e.push(" <p>");e.push(" This dataset is unrestricted so everybody can access it. Just share the URL of this page. ");e.push(' <button data-toggle="tooltip" data-placement="top" title="Copy to clipboard" class="btn btn-default btn-copy-link-to-clipboard primary-button" type="button"><span class="fa fa-clipboard"></span> To Clipboard</span></button> ');e.push(" </p>");e.push('<div class="dataset_table">');e.push(' <table class="grid table table-striped table-condensed">');e.push(" <tr>");e.push(' <th scope="row" id="id_row" data-id="<%= _.escape(item.get("ldda_id")) %>">Name</th>');e.push(' <td><%= _.escape(item.get("name")) %></td>');e.push(" </tr>");e.push(' <% if (item.get("file_ext")) { %>');e.push(" <tr>");e.push(' <th scope="row">Data type</th>');e.push(' <td><%= _.escape(item.get("file_ext")) %></td>');e.push(" </tr>");e.push(" <% } %>");e.push(" </table>");e.push("</div>");e.push("</div>");return _.template(e.join(""))},templateLibraryPermissions:function(){var e=[];e.push('<div class="library_style_container">');e.push(' <div id="library_toolbar">');e.push(' <a href="#"><button data-toggle="tooltip" data-placement="top" title="Go back to the list of Libraries" class="btn btn-default primary-button" type="button"><span class="fa fa-list"></span> Libraries</span></button></a>');e.push(" </div>");e.push('<h1>Library: <%= _.escape(library.get("name")) %></h1>');e.push('<div class="alert alert-warning">');e.push("<% if (is_admin) { %>");e.push("You are logged in as an <strong>administrator</strong> therefore you can manage any library on this Galaxy instance. Please make sure you understand the consequences.");e.push("<% } else { %>");e.push("You can assign any number of roles to any of the following permission types. However please read carefully the implications of such actions.");e.push("<% }%>");e.push("</div>");e.push('<div class="dataset_table">');e.push("<h2>Library permissions</h2>");e.push("<h4>Roles that can access the library</h4>");e.push('<div id="access_perm" class="access_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can access this library. If there are no access roles set on the library it is considered <strong>unrestricted</strong>.</div>');e.push("<h4>Roles that can manage permissions on this library</h4>");e.push('<div id="manage_perm" class="manage_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can manage permissions on this library (includes giving access).</div>');e.push("<h4>Roles that can add items to this library</h4>");e.push('<div id="add_perm" class="add_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can add items to this library (folders and datasets).</div>');e.push("<h4>Roles that can modify this library</h4>");e.push('<div id="modify_perm" class="modify_perm roles-selection"></div>');e.push('<div class="alert alert-info roles-selection">User with <strong>any</strong> of these roles can modify this library (name, synopsis, etc.).</div>');e.push('<button data-toggle="tooltip" data-placement="top" title="Save modifications made on this page" class="btn btn-default toolbtn_save_permissions primary-button" type="button"><span class="fa fa-floppy-o"></span> Save</span></button>');e.push("</div>");e.push("</div>");return _.template(e.join(""))}});return{LibraryView:b}}); \ No newline at end of file diff -r 901816dc392031f2b69373c795aaa71d437fabc9 -r 188aa379bd9b25322e8532da73fae6dcece47231 static/scripts/packed/mvc/tools/tools-datasets.js --- a/static/scripts/packed/mvc/tools/tools-datasets.js +++ b/static/scripts/packed/mvc/tools/tools-datasets.js @@ -1,1 +1,1 @@ -define(["mvc/history/history-contents"],function(a){return Backbone.Model.extend({initialize:function(c){this.currHistoryContents=new a.HistoryContents({});this.currHistoryContents.historyId="f597429621d6eb2b";var b=this;var d=this.currHistoryContents.fetchAllDetails().done(function(){console.debug("tools-datasets::initialize() - Completed.");c.success&&c.success()}).fail(function(){console.debug("tools-datasets::initialize() - Ajax request failed.")})},filterType:function(b){return this.currHistoryContents.filter(function(c){var d=c.get("history_content_type");var e=c.get("data_type");return d==="dataset"})},filter:function(b){return _.first(this.currHistoryContents.filter(function(c){return c.get("id")===b}))}})}); \ No newline at end of file +define(["mvc/history/history-contents"],function(a){return Backbone.Model.extend({initialize:function(c){this.currHistoryContents=new a.HistoryContents({});this.currHistoryContents.historyId="f597429621d6eb2b";var b=this;var d=this.currHistoryContents.fetchAllDetails().done(function(){console.debug("tools-datasets::initialize() - Completed.");c.success&&c.success()}).fail(function(){console.debug("tools-datasets::initialize() - Ajax request failed.")})},filterType:function(b){return this.currHistoryContents.filter(function(c){var d=c.get("history_content_type");var e=c.get("file_ext");return d==="dataset"})},filter:function(b){return _.first(this.currHistoryContents.filter(function(c){return c.get("id")===b}))}})}); \ 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.
participants (1)
-
commits-noreply@bitbucket.org