diff --git a/frontend/src/components/Results/BiosamplesResults/TableResultsBiosamples.js b/frontend/src/components/Results/BiosamplesResults/TableResultsBiosamples.js index ed11658..73b82b1 100644 --- a/frontend/src/components/Results/BiosamplesResults/TableResultsBiosamples.js +++ b/frontend/src/components/Results/BiosamplesResults/TableResultsBiosamples.js @@ -20,7 +20,7 @@ function TableResultsBiosamples (props) { const [showCrossQuery, setShowCrossQuery] = useState(false) const [parameterCrossQuery, setParamCrossQuery] = useState('') const [expandedRows, setExpandedRows] = useState( - new Array(props.beaconsList.length).fill(false) + Array.from({ length: props.beaconsList.length }, (_, index) => index) ) const [currentPage, setCurrentPage] = useState(1) const [rowsPerPage] = useState(10) // You can make this dynamic if needed @@ -827,10 +827,9 @@ function TableResultsBiosamples (props) { return (
{showDatsets === true && - props.results.length > 0 && props.beaconsList.map((result, beaconIndex) => { return ( - +
@@ -839,91 +838,127 @@ function TableResultsBiosamples (props) { - {props.resultsPerDataset.map((dataset, index2) => ( - + {props.results.length > 0 && + props.resultsPerDataset.map((dataset, index2) => { + const totalCount = dataset[3] + ? dataset[3].reduce((acc, count) => acc + count, 0) + : 0 + const allTrue = dataset[2] + ? dataset[2].every(booleanElement => booleanElement) + : 'No, sorry' + + return ( + + toggleRow(index2)} + > + + + + + {expandedRows.includes(index2) && ( + + {props.show === 'boolean' && + dataset[2].map((booleanElement, booleanIndex) => ( + + + + + + ))} + {props.show === 'count' && + dataset[3].map((countElement, countIndex) => ( + + + + + + ))} + + )} + + ) + })} + {props.results.length === 0 && ( + toggleRow(index2)} + onClick={() => toggleRow(beaconIndex)} > - + + + {props.show === 'boolean' && ( + + )} + {props.show === 'count' && ( + + )} - {expandedRows.includes(index2) && ( - - {props.show === 'boolean' && - dataset[2].map((booleanElement, booleanIndex) => ( - - - - - - ))} - {props.show === 'count' && - dataset[3].map((countElement, countIndex) => ( - - - - - - ))} - - )} - ))} + )}
Beacon
+ {dataset[0]} + {expandedRows.includes(index2) ? ( + + ) : ( + + )} + + {props.show === 'boolean' + ? allTrue + ? 'YES' + : 'No, sorry' + : totalCount} +
+ {dataset[1][booleanIndex]} + + {booleanElement ? 'YES' : 'No, sorry'} +
+ {dataset[1][countIndex]} + + {countElement} +
- {dataset[0]} - {expandedRows.includes(index2) ? ( - - ) : ( - - )} - {result.id} + No, sorry + 0 results
- {dataset[1][booleanIndex]} - - {booleanElement ? 'YES' : 'No, sorry'} -
- {dataset[1][countIndex]} - - {countElement} -
) })} - {showDatsets === true && props.results.length === 0 && ( -
- No results, sorry. Please check the connection and retry -
- )} - {!showCrossQuery && showDatsets === false && props.results.length > 0 && @@ -1642,11 +1677,13 @@ function TableResultsBiosamples (props) {
)} + {props.show === 'full' && props.results.length === 0 && !showCrossQuery && (
No results, sorry.
)} + {showCrossQuery && ( index) ) const [currentPage, setCurrentPage] = useState(1) const [rowsPerPage] = useState(10) // You can make this dynamic if needed @@ -253,6 +253,7 @@ function TableResultsVariants (props) { console.log(e.target.innerText.trim()) setParamCrossQuery(e.target.innerText) } + const toggleRow = index => { setExpandedRows(prevState => { const currentIndex = prevState.indexOf(index) @@ -480,10 +481,9 @@ function TableResultsVariants (props) { return (
{showDatsets === true && - props.results.length > 0 && - props.beaconsList.map((result, beaconIndex) => { + props.beaconsList.map((result, beaconIndex) => { return ( - +
@@ -492,411 +492,481 @@ function TableResultsVariants (props) { - {props.resultsPerDataset.map((dataset, index2) => ( - + {props.results.length > 0 && + props.resultsPerDataset.map((dataset, index2) => { + const totalCount = dataset[3] + ? dataset[3].reduce((acc, count) => acc + count, 0) + : 0 + const allTrue = dataset[2] + ? dataset[2].every(booleanElement => booleanElement) + : 'No, sorry' + + return ( + + toggleRow(index2)} + > + + + + + {expandedRows.includes(index2) && ( + + {props.show === 'boolean' && + dataset[2].map((booleanElement, booleanIndex) => ( + + + + + + ))} + {props.show === 'count' && + dataset[3].map((countElement, countIndex) => ( + + + + + + ))} + + )} + + ) + })} + {props.results.length === 0 && ( + toggleRow(index2)} + onClick={() => toggleRow(beaconIndex)} > - + + + {props.show === 'boolean' && ( + + )} + {props.show === 'count' && ( + + )} - {expandedRows.includes(index2) && ( - - {props.show === 'boolean' && - dataset[2].map((booleanElement, booleanIndex) => ( - - - - - - ))} - {props.show === 'count' && - dataset[3].map((countElement, countIndex) => ( - - - - - - ))} - - )} - ))} + )}
Beacon
+ {dataset[0]} + {expandedRows.includes(index2) ? ( + + ) : ( + + )} + + {props.show === 'boolean' + ? allTrue + ? 'YES' + : 'No, sorry' + : totalCount} +
+ {dataset[1][booleanIndex]} + + {booleanElement ? 'YES' : 'No, sorry'} +
+ {dataset[1][countIndex]} + + {countElement} +
- {dataset[0]} - {expandedRows.includes(index2) ? ( - - ) : ( - - )} - {result.id} + No, sorry + 0 results
- {dataset[1][booleanIndex]} - - {booleanElement ? 'YES' : 'No, sorry'} -
- {dataset[1][countIndex]} - - {countElement} -
) })} - {showDatsets === true && props.results.length === 0 && ( -
- No results, sorry. Please check the connection and retry -
- )} - {!showCrossQuery && showDatsets === false && props.results.length > 0 && showResults === true && ( -
-
-
- - {exportMenuVisible && ( - <> -
    -
  • Export to JSON
  • -
  • Export to CSV
  • -
- - )} -
-
- - {menuVisible && ( - <> -
    -
  • - Show All Columns - -
  • - {Object.keys(columnVisibility).map(column => ( -
  • toggleColumnVisibility(column)} - > - {column} - {columnVisibility[column] ? : } + + {!showCrossQuery && + showDatsets === false && + props.results.length > 0 && + showResults === true && ( +
    +
    +
    + + {exportMenuVisible && ( + <> +
      +
    • Export to JSON
    • +
    • Export to CSV
    • +
    + + )} +
    +
    + + {menuVisible && ( + <> +
      +
    • + Show All Columns +
    • - ))} -
    - - )} + {Object.keys(columnVisibility).map(column => ( +
  • toggleColumnVisibility(column)} + > + {column} + {columnVisibility[column] ? ( + + ) : ( + + )} +
  • + ))} +
+ + )} +
-
-
- - - - - - - - - - - - - - {/* Add more column headers here */} - - -
- Variant ID - - handleFilterChange(e, 'variantInternalId')} - /> - - Variation - - handleFilterChange(e, 'variation')} - /> - - Beacon - - handleFilterChange(e, 'Beacon')} - /> - - Identifiers - - handleFilterChange(e, 'identifiers')} - /> - - Molecular Attributes - - - handleFilterChange(e, 'molecularAttributes') - } - /> - - Molecular Effects - - handleFilterChange(e, 'molecularEffects')} - /> - - Case Level Data - - handleFilterChange(e, 'caseLevelData')} - /> - - Variant Level Data - - handleFilterChange(e, 'variantLevelData')} - /> - - Frequency In Populations - - - handleFilterChange(e, 'frequencyInPopulations') - } - /> -
-
-
- - - {currentRows.map((row, index) => ( - -
+ + + + + + {/* Add more column headers here */} - ))} - -
- {row.variantInternalId} - - Variant ID + + + handleFilterChange(e, 'variantInternalId') + } + /> + + - {row.variation} - - Variation + + handleFilterChange(e, 'variation')} + /> + + - {row.Beacon} - - Beacon + + handleFilterChange(e, 'Beacon')} + /> + + - {row.identifiers} - - Identifiers + + handleFilterChange(e, 'identifiers')} + /> + + - {row.molecularAttributes} - - Molecular Attributes + + + handleFilterChange(e, 'molecularAttributes') + } + /> + + - {row.molecularEffects} - - Molecular Effects + + + handleFilterChange(e, 'molecularEffects') + } + /> + + - {row.caseLevelData} - - Case Level Data + + handleFilterChange(e, 'caseLevelData')} + /> + + - {row.variantLevelData} - - Variant Level Data + + + handleFilterChange(e, 'variantLevelData') + } + /> + + - {row.frequencyInPopulations} - - - {/* Render other row cells here */} + Frequency In Populations + + + handleFilterChange(e, 'frequencyInPopulations') + } + /> +
+ +
+
+
+ + + {currentRows.map((row, index) => ( + + + + + + + + + + + + {/* Render other row cells here */} + + ))} + +
+ {row.variantInternalId} + + {row.variation} + + {row.Beacon} + + {row.identifiers} + + {row.molecularAttributes} + + {row.molecularEffects} + + {row.caseLevelData} + + {row.variantLevelData} + + {row.frequencyInPopulations} +
+
- - )} + )} + {props.show === 'full' && !showCrossQuery && props.results.length > 0 && (
)} + {props.show === 'full' && props.results.length === 0 && !showCrossQuery && (
No results, sorry.
)} + {showCrossQuery && (