Skip to content

Commit b7f19fb

Browse files
authored
Merge pull request #469 from ImagingDataCommons/idc-test-sp
Sprint 15
2 parents e8077a7 + fd96bde commit b7f19fb

File tree

6 files changed

+276
-118
lines changed

6 files changed

+276
-118
lines changed

idc/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
GCLOUD_PROJECT_NUMBER = os.environ.get('GCLOUD_PROJECT_NUMBER', '')
8181
BIGQUERY_PROJECT_ID = os.environ.get('BIGQUERY_PROJECT_ID', GCLOUD_PROJECT_ID)
8282
BIGQUERY_DATA_PROJECT_ID = os.environ.get('BIGQUERY_DATA_PROJECT_ID', GCLOUD_PROJECT_ID)
83+
BIGQUERY_USER_MANIFEST_DATASET = os.environ.get('BIGQUERY_USER_MANIFEST_DATASET', 'dev_user_dataset')
8384

8485
# Deployment module
8586
CRON_MODULE = os.environ.get('CRON_MODULE')

static/js/cohorts/cohort-details.js

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ require([
5858
tippy('.manifest-size-warning',{
5959
content: 'Your cohort is too large to be downloaded in its entirety, and will be truncated at 65,000 records ' +
6060
'ordered by PatientID, CollectionID, StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID, SourceDOI, ' +
61-
'CRDCInstanceUUID, and GCSPath.',
61+
'CRDCInstanceUUID, and GCS_URL.',
6262
theme: 'light',
6363
placement: 'left',
6464
arrow: false,
6565
maxWidth: 400
6666
});
6767

68+
var enable_buttons = function() {
69+
$('#download-csv').removeAttr('disabled');
70+
$('#download-tsv').removeAttr('disabled');
71+
$('#download-json').removeAttr('disabled');
72+
$('#get-bq-table').removeAttr('disabled');
73+
};
74+
6875
var downloadToken = new Date().getTime();
6976

7077
$('#download-csv').on('click', function(e) {
@@ -92,14 +99,16 @@ require([
9299
update_export_option("file-manifest");
93100

94101
var download_manifest = function(file_type, clicked_button, e) {
102+
let manifest_type = $('input[name="manifest-type"]:checked').val();
103+
95104
$('#unallowed-chars-alert').hide();
96105
$('#name-too-long-alert-modal').hide();
97106

98107
var name = $('#export-manifest-name').val();
99108
var unallowed = (name.match(base.blacklist) || []);
100109

101110
if (name.length == 0) {
102-
$('#download-csv').prop('title','Please input the name.');
111+
$('#download-csv').prop('title','Please provide a file name.');
103112
$('#export-manifest-name')[0].focus();
104113
e.preventDefault();
105114
return false;
@@ -123,20 +132,19 @@ require([
123132
return false;
124133
}
125134

126-
$('#export-manifest-form').submit();
127-
128135
$('#download-csv').attr('disabled','disabled');
129136
$('#download-tsv').attr('disabled','disabled');
130137
$('#download-json').attr('disabled','disabled');
138+
$('#get-bq-table').attr('disabled','disabled');
131139

132-
$('#download-in-progress').modal('show');
140+
$('#manifest-in-progress').modal('show');
133141

134-
base.blockResubmit(function() {
135-
$('#download-csv').removeAttr('disabled');
136-
$('#download-tsv').removeAttr('disabled');
137-
$('#download-json').removeAttr('disabled');
138-
$('#download-in-progress').modal('hide');
139-
},downloadToken, 'downloadToken');
142+
if(manifest_type == 'file-manifest') {
143+
base.blockResubmit(function () {
144+
enable_buttons();
145+
$('#manifest-in-progress').modal('hide');
146+
}, downloadToken, 'downloadToken');
147+
}
140148

141149
var checked_fields = [];
142150
$('.field-checkbox').each(function()
@@ -158,25 +166,52 @@ require([
158166
}
159167
});
160168

161-
var include_header = $('#include-header-checkbox')[0].checked;
162-
163-
var url = BASE_URL + '/cohorts/download_manifest/' + cohort_id + '/';
164-
url += ("?file_type=" + file_type);
165-
url += ("&include_header=" + include_header);
166-
url += ("&file_name=" + name);
167-
url += ("&header_fields=" + JSON.stringify(checked_fields));
168-
url += ("&columns=" + JSON.stringify(checked_columns));
169-
url += ("&downloadToken=" + downloadToken);
169+
$('input[name="file_type"]').val(file_type);
170+
$('input[name="header_fields"]').val(JSON.stringify(checked_fields));
171+
$('input[name="columns"]').val(JSON.stringify(checked_columns));
172+
$('input[name="downloadToken"]').val(downloadToken);
173+
$('input[name="include_header"]').val($('#include-header-checkbox').is(':checked') ? 'true': 'false');
170174

171175
var select_box_div = $('#file-part-select-box');
172176
var select_box = select_box_div.find('select');
173-
if (select_box_div.is(":visible"))
174-
{
177+
if (select_box_div.is(":visible")) {
175178
var selected_file_part = select_box.children("option:selected").val();
176-
url += ("&file_part=" + selected_file_part);
179+
$('input[name="file_part"]').val(selected_file_part);
180+
} else {
181+
$('input[name="file_part"]').val("");
177182
}
178183

179-
location.href = url;
184+
if(manifest_type == 'file-manifest') {
185+
$('#export-manifest-form').submit();
186+
} else {
187+
$.ajax({
188+
url: $('#export-manifest-form').attr('action'),
189+
data: $('#export-manifest-form').serialize(),
190+
method: 'GET',
191+
success: function (data) {
192+
if(data.message) {
193+
base.showJsMessage("info",data.message,true);
194+
}
195+
},
196+
error: function (xhr) {
197+
var responseJSON = $.parseJSON(xhr.responseText);
198+
// If we received a redirect, honor that
199+
if(responseJSON.redirect) {
200+
base.setReloadMsg(responseJSON.level || "error",responseJSON.message);
201+
window.location = responseJSON.redirect;
202+
} else {
203+
base.showJsMessage(responseJSON.level || "error",responseJSON.message,true);
204+
}
205+
},
206+
complete: function(xhr, status) {
207+
$('#manifest-in-progress').modal('hide');
208+
enable_buttons();
209+
$('#export-manifest-modal').modal('hide');
210+
$('input[name="manifest-type"][value="file-manifest"]').triggerHandler('click');
211+
$('#export-manifest-form')[0].reset();
212+
}
213+
});
214+
}
180215
};
181216

182217
$('.column-checkbox').change(function() {
@@ -213,4 +248,9 @@ require([
213248
};
214249

215250
update_download_manifest_buttons();
251+
252+
$('#get-bq-table').on('click',function(){
253+
download_manifest('',$(this));
254+
});
255+
216256
});

0 commit comments

Comments
 (0)