Skip to content

Commit 65b5729

Browse files
authored
Merge pull request #483 from ImagingDataCommons/idc-test-sp
Sprint 15
2 parents 2a88f70 + 06004a7 commit 65b5729

File tree

4 files changed

+48
-80
lines changed

4 files changed

+48
-80
lines changed

static/js/cohorts/cohort-details.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@ require([
5555
], function($, jqueryui, base, tippy, bootstrap) {
5656
A11y.Core();
5757

58-
var enable_buttons = function() {
59-
$('#download-csv').removeAttr('disabled');
60-
$('#download-tsv').removeAttr('disabled');
61-
$('#download-json').removeAttr('disabled');
62-
$('#get-bq-table').removeAttr('disabled');
63-
};
64-
6558
var downloadToken = new Date().getTime();
6659

6760
$('#download-csv').on('click', function(e) {
@@ -131,7 +124,7 @@ require([
131124

132125
if(manifest_type == 'file-manifest') {
133126
base.blockResubmit(function () {
134-
enable_buttons();
127+
update_download_manifest_buttons();
135128
$('#manifest-in-progress').modal('hide');
136129
}, downloadToken, 'downloadToken');
137130
}
@@ -194,11 +187,11 @@ require([
194187
}
195188
},
196189
complete: function(xhr, status) {
190+
update_download_manifest_buttons();
197191
$('#manifest-in-progress').modal('hide');
198-
enable_buttons();
199192
$('#export-manifest-modal').modal('hide');
200-
$('input[name="manifest-type"][value="file-manifest"]').triggerHandler('click');
201193
$('#export-manifest-form')[0].reset();
194+
$('#bq-export-option input').prop('checked', true).trigger("click");
202195
}
203196
});
204197
}
@@ -220,12 +213,14 @@ require([
220213
$('#download-csv').attr('disabled', 'disabled');
221214
$('#download-tsv').attr('disabled', 'disabled');
222215
$('#download-json').attr('disabled', 'disabled');
216+
$('#get-bq-table').attr('disabled', 'disabled');
223217
}
224218
else
225219
{
226220
$('#download-csv').removeAttr('disabled');
227221
$('#download-tsv').removeAttr('disabled');
228222
$('#download-json').removeAttr('disabled');
223+
$('#get-bq-table').removeAttr('disabled');
229224
}
230225

231226
if (num_selected_column == 0) {

static/js/image_search.js

Lines changed: 36 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,50 +1669,38 @@ require([
16691669
filtObj = new Object();
16701670
for (ckey in window.filterObj){
16711671
if (ckey ==='Program'){
1672-
16731672
for (ind=0;ind<window.filterObj[ckey].length;ind++){
16741673
program = window.filterObj[ckey][ind];
16751674
if (program in window.projSets){
16761675
if (!('Program.'+program in window.filterObj)){
16771676
collObj= collObj.concat(window.projSets[program]);
16781677
}
1679-
}
1680-
else {
1678+
} else {
16811679
collObj.push(program);
16821680
}
16831681
}
1684-
}
1685-
else if (ckey.startsWith('Program.')){
1682+
} else if (ckey.startsWith('Program.')){
16861683
for (ind=0;ind<window.filterObj[ckey].length;ind++){
16871684
collObj.push(window.filterObj[ckey][ind]);
16881685
}
1689-
}
1690-
else{
1686+
} else {
16911687
nmA = ckey.split('.');
16921688
nm=nmA[nmA.length-1];
16931689
if (nm.endsWith('_rng')){
16941690
if (window.filterObj[ckey].type==='none'){
16951691
nm=nm.replace('_rng','');
1696-
}
1697-
else {
1692+
} else {
16981693
nm = nm.replace('_rng', '_' + window.filterObj[ckey].type);
16991694
}
17001695
if ( ('rng' in window.filterObj[ckey]) && ('none' in window.filterObj[ckey]) ){
17011696
filtObj[nm] = [window.filterObj[ckey]['rng'],'None']
1702-
}
1703-
1704-
else if ('rng' in window.filterObj[ckey]){
1697+
} else if ('rng' in window.filterObj[ckey]){
17051698
filtObj[nm] = window.filterObj[ckey]['rng']
1706-
}
1707-
else if ('none' in window.filterObj[ckey]){
1699+
} else if ('none' in window.filterObj[ckey]){
17081700
noneKey=nm.replace('_rng','');
17091701
filtObj[noneKey]=['None'];
17101702
}
1711-
1712-
1713-
1714-
}
1715-
else {
1703+
} else {
17161704
filtObj[nm] = window.filterObj[ckey];
17171705
}
17181706
}
@@ -1747,11 +1735,19 @@ require([
17471735
if (is_cohort) {
17481736
if (data.file_parts_count > data.display_file_parts_count) {
17491737
$('#file-export-option').prop('title', 'Your cohort exceeds the maximum for download.');
1750-
$('#file-manifest-max-exceeded').show();
17511738
$('#file-export-option input').prop('disabled', 'disabled');
17521739
$('#file-export-option input').prop('checked', false);
1753-
$('#bq-export-option input').prop('checked', true).trigger("click");
1740+
$('#file-manifest').hide();
1741+
if(!user_is_social) {
1742+
$('#need-social-account').show();
1743+
} else {
1744+
$('#file-manifest-max-exceeded').show();
1745+
$('#bq-export-option input').prop('checked', true).trigger("click");
1746+
}
17541747
} else {
1748+
$('#file-manifest-max-exceeded').hide();
1749+
$('#file-manifest').show();
1750+
17551751
var select_box_div = $('#file-part-select-box');
17561752
var select_box = select_box_div.find('select');
17571753
if (data.file_parts_count > 1) {
@@ -2527,12 +2523,8 @@ require([
25272523
filtnm=checkBox.value;
25282524
hasCheckBox = true;
25292525
numCheckBoxes++;
2530-
}
2531-
else
2532-
{
2533-
2526+
} else {
25342527
filtnm=$(filterCat).children('.list-group-sub-item__body, .list-group-item__body, .collection-list')[0].id;
2535-
25362528
if ($(filterCat).children('.list-group-item__heading').children('input:checkbox').length>0) {
25372529
hasCheckBox = true;
25382530
numCheckBoxes++;
@@ -2662,35 +2654,26 @@ require([
26622654

26632655
if (item1 ===item2){
26642656
if ( isSeries && (curInd===0)){
2665-
26662657
var seriesNuma = parseInt( $(a).children()[1].innerText );
26672658
var seriesNumb = parseInt( $(b).children()[1].innerText );
2668-
26692659
if (seriesNuma === seriesNumb){
26702660
return 0;
2671-
}
2672-
else if (((seriesNuma > seriesNumb) )){
2661+
} else if (((seriesNuma > seriesNumb) )){
26732662
return 1;
2674-
}
2675-
else {
2663+
} else {
26762664
return -1;
26772665
}
2678-
}
2679-
else{
2666+
} else {
26802667
return 0;
26812668
}
2682-
}
2683-
2684-
else if (((item1 > item2) && asc) || ((item2 > item1) && !asc)) {
2669+
} else if (((item1 > item2) && asc) || ((item2 > item1) && !asc)) {
26852670
return 1;
2686-
}
2687-
else {
2671+
} else {
26882672
return -1
26892673
}
26902674
});
26912675
$(tbl).find('tbody').append(rowSet);
2692-
}
2693-
2676+
};
26942677

26952678
var filterItemBindings = function (filterId) {
26962679
$('#' + filterId).find('input:checkbox').on('click', function () {
@@ -2803,16 +2786,16 @@ require([
28032786

28042787
}
28052788

2806-
}
2789+
};
28072790

28082791
var addFilterBindings = function(id){
28092792
var filterCats = findFilterCats(id,false);
28102793
for (var i=0;i<filterCats.length;i++){
28112794
filterItemBindings(filterCats[i]);
28122795
}
2813-
}
2796+
};
28142797

2815-
var addSliders = function(id,initialized,hideZeros, parStr){
2798+
var addSliders = function(id,initialized,hideZeros, parStr){
28162799
$('#'+id).find('.list-group-item__body.isQuant').each(function() {
28172800
$(this).find('.more-checks').addClass('hide');
28182801
$(this).find('.less-checks').addClass('hide');
@@ -2828,7 +2811,6 @@ require([
28282811
var wNone = $(this).hasClass('wNone');
28292812
var checked = ($(this).find('.noneBut').length>0) ? $(this).find('.noneBut').find(':input')[0].checked : false;
28302813

2831-
28322814
if (!initialized) {
28332815
var slideDivId = $(this).prop('id') + '_slide';
28342816
curmin = $(this).attr('data-curmin');
@@ -2846,51 +2828,39 @@ require([
28462828
addSlider = false;
28472829
$(this).removeClass('hasSlider');
28482830
//$(this).removeClass('isActive');
2849-
}
2850-
else if (isActive){
2831+
} else if (isActive){
28512832
if (curmin === 'NA') {
28522833
min = lower;
2853-
}
2854-
else {
2834+
} else {
28552835
min = Math.min(lower, Math.floor(curmin));
28562836
}
28572837
if (curmax === 'NA'){
28582838
max = upper;
2859-
}
2860-
else {
2839+
} else {
28612840
max = Math.max(upper, Math.ceil(curmax));
28622841
}
2863-
2864-
}
2865-
else{
2842+
} else {
28662843
min = Math.floor(curmin);
28672844
max = Math.ceil(curmax);
28682845
lower=min;
28692846
upper=max;
28702847
//$(this).attr('data-curminrng', lower);
28712848
//$(this).attr('data-curmaxrng', upper);
2872-
}
28732849
}
2874-
2875-
else if (!isActive){
2850+
} else if (!isActive){
28762851
lower=min;
28772852
upper=max;
28782853
//$(this).attr('data-curminrng', lower);
28792854
//$(this).attr('data-curmaxrng', upper);
28802855
}
2881-
2882-
28832856
}
28842857

2885-
28862858
if (addSlider) {
28872859
$(this).addClass('hasSlider');
28882860
mkSlider($(this).prop('id'), min, max, 1, true, wNone, parStr, $(this).data('filter-attr-id'), $(this).data('filter-display-attr'), lower, upper, isActive,checked);
2889-
}
2890-
else{
2861+
} else{
28912862
$(this).removeClass('hasSlider');
28922863
//$(this).removeClass('isActive');
2893-
28942864
}
28952865
});
28962866
};
@@ -2952,10 +2922,8 @@ require([
29522922
// For collection list
29532923
$('.collection-list').each(function() {
29542924
var $group = $(this);
2955-
29562925
var checkboxes = $group.find("input:checked");
2957-
if (checkboxes.length > 0)
2958-
{
2926+
if (checkboxes.length > 0) {
29592927
var values = [];
29602928
var my_id = "";
29612929
checkboxes.each(function() {
@@ -3040,7 +3008,6 @@ require([
30403008
var cohort_loaded = false;
30413009
function load_preset_filters() {
30423010
if (is_cohort && !cohort_loaded) {
3043-
console.debug("Unloaded cohort found, loading...");
30443011
var loadPending = load_filters(cohort_filters);
30453012
loadPending.done(function () {
30463013
console.debug("Load pending complete.");
@@ -3060,7 +3027,7 @@ require([
30603027
} else if (Object.keys(filters_for_load).length > 0) {
30613028
var loadPending = load_filters(filters_for_load);
30623029
loadPending.done(function () {
3063-
console.debug("External filter load done.");
3030+
//console.debug("External filter load done.");
30643031
});
30653032
} else {
30663033
// check for localStorage key of saved filters from a login
@@ -3070,7 +3037,7 @@ require([
30703037
if (has_sliders) {
30713038
let loadPending = load_sliders(ANONYMOUS_SLIDERS, !has_filters);
30723039
loadPending.done(function () {
3073-
console.debug("Sliders loaded from anonymous login.");
3040+
//console.debug("Sliders loaded from anonymous login.");
30743041
});
30753042
}
30763043
if (has_filters) {

templates/cohorts/cohort_details.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ <h3 class="pull-left" role="heading" aria-level="1">Cohort Name: {{ cohort.name
8585
<script>
8686
var cohort_filters = {{ cohort_filters|safe }};
8787
var is_cohort = true;
88-
var collection_tooltips = {{ collection_tooltips|safe }};
8988
var cohort_version = "{{ cohort_version|safe }}";
9089
var cohort_id = "{{ cohort_id|safe }}";
90+
var user_is_social = {% if is_social %}true{% else %}false{% endif %};
91+
var collection_tooltips = {{ collection_tooltips|safe }};
9192
</script>
9293
<script type="text/javascript" src="{% static 'js/libs/d3.v5.min.js' %}"></script>
9394
{{ block.super }}

templates/cohorts/export-manifest-modal.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ <h4 class="modal-title" id="exportManifestModal">Export Cohort Manifest</h4>
2222
<button type="button" class="close" data-hide="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
2323
Your manifest is too large to be downloaded. Please use our BigQuery export option. (This requires a Google Account login.)
2424
</div>
25+
<div id="need-social-account" class="alert alert-warning alert-dismissable" style="display: none;">
26+
<button type="button" class="close" data-hide="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
27+
Your cohort exceeds the maximum size allowed for download, but your account doesn't appear to be a linked Google account.
28+
A Google linked account is required for BigQuery table export.
29+
</div>
2530
</div>
2631
</div>
2732

0 commit comments

Comments
 (0)