From 5ad08852a97f07d754a34e44bf8f6ac849b79c8e Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Tue, 7 Jan 2014 15:39:17 -0500 Subject: [PATCH] data libraries fix for modal handling and folder creation --- static/scripts/galaxy.library.js | 25 +++++++++++++------------ static/scripts/galaxy.modal.js | 4 ++-- static/scripts/packed/galaxy.library.js | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/static/scripts/galaxy.library.js b/static/scripts/galaxy.library.js index 17817ddbb3c..d133fb8cef3 100644 --- a/static/scripts/galaxy.library.js +++ b/static/scripts/galaxy.library.js @@ -408,7 +408,6 @@ var FolderContentView = Backbone.View.extend({ renderModalAfterFetch : function(item, histories){ var size = this.size_to_string(item.get('file_size')); var template = _.template(this.templateDatasetModal(), { item : item, size : size }); - this.modal = null; // make modal var self = this; this.modal = new mod_modal.GalaxyModal({ @@ -418,7 +417,7 @@ var FolderContentView = Backbone.View.extend({ buttons : { 'Import' : function() { self.importCurrentIntoHistory() }, 'Download' : function() { self.downloadCurrent() }, - 'Close' : function() { self.modal.hideOrDestroy; self.modal = null; } + 'Close' : function() { self.modal.hideOrDestroy() } } }); @@ -574,7 +573,7 @@ var FolderContentView = Backbone.View.extend({ body : history_modal_tmpl, buttons : { 'Import' : function() {self.importAllIntoHistory()}, - 'Close' : function() {self.modal.hideOrDestroy; self.modal = null;} + 'Close' : function() {self.modal.hideOrDestroy();} } }); self.modal.bindEvents(); @@ -626,9 +625,7 @@ var FolderContentView = Backbone.View.extend({ var popped_item = history_item_set.pop(); if (typeof popped_item === "undefined") { mod_toastr.success('All datasets imported'); - - //this will destroy other modals too - including those hidden!!! - this.modal.destroy(); + this.modal.hideOrDestroy(); return } var promise = $.when(popped_item.save({content: popped_item.content, source: popped_item.source})).done(function(a1){ @@ -712,7 +709,7 @@ var FolderContentView = Backbone.View.extend({ body : this.template_new_folder(), buttons : { 'Create' : function() {self.create_new_folder_event()}, - 'Close' : function() {self.modal.destroy(); self.modal = null;} + 'Close' : function() {self.modal.hideOrDestroy(); self.modal = null;} } }); this.modal.bindEvents(); @@ -725,13 +722,17 @@ var FolderContentView = Backbone.View.extend({ var folderDetails = this.serialize_new_folder(); if (this.validate_new_folder(folderDetails)){ var folder = new FolderAsModel(); - folder.url = folder.urlRoot + '/F2fdbd5c5858e78fb' //load real ID + + url_items = Backbone.history.fragment.split('/'); + current_folder_id = url_items[url_items.length-1]; + folder.url = folder.urlRoot + '/' + current_folder_id ; + var self = this; folder.save(folderDetails, { success: function (folder) { - self.modal.destroy(); + self.modal.hideOrDestroy(); mod_toastr.success('Folder created'); - self.render({id: 'F2fdbd5c5858e78fb'}); //put real id + self.render({id: current_folder_id}); }, error: function(){ mod_toastr.error('An error occured :('); @@ -865,7 +866,7 @@ var GalaxyLibraryview = Backbone.View.extend({ body : this.template_new_library(), buttons : { 'Create' : function() {self.create_new_library_event()}, - 'Close' : function() {self.modal.hideOrDestroy(); self.modal = null;} + 'Close' : function() {self.modal.hideOrDestroy();} } }); this.modal.bindEvents(); @@ -881,7 +882,7 @@ var GalaxyLibraryview = Backbone.View.extend({ var self = this; library.save(libraryDetails, { success: function (library) { - self.modal.destroy(); + self.modal.hideOrDestroy(); self.clear_library_modal(); self.render(); mod_toastr.success('Library created'); diff --git a/static/scripts/galaxy.modal.js b/static/scripts/galaxy.modal.js index 81a7a26ab4b..f35a0a859d2 100644 --- a/static/scripts/galaxy.modal.js +++ b/static/scripts/galaxy.modal.js @@ -95,7 +95,7 @@ var GalaxyModal = Backbone.View.extend( this.visible = true; }, - // hide modal + // hide modal, shouldn't be called directly but through hideOrDestroy() hide: function(){ // fade out this.$el.fadeOut('fast'); @@ -105,7 +105,7 @@ var GalaxyModal = Backbone.View.extend( this.unbindEvents(); }, - // destroy modal + // destroy modal, shouldn't be called directly but through hideOrDestroy() destroy: function(){ // set flag this.visible = false; diff --git a/static/scripts/packed/galaxy.library.js b/static/scripts/packed/galaxy.library.js index e42ee45b0a1..83f857ee9b8 100644 --- a/static/scripts/packed/galaxy.library.js +++ b/static/scripts/packed/galaxy.library.js @@ -1 +1 @@ -var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","libs/toastr"],function(k,l,h,n){var f=Backbone.Model.extend({urlRoot:"/api/libraries"});var c=Backbone.Model.extend({urlRoot:"/api/folders"});var o=Backbone.Collection.extend({url:"/api/libraries",model:f});var i=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var d=Backbone.Collection.extend({model:i});var e=Backbone.Model.extend({defaults:{folder:new d(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(r){this.full_path=r[0].full_path;this.get("folder").reset(r[1].folder_contents);return r}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var j=Backbone.Model.extend({url:"/api/histories/"});var p=Backbone.Collection.extend({url:"/api/histories",model:j});var q=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var m=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var r=[];r.push('
');r.push('

New Data Libraries. This is work in progress. Report problems & ideas to Marten.

');r.push('
');r.push(' ');r.push(' ');r.push(' ");r.push("
");r.push('
');r.push('Libraries | ');r.push("<% _.each(path, function(path_item) { %>");r.push("<% if (path_item[0] != id) { %>");r.push('<%- path_item[1] %> | ');r.push("<% } else { %>");r.push('<%- path_item[1] %>');r.push("<% } %>");r.push("<% }); %>");r.push("
");r.push('');r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" <% _.each(items, function(content_item) { %>");r.push(' ');r.push(' <% if (content_item.get("type") === "folder") { %>');r.push(" ");r.push(' ');r.push(' ");r.push(" ");r.push(' ');r.push(" <% } else { %>");r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(' ');r.push(" <% } %> ");r.push(' ');r.push(" ");r.push(" <% }); %>");r.push(" ");r.push(" ");r.push("
viewnamedata typesizedate
<%- content_item.get("name") %>');r.push(' <% if (content_item.get("item_count") === 0) { %>');r.push(' (empty folder)');r.push(" <% } %>");r.push(" folder<%= _.escape(content_item.get("item_count")) %> item(s)");r.push(' ");r.push(" <%- content_item.get("name") %><%= _.escape(content_item.get("data_type")) %><%= _.escape(content_item.get("readable_size")) %><%= _.escape(content_item.get("time_updated")) %>
");r.push("
");return r.join("")},templateDatasetModal:function(){var r=[];r.push('
');r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(' <% if (item.get("metadata_comment_lines") === "") { %>');r.push(' ');r.push(" <% } else { %>");r.push(' ');r.push(" <% } %>");r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push("
">Name<%= _.escape(item.get("name")) %>
Data type<%= _.escape(item.get("data_type")) %>
Genome build<%= _.escape(item.get("genome_build")) %>
Size<%= _.escape(size) %>
Date uploaded<%= _.escape(item.get("date_uploaded")) %>
Uploaded by<%= _.escape(item.get("uploaded_by")) %>
Data Lines<%= _.escape(item.get("metadata_data_lines")) %>
Comment Lines<%= _.escape(item.get("metadata_comment_lines")) %>unknown
Number of Columns<%= _.escape(item.get("metadata_columns")) %>
Column Types<%= _.escape(item.get("metadata_column_types")) %>
Miscellaneous information<%= _.escape(item.get("misc_blurb")) %>
");r.push('
');r.push("   
");r.push("
");return r.join("")},templateHistorySelectInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push('");r.push("");return r.join("")},templateBulkImportInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push('");r.push("");return r.join("")},size_to_string:function(r){var s="";if(r>=100000000000){r=r/100000000000;s="TB"}else{if(r>=100000000){r=r/100000000;s="GB"}else{if(r>=100000){r=r/100000;s="MB"}else{if(r>=100){r=r/100;s="KB"}else{r=r*10;s="b"}}}}return(Math.round(r)/10)+s},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderFromModal","click .btn_open_folder":"navigateToFolder"},render:function(r){$("#center").css("overflow","auto");view=this;var t=this;var s=new e({id:r.id});s.url=s.attributes.urlRoot+r.id+"/contents";s.fetch({success:function(u){for(var w=0;w0){$(this.modal.elMain).find("#dataset_import_single").val(s.lastSelectedHistory)}this.modal.bindEvents();this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var r=[];r.push($("#id_row").attr("data-id"));var s="/api/libraries/datasets/download/uncompressed";var t={ldda_ids:r};folderContentView.processDownload(s,t);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var t=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=t;var r=$("#id_row").attr("data-id");var u=new b();var s=this;u.url=u.urlRoot+t+"/contents";u.save({content:r,source:"library"},{success:function(){n.success("Dataset imported");s.modal.enableButton("Import");s.modal.enableButton("Download")},error:function(){n.error("An error occured! Dataset not imported. Please try again.");s.modal.enableButton("Import");s.modal.enableButton("Download")}})},selectAll:function(s){var r=s.target.checked;that=this;$(":checkbox").each(function(){this.checked=r;$row=$(this.parentElement.parentElement);(r)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(s){var u="";var r;var t;if(s.target.localName==="input"){u=s.target;r=$(s.target.parentElement.parentElement);t="input"}else{if(s.target.localName==="td"){u=$("#"+s.target.parentElement.id).find(":checkbox")[0];r=$(s.target.parentElement);t="td"}}if(u===""){s.stopPropagation();return}if(u===undefined){s.stopPropagation();return}if(u.checked){if(t==="td"){u.checked="";this.makeWhiteRow(r)}else{if(t==="input"){this.makeDarkRow(r)}}}else{if(t==="td"){u.checked="selected";this.makeDarkRow(r)}else{if(t==="input"){this.makeWhiteRow(r)}}}this.checkTools()},makeDarkRow:function(r){r.removeClass("light");r.find("a").removeClass("light");r.addClass("dark");r.find("a").addClass("dark")},makeWhiteRow:function(r){r.removeClass("dark");r.find("a").removeClass("dark");r.addClass("light");r.find("a").addClass("light")},checkTools:function(){var r=$("#folder_table").find(":checked");if(r.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var s=this;var r=new p();r.fetch({success:function(t){var u=_.template(s.templateBulkImportInModal(),{histories:t.models});s.modal=new k.GalaxyModal({destructible:true,title:"Import into History",body:u,buttons:{Import:function(){s.importAllIntoHistory()},Close:function(){s.modal.hideOrDestroy;s.modal=null}}});s.modal.bindEvents();s.modal.show()}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var t=$("select[name=dataset_import_bulk] option:selected").val();var x=$("select[name=dataset_import_bulk] option:selected").text();var z=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){z.push(this.parentElement.parentElement.id)}});var y=_.template(this.templateProgressBar(),{history_name:x});$(this.modal.elMain).find(".modal-body").html(y);var u=100/z.length;this.initProgress(u);var r=[];for(var s=z.length-1;s>=0;s--){library_dataset_id=z[s];var v=new b();var w=this;v.url=v.urlRoot+t+"/contents";v.content=library_dataset_id;v.source="library";r.push(v)}this.chainCall(r)},chainCall:function(s){var r=this;var t=s.pop();if(typeof t==="undefined"){n.success("All datasets imported");this.modal.destroy();return}var u=$.when(t.save({content:t.content,source:t.source})).done(function(v){r.updateProgress();responses.push(v);r.chainCall(s)})},initProgress:function(r){this.progress=0;this.progressStep=r},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},templateProgressBar:function(){var r=[];r.push('
');r.push("Importing selected datasets to history <%= _.escape(history_name) %>");r.push("
");r.push('
');r.push('
');r.push(' 0% Complete');r.push("
");r.push("
");r.push("");return r.join("")},download:function(r,v){var t=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){t.push(this.parentElement.parentElement.id)}});var s="/api/libraries/datasets/download/"+v;var u={ldda_ids:t};this.processDownload(s,u,"get")},processDownload:function(s,t,u){if(s&&t){t=typeof t=="string"?t:$.param(t);var r="";$.each(t.split("&"),function(){var v=this.split("=");r+=''});$('
'+r+"
").appendTo("body").submit().remove();n.info("Your download will begin soon")}},createFolderFromModal:function(){event.preventDefault();event.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Folder",body:this.template_new_folder(),buttons:{Create:function(){r.create_new_folder_event()},Close:function(){r.modal.destroy();r.modal=null}}});this.modal.bindEvents();this.modal.show()},create_new_folder_event:function(){var r=this.serialize_new_folder();if(this.validate_new_folder(r)){var t=new c();t.url=t.urlRoot+"/F2fdbd5c5858e78fb";var s=this;t.save(r,{success:function(u){s.modal.destroy();n.success("Folder created");s.render({id:"F2fdbd5c5858e78fb"})},error:function(){n.error("An error occured :(")}})}else{n.error("Folder's name is missing")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(r){return r.name!==""},template_new_folder:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},template_library_list:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("");tmpl_array.push('

New Data Libraries. This is work in progress. Report problems & ideas to Marten.

');tmpl_array.push('New Library');tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(" <% }); %>");tmpl_array.push(" ");tmpl_array.push("
namedescriptionsynopsismodel type
<%- library.get("name") %><%= _.escape(library.get("description")) %><%= _.escape(library.get("synopsis")) %><%= _.escape(library.get("model_class")) %>
");tmpl_array.push("
");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var r=this;libraries=new o();libraries.fetch({success:function(s){var t=_.template(r.template_library_list(),{libraries:s.models});r.$el.html(t)},error:function(t,s){if(s.statusCode().status===403){n.error("Please log in first. Redirecting to login page in 3s.");setTimeout(r.redirectToLogin,3000)}else{n.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(s){s.preventDefault();s.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Library",body:this.template_new_library(),buttons:{Create:function(){r.create_new_library_event()},Close:function(){r.modal.hideOrDestroy();r.modal=null}}});this.modal.bindEvents();this.modal.show()},create_new_library_event:function(){var t=this.serialize_new_library();if(this.validate_new_library(t)){var s=new f();var r=this;s.save(t,{success:function(u){r.modal.destroy();r.clear_library_modal();r.render();n.success("Library created")},error:function(){n.error("An error occured :(")}})}else{n.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(r){return r.name!==""},template_new_library:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")}});var g=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new m();galaxyLibraryview=new a();library_router=new q();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(r){folderContentView.render({id:r})});library_router.on("route:download",function(r,s){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+r,{trigger:true,replace:true})}else{folderContentView.download(r,s);library_router.navigate("folders/"+r,{trigger:false,replace:true})}});Backbone.history.start();return this}});return{GalaxyApp:g}}); \ No newline at end of file +var view=null;var library_router=null;var responses=[];define(["galaxy.modal","galaxy.masthead","utils/galaxy.utils","libs/toastr"],function(k,l,h,n){var f=Backbone.Model.extend({urlRoot:"/api/libraries"});var c=Backbone.Model.extend({urlRoot:"/api/folders"});var o=Backbone.Collection.extend({url:"/api/libraries",model:f});var i=Backbone.Model.extend({urlRoot:"/api/libraries/datasets"});var d=Backbone.Collection.extend({model:i});var e=Backbone.Model.extend({defaults:{folder:new d(),full_path:"unknown",urlRoot:"/api/folders/",id:"unknown"},parse:function(r){this.full_path=r[0].full_path;this.get("folder").reset(r[1].folder_contents);return r}});var b=Backbone.Model.extend({urlRoot:"/api/histories/"});var j=Backbone.Model.extend({url:"/api/histories/"});var p=Backbone.Collection.extend({url:"/api/histories",model:j});var q=Backbone.Router.extend({routes:{"":"libraries","folders/:id":"folder_content","folders/:folder_id/download/:format":"download"}});var m=Backbone.View.extend({el:"#center",progress:0,progressStep:1,lastSelectedHistory:"",modal:null,folders:null,initialize:function(){this.folders=[];this.queue=jQuery.Deferred();this.queue.resolve()},templateFolder:function(){var r=[];r.push('
');r.push('

New Data Libraries. This is work in progress. Report problems & ideas to Marten.

');r.push('
');r.push(' ');r.push(' ');r.push(' ");r.push("
");r.push('
');r.push('Libraries | ');r.push("<% _.each(path, function(path_item) { %>");r.push("<% if (path_item[0] != id) { %>");r.push('<%- path_item[1] %> | ');r.push("<% } else { %>");r.push('<%- path_item[1] %>');r.push("<% } %>");r.push("<% }); %>");r.push("
");r.push('');r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" ");r.push(" <% _.each(items, function(content_item) { %>");r.push(' ');r.push(' <% if (content_item.get("type") === "folder") { %>');r.push(" ");r.push(' ');r.push(' ");r.push(" ");r.push(' ');r.push(" <% } else { %>");r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(' ');r.push(" <% } %> ");r.push(' ');r.push(" ");r.push(" <% }); %>");r.push(" ");r.push(" ");r.push("
viewnamedata typesizedate
<%- content_item.get("name") %>');r.push(' <% if (content_item.get("item_count") === 0) { %>');r.push(' (empty folder)');r.push(" <% } %>");r.push(" folder<%= _.escape(content_item.get("item_count")) %> item(s)");r.push(' ");r.push(" <%- content_item.get("name") %><%= _.escape(content_item.get("data_type")) %><%= _.escape(content_item.get("readable_size")) %><%= _.escape(content_item.get("time_updated")) %>
");r.push("
");return r.join("")},templateDatasetModal:function(){var r=[];r.push('
');r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(" ");r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(' ');r.push(' ');r.push(" ");r.push(' ');r.push(' <% if (item.get("metadata_comment_lines") === "") { %>');r.push(' ');r.push(" <% } else { %>");r.push(' ');r.push(" <% } %>");r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push(" ");r.push(' ');r.push(' ');r.push(" ");r.push("
">Name<%= _.escape(item.get("name")) %>
Data type<%= _.escape(item.get("data_type")) %>
Genome build<%= _.escape(item.get("genome_build")) %>
Size<%= _.escape(size) %>
Date uploaded<%= _.escape(item.get("date_uploaded")) %>
Uploaded by<%= _.escape(item.get("uploaded_by")) %>
Data Lines<%= _.escape(item.get("metadata_data_lines")) %>
Comment Lines<%= _.escape(item.get("metadata_comment_lines")) %>unknown
Number of Columns<%= _.escape(item.get("metadata_columns")) %>
Column Types<%= _.escape(item.get("metadata_column_types")) %>
Miscellaneous information<%= _.escape(item.get("misc_blurb")) %>
");r.push('
');r.push("   
");r.push("
");return r.join("")},templateHistorySelectInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push('");r.push("");return r.join("")},templateBulkImportInModal:function(){var r=[];r.push('');r.push("Select history: ");r.push('");r.push("");return r.join("")},size_to_string:function(r){var s="";if(r>=100000000000){r=r/100000000000;s="TB"}else{if(r>=100000000){r=r/100000000;s="GB"}else{if(r>=100000){r=r/100000;s="MB"}else{if(r>=100){r=r/100;s="KB"}else{r=r*10;s="b"}}}}return(Math.round(r)/10)+s},events:{"click #select-all-checkboxes":"selectAll","click .folder_row":"selectClickedRow","click #toolbtn_bulk_import":"modalBulkImport","click #toolbtn_dl":"bulkDownload","click .library-dataset":"showDatasetDetails","click #toolbtn_create_folder":"createFolderFromModal","click .btn_open_folder":"navigateToFolder"},render:function(r){$("#center").css("overflow","auto");view=this;var t=this;var s=new e({id:r.id});s.url=s.attributes.urlRoot+r.id+"/contents";s.fetch({success:function(u){for(var w=0;w0){$(this.modal.elMain).find("#dataset_import_single").val(s.lastSelectedHistory)}this.modal.bindEvents();this.modal.show()},downloadCurrent:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var r=[];r.push($("#id_row").attr("data-id"));var s="/api/libraries/datasets/download/uncompressed";var t={ldda_ids:r};folderContentView.processDownload(s,t);this.modal.enableButton("Import");this.modal.enableButton("Download")},importCurrentIntoHistory:function(){this.modal.disableButton("Import");this.modal.disableButton("Download");var t=$(this.modal.elMain).find("select[name=dataset_import_single] option:selected").val();this.lastSelectedHistory=t;var r=$("#id_row").attr("data-id");var u=new b();var s=this;u.url=u.urlRoot+t+"/contents";u.save({content:r,source:"library"},{success:function(){n.success("Dataset imported");s.modal.enableButton("Import");s.modal.enableButton("Download")},error:function(){n.error("An error occured! Dataset not imported. Please try again.");s.modal.enableButton("Import");s.modal.enableButton("Download")}})},selectAll:function(s){var r=s.target.checked;that=this;$(":checkbox").each(function(){this.checked=r;$row=$(this.parentElement.parentElement);(r)?that.makeDarkRow($row):that.makeWhiteRow($row)});this.checkTools()},selectClickedRow:function(s){var u="";var r;var t;if(s.target.localName==="input"){u=s.target;r=$(s.target.parentElement.parentElement);t="input"}else{if(s.target.localName==="td"){u=$("#"+s.target.parentElement.id).find(":checkbox")[0];r=$(s.target.parentElement);t="td"}}if(u===""){s.stopPropagation();return}if(u===undefined){s.stopPropagation();return}if(u.checked){if(t==="td"){u.checked="";this.makeWhiteRow(r)}else{if(t==="input"){this.makeDarkRow(r)}}}else{if(t==="td"){u.checked="selected";this.makeDarkRow(r)}else{if(t==="input"){this.makeWhiteRow(r)}}}this.checkTools()},makeDarkRow:function(r){r.removeClass("light");r.find("a").removeClass("light");r.addClass("dark");r.find("a").addClass("dark")},makeWhiteRow:function(r){r.removeClass("dark");r.find("a").removeClass("dark");r.addClass("light");r.find("a").addClass("light")},checkTools:function(){var r=$("#folder_table").find(":checked");if(r.length>0){$("#toolbtn_bulk_import").show();$("#toolbtn_dl").show()}else{$("#toolbtn_bulk_import").hide();$("#toolbtn_dl").hide()}},modalBulkImport:function(){var s=this;var r=new p();r.fetch({success:function(t){var u=_.template(s.templateBulkImportInModal(),{histories:t.models});s.modal=new k.GalaxyModal({destructible:true,title:"Import into History",body:u,buttons:{Import:function(){s.importAllIntoHistory()},Close:function(){s.modal.hideOrDestroy()}}});s.modal.bindEvents();s.modal.show()}})},importAllIntoHistory:function(){this.modal.disableButton("Import");var t=$("select[name=dataset_import_bulk] option:selected").val();var x=$("select[name=dataset_import_bulk] option:selected").text();var z=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){z.push(this.parentElement.parentElement.id)}});var y=_.template(this.templateProgressBar(),{history_name:x});$(this.modal.elMain).find(".modal-body").html(y);var u=100/z.length;this.initProgress(u);var r=[];for(var s=z.length-1;s>=0;s--){library_dataset_id=z[s];var v=new b();var w=this;v.url=v.urlRoot+t+"/contents";v.content=library_dataset_id;v.source="library";r.push(v)}this.chainCall(r)},chainCall:function(s){var r=this;var t=s.pop();if(typeof t==="undefined"){n.success("All datasets imported");this.modal.hideOrDestroy();return}var u=$.when(t.save({content:t.content,source:t.source})).done(function(v){r.updateProgress();responses.push(v);r.chainCall(s)})},initProgress:function(r){this.progress=0;this.progressStep=r},updateProgress:function(){this.progress+=this.progressStep;$(".progress-bar-import").width(Math.round(this.progress)+"%");txt_representation=Math.round(this.progress)+"% Complete";$(".completion_span").text(txt_representation)},templateProgressBar:function(){var r=[];r.push('
');r.push("Importing selected datasets to history <%= _.escape(history_name) %>");r.push("
");r.push('
');r.push('
');r.push(' 0% Complete');r.push("
");r.push("
");r.push("");return r.join("")},download:function(r,v){var t=[];$("#folder_table").find(":checked").each(function(){if(this.parentElement.parentElement.id!=""){t.push(this.parentElement.parentElement.id)}});var s="/api/libraries/datasets/download/"+v;var u={ldda_ids:t};this.processDownload(s,u,"get")},processDownload:function(s,t,u){if(s&&t){t=typeof t=="string"?t:$.param(t);var r="";$.each(t.split("&"),function(){var v=this.split("=");r+=''});$('
'+r+"
").appendTo("body").submit().remove();n.info("Your download will begin soon")}},createFolderFromModal:function(){event.preventDefault();event.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Folder",body:this.template_new_folder(),buttons:{Create:function(){r.create_new_folder_event()},Close:function(){r.modal.hideOrDestroy();r.modal=null}}});this.modal.bindEvents();this.modal.show()},create_new_folder_event:function(){var r=this.serialize_new_folder();if(this.validate_new_folder(r)){var t=new c();url_items=Backbone.history.fragment.split("/");current_folder_id=url_items[url_items.length-1];t.url=t.urlRoot+"/"+current_folder_id;var s=this;t.save(r,{success:function(u){s.modal.hideOrDestroy();n.success("Folder created");s.render({id:current_folder_id})},error:function(){n.error("An error occured :(")}})}else{n.error("Folder's name is missing")}return false},serialize_new_folder:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val()}},validate_new_folder:function(r){return r.name!==""},template_new_folder:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")}});var a=Backbone.View.extend({el:"#center",events:{"click #create_new_library_btn":"show_library_modal"},initialize:function(){},template_library_list:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("");tmpl_array.push('

New Data Libraries. This is work in progress. Report problems & ideas to Marten.

');tmpl_array.push('New Library');tmpl_array.push('');tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" ");tmpl_array.push(" <% _.each(libraries, function(library) { %>");tmpl_array.push(" ");tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(' ');tmpl_array.push(" ");tmpl_array.push(" <% }); %>");tmpl_array.push(" ");tmpl_array.push("
namedescriptionsynopsismodel type
<%- library.get("name") %><%= _.escape(library.get("description")) %><%= _.escape(library.get("synopsis")) %><%= _.escape(library.get("model_class")) %>
");tmpl_array.push("
");return tmpl_array.join("")},render:function(){$("#center").css("overflow","auto");var r=this;libraries=new o();libraries.fetch({success:function(s){var t=_.template(r.template_library_list(),{libraries:s.models});r.$el.html(t)},error:function(t,s){if(s.statusCode().status===403){n.error("Please log in first. Redirecting to login page in 3s.");setTimeout(r.redirectToLogin,3000)}else{n.error("An error occured. Please try again.")}}})},redirectToHome:function(){window.location="../"},redirectToLogin:function(){window.location="/user/login"},modal:null,show_library_modal:function(s){s.preventDefault();s.stopPropagation();var r=this;this.modal=new k.GalaxyModal({destructible:true,title:"Create New Library",body:this.template_new_library(),buttons:{Create:function(){r.create_new_library_event()},Close:function(){r.modal.hideOrDestroy()}}});this.modal.bindEvents();this.modal.show()},create_new_library_event:function(){var t=this.serialize_new_library();if(this.validate_new_library(t)){var s=new f();var r=this;s.save(t,{success:function(u){r.modal.hideOrDestroy();r.clear_library_modal();r.render();n.success("Library created")},error:function(){n.error("An error occured :(")}})}else{n.error("Library's name is missing")}return false},clear_library_modal:function(){$("input[name='Name']").val("");$("input[name='Description']").val("");$("input[name='Synopsis']").val("")},serialize_new_library:function(){return{name:$("input[name='Name']").val(),description:$("input[name='Description']").val(),synopsis:$("input[name='Synopsis']").val()}},validate_new_library:function(r){return r.name!==""},template_new_library:function(){tmpl_array=[];tmpl_array.push('
');tmpl_array.push("
");tmpl_array.push('');tmpl_array.push('');tmpl_array.push('');tmpl_array.push("
");tmpl_array.push("
");return tmpl_array.join("")}});var g=Backbone.View.extend({folderContentView:null,galaxyLibraryview:null,initialize:function(){folderContentView=new m();galaxyLibraryview=new a();library_router=new q();library_router.on("route:libraries",function(){galaxyLibraryview.render()});library_router.on("route:folder_content",function(r){folderContentView.render({id:r})});library_router.on("route:download",function(r,s){if($("#center").find(":checked").length===0){library_router.navigate("folders/"+r,{trigger:true,replace:true})}else{folderContentView.download(r,s);library_router.navigate("folders/"+r,{trigger:false,replace:true})}});Backbone.history.start();return this}});return{GalaxyApp:g}}); \ No newline at end of file