diff --git a/src/dgenies/lib/functions.py b/src/dgenies/lib/functions.py index 08c1c23..e3bd5a7 100644 --- a/src/dgenies/lib/functions.py +++ b/src/dgenies/lib/functions.py @@ -161,7 +161,7 @@ def send_fasta_ready(mailer, job_name, sample_name, compressed=False, path="fast @staticmethod - def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mailer=None): + def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mailer=None, mode="webserver"): index, sample_name = Functions.read_index(index_file) is_compressed = fasta_file.endswith(".gz") if is_compressed: @@ -185,7 +185,7 @@ def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mail if compress: Functions.compress(fasta_file_o) os.remove(lock_file) - if mailer is not None and not os.path.exists(lock_file + ".pending"): + if mode == "webserver" and mailer is not None and not os.path.exists(lock_file + ".pending"): Functions.send_fasta_ready(mailer, job_name, sample_name, compress) @staticmethod diff --git a/src/dgenies/static/js/dgenies.result.export.js b/src/dgenies/static/js/dgenies.result.export.js index 9439489..30dc99f 100644 --- a/src/dgenies/static/js/dgenies.result.export.js +++ b/src/dgenies/static/js/dgenies.result.export.js @@ -86,36 +86,41 @@ dgenies.result.export.export_fasta = function(compress=false) { }; dgenies.result.export.ask_export_fasta = function () { - let dialog = $("
"); - body.append(icon); - body.append("Compression is recommanded on slow connections. Download Gzip file?"); - dialog.append(body); - dialog.dialog({ - resizable: false, - height: "auto", - width: 500, - modal: true, - buttons: { - "Use default": function() { - $( this ).dialog( "close" ); - dgenies.result.export.export_fasta(false); - }, - "Use Gzip": function () { - $( this ).dialog( "close" ); - dgenies.result.export.export_fasta(true); - }, - Cancel: function () { - $( this ).dialog( "close" ); + if (dgenies.mode === "webserver") { + let dialog = $("
"); + body.append(icon); + body.append("Compression is recommanded on slow connections. Download Gzip file?"); + dialog.append(body); + dialog.dialog({ + resizable: false, + height: "auto", + width: 500, + modal: true, + buttons: { + "Use default": function () { + $(this).dialog("close"); + dgenies.result.export.export_fasta(false); + }, + "Use Gzip": function () { + $(this).dialog("close"); + dgenies.result.export.export_fasta(true); + }, + Cancel: function () { + $(this).dialog("close"); + } } - } - }); + }); + } + else { + dgenies.result.export.export_fasta(false); + } }; dgenies.result.export.export_association_table = function () { diff --git a/src/dgenies/static/js/dgenies.result.min.js b/src/dgenies/static/js/dgenies.result.min.js index c8e2b81..c1e7d3d 100644 --- a/src/dgenies/static/js/dgenies.result.min.js +++ b/src/dgenies/static/js/dgenies.result.min.js @@ -1,7 +1,7 @@ if(!dgenies){throw"dgenies wasn't included!"}dgenies.result={};// GLOBAL VARIABLES: dgenies.result.id_res=null;dgenies.result.init=function(id_res){dgenies.result.id_res=id_res;dgenies.result.add_to_list();d3.boxplot.init()};dgenies.result.add_to_list=function(){console.log("pass",dgenies.result.id_res);let cookies=$.cookie("results");cookies=cookies!==undefined?cookies.split("|"):[];console.log(cookies);if(cookies.indexOf(dgenies.result.id_res)===-1){console.log("oui");cookies.splice(0,0,dgenies.result.id_res);dgenies.save_cookies(cookies);dgenies.update_results(cookies)}};dgenies.result.remove_job_from_cookie=function(job){let cookies=$.cookie("results");cookies=cookies!==undefined?cookies.split("|"):[];let index=cookies.indexOf(job);let need_update=false;if(index>-1){need_update=true;cookies.splice(index,1)}$.cookie("results",cookies.join("|"),{path:"/"});if(need_update){dgenies.update_results(cookies)}}; if(!dgenies||!dgenies.result){throw"dgenies.result wasn't included!"}dgenies.result.controls={};dgenies.result.controls.init=function(){$("#sort-contigs").click(dgenies.result.controls.launch_sort_contigs);$("#hide-noise").click(dgenies.result.controls.launch_hide_noise);$("#summary").click(dgenies.result.controls.summary);$("#delete-job").click(dgenies.result.controls.delete_job);$("form#select-zone input.submit").click(dgenies.result.controls.select_zone);$("form#export select").change(dgenies.result.export.export)};dgenies.result.controls.summary=function(){dgenies.show_loading("Building...");window.setTimeout(()=>{dgenies.post(`/summary/${dgenies.result.id_res}`,{},function(data){dgenies.hide_loading();if(data["success"]){if(data["status"]==="done"){dgenies.result.summary.show(data["percents"])}else if(data["status"]==="waiting"){dgenies.result.controls.summary()}}else{dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)};dgenies.result.controls.launch_sort_contigs=function(){d3.boxplot.zoom.reset_scale();window.setTimeout(()=>{dgenies.show_loading("Building...");window.setTimeout(()=>{dgenies.post(`/sort/${dgenies.result.id_res}`,{},function(data){if(data["success"]){dgenies.reset_loading_message();window.setTimeout(()=>{d3.boxplot.launch(data,true)},0)}else{dgenies.hide_loading();dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)},0)};dgenies.result.controls.launch_reverse_contig=function(){if(d3.boxplot.query_selected!==null){d3.boxplot.zoom.reset_scale();window.setTimeout(()=>{dgenies.show_loading("Building...");window.setTimeout(()=>{dgenies.post(`/reverse-contig/${dgenies.result.id_res}`,{"contig":d3.boxplot.query_selected},function(data){if(data["success"]){dgenies.reset_loading_message();window.setTimeout(()=>{d3.boxplot.launch(data,true)},0)}else{dgenies.hide_loading();dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)},0)}else{dgenies.notify("Error: no query selected. Please contact us to report the bug","danger")}};dgenies.result.controls.launch_hide_noise=function(){d3.boxplot.zoom.reset_scale();window.setTimeout(()=>{dgenies.show_loading("Building...");window.setTimeout(()=>{dgenies.post(`/freenoise/${dgenies.result.id_res}`,{noise:dgenies.noise?0:1},function(data){if(data["success"]){dgenies.noise=!dgenies.noise;dgenies.reset_loading_message();window.setTimeout(()=>{d3.boxplot.launch(data,true,true)},0)}else{dgenies.hide_loading();dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)},0)};dgenies.result.controls.select_zone=function(){let contig_select=$("#select-contig").find(":selected");let target_select=$("#select-target").find(":selected");if(contig_select.val()!=="###NONE###"&&target_select.val()!=="###NONE###"){d3.boxplot.select_zone(null,null,target_select.val(),contig_select.val(),true)}else{dgenies.notify("Please select zones into zoom!","danger",2000)}};dgenies.result.controls.do_delete_job=function(){dgenies.post(`/delete/${dgenies.result.id_res}`,{},function(data){if(data["success"]){dgenies.notify("Your job has been deleted!","success",1500);window.setTimeout(()=>{dgenies.result.remove_job_from_cookie(dgenies.result.id_res);window.location="/"},1500)}else{dgenies.notify("error"in data?data["error"]:"An error has occurred. Please contact the support","danger")}})};dgenies.result.controls.delete_job=function(){let dialog=$("
");body.append(icon);body.append("Confirm deletion of this job? This operation is definitive.");dialog.append(body);dialog.dialog({resizable:false,height:"auto",width:500,modal:true,buttons:{"Yes":function(){$(this).dialog("close");dgenies.result.controls.do_delete_job()},"No":function(){$(this).dialog("close")}}})}; -if(!dgenies||!dgenies.result){throw"dgenies.result wasn't included!"}dgenies.result.export={};dgenies.result.export.get_svg=function(){return""};dgenies.result.export.save_file=function(blob,format){dgenies.hide_loading();saveAs(blob,`map_${d3.boxplot.name_y}_to_${d3.boxplot.name_x}.${format}`)};dgenies.result.export.export_png=function(){dgenies.show_loading("Building picture...",210);window.setTimeout(()=>{let export_div=$("div#export-pict");export_div.html("").append($("