Commit 4272a29e authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix export file names

parent 0642caca
......@@ -137,7 +137,7 @@ dgenies.result.export.save_file(blob,"svg")},0)};/**
* Download association table between queries and targets
*/dgenies.result.export.export_association_table=function(){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/qt-assoc/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_assoc.tsv").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()};/**
* Download backup file of the project
*/dgenies.result.export.export_backup_file=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/backup/${dgenies.result.id_res}`).attr("download",dgenies.result.id_res+".tar").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()})};/**
*/dgenies.result.export.export_backup_file=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/backup/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_"+dgenies.result.id_res+".tar").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()})};/**
* Export list of contigs with no association with any target or any query
* @param {string} to: query or target
*/dgenies.result.export.export_no_association_file=function(to){window.setTimeout(()=>{dgenies.show_loading("Building file...",180);let on=to==="query"?"target":"query";dgenies.post("/no-assoc/"+dgenies.result.id_res,{"to":to},function(data,success){dgenies.hide_loading();if(!data["empty"]){let blob=new Blob([data["file_content"]],{type:"text/plain"});saveAs(blob,`no_${to}_matches_${d3.boxplot.name_y}_to_${d3.boxplot.name_x}.txt`)}else{dgenies.notify(`No contigs in ${to} have None match with any ${on}!`,"success")}})},0)};/**
......@@ -146,7 +146,7 @@ dgenies.result.export.save_file(blob,"svg")},0)};/**
* Export query like reference fasta file (standalone mode)
*/dgenies.result.export.export_query_as_reference_fasta_standalone=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/build-query-as-reference/${dgenies.result.id_res}`,{},function(data,success){if(data["success"]){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/get-query-as-reference/${dgenies.result.id_res}`).attr("download",`as_reference_${d3.boxplot.name_y}.fasta`).attr("id","my-download").text("download"));document.getElementById("my-download").click();dgenies.hide_loading()}else{dgenies.notify(`An error has occurred. Please contact the support`,"danger")}})},0)};/**
* Download offline viewer
*/dgenies.result.export.export_offline_viewer=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/summary/${dgenies.result.id_res}`,{},function(data){dgenies.hide_loading();if(data["success"]){if(data["status"]==="done"){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/viewer/${dgenies.result.id_res}`).attr("download",dgenies.result.id_res+".html").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()}else if(data["status"]==="waiting"){dgenies.result.export.export_offline_viewer()}}else{dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)};/**
*/dgenies.result.export.export_offline_viewer=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/summary/${dgenies.result.id_res}`,{},function(data){dgenies.hide_loading();if(data["success"]){if(data["status"]==="done"){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/viewer/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_"+dgenies.result.id_res+".html").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()}else if(data["status"]==="waiting"){dgenies.result.export.export_offline_viewer()}}else{dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)};/**
* Manage exports
*/dgenies.result.export.export=function(){let select=$("form#export select");let selection=parseInt(select.val());window.setTimeout(()=>{if(selection>0){let async=false;if(selection===1){dgenies.result.export.export_svg();async=true}else if(selection===2){dgenies.result.export.export_png();async=true}else if(selection===3)dgenies.result.export.export_paf();else if(selection===4){dgenies.result.export.ask_export_fasta();async=true}else if(selection===5){dgenies.result.export.export_association_table()}else if(selection===6){dgenies.result.export.export_no_association_file("query");async=true}else if(selection===7){dgenies.result.export.export_no_association_file("target");async=true}else if(selection===8){if(dgenies.mode==="webserver"){dgenies.result.export.export_query_as_reference_fasta_webserver()}else{dgenies.result.export.export_query_as_reference_fasta_standalone();async=true}}else if(selection===9){dgenies.result.export.export_backup_file();async=true}else if(selection===10){dgenies.result.export.export_offline_viewer();async=true}else dgenies.notify("Not supported yet!","danger",2000);if(!async)dgenies.hide_loading();select.val("0")}},0)};if(!dgenies||!dgenies.result){throw"dgenies.result wasn't included!"}dgenies.result.summary={};dgenies.result.summary.percents={};/**
* Show summary window
......
......@@ -174,7 +174,7 @@ dgenies.result.export.export_backup_file = function() {
let export_div = $("div#export-pict");
export_div.html("");
export_div.append($("<a>").attr("href", `/backup/${dgenies.result.id_res}`)
.attr("download", dgenies.result.id_res + ".tar").attr("id", "my-download")
.attr("download", d3.boxplot.name_y + "_" + d3.boxplot.name_x + "_" + dgenies.result.id_res + ".tar").attr("id", "my-download")
.text("download"));
dgenies.hide_loading();
document.getElementById('my-download').click();
......@@ -260,7 +260,8 @@ dgenies.result.export.export_offline_viewer = function() {
let export_div = $("div#export-pict");
export_div.html("");
export_div.append($("<a>").attr("href", `/viewer/${dgenies.result.id_res}`)
.attr("download", dgenies.result.id_res + ".html").attr("id", "my-download")
.attr("download", d3.boxplot.name_y + "_" + d3.boxplot.name_x + "_" +
dgenies.result.id_res + ".html").attr("id", "my-download")
.text("download"));
dgenies.hide_loading();
document.getElementById('my-download').click();
......
......@@ -54,7 +54,7 @@ dgenies.result.export.save_file(blob,"svg")},0)};/**
* Download association table between queries and targets
*/dgenies.result.export.export_association_table=function(){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/qt-assoc/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_assoc.tsv").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()};/**
* Download backup file of the project
*/dgenies.result.export.export_backup_file=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/backup/${dgenies.result.id_res}`).attr("download",dgenies.result.id_res+".tar").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()})};/**
*/dgenies.result.export.export_backup_file=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/backup/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_"+dgenies.result.id_res+".tar").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()})};/**
* Export list of contigs with no association with any target or any query
* @param {string} to: query or target
*/dgenies.result.export.export_no_association_file=function(to){window.setTimeout(()=>{dgenies.show_loading("Building file...",180);let on=to==="query"?"target":"query";dgenies.post("/no-assoc/"+dgenies.result.id_res,{"to":to},function(data,success){dgenies.hide_loading();if(!data["empty"]){let blob=new Blob([data["file_content"]],{type:"text/plain"});saveAs(blob,`no_${to}_matches_${d3.boxplot.name_y}_to_${d3.boxplot.name_x}.txt`)}else{dgenies.notify(`No contigs in ${to} have None match with any ${on}!`,"success")}})},0)};/**
......@@ -63,7 +63,7 @@ dgenies.result.export.save_file(blob,"svg")},0)};/**
* Export query like reference fasta file (standalone mode)
*/dgenies.result.export.export_query_as_reference_fasta_standalone=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/build-query-as-reference/${dgenies.result.id_res}`,{},function(data,success){if(data["success"]){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/get-query-as-reference/${dgenies.result.id_res}`).attr("download",`as_reference_${d3.boxplot.name_y}.fasta`).attr("id","my-download").text("download"));document.getElementById("my-download").click();dgenies.hide_loading()}else{dgenies.notify(`An error has occurred. Please contact the support`,"danger")}})},0)};/**
* Download offline viewer
*/dgenies.result.export.export_offline_viewer=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/summary/${dgenies.result.id_res}`,{},function(data){dgenies.hide_loading();if(data["success"]){if(data["status"]==="done"){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/viewer/${dgenies.result.id_res}`).attr("download",dgenies.result.id_res+".html").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()}else if(data["status"]==="waiting"){dgenies.result.export.export_offline_viewer()}}else{dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)};/**
*/dgenies.result.export.export_offline_viewer=function(){dgenies.show_loading("Building file...",180);window.setTimeout(()=>{dgenies.post(`/summary/${dgenies.result.id_res}`,{},function(data){dgenies.hide_loading();if(data["success"]){if(data["status"]==="done"){let export_div=$("div#export-pict");export_div.html("");export_div.append($("<a>").attr("href",`/viewer/${dgenies.result.id_res}`).attr("download",d3.boxplot.name_y+"_"+d3.boxplot.name_x+"_"+dgenies.result.id_res+".html").attr("id","my-download").text("download"));dgenies.hide_loading();document.getElementById("my-download").click()}else if(data["status"]==="waiting"){dgenies.result.export.export_offline_viewer()}}else{dgenies.notify(data["message"]||"An error occurred! Please contact us to report the bug","danger")}})},0)};/**
* Manage exports
*/dgenies.result.export.export=function(){let select=$("form#export select");let selection=parseInt(select.val());window.setTimeout(()=>{if(selection>0){let async=false;if(selection===1){dgenies.result.export.export_svg();async=true}else if(selection===2){dgenies.result.export.export_png();async=true}else if(selection===3)dgenies.result.export.export_paf();else if(selection===4){dgenies.result.export.ask_export_fasta();async=true}else if(selection===5){dgenies.result.export.export_association_table()}else if(selection===6){dgenies.result.export.export_no_association_file("query");async=true}else if(selection===7){dgenies.result.export.export_no_association_file("target");async=true}else if(selection===8){if(dgenies.mode==="webserver"){dgenies.result.export.export_query_as_reference_fasta_webserver()}else{dgenies.result.export.export_query_as_reference_fasta_standalone();async=true}}else if(selection===9){dgenies.result.export.export_backup_file();async=true}else if(selection===10){dgenies.result.export.export_offline_viewer();async=true}else dgenies.notify("Not supported yet!","danger",2000);if(!async)dgenies.hide_loading();select.val("0")}},0)};
if(!dgenies||!dgenies.result){throw"dgenies.result wasn't included!"}dgenies.result.summary={};dgenies.result.summary.percents={};/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment