Commit 38710b45 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix bug in run form with an invalid URL

parent 284ee10f
......@@ -22,6 +22,7 @@ dgenies.run.target_example = "";
dgenies.run.query_example = "";
dgenies.run.tool_has_ava = {};
dgenies.run.enabled = true;
dgenies.run.valid = true;
/**
* Initialise app for run page
......@@ -454,6 +455,7 @@ dgenies.run.do_submit = function () {
*/
dgenies.run.add_error = function (error) {
$("div.errors-submit ul.flashes").append($("<li>").append(error));
dgenies.run.valid = false;
};
/**
......@@ -671,12 +673,17 @@ dgenies.run.start_uploads = function() {
let test_has_uploads = dgenies.run._start_upload(input[0], input[1]);
has_uploads = has_uploads || test_has_uploads;
});
if (has_uploads) {
$("div#uploading-loading").html("Asking for upload...");
dgenies.run.ask_for_upload();
if (dgenies.run.valid) {
if (has_uploads) {
$("div#uploading-loading").html("Asking for upload...");
dgenies.run.ask_for_upload();
}
else {
dgenies.run.upload_next();
}
}
else {
dgenies.run.upload_next();
dgenies.run.valid = true;
}
};
......
if(!dgenies){throw"dgenies wasn't included!"}dgenies.run={};// Init global variables:
dgenies.run.s_id=null;dgenies.run.allowed_ext=[];dgenies.run.max_upload_file_size=-1;dgenies.run.files=[undefined,undefined,undefined,undefined,undefined,undefined];dgenies.run.files_nb={"query":0,"target":1,"queryidx":2,"targetidx":3,"alignfile":4,"backup":5};dgenies.run.allow_upload=false;dgenies.run.ping_interval=null;dgenies.run.target_example="";dgenies.run.query_example="";dgenies.run.tool_has_ava={};dgenies.run.enabled=true;/**
dgenies.run.s_id=null;dgenies.run.allowed_ext=[];dgenies.run.max_upload_file_size=-1;dgenies.run.files=[undefined,undefined,undefined,undefined,undefined,undefined];dgenies.run.files_nb={"query":0,"target":1,"queryidx":2,"targetidx":3,"alignfile":4,"backup":5};dgenies.run.allow_upload=false;dgenies.run.ping_interval=null;dgenies.run.target_example="";dgenies.run.query_example="";dgenies.run.tool_has_ava={};dgenies.run.enabled=true;dgenies.run.valid=true;/**
* Initialise app for run page
*
* @param {string} s_id session id
......@@ -90,7 +90,7 @@ $(`button#button-${ftype}`).click(function(){$(`input.file-${ftype}`).trigger("c
* Add an error to the form
*
* @param {string} error error message to display
*/dgenies.run.add_error=function(error){$("div.errors-submit ul.flashes").append($("<li>").append(error))};/**
*/dgenies.run.add_error=function(error){$("div.errors-submit ul.flashes").append($("<li>").append(error));dgenies.run.valid=false};/**
* Validate form
*
* @returns {boolean} true if form is valid, else false
......@@ -135,7 +135,7 @@ return!has_errors};/**
* @private
*/dgenies.run._start_upload=function(ftype,fname){let has_uploads=false;let fasta_type=parseInt($(`select.${ftype}`).val());let fasta_val=$(`input#${ftype}`).val();if(fasta_type===0&&fasta_val.length>0){$(`button#button-${ftype}`).hide();dgenies.run.show_loading(ftype);has_uploads=true}else{dgenies.run.files[0]=undefined;if(fasta_val!==""&&!dgenies.run.check_url(fasta_val)){dgenies.run.add_error(`${fname} file: invalid URL`,"error");dgenies.run.enable_form();return false}}return has_uploads};/**
* Launch upload of files
*/dgenies.run.start_uploads=function(){let has_uploads=false;let tab=$("#tabs .tab.active").attr("id");let inputs=[];if(tab==="tab1"){dgenies.run.reset_file_form("tab2");inputs=[["query","Query"],["target","Target"]]}else{dgenies.run.reset_file_form("tab1");inputs=[["queryidx","Query"],["targetidx","Target"],["alignfile","Alignment"],["backup","Backup"]]}$.each(inputs,function(i,input){let test_has_uploads=dgenies.run._start_upload(input[0],input[1]);has_uploads=has_uploads||test_has_uploads});if(has_uploads){$("div#uploading-loading").html("Asking for upload...");dgenies.run.ask_for_upload()}else{dgenies.run.upload_next()}};/**
*/dgenies.run.start_uploads=function(){let has_uploads=false;let tab=$("#tabs .tab.active").attr("id");let inputs=[];if(tab==="tab1"){dgenies.run.reset_file_form("tab2");inputs=[["query","Query"],["target","Target"]]}else{dgenies.run.reset_file_form("tab1");inputs=[["queryidx","Query"],["targetidx","Target"],["alignfile","Alignment"],["backup","Backup"]]}$.each(inputs,function(i,input){let test_has_uploads=dgenies.run._start_upload(input[0],input[1]);has_uploads=has_uploads||test_has_uploads});if(dgenies.run.valid){if(has_uploads){$("div#uploading-loading").html("Asking for upload...");dgenies.run.ask_for_upload()}else{dgenies.run.upload_next()}}else{dgenies.run.valid=true}};/**
* Show global loading
*/dgenies.run.show_global_loading=function(){$("button#submit").hide();$("button#example").hide();$("div#uploading-loading").show()};/**
* Submit form
......
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