Skip to content

Commit e904810

Browse files
authored
Merge pull request #461 from ImagingDataCommons/user/mt/multi-part-manifest
Update download manifest dialog to support fetching very large manifest (multi-chunk download, BQ, etc.) #432
2 parents 17e8002 + 1746657 commit e904810

File tree

5 files changed

+81
-21
lines changed

5 files changed

+81
-21
lines changed

static/js/cohorts/cohort-details.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ require([
7979
download_manifest("json", $(this), e)
8080
});
8181

82+
$('.export-option input[type="radio"]').click(function(){
83+
update_export_option($(this).attr("value"));
84+
});
85+
86+
var update_export_option = function(export_option) {
87+
$('#bq-manifest').hide();
88+
$('#file-manifest').hide();
89+
$('#' + export_option).show();
90+
};
91+
92+
update_export_option("file-manifest");
93+
8294
var download_manifest = function(file_type, clicked_button, e) {
8395
$('#unallowed-chars-alert').hide();
8496
$('#name-too-long-alert-modal').hide();
@@ -146,13 +158,24 @@ require([
146158
}
147159
});
148160

161+
var include_header = $('#include-header-checkbox')[0].checked;
162+
149163
var url = BASE_URL + '/cohorts/download_manifest/' + cohort_id + '/';
150164
url += ("?file_type=" + file_type);
165+
url += ("&include_header=" + include_header);
151166
url += ("&file_name=" + name);
152167
url += ("&header_fields=" + JSON.stringify(checked_fields));
153168
url += ("&columns=" + JSON.stringify(checked_columns));
154169
url += ("&downloadToken=" + downloadToken);
155170

171+
var select_box_div = $('#file-part-select-box');
172+
var select_box = select_box_div.find('select');
173+
if (select_box_div.is(":visible"))
174+
{
175+
var selected_file_part = select_box.children("option:selected").val();
176+
url += ("&file_part=" + selected_file_part);
177+
}
178+
156179
location.href = url;
157180
};
158181

static/js/image_search.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,12 +1723,30 @@ require([
17231723
contentType: 'application/x-www-form-urlencoded',
17241724
success: function (data) {
17251725
var isFiltered = Boolean($('#search_def p').length>0);
1726-
if(is_cohort) {
1726+
if (is_cohort) {
17271727
if(data.total > 65000) {
17281728
$('.manifest-size-warning').show();
17291729
} else {
17301730
$('.manifest-size-warning').hide();
17311731
}
1732+
1733+
var select_box_div = $('#file-part-select-box');
1734+
var select_box = select_box_div.find('select');
1735+
if (data.file_parts_count > 1)
1736+
{
1737+
select_box_div.show();
1738+
for (let i = 0; i < data.file_parts_count; ++i)
1739+
{
1740+
select_box.append($('<option/>', {
1741+
value: i,
1742+
text : "File Part " + (i + 1)
1743+
}));
1744+
}
1745+
}
1746+
else
1747+
{
1748+
select_box_div.hide();
1749+
}
17321750
} else {
17331751
if (isFiltered && data.total > 0){
17341752
$('#save-cohort-btn').prop('disabled','');
@@ -2945,6 +2963,7 @@ require([
29452963
// Do not disable checkboxes for export manifest dialog
29462964
$('.field-checkbox').removeAttr('disabled');
29472965
$('.column-checkbox').removeAttr('disabled');
2966+
$('#include-header-checkbox').removeAttr('disabled');
29482967

29492968
$('div.ui-slider').siblings('button').prop('disabled', 'disabled');
29502969
$('input#hide-zeros').prop("disabled", "");
@@ -2977,7 +2996,6 @@ require([
29772996
}
29782997

29792998
$(document).ready(function () {
2980-
29812999
// $('#proj_table').DataTable();
29823000
// window.filterObj.collection_id = window.tcgaColls;
29833001
window.selItems = new Object();

templates/cohorts/cohort_details.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ <h3 class="pull-left" role="heading" aria-level="1">Cohort Name: {{ cohort.name
4646
<button id="export-manifest" class="btn btn-special pull-right" data-toggle="modal"
4747
data-target="#export-manifest-modal"> Export Cohort Manifest
4848
</button>
49-
<!--
50-
<a id="download-manifest" class="btn btn-default pull-right" title="Download this cohort's manifest." href="{% url 'cohort_manifest' cohort.id %}">
51-
Download Cohort Manifest
52-
</a>
53-
-->
5449
</div>
5550
</div>
5651
</div>
@@ -68,8 +63,8 @@ <h3 class="pull-left" role="heading" aria-level="1">Cohort Name: {{ cohort.name
6863
</script>
6964

7065
{% with is_cohort=True %}
71-
{% include "idc/explore_data_core.html" %}
7266
{% include "cohorts/export-manifest-modal.html" %}
67+
{% include "idc/explore_data_core.html" %}
7368
{% endwith %}
7469

7570
<!-- Download In Progress Modal -->

templates/cohorts/export-manifest-modal.html

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,43 @@ <h4 class="modal-title" id="exportManifestModal">Export Cohort Manifest</h4>
112112
<span class="value">GCS URL </span>
113113
</label></li>
114114
</div>
115-
</div>
116-
</div>
115+
<br>
116+
117+
<!-- Export Option -->
118+
<div class="export-option">
119+
<span class="value"><input type="radio" name="colorRadio" value="file-manifest" checked> Files</span>
120+
<span style="margin-left:10px" class="value"><input type="radio" name="colorRadio" value="bq-manifest"> BigQuery</span>
121+
</div>
122+
<br>
117123

118-
<div class="modal-footer">
119-
{% csrf_token %}
120-
<a id="download-csv" class="btn btn-primary" title="Download this cohort's manifest in CSV format.">
121-
Download CSV
122-
</a>
123-
<a id="download-tsv" class="btn btn-primary " title="Download this cohort's manifest in TSV format.">
124-
Download TSV
125-
</a>
126-
<a id="download-json" class="btn btn-primary " title="Download this cohort's manifest in JSON format.">
127-
Download JSON
128-
</a>
124+
<div id="bq-manifest">
125+
<a id="get-bq-table" class="btn btn-primary" title="Get BQ Table of this manifest.">
126+
Get BQ Table
127+
</a>
128+
</div>
129+
<div id="file-manifest">
130+
<div id="file-part-select-box">
131+
<select class="form-control">
132+
</select>
133+
<br>
134+
</div>
135+
136+
<span><input id="include-header-checkbox" type="checkbox" checked> Include header fields (CSV and TSV only)</span>
137+
<br>
138+
<br>
139+
140+
{% csrf_token %}
141+
<a id="download-csv" class="btn btn-primary" title="Download this cohort's manifest in CSV format.">
142+
Download CSV
143+
</a>
144+
<a id="download-tsv" class="btn btn-primary " title="Download this cohort's manifest in TSV format.">
145+
Download TSV
146+
</a>
147+
<a id="download-json" class="btn btn-primary " title="Download this cohort's manifest in JSON format.">
148+
Download JSON
149+
</a>
150+
</div>
151+
</div>
129152
</div>
130153
</form>
131154
</div>

templates/idc/landing.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
</div>
123123
</div>
124124
{% include 'share/site_footer.html' %}
125+
125126
</div>
126127
{% endblock %}
127128

0 commit comments

Comments
 (0)