Skip to content

Commit 7bf0a3d

Browse files
Enhanced export flexibility regarding ability to push to external tools
1 parent cf9efc3 commit 7bf0a3d

File tree

3 files changed

+53
-36
lines changed

3 files changed

+53
-36
lines changed

src/main/webapp/index.jsp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,23 @@ https://doi.org/10.1093/gigascience/giz051</pre>
277277
</label>&nbsp;<br/>
278278
<select disabled id="exportedIndividualMetadata" multiple style="width:100%;" size="12"></select>
279279
</div>
280-
<div style="width:100%; text-align:center;">
281-
<label class="margin-top margin-bottom label-checkbox" style="margin-left:-10px;">
282-
<input type="checkbox" onclick="var serverAddr=location.origin.substring(location.origin.indexOf('//') + 2); $('div#serverExportWarning').html($(this).prop('checked') && (serverAddr.toLowerCase().indexOf('localhost') == 0 || serverAddr.indexOf('127.0.0.1') == 0) ? 'WARNING: Gigwa seems to be running on localhost, any external tool running on a different machine will not be able to access exported files! If the computer running the webapp has an external IP address or domain name, you should use that instead.' : '');" id="keepExportOnServ" title="If ticked, generates a file URL instead of initiating a direct download. Required for pushing exported data to external online tools." class="input-checkbox"> Keep files on server&nbsp;&nbsp;
283-
</label>
280+
<div style="width:100%; margin-left:-10px;" class="margin-top margin-bottom label-checkbox">
284281
<div>
285-
<button id="export-btn" class="btn btn-primary btn-sm" onclick="exportData();">Export</button>
282+
<input type="checkbox" id="keepExportOnServ" style="vertical-align:top; margin-left:15px; margin-right:5px;" onclick="var enabled=$(this).is(':checked'); $('#enableExportPush').prop('checked', enabled); $('#enableExportPush').prop('disabled', enabled);" title="If ticked, export data will remain downloadable for at least 48h. You may then share its URL with collaborators." class="input-checkbox">
283+
<label style="width:120px;" for="keepExportOnServ">Keep files on server</label>
286284
</div>
285+
<div style="text-align:center;">
286+
<input type="checkbox" id="enableExportPush" style="vertical-align:top; margin-left:15px; margin-right:5px;" onclick="var serverAddr=location.origin.substring(location.origin.indexOf('//') + 2); $('div#serverExportWarning').html($(this).prop('checked') && (serverAddr.toLowerCase().indexOf('localhost') == 0 || serverAddr.indexOf('127.0.0.1') == 0) ? 'WARNING: Gigwa seems to be running on localhost, any external tool running on a different machine will not be able to access exported files! If the computer running the webapp has an external IP address or domain name, you should use that instead.' : '');" title="If ticked, exported data will be provided by URL, and available for pushing into external online tools." class="input-checkbox">
287+
<label style="width:120px;" for="enableExportPush">Provide export URL</label>
288+
</div>
289+
</div>
290+
<div>
291+
<button id="export-btn" class="btn btn-primary btn-sm" onclick="exportData();">Export</button>
287292
</div>
288293
</div>
289294
</div>
290-
<div id="serverExportWarning" style="white-space: initial"></div>
291295
</div>
296+
<div id="serverExportWarning" style="white-space: initial"></div>
292297
</div>
293298
</div>
294299
<a class="btn icon-btn btn-default" id="exportBoxToggleButton" data-toggle="button" class-toggle="btn-inverse" style="padding:5px 10px 4px 10px;" href="#" onclick="toggleExportPanel();" title="Export selection">
@@ -316,7 +321,6 @@ https://doi.org/10.1093/gigascience/giz051</pre>
316321
</div>
317322
</div>
318323
</div>
319-
</div>
320324
</main>
321325
<!-- modal which display process progress -->
322326
<div class="modal" tabindex="-1" id="progress" aria-hidden="true">
@@ -329,7 +333,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
329333
<div class="c3"></div>
330334
<div class="c4"></div>
331335
</div>
332-
<h3 class="loading-message"><span id="progressText" class="loading-message">Please wait...</span><span id="ddlWarning" style="display:none;"><br/><br/>Output file is being generated and will not be valid before this message disappears</span></h3>
336+
<h3 class="loading-message"><span id="progressText" class="loading-message">Please wait...</span></h3>
333337
<br/>
334338
<button style="display:inline; margin-right:10px;" class="btn btn-danger btn-sm" type="button" name="abort" id='abort' onclick="abort($(this).attr('rel')); $('a#exportBoxToggleButton').removeClass('active');">Abort</button>
335339
<button style="display:inline; margin-left:10px;" id="asyncProgressButton" class="btn btn-info btn-sm" type="button" onclick="window.open('ProgressWatch.jsp?process=export_' + token + '&abortable=true&successURL=' + escape(downloadURL) + '&module=' + getModuleName() + '&exportFormat=' + $('#exportFormat').val() + '&keepExportOnServ=' + $('#keepExportOnServ').prop('checked') + '&galaxyInstanceUrl=' + $('#galaxyInstanceURL').val() + '&exportedVariantCount=' + count + '&exportedIndividualCount=' + exportedIndividualCount + '&exportFormatExtensions=' + $('#exportFormat option:selected').data('ext') + '&exportedTsvMetadata=' + ($('#exportPanel input#exportedIndividualMetadataCheckBox').is(':checked') && 'FLAPJACK' != $('#exportFormat').val() && 'DARWIN' != $('#exportFormat').val()));" title="This will open a separate page allowing to watch export progress at any time. Leaving the current page will not abort the export process.">Open async progress watch page</button>
@@ -464,7 +468,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
464468
(feature available when the 'Keep files on server' box is ticked)<br />
465469
</div>
466470
<hr />
467-
<span class='bold'>Favourite <a href="https://galaxyproject.org/" target="_blank" border="0" style="background-color:#333333; color:white; border-radius:3px; padding:3px;"><img alt="southgreen" height="15" src="images/logo-galaxy.png" /> Galaxy</a> instance URL</span>
471+
<span class='bold'>Favourite <a href="https://galaxyproject.org/" target="_blank" border="0" style="background-color:#333333; color:white; border-radius:3px; padding:6px;"><img alt="Galaxy" height="15" src="images/logo-galaxy.png" /> Galaxy</a> instance URL</span>
468472
<input type="text" style="font-size:11px; width:230px; margin-bottom:5px;" placeholder="https://usegalaxy.org/" id="galaxyInstanceURL" onfocus="$(this).prop('previousVal', $(this).val());" onkeyup="checkIfOuputToolConfigChanged();" />
469473
<br/>
470474
(You will be requested to provide an API key to be able to push exported files there)
@@ -1333,7 +1337,6 @@ https://doi.org/10.1093/gigascience/giz051</pre>
13331337
if (gotMetaData) {
13341338
$('#asyncProgressButton').hide();
13351339
$('button#abort').hide();
1336-
$('#ddlWarning').hide();
13371340
$('#progressText').html("Loading individuals' metadata...");
13381341
$('#progress').modal({
13391342
backdrop: 'static',
@@ -1505,7 +1508,6 @@ https://doi.org/10.1093/gigascience/giz051</pre>
15051508
if ($('#exportPanel').is(':visible'))
15061509
$('#exportBoxToggleButton').click()
15071510
$('#asyncProgressButton').hide();
1508-
$('#ddlWarning').hide();
15091511
$('button#abort').show();
15101512
$('#progressText').html("Please wait...");
15111513
$('#progress').modal({
@@ -1852,15 +1854,15 @@ https://doi.org/10.1093/gigascience/giz051</pre>
18521854
}
18531855
18541856
function exportData() {
1855-
var keepExportOnServer = $('#keepExportOnServ').prop('checked');
18561857
var indToExport = $('#exportedIndividuals').val() == "choose" ? $('#exportedIndividuals').parent().parent().find("select.individualSelector").val() : ($('#exportedIndividuals').val() == "allGroups" ? getSelectedIndividuals() : ($('#exportedIndividuals').val() == "" ? [] : getSelectedIndividuals([parseInt($('#exportedIndividuals').val())])));
18571858
exportedIndividualCount = indToExport == null ? indOpt.length : indToExport.length;
1858-
if (!keepExportOnServer && $('#exportPanel div.individualRelated:visible').size() > 0) {
1859-
if (exportedIndividualCount * count > 1000000000) {
1860-
alert("The matrix you are about to export contains more than 1 billion genotypes and is too large to be downloaded directly. Please tick the 'Keep files on server' box.");
1861-
return;
1862-
}
1863-
}
1859+
var keepExportOnServer = $('#keepExportOnServ').prop('checked');
1860+
// if (!keepExportOnServer && $('#exportPanel div.individualRelated:visible').size() > 0) {
1861+
// if (exportedIndividualCount * count > 1000000000) {
1862+
// alert("The matrix you are about to export contains more than 1 billion genotypes and is too large to be downloaded directly. Please tick the 'Keep files on server' box.");
1863+
// return;
1864+
// }
1865+
// }
18641866
18651867
var supportedTypes = $('#exportFormat').children().filter(':selected').data('type');
18661868
if (supportedTypes != null) {
@@ -1883,7 +1885,6 @@ https://doi.org/10.1093/gigascience/giz051</pre>
18831885
18841886
exporting = true;
18851887
1886-
$('#ddlWarning').hide();
18871888
$('#asyncProgressButton').show();
18881889
$('button#abort').show();
18891890
$('#progressText').html("Please wait...");
@@ -1895,7 +1896,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
18951896
18961897
var url = '<c:url value="<%=GigwaRestController.REST_PATH + GigwaRestController.BASE_URL + GigwaRestController.EXPORT_DATA_PATH%>" />';
18971898
var query = buildSearchQuery(3, currentPageToken);
1898-
query["keepExportOnServer"] = keepExportOnServer;
1899+
query["keepExportOnServer"] = keepExportOnServer;
18991900
query["exportFormat"] = $('#exportFormat').val();
19001901
query["exportedIndividuals"] = indToExport === null ? [] : indToExport;
19011902
query["metadataFields"] = $('#exportPanel select#exportedIndividualMetadata').prop('disabled') || $('#exportPanel div.individualRelated:visible').size() == 0 ? [] : $("#exportedIndividualMetadata").val();
@@ -1920,11 +1921,11 @@ https://doi.org/10.1093/gigascience/giz051</pre>
19201921
});
19211922
19221923
displayProcessProgress(2, "export_" + token, null, function() {
1923-
if (keepExportOnServer) {
1924+
if ($('#enableExportPush').prop('checked')) {
19241925
let fileExtensions = $("#exportFormat option:selected").data('ext').split(";");
19251926
if ($('#exportPanel input#exportedIndividualMetadataCheckBox').is(':checked') && "FLAPJACK" != $('#exportFormat').val() && "DARWIN" != $('#exportFormat').val() /* these two already have their own metadata file format*/)
19261927
fileExtensions.push("tsv");
1927-
showServerExportBox(fileExtensions, $('#keepExportOnServ').prop('checked'));
1928+
showServerExportBox(fileExtensions, keepExportOnServer);
19281929
}
19291930
else {
19301931
var link = document.createElement('a');

src/main/webapp/js/common.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
var minimumProcessQueryIntervalUnit = 100;
2424
var emptyResponseCountsByProcess = [];
25+
26+
var archivedDataFiles = new Array();
27+
2528
var StringBuffer = function() {
2629
this.buffer = new Array();
2730
};
@@ -311,6 +314,20 @@ function grabNcbiTaxon(inputObj)
311314
$(inputObj).val(taxonName);
312315
}
313316

317+
function showGalaxyPushButton()
318+
{
319+
var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim();
320+
if (galaxyInstanceUrl.startsWith("http")) {
321+
var fileURLs = "";
322+
for (key in archivedDataFiles)
323+
fileURLs += (fileURLs == "" ? "" : " ,") + "'" + archivedDataFiles[key] + "'";
324+
$('#galaxyPushButton').html('<div style="display:inline; width:70px; font-weight:bold; background-color:#333333; color:white; border-radius:3px; padding:7px;"><img alt="Galaxy" height="15" src="images/logo-galaxy.png" /> Galaxy</div>&nbsp;<input style="margin-bottom:20px;" type="button" value="Send exported data to ' + galaxyInstanceUrl + '" onclick="sendToGalaxy([' + fileURLs + ']);" />');
325+
$("#galaxyPushButton").show();
326+
}
327+
else
328+
$("#galaxyPushButton").hide();
329+
}
330+
314331
function showServerExportBox(exportFormatExtensions, keepExportOnServer)
315332
{
316333
$("div#exportPanel").hide();
@@ -319,30 +336,25 @@ function showServerExportBox(exportFormatExtensions, keepExportOnServer)
319336
return;
320337

321338
var fileName = downloadURL.substring(downloadURL.lastIndexOf("/") + 1);
322-
$('#serverExportBox').html('<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="float:right;" onclick="$(\'#serverExportBox\').hide();">x&nbsp;</button></button>&nbsp;Export file ' + (keepExportOnServer ? 'may be downloaded from this URL' : 'will be available at this URL for 48h') + ':<br/><a id="exportOutputUrl" download href="' + downloadURL + '">' + fileName + '</a> ').show();
339+
$('#serverExportBox').html('<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="float:right;" onclick="$(\'#serverExportBox\').hide();">x&nbsp;</button></button>&nbsp;Export file will be available at this URL for ' + (!keepExportOnServer ? 1 : 48) + 'h:<br/><a id="exportOutputUrl" download href="' + downloadURL + '">' + fileName + '</a><br/><br/>').show();
323340
var exportedFormat = $('#exportFormat').val().toUpperCase();
324341
if ("VCF" == exportedFormat)
325342
addIgvExportIfRunning();
326343
else if ("FLAPJACK" == exportedFormat)
327344
addFjBytesExport();
345+
346+
$('#serverExportBox').append("<div id='galaxyPushButton' />");
328347

329-
var archivedDataFiles = new Array();
348+
archivedDataFiles = new Array();
330349
for (var key in exportFormatExtensions)
331350
archivedDataFiles[exportFormatExtensions[key]] = location.origin + downloadURL.replace(new RegExp(/\.[^.]*$/), '.' + exportFormatExtensions[key]);
332351

333-
var galaxyInstanceUrl = $("#galaxyInstanceURL").val().trim();
334-
if (galaxyInstanceUrl.startsWith("http")) {
335-
var fileURLs = "";
336-
for (key in archivedDataFiles)
337-
fileURLs += (fileURLs == "" ? "" : " ,") + "'" + archivedDataFiles[key] + "'";
338-
$('#serverExportBox').append('<br/><br/>&nbsp;<input type="button" value="Send exported data to Galaxy" onclick="sendToGalaxy([' + fileURLs + ']);" />&nbsp;');
339-
}
352+
showGalaxyPushButton();
340353

341354
if (onlineOutputTools != null)
342355
for (var toolName in onlineOutputTools) {
343356
var toolConfig = getOutputToolConfig(toolName);
344-
if (toolConfig['url'] != null && toolConfig['url'].trim() != "" && (toolConfig['formats'] == null || toolConfig['formats'].trim() == "" || toolConfig['formats'].toUpperCase().split(",").includes($('#exportFormat').val().toUpperCase()))) {
345-
357+
if (toolConfig['url'] != null && toolConfig['url'].trim() != "" && (toolConfig['formats'] == null || toolConfig['formats'].trim() == "" || toolConfig['formats'].toUpperCase().split(",").includes($('#exportFormat').val().toUpperCase()))) {
346358
var formatsForThisButton = "", urlForThisButton = toolConfig['url'];
347359
var matchResult = urlForThisButton.match(/{([^}]+)}/g);
348360
if (matchResult != null) {
@@ -369,7 +381,7 @@ function showServerExportBox(exportFormatExtensions, keepExportOnServer)
369381
}
370382

371383
if (formatsForThisButton != "")
372-
$('#serverExportBox').append('<br/><br/>&nbsp;<input type="button" value="Send ' + formatsForThisButton + ' file(s) to ' + toolName + '" onclick="window.open(\'' + urlForThisButton + '\');" />&nbsp;')
384+
$('#serverExportBox').append('<input style="margin-bottom:20px;" type="button" value="Send ' + formatsForThisButton + ' file(s) to ' + toolName + '" onclick="window.open(\'' + urlForThisButton + '\');" />&nbsp;')
373385
}
374386
}
375387
}

src/main/webapp/js/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ function checkGroupOverlap(groupNumber) {
10571057
});
10581058
}
10591059

1060-
function applyOutputToolConfig(t) {
1060+
function applyOutputToolConfig() {
10611061
if ($("input#outputToolURL").val().trim() == "") {
10621062
localStorage.removeItem("outputTool_" + $("#onlineOutputTools").val());
10631063
configureSelectedExternalTool();
@@ -1066,8 +1066,12 @@ function applyOutputToolConfig(t) {
10661066

10671067
if ($("input#galaxyInstanceURL").val().trim() == "")
10681068
localStorage.removeItem("galaxyInstanceURL");
1069-
else
1069+
else {
10701070
localStorage.setItem("galaxyInstanceURL", $("input#galaxyInstanceURL").val());
1071+
$("#galaxyPushButton input").val("Send exported data to " + $("input#galaxyInstanceURL").val());
1072+
}
1073+
1074+
showGalaxyPushButton();
10711075

10721076
$("#applyOutputToolConfig").prop("disabled", "disabled");
10731077
}

0 commit comments

Comments
 (0)