Skip to content

Commit

Permalink
bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemma committed Mar 25, 2024
1 parent 8645816 commit f267b8c
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 79 deletions.
206 changes: 133 additions & 73 deletions frontend/src/components/Datasets/ResultsDatasets.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,138 @@

import './ResultsDatasets.css'
import axios from "axios";
import { useState, useEffect } from 'react';
import configData from "../../config.json";

function ResultsDatasets(props) {

const [resp, setResponse] = useState([])

const [trigger, setTrigger] = useState(false)


useEffect(() => {

const apiCall = async () => {

try {
let res = await axios.get(configData.API_URL +'/info')
res.data.responses.forEach(element => {
resp.push(element)
});
setTrigger(true)
import axios from 'axios'
import { useState, useEffect } from 'react'
import configData from '../../config.json'

function ResultsDatasets (props) {
const [resp, setResponse] = useState([])

const [trigger, setTrigger] = useState(false)

useEffect(() => {
const apiCall = async () => {
try {
let res = await axios.get(configData.API_URL + '/info')
res.data.responses.forEach(element => {
resp.push(element)
})
setTrigger(true)

resp.forEach((element, index) => {
if (element.meta.beaconId === 'org.ega-archive.ga4gh-approval-beacon-test'){
resp.splice(index, 1)
resp.push(element)
resp.reverse()
} catch (error) {
console.log(error)
}
}
apiCall()

}, [props.trigger])

return (

<div className='resultsRecord'>

{resp.map((result) => {
return (
<div className="datasetCard">
<div className='tittle'>
<div className="tittle2">
<img className="logoBeacon" src={result.response.organization.logoUrl} alt={result.meta.beaconId} />
<h1>{result.response.name}</h1>
</div>
<h2>{result.response.organization.name}</h2>
</div>
<hr className='line'></hr>
{!result.response.description.includes('<a href') && <p>{result.response.description}</p>}
{result.response.description.includes('<a href') && <p dangerouslySetInnerHTML={{__html: result.response.description}}/>}
<div className="linksBeacons">
{result.meta.beaconId === 'org.ega-archive.ga4gh-approval-beacon-test' &&
<a href="https://beacon-apis-demo.ega-archive.org/api" target="_blank" rel="noreferrer" >Beacon API</a>}
{result.meta.beaconId === 'es.elixir.bsc.beacon' &&
<a href="https://beacons.bsc.es/beacon/v2.0.0/" target="_blank" rel="noreferrer" >Beacon API</a>}
{result.meta.beaconId === 'org.progenetix' &&
<a href="https://beaconplus.progenetix.org/" target="_blank" rel="noreferrer">Beacon API</a>}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' && result.meta.beaconId !== 'org.progenetix' && result.meta.beaconId !== 'org.ega-archive.ga4gh-approval-beacon-test' &&
<a href={result.response.alternativeUrl} target="_blank" rel="noreferrer">Beacon API</a>}
{result.meta.beaconId === 'es.elixir.bsc.beacon' &&
<a href="https://www.bsc.es/" target="_blank" rel="noreferrer">Visit us</a>}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' &&
<a href={result.response.organization.welcomeUrl} target="_blank" rel="noreferrer">Visit us</a>}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' &&
<a href={result.response.organization.contactUrl} target="_blank" rel="noreferrer">Contact us</a>}
{result.meta.beaconId === 'es.elixir.bsc.beacon' &&
<a href="mailto:[email protected]" target="_blank" rel="noreferrer">Contact us</a>}
</div>
</div>
)

})}

</div>
)

})
} catch (error) {
console.log(error)
}
}
apiCall()
}, [props.trigger])

return (
<div className='resultsRecord'>
{resp.map(result => {
return (
<div className='datasetCard'>
<div className='tittle'>
<div className='tittle2'>
<img
className='logoBeacon'
src={result.response.organization.logoUrl}
alt={result.meta.beaconId}
/>
<h1>{result.response.name}</h1>
</div>
<h2>{result.response.organization.name}</h2>
</div>
<hr className='line'></hr>
{!result.response.description.includes('<a href') && (
<p>{result.response.description}</p>
)}
{result.response.description.includes('<a href') && (
<p
dangerouslySetInnerHTML={{
__html: result.response.description
}}
/>
)}
<div className='linksBeacons'>
{result.meta.beaconId ===
'org.ega-archive.ga4gh-approval-beacon-test' && (
<a
href='https://beacon-apis-demo.ega-archive.org/api'
target='_blank'
rel='noreferrer'
>
Beacon API
</a>
)}
{result.meta.beaconId === 'es.elixir.bsc.beacon' && (
<a
href='https://beacons.bsc.es/beacon/v2.0.0/'
target='_blank'
rel='noreferrer'
>
Beacon API
</a>
)}
{result.meta.beaconId === 'org.progenetix' && (
<a
href='https://beaconplus.progenetix.org/'
target='_blank'
rel='noreferrer'
>
Beacon API
</a>
)}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' &&
result.meta.beaconId !== 'org.progenetix' &&
result.meta.beaconId !==
'org.ega-archive.ga4gh-approval-beacon-test' && (
<a
href={result.response.alternativeUrl}
target='_blank'
rel='noreferrer'
>
Beacon API
</a>
)}
{result.meta.beaconId === 'es.elixir.bsc.beacon' && (
<a href='https://www.bsc.es/' target='_blank' rel='noreferrer'>
Visit us
</a>
)}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' && (
<a
href={result.response.organization.welcomeUrl}
target='_blank'
rel='noreferrer'
>
Visit us
</a>
)}
{result.meta.beaconId !== 'es.elixir.bsc.beacon' && (
<a
href={result.response.organization.contactUrl}
target='_blank'
rel='noreferrer'
>
Contact us
</a>
)}
{result.meta.beaconId === 'es.elixir.bsc.beacon' && (
<a href='mailto:[email protected]' target='_blank' rel='noreferrer'>
Contact us
</a>
)}
</div>
</div>
)
})}
</div>
)
}

export default ResultsDatasets;
export default ResultsDatasets
7 changes: 1 addition & 6 deletions frontend/src/components/Layout/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,7 @@ function Layout (props) {
setResultsetAux(resultSet)
setQueryAux(query)

if (resultSet !== resultSetAux) {
setTriggerQuery(!triggerQuery)
}
if (queryAux !== query) {
setTriggerQuery(!triggerQuery)
}
setTriggerQuery(!triggerQuery)

setExampleQ([])

Expand Down

0 comments on commit f267b8c

Please sign in to comment.