Skip to content

Commit

Permalink
Merge pull request #1892 from 4dn-dcic/select_all_button
Browse files Browse the repository at this point in the history
Bug Fix - "Select All" button not turns into "Deselect All" in /browse
  • Loading branch information
utku-ozturk authored May 27, 2024
2 parents cd3f396 + d2c0472 commit 13b6e02
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ fourfront
Change Log
----------

7.5.5
=====

* bug fix - button "Select All" not turns into "Deselect All" in /browse after QuickInfoBar updates in 7.5.0


7.5.4
=====

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
# Note: Various modules refer to this system as "encoded", not "fourfront".
name = "encoded"
version = "7.5.4"
version = "7.5.5"
description = "4DN-DCIC Fourfront"
authors = ["4DN-DCIC Team <[email protected]>"]
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,21 @@ export class SelectAllFilesButton extends React.PureComponent {
}

render(){
const { totalOPFCount } = this.props;
const { selecting } = this.state;
const isAllSelected = this.isAllSelected();
const isEnabled = this.isEnabled();
const iconClassName = (
"mr-05 icon icon-fw icon-" + (selecting ? 'circle-notch icon-spin fas' : (isAllSelected ? 'square far' : 'check-square far'))
);
const cls = "btn " + (isAllSelected ? "btn-outline-primary" : "btn-primary");
const tooltip = (!isAllSelected && !isEnabled) ? `"Select All" is disabled since the total file count exceeds the upper limit: ${SELECT_ALL_LIMIT}` : null;

let tooltip = null;
if (!isAllSelected && !isEnabled) {
tooltip = `"Select All" is disabled since the total file count exceeds the upper limit: ${SELECT_ALL_LIMIT}`;
} else if (!isAllSelected) {
tooltip = 'Select All Files' + (totalOPFCount ? ` - please note that Supplementary files (${totalOPFCount}) will not be included in the selection` : '');
}

return (
<div className="pull-left box selection-buttons">
Expand Down Expand Up @@ -288,22 +295,25 @@ export const SelectedFilesControls = React.memo(function SelectedFilesControls(p
} = props;
const selectedFileProps = SelectedFilesController.pick(props);

let totalUniqueFilesCount;
let totalUniqueFilesCount = 0, totalUniqueOPFCount = 0;
if (Array.isArray(context['@type']) && context['@type'].indexOf('FileSearchResults') > -1) {
totalUniqueFilesCount = context.total || 0;
} else {
const barPlotData = (barplot_data_filtered || barplot_data_unfiltered);
// This gets unique file count from ES aggs. In future we might be able to get total including
// duplicates, in which case should change up logic downstream from this component for e.g. `isAllSelected`
// in SelectAllFilesButton & similar.
totalUniqueFilesCount = (barPlotData && barPlotData.total && barPlotData.total.files) || 0;
if (barPlotData && barPlotData.total) {
totalUniqueFilesCount = barPlotData.total.files || 0;
totalUniqueOPFCount = barPlotData.total.files_opf || 0;
}
}

return (
// This rendered within a row by AboveTableControlsBase.js
// TODO maybe refactor some of this stuff to be simpler.
<div className="col">
<SelectAllFilesButton {...selectedFileProps} {...{ href, context }} totalFilesCount={totalUniqueFilesCount} />
<SelectAllFilesButton {...selectedFileProps} {...{ href, context }} totalFilesCount={totalUniqueFilesCount} totalOPFCount={totalUniqueOPFCount} />
<div className="pull-left box selection-buttons">
<div className="btn-group">
<BrowseViewSelectedFilesDownloadButton {...{ selectedFiles, subSelectedFiles, context, session }} totalFilesCount={totalUniqueFilesCount} />
Expand Down
8 changes: 5 additions & 3 deletions src/encoded/static/components/viz/QuickInfoBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,26 +273,28 @@ const StatsCol = React.memo(function StatsCol(props){
const { total, current } = QuickInfoBar.getCountsFromProps(props);
const expSetFilters = QuickInfoBar.expSetFilters((context && context.filters) || null, navigate.getBrowseBaseParams(browseBaseState));

const totalFilesIncludingOPF = (total.files || 0) + (total.files_opf || 0);
const currentFilesIncludingOPF = current ? (current.files || 0) + (current.files_opf || 0) : 0;
let stats;
if (current && (typeof current.experiment_sets === 'number' || typeof current.experiments === 'number' || typeof current.files === 'number')) {
stats = {
'experiment_sets' : <span>{ current.experiment_sets }<small> / { total.experiment_sets || 0 }</small></span>,
'experiments' : <span>{ current.experiments }<small> / {total.experiments || 0}</small></span>,
'files' : <span>{ current.files }<small> / {total.files || 0}</small></span>
'files' : <span>{ currentFilesIncludingOPF }<small> / { totalFilesIncludingOPF }</small></span>
};
} else {
stats = {
'experiment_sets' : total.experiment_sets || 0,
'experiments' : total.experiments || 0,
'files' : total.files || 0
'files' : totalFilesIncludingOPF
};
}
const statProps = _.extend(_.pick(props, 'id', 'href', 'isLoadingChartData', 'browseBaseState'), { 'expSetFilters' : expSetFilters });
return (
<div className="col-8 left-side clearfix">
<Stat {...statProps} shortLabel="Experiment Sets" longLabel="Experiment Sets" classNameID="expsets" value={stats.experiment_sets} key="expsets" />
<Stat {...statProps} shortLabel="Experiments" longLabel="Experiments" classNameID="experiments" value={stats.experiments} key="experiments" />
<Stat {...statProps} shortLabel="Files" longLabel="Files in Experiments" classNameID="files" value={stats.files} key="files" />
<Stat {...statProps} shortLabel="Files" longLabel="Raw, Processed and Supplementary Files in Experiments" classNameID="files" value={stats.files} key="files" />
<div className={"any-filters glance-label" + (show ? " showing" : "")} data-tip={anyFiltersSet ? "Filtered" : "No Filters Set"}
onMouseEnter={onIconMouseEnter}>
<i className="icon icon-filter fas" style={{ 'opacity' : anyFiltersSet ? 1 : 0.25 }} />
Expand Down
30 changes: 20 additions & 10 deletions src/encoded/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,18 @@ def trace_workflow_runs(context, request):
"buckets_path": {
"expSetProcessedFiles": "total_expset_processed_files",
"expProcessedFiles": "total_exp_processed_files",
"expRawFiles": "total_exp_raw_files"
},
"script" : "params.expSetProcessedFiles + params.expProcessedFiles + params.expRawFiles"
}
},
"total_opf_files" : {
"bucket_script" : {
"buckets_path": {
"expSetOtherProcessedFiles": "total_expset_other_processed_files",
"expOtherProcessedFiles": "total_exp_other_processed_files",
"expRawFiles": "total_exp_raw_files"
},
"script" : "params.expSetProcessedFiles + params.expProcessedFiles + params.expSetOtherProcessedFiles + params.expOtherProcessedFiles + params.expRawFiles"
"script" : "params.expSetOtherProcessedFiles + params.expOtherProcessedFiles"
}
},
"total_experiments" : {
Expand Down Expand Up @@ -252,6 +259,7 @@ def bar_plot_chart(context, request):

primary_agg.update(deepcopy(SUM_FILES_EXPS_AGGREGATION_DEFINITION))
del primary_agg['total_files'] # "bucket_script" not supported on root-level aggs
del primary_agg['total_opf_files'] # "bucket_script" not supported on root-level aggs

# Nest in additional fields, if any
curr_field_aggs = primary_agg['field_0']['aggs']
Expand All @@ -278,19 +286,20 @@ def bar_plot_chart(context, request):
continue
del search_result[field_to_delete]

raw_and_processed_count = (search_result['aggregations']['total_expset_processed_files']['value'] +
search_result['aggregations']['total_exp_raw_files']['value'] +
search_result['aggregations']['total_exp_processed_files']['value'])
opf_count = (search_result['aggregations']['total_expset_other_processed_files']['value'] +
search_result['aggregations']['total_exp_other_processed_files']['value'])

ret_result = { # We will fill up the "terms" here from our search_result buckets and then return this dictionary.
"field": fields_to_aggregate_for[0],
"terms": {},
"total": {
"experiment_sets": search_result['total'],
"experiments": search_result['aggregations']['total_experiments']['value'],
"files": (
search_result['aggregations']['total_expset_processed_files']['value'] +
search_result['aggregations']['total_exp_raw_files']['value'] +
search_result['aggregations']['total_exp_processed_files']['value'] +
search_result['aggregations']['total_expset_other_processed_files']['value'] +
search_result['aggregations']['total_exp_other_processed_files']['value']
)
"files": raw_and_processed_count,
"files_opf": opf_count
},
"other_doc_count": search_result['aggregations']['field_0'].get('sum_other_doc_count', 0),
"time_generated": str(datetime.utcnow())
Expand All @@ -301,7 +310,8 @@ def format_bucket_result(bucket_result, returned_buckets, curr_field_depth = 0):
curr_bucket_totals = {
'experiment_sets' : int(bucket_result['doc_count']),
'experiments' : int(bucket_result['total_experiments']['value']),
'files' : int(bucket_result['total_files']['value'])
'files' : int(bucket_result['total_files']['value']),
'files_opf' : int(bucket_result['total_opf_files']['value'])
}

next_field_name = None
Expand Down

0 comments on commit 13b6e02

Please sign in to comment.