-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gemma
committed
Mar 25, 2024
1 parent
8645816
commit f267b8c
Showing
2 changed files
with
134 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters