Skip to content

Commit 77cd707

Browse files
committed
Merge branch 'master' of https://github.com/ImagingDataCommons/IDC-WebApp into idc-test
2 parents f0c3218 + 82fa61d commit 77cd707

6 files changed

Lines changed: 54 additions & 54 deletions

File tree

static/js/cartutils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ define(['filterutils','jquery', 'tippy', 'base' ], function(filterutils, $, tip
126126
var buttonContents = '<button class="btn filter-type clear-cart" role="button" title="Empty your cart."><i class="fa fa-rotate-left"></i></button>';
127127
let cart_has_contents = Boolean(Object.keys(window.proj_in_cart).length>0);
128128
let cart_controls = $('.cart-activated-controls');
129+
var nmseries = 0;
129130
if (cart_has_contents){
130131
var nmprojs = 0;
131132
var nmcases=0;
132133
var nmstudies=0;
133-
var nmseries =0;
134134
for (projid in window.proj_in_cart){
135135
nmprojs++;
136136
nmcases=nmcases+window.proj_in_cart[projid]['cases'];
@@ -176,7 +176,7 @@ define(['filterutils','jquery', 'tippy', 'base' ], function(filterutils, $, tip
176176
cart_disk_display_size = cart_disk_res['display_size'];
177177
}
178178
$('.cart_disk_size').html(cart_disk_display_size);
179-
base.updateDownloadBtns('cart', cart_has_contents, cart_disk_size);
179+
base.updateDownloadBtns('cart', cart_has_contents, cart_disk_size, nmseries);
180180

181181
}
182182

static/js/downloader.js

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -785,53 +785,49 @@ require([
785785

786786
let series = [];
787787
if(download_type !== "series") {
788-
if(parseInt(clicked.attr('data-total-series')) > 65000) {
789-
790-
} else {
791-
let response = null;
792-
if(["cohort", "cart"].includes(download_type)) {
793-
downloader_manager.pendingFetchMessage(download_type);
794-
let filter_and_cart = {};
795-
if (download_type === "cohort") {
796-
let filtergrp_list = [];
797-
for(const [attr, vals] of Object.entries(filterutils.parseFilterObj())) {
798-
filtergrp_list.push({[attr]: vals});
799-
}
800-
filter_and_cart["filtergrp_list"] = filtergrp_list;
801-
} else {
802-
window.updatePartitionsFromScratch();
803-
let ret = cartutils.formcartdata();
804-
window.partitions = ret[0];
805-
window.filtergrp_lst = ret[1];
806-
let filterSets = [];
807-
for(let i=0; i< window.cartHist.length;i++) {
808-
filterSets.push(window.cartHist[i]['filter']);
809-
}
810-
filter_and_cart['partitions'] = window.partitions;
811-
filter_and_cart['filtergrp_list'] = filterSets;
788+
let response = null;
789+
if(["cohort", "cart"].includes(download_type)) {
790+
downloader_manager.pendingFetchMessage(download_type);
791+
let filter_and_cart = {};
792+
if (download_type === "cohort") {
793+
let filtergrp_list = [];
794+
for(const [attr, vals] of Object.entries(filterutils.parseFilterObj())) {
795+
filtergrp_list.push({[attr]: vals});
812796
}
813-
response = await fetch(`${BASE_URL}${SERIES_IDS_FILTER_URL}`, {
814-
method: "POST",
815-
body: JSON.stringify(filter_and_cart),
816-
headers: {
817-
"X-CSRFToken": csrftoken,
818-
"content-type": "application/json"
819-
}
820-
});
797+
filter_and_cart["filtergrp_list"] = filtergrp_list;
821798
} else {
822-
let study_uri = (study_id !== undefined && study_id !== null) ? `${study_id}/` : "";
823-
let patient_uri = (patient_id !== undefined && patient_id !== null) ? `${patient_id}/` : "";
824-
response = await fetch(`${BASE_URL}${SERIES_IDS_URL}${collection_id}/${patient_uri}${study_uri}`);
825-
}
826-
if (!response.ok) {
827-
console.error(`[ERROR] Failed to retrieve series IDs: ${response.status}`);
828-
return;
829-
}
830-
const series_data = await response.json();
831-
series.push(...series_data['result']);
832-
if('download_stats' in series_data){
833-
downloader_manager.set_download_stats(series_data['download_stats']);
799+
window.updatePartitionsFromScratch();
800+
let ret = cartutils.formcartdata();
801+
window.partitions = ret[0];
802+
window.filtergrp_lst = ret[1];
803+
let filterSets = [];
804+
for(let i=0; i< window.cartHist.length;i++) {
805+
filterSets.push(window.cartHist[i]['filter']);
806+
}
807+
filter_and_cart['partitions'] = window.partitions;
808+
filter_and_cart['filtergrp_list'] = filterSets;
834809
}
810+
response = await fetch(`${BASE_URL}${SERIES_IDS_FILTER_URL}`, {
811+
method: "POST",
812+
body: JSON.stringify(filter_and_cart),
813+
headers: {
814+
"X-CSRFToken": csrftoken,
815+
"content-type": "application/json"
816+
}
817+
});
818+
} else {
819+
let study_uri = (study_id !== undefined && study_id !== null) ? `${study_id}/` : "";
820+
let patient_uri = (patient_id !== undefined && patient_id !== null) ? `${patient_id}/` : "";
821+
response = await fetch(`${BASE_URL}${SERIES_IDS_URL}${collection_id}/${patient_uri}${study_uri}`);
822+
}
823+
if (!response.ok) {
824+
console.error(`[ERROR] Failed to retrieve series IDs: ${response.status}`);
825+
return;
826+
}
827+
const series_data = await response.json();
828+
series.push(...series_data['result']);
829+
if('download_stats' in series_data){
830+
downloader_manager.set_download_stats(series_data['download_stats']);
835831
}
836832
} else {
837833
series.push({

static/js/explore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ require([
482482
let disabled_messages = {
483483
'download-all-disabled': chromium_only,
484484
'download-size-disabled': "This set of images is over 3TB in size. Please use manifest download to obtain these images.",
485+
'download-count-disabled': "This set of images contains over 65000 records. Please use manifest download to obtain these images.",
485486
'download-cart-disabled': "Add items to the cart to enable this feature.",
486487
'download-cohort-disabled': "Select a filter to enable this feature."
487488
};

static/js/filterutils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ define(['jquery', 'base'], function($, base) {
643643
window.handleFilterSelectionUpdate(null, true, true);
644644
}
645645

646-
647646
window.handleFilterSelectionUpdate = function(filterElem, mkFilt, doUpdate) {
648647
var promise = null
649648
if (!(filterElem ===null)) {

static/js/image_search.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ require([
191191
data.totals.StudyInstanceUID.toString() + " studies (Size on disk: " +
192192
data.totals.disk_size + ")"
193193
);
194-
base.updateDownloadBtns("cohort", true, data.totals.disk_size_tb);
194+
base.updateDownloadBtns("cohort", true, data.totals.disk_size_tb, data.totals.SeriesInstanceUID);
195195
} else if(isFiltered && data.total <= 0) {
196196
$('#search_def_stats').html('<span style="color:red">There are no cases matching the selected set of filters</span>');
197+
base.updateDownloadBtns("cohort", false, 0, 0);
198+
$('.citations-button').attr("disabled","disabled");
199+
$('.citations-button').attr("title", "There are no cases matching the selected set of filters");
197200
} else {
198201
$('#search_def_stats').html("&nbsp;");
199-
base.updateDownloadBtns("cohort", false, 0);
202+
base.updateDownloadBtns("cohort", false, 0, 0);
200203
}
201204

202205
filterutils.updateCollectionTotals('Program', data.programs);

static/js/utils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ 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
44+
// Terabyte and record count warning and cutoffs for download button tooltips and enabling
4545
let DOWNLOAD_SIZE_LIMIT = 3;
4646
let DOWNLOAD_SIZE_WARN = 2;
47+
let DOWNLOAD_COUNT_LIMIT = 65000;
4748

4849
// Download block poll with cookie via StackOverflow:
4950
// https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
@@ -148,8 +149,8 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
148149
// type - string, ID selector subtype for the buttons and tooltips to adjust
149150
// enabled - bool, sets if the button is to be disabled or enabled
150151
// 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
152-
function _updateDownloadBtns(type, enabled, disk_size) {
152+
// requires setting DOWNLOAD_COUNT_LIMIT, DOWNLOAD_SIZE_LIMIT, and DOWNLOAD_SIZE_WARN
153+
function _updateDownloadBtns(type, enabled, disk_size, record_count) {
153154
let btn = $(`#download-${type}-images`);
154155
let btn_tip = $(`#download-${type}-images-tooltips`);
155156
let btn_and_tips = $(`#download-${type}-images-tooltips, #download-${type}-images-tooltips`);
@@ -161,10 +162,10 @@ define(['jquery', 'jqueryui'], function($, jqueryui) {
161162
}
162163
if ("showDirectoryPicker" in window) {
163164
btn_and_tips.removeClass('is-disabled download-all-instances download-size-warning');
164-
if (disk_size > DOWNLOAD_SIZE_LIMIT) {
165+
if (disk_size > DOWNLOAD_SIZE_LIMIT || record_count > DOWNLOAD_COUNT_LIMIT) {
165166
btn_tip.addClass('is-disabled');
166-
btn_tip.attr('data-disabled-type', "download-size-disabled");
167167
btn.attr("disabled", "disabled");
168+
btn_tip.attr('data-disabled-type', (disk_size > DOWNLOAD_SIZE_LIMIT ? "download-size-disabled" : "download-count-disabled"));
168169
} else {
169170
btn.removeAttr("disabled");
170171
btn_tip.attr('data-disabled-type', "");

0 commit comments

Comments
 (0)