Skip to content

Commit f0c3218

Browse files
committed
Merge branch 'master' of https://github.com/ImagingDataCommons/IDC-WebApp into idc-test
2 parents 44f3251 + b68b5cc commit f0c3218

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

static/js/image_search.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,14 @@ require([
184184
$('#search_def_access').addClass('is-hidden');
185185
$('.access_warn').addClass('is-hidden');
186186
}
187-
let download_btn = $('#download-cohort-images');
188-
let download_btn_tips = $('#download-cohort-images-tooltips');
189187
if(isFiltered && data.total > 0) {
190188
$('#search_def_stats').html("Cohort filter contents: " +
191189
data.totals.SeriesInstanceUID.toString() + " series from " +
192190
data.totals.PatientID.toString() + " cases / " +
193191
data.totals.StudyInstanceUID.toString() + " studies (Size on disk: " +
194192
data.totals.disk_size + ")"
195193
);
196-
base.updateDownloadBtns("cohort", true, parseFloat(data.totals.disk_size.split(" ")[0]));
197-
194+
base.updateDownloadBtns("cohort", true, data.totals.disk_size_tb);
198195
} else if(isFiltered && data.total <= 0) {
199196
$('#search_def_stats').html('<span style="color:red">There are no cases matching the selected set of filters</span>');
200197
} else {

static/js/utils.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ require.config({
4141

4242
// Return an object for consts/methods used by most views
4343
define(['jquery', 'jqueryui'], function($, jqueryui) {
44+
// Terabyte cutoffs for download button tooltips and enabling
45+
let DOWNLOAD_SIZE_LIMIT = 3;
46+
let DOWNLOAD_SIZE_WARN = 2;
4447

4548
// Download block poll with cookie via StackOverflow:
4649
// https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
@@ -142,8 +145,10 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
142145
_hideFloatingMessage(true);
143146
});
144147

145-
146-
// Enabled is equivalent to 'is there a filter' or 'is something in the cart'
148+
// type - string, ID selector subtype for the buttons and tooltips to adjust
149+
// enabled - bool, sets if the button is to be disabled or enabled
150+
// disk_size - size for determining size limit enabling and tooltip message, is assumed to be in TB
151+
// requires setting DOWNLOAD_SIZE_LIMIT and DOWNLOAD_SIZE_WARN
147152
function _updateDownloadBtns(type, enabled, disk_size) {
148153
let btn = $(`#download-${type}-images`);
149154
let btn_tip = $(`#download-${type}-images-tooltips`);
@@ -156,14 +161,14 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
156161
}
157162
if ("showDirectoryPicker" in window) {
158163
btn_and_tips.removeClass('is-disabled download-all-instances download-size-warning');
159-
if (disk_size > 3) {
164+
if (disk_size > DOWNLOAD_SIZE_LIMIT) {
160165
btn_tip.addClass('is-disabled');
161166
btn_tip.attr('data-disabled-type', "download-size-disabled");
162167
btn.attr("disabled", "disabled");
163168
} else {
164169
btn.removeAttr("disabled");
165170
btn_tip.attr('data-disabled-type', "");
166-
(disk_size > 2) ? btn.addClass('download-size-warning') : btn.addClass('download-all-instances');
171+
(disk_size > DOWNLOAD_SIZE_WARN) ? btn.addClass('download-size-warning') : btn.addClass('download-all-instances');
167172
}
168173
} else {
169174
btn_tip.addClass('is-disabled');

0 commit comments

Comments
 (0)