Skip to content

Commit

Permalink
fixed resultsets per dataset individuals
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemma committed Dec 29, 2023
1 parent b7373a4 commit c445249
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 75 deletions.
8 changes: 7 additions & 1 deletion frontend/src/components/GenomicVariations/VariantsResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ function VariantsResults (props) {
}

if (token === null) {
console.log(jsonData1)
res = await axios.post(
configData.API_URL + '/g_variants',
jsonData1
)

console.log(res)
} else {
const headers = { Authorization: `Bearer ${token}` }

Expand Down Expand Up @@ -298,9 +301,9 @@ function VariantsResults (props) {
}
}
} catch (error) {
setError('Connection error. Please retry')
setTimeOut(true)
console.log(error)
setError(error)
}
}
apiCall()
Expand Down Expand Up @@ -379,6 +382,9 @@ function VariantsResults (props) {
)}
</div>
)}
{timeOut && error === 'Connection error. Please retry' && (
<h3>&nbsp; {error} </h3>
)}
</div>
)}
</div>
Expand Down
71 changes: 54 additions & 17 deletions frontend/src/components/Individuals/IndividualsResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,34 @@ function IndividualsResults (props) {
setBoolean(false)
} else {
res.data.response.resultSets.forEach((element, index) => {
console.log(res.data.response)
if (element.id && element.id !== '') {
let arrayResultsPerDataset = [
element.beaconId,
element.id,
element.exists,
element.resultsCount
]
resultsPerDataset.push(arrayResultsPerDataset)
if (resultsPerDataset.length > 0) {
resultsPerDataset.forEach(element2 => {
if (element2[0] === element.beaconId) {
element2[1].push(element.id)
element2[2].push(element.exists)
element2[3].push(element.resultsCounts)
} else {
console.log('hola')
let arrayResultsPerDataset = [
element.beaconId,
[element.id],
[element.exists],
[element.resultsCount]
]
resultsPerDataset.push(arrayResultsPerDataset)
}
})
} else {
let arrayResultsPerDataset = [
element.beaconId,
[element.id],
[element.exists],
[element.resultsCount]
]
resultsPerDataset.push(arrayResultsPerDataset)
}
}

if (element.id === undefined || element.id === '') {
Expand All @@ -238,9 +258,6 @@ function IndividualsResults (props) {
}
})
}



} else {
var jsonData2 = {
meta: {
Expand Down Expand Up @@ -292,14 +309,34 @@ function IndividualsResults (props) {
setBoolean(false)
} else {
res.data.response.resultSets.forEach((element, index) => {
console.log(res.data.response)
if (element.id && element.id !== '') {
let arrayResultsPerDataset = [
element.beaconId,
element.id,
element.exists,
element.resultsCount
]
resultsPerDataset.push(arrayResultsPerDataset)
if (resultsPerDataset.length > 0) {
resultsPerDataset.forEach(element2 => {
if (element2[0] === element.beaconId) {
element2[1].push(element.id)
element2[2].push(element.exists)
element2[3].push(element.resultsCounts)
} else {
console.log('hola')
let arrayResultsPerDataset = [
element.beaconId,
[element.id],
[element.exists],
[element.resultsCount]
]
resultsPerDataset.push(arrayResultsPerDataset)
}
})
} else {
let arrayResultsPerDataset = [
element.beaconId,
[element.id],
[element.exists],
[element.resultsCount]
]
resultsPerDataset.push(arrayResultsPerDataset)
}
}

if (element.id === undefined || element.id === '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function TableResultsIndividuals (props) {
sex: stringSex,
diseases: diseases
})

if (index === resultsSelectedFinal.length - 1) {
setEditable(rows.map(o => ({ ...o })))
setTrigger2(true)
Expand All @@ -358,7 +358,9 @@ function TableResultsIndividuals (props) {
}, [trigger, resultsSelectedFinal])

useEffect(() => {

console.log(props.resultsPerDataset)
console.log(props.beaconsList)
console.log(arrayBeaconsIds)
let count = 0
props.beaconsList.forEach((element2, index2) => {
count = getOccurrence(arrayBeaconsIds, element2.meta.beaconId)
Expand Down Expand Up @@ -390,40 +392,56 @@ function TableResultsIndividuals (props) {
return (
<>
{props.show !== 'full' && (
<div className='datasetCardResults'>
<div className='tittleResults'>
<div className='tittle4'>
<img
className='logoBeacon'
src={result[0].response.organization.logoUrl}
alt={result[0].meta.beaconId}
/>
<h4>{result[0].response.organization.name}</h4>
</div>

<>
{props.resultsPerDataset.map((element, index) => {
return (
<>
{element[0] === result[0].meta.beaconId && (
<div className='resultSetsContainer'>
<button
className='resultSetsButton'
onClick={() => handleClickDatasets(index)}
>
<h7>{element[1].replaceAll('_', ' ')}</h7>
</button>
{openDatasetArray[index] === true &&
triggerArray[index] === true &&
element[2] === true &&
props.show === 'boolean' && <h6>FOUND</h6>}
{openDatasetArray[index] === true &&
triggerArray[index] === true &&
element[2] === false &&
props.show === 'boolean' && <h5>NOT FOUND</h5>}
{props.show === 'count' &&
triggerArray[index] === true && (
<h6>{element[3]}</h6>
)}
<div className='datasetCardResults'>
<div className='tittleResults'>
<div className='tittle4'>
<img
className='logoBeacon'
src={
result[0].response.organization.logoUrl
}
alt={result[0].meta.beaconId}
/>
<h4>
{result[0].response.organization.name}
</h4>
</div>

{element[1].map((datasetObject, indexDataset) => {
return (

<div className='resultSetsContainer'>
<button
className='resultSetsButton'
onClick={() => handleClickDatasets(indexDataset)}
>
<h7>{datasetObject.replaceAll('_', ' ')}</h7>
</button>
{openDatasetArray[indexDataset] === true &&
triggerArray[indexDataset] === true &&
element[2][indexDataset] === true &&
props.show === 'boolean' && <h6>FOUND</h6>}
{openDatasetArray[indexDataset] === true &&
triggerArray[indexDataset] === true &&
element[2][indexDataset] === false &&
props.show === 'boolean' && (
<h5>NOT FOUND</h5>
)}
{props.show === 'count' &&
triggerArray[index] === true && (
<h6>{element[3][indexDataset]}</h6>
)}
</div>
)
})}


</div>
</div>
)}
</>
Expand All @@ -436,44 +454,93 @@ function TableResultsIndividuals (props) {
{result[2] === true &&
props.show === 'boolean' &&
element[0] === result[0].meta.beaconId && (
<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h6>FOUND </h6>
<div className='datasetCardResults'>
<div className='tittleResults'>
<div className='tittle4'>
<img
className='logoBeacon'
src={
result[0].response.organization.logoUrl
}
alt={result[0].meta.beaconId}
/>
<h4>
{result[0].response.organization.name}
</h4>
</div>

<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h6>FOUND </h6>
</div>
</div>
</div>
)}
{result[2] === false &&
props.show === 'boolean' &&
element[0] === result[0].meta.beaconId && (
<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h5 className='buttonResults'>NOT FOUND</h5>
<div className='datasetCardResults'>
<div className='tittleResults'>
<div className='tittle4'>
<img
className='logoBeacon'
src={
result[0].response.organization.logoUrl
}
alt={result[0].meta.beaconId}
/>
<h4>
{result[0].response.organization.name}
</h4>
</div>
<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h5 className='buttonResults'>NOT FOUND</h5>
</div>
</div>
</div>
)}

{props.show === 'count' &&
element[0] === result[0].meta.beaconId && (
<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h6 className='buttonResults'>
{result[1]} results
</h6>
<div className='datasetCardResults'>
<div className='tittleResults'>
<div className='tittle4'>
<img
className='logoBeacon'
src={
result[0].response.organization.logoUrl
}
alt={result[0].meta.beaconId}
/>
<h4>
{result[0].response.organization.name}
</h4>
</div>
<div className='resultSetsContainer'>
<h7>No datasets available</h7>
<h6 className='buttonResults'>
{result[1]} results
</h6>
</div>
<button
className='buttonResults'
onClick={() => {
handleSeeResults(result[0].meta.beaconId)
}}
>
{result[2] === true &&
props.show === 'full' && (
<h7>See results</h7>
)}
</button>
</div>
</div>
)}
</>
)
})}

<button
className='buttonResults'
onClick={() => {
handleSeeResults(result[0].meta.beaconId)
}}
>
{result[2] === true && props.show === 'full' && (
<h7>See results</h7>
)}
</button>
</div>
</div>
</>
)}
{props.show === 'full' && result[2] === true && (
<div className='datasetCardResults'>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"API_URL": "https://beacon-network-backend-test.ega-archive.org/beacon-network/v2.0.0",
"API_URL": "https://beacons.bsc.es/beacon-network/v2.0.0",
"REDIRECT_URL": "http://localhost:3000/",
"KEYCLOAK_URL": "https://beacon-network-demo2.ega-archive.org"
}

0 comments on commit c445249

Please sign in to comment.