From 5bed3c9c1a2910a0fe6cf25bbe87dcdf8bc13084 Mon Sep 17 00:00:00 2001 From: Gemma Date: Wed, 14 Feb 2024 13:12:55 +0100 Subject: [PATCH 1/2] show label in the query instead of ontology --- frontend/src/App.css | 66 +++-- .../FilteringTerms/FilteringTerms.css | 2 +- frontend/src/components/Layout/Layout.js | 271 +++++++++--------- 3 files changed, 181 insertions(+), 158 deletions(-) diff --git a/frontend/src/App.css b/frontend/src/App.css index 1b8de9a..8069d92 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -499,20 +499,26 @@ html { } .exampleQuery:hover .text-example { + margin-right: 14px; display: flex; align-items: center; justify-content: center; border: solid #c8c8c8; background-color: #c8c8c8; color: black; + width: -moz-fit-content; width: fit-content; border-radius: 6px; - margin-left: 10px; - padding: 1px; + margin-left: -98px; + + padding-top: 1px; + padding-bottom: 1px; + padding-left: 2px; + padding-right: 2px; } .examplesQueriesList { - width: 111px; + width: fit-content; display: flex; flex-direction: column; justify-content: center; @@ -692,7 +698,6 @@ hr { sans-serif; text-transform: uppercase; font-size: 12px; - margin-left: 33px; } .exampleQueries:hover { @@ -700,9 +705,13 @@ hr { } .bulbExample { + margin-right: 48px; + padding-right: 19px; + border-right: 1.7px solid #f1f1f1; display: flex; + justify-content: center; align-items: center; - border-left: 1.7px solid #f1f1f1; + flex-direction: row-reverse; } .helpButton { @@ -780,10 +789,10 @@ hr { .example { display: flex; align-items: center; - margin-right: -117px; + /* margin-right: -117px; */ margin-top: 22px; margin-bottom: 22px; - flex-direction: row-reverse; + flex-direction: row; align-content: space-between; justify-content: center; } @@ -803,7 +812,7 @@ hr { padding: 5px; cursor: pointer; display: flex; - flex-direction: row-reverse; + flex-direction: row; align-content: center; justify-content: center; align-items: center; @@ -1063,8 +1072,8 @@ h5 { sans-serif; text-transform: uppercase; font-size: 12px; - margin-right: 36px; - margin-left: 27px; + margin-right: 32px; + margin-left: -20px; } .filters:hover { @@ -1177,7 +1186,7 @@ h5 { padding: 5px; cursor: pointer; display: flex; - flex-direction: row-reverse; + flex-direction: row; align-content: center; justify-content: center; align-items: center; @@ -1264,10 +1273,8 @@ h5 { 'Helvetica Neue', sans-serif; text-transform: uppercase; font-size: 10px; - margin-left: 2px !important; - margin-right: 7px !important; - /* margin-right: 36px; */ - /* margin-left: 27px; */ + margin-right: 3px; + margin-left: -23px; } .container-fluid { @@ -1285,7 +1292,7 @@ h5 { margin-right: 0px; margin-top: 22px; margin-bottom: 22px; - flex-direction: row-reverse; + flex-direction: row; align-content: space-between; justify-content: center; } @@ -1327,13 +1334,14 @@ h5 { height: 27px; } .bulbExample { + margin-right: 48px; + padding-right: 19px; + border-right: 1.7px solid #f1f1f1; display: flex; - border-left: 1.7px solid #f1f1f1; - flex-direction: column; - justify-content: center; - align-content: center; - align-items: center; - width: 112px; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', + 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', + 'Helvetica Neue', sans-serif; + text-transform: uppercase; } .searchIcon { width: 26px; @@ -1364,7 +1372,7 @@ h5 { justify-content: center; align-content: center; align-items: flex-start; - width: 189px; + width: fit-content; border-radius: 5px; font-size: 9px; margin-left: 10px !important; @@ -1372,12 +1380,14 @@ h5 { } .bulbExample { + margin-right: 49px; display: flex; - border-left: 1.7px solid #f1f1f1; - flex-direction: column; - justify-content: center; - align-content: center; - align-items: center; + padding-right: 13px; + border-right: 1.7px solid #f1f1f1; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', + 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', + 'Helvetica Neue', sans-serif; + text-transform: uppercase; } .NavlinkVerifier { diff --git a/frontend/src/components/FilteringTerms/FilteringTerms.css b/frontend/src/components/FilteringTerms/FilteringTerms.css index cf5bf50..025b070 100644 --- a/frontend/src/components/FilteringTerms/FilteringTerms.css +++ b/frontend/src/components/FilteringTerms/FilteringTerms.css @@ -35,7 +35,7 @@ thead { } .tableWrapper { - height: 70vh; + height: 100vh; width: 90vw; overflow: scroll; } diff --git a/frontend/src/components/Layout/Layout.js b/frontend/src/components/Layout/Layout.js index 60828b3..767e724 100644 --- a/frontend/src/components/Layout/Layout.js +++ b/frontend/src/components/Layout/Layout.js @@ -181,125 +181,26 @@ function Layout (props) { setIsOpenModal6(true) } - const handleFilteringTerms = async e => { - setTimeOut(false) - if (props.collection === 'Individuals') { - try { - let res = await axios.get( - configData.API_URL + '/individuals/filtering_terms' - ) - setTimeOut(true) - - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Individuals collection') - setTimeOut(true) - } - } else if (props.collection === 'Cohorts') { - try { - let res = await axios.get( - configData.API_URL + '/cohorts/filtering_terms' - ) - setTimeOut(true) - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Cohorts collection') - setTimeOut(true) - } - } else if (props.collection === 'Variant') { - try { - let res = await axios.get( - configData.API_URL + '/g_variants/filtering_terms' - ) - setTimeOut(true) - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Variant collection') - setTimeOut(true) - } - } else if (props.collection === 'Analyses') { - try { - let res = await axios.get( - configData.API_URL + '/analyses/filtering_terms' - ) - setTimeOut(true) - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Analyses collection') - setTimeOut(true) - } - } else if (props.collection === 'Runs') { - try { - let res = await axios.get(configData.API_URL + '/runs/filtering_terms') - setTimeOut(true) - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Runs collection') - setTimeOut(true) - } - } else if (props.collection === 'Biosamples') { - try { - let res = await axios.get( - configData.API_URL + '/biosamples/filtering_terms' - ) - setTimeOut(true) - if (res.data.response.filteringTerms !== undefined) { - setFilteringTerms(res) - setResults(null) - } else { - setTimeOut(true) - setError('No filtering terms now available') - } - } catch (error) { - setError('No filtering terms now available for Biosamples collection') - setTimeOut(true) - } - } - + const handleSeeFilteringTerms = () => { setShowFilteringTerms(true) } const handleExQueries = () => { if (props.collection === 'Individuals') { setExampleQ([ + ['female', 'NCIT:C16576'], + ['African', 'NCIT:C42331'], + ['Cardiovascular Neoplasm', 'NCIT:C4784'], ['Weight>100'], - ['NCIT:C16576', 'female'], ['geographicOrigin=%land%'], - ['geographicOrigin!England'], - ['NCIT:C42331', 'African'], - ['NCIT:C4784', 'Cardiovascular Neoplasm'] + ['geographicOrigin!England'] ]) } else if (props.collection === 'Variant') { setExampleQ([['GENO:GENO_0000458']]) } else if (props.collection === 'Biosamples') { setExampleQ([ - ['UBERON:0000178', 'blood'], - ['EFO:0009654', 'reference sample'], + ['blood', 'UBERON:0000178'], + ['reference sample', 'EFO:0009654'], ['sampleOriginType:blood'] ]) } else if (props.collection === 'Runs') { @@ -451,22 +352,125 @@ function Layout (props) { const fetchData = async () => { //for query expansion try { - let res = await axios.get( - configData.API_URL + '/individuals/filtering_terms' - ) - if (res !== null) { - res.data.response.filteringTerms.forEach(element => { - if (element.type !== 'custom') { - arrayFilteringTerms.push(element.id) - arrayFilteringTermsQE.push(element) + setTimeOut(false) + if (props.collection === 'Individuals') { + try { + let res = await axios.get( + configData.API_URL + '/individuals/filtering_terms' + ) + setTimeOut(true) + + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setError('No filtering terms now available') } - }) - - setstate({ - query: '', - list: arrayFilteringTerms - }) + if (res !== null) { + res.data.response.filteringTerms.forEach(element => { + if (element.type !== 'custom') { + arrayFilteringTerms.push(element.id) + arrayFilteringTermsQE.push(element) + } + }) + + setstate({ + query: '', + list: arrayFilteringTerms + }) + } + } catch (error) { + setError( + 'No filtering terms now available for Individuals collection' + ) + setTimeOut(true) + } + } else if (props.collection === 'Cohorts') { + try { + let res = await axios.get( + configData.API_URL + '/cohorts/filtering_terms' + ) + setTimeOut(true) + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setError('No filtering terms now available') + } + } catch (error) { + setError('No filtering terms now available for Cohorts collection') + setTimeOut(true) + } + } else if (props.collection === 'Variant') { + try { + let res = await axios.get( + configData.API_URL + '/g_variants/filtering_terms' + ) + setTimeOut(true) + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setError('No filtering terms now available') + } + } catch (error) { + setError('No filtering terms now available for Variant collection') + setTimeOut(true) + } + } else if (props.collection === 'Analyses') { + try { + let res = await axios.get( + configData.API_URL + '/analyses/filtering_terms' + ) + setTimeOut(true) + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setError('No filtering terms now available') + } + } catch (error) { + setError('No filtering terms now available for Analyses collection') + setTimeOut(true) + } + } else if (props.collection === 'Runs') { + try { + let res = await axios.get( + configData.API_URL + '/runs/filtering_terms' + ) + setTimeOut(true) + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setError('No filtering terms now available') + } + } catch (error) { + setError('No filtering terms now available for Runs collection') + setTimeOut(true) + } + } else if (props.collection === 'Biosamples') { + try { + let res = await axios.get( + configData.API_URL + '/biosamples/filtering_terms' + ) + setTimeOut(true) + if (res.data.response.filteringTerms !== undefined) { + setFilteringTerms(res) + setResults(null) + } else { + setTimeOut(true) + setError('No filtering terms now available') + } + } catch (error) { + setError( + 'No filtering terms now available for Biosamples collection' + ) + setTimeOut(true) + } } + + } catch (error) { console.log(error) } @@ -479,6 +483,8 @@ function Layout (props) { }, []) const onSubmit = async event => { + console.log(query) + console.log(value) event.preventDefault() setIsSub(true) @@ -683,8 +689,8 @@ function Layout (props) { className='exampleQuery' onClick={() => { setPlaceholder(`${result[0]}`) - setQuery(`${result[0]}`) - setValue(`${result[0]}`) + setQuery(`${[result[0]]}`) + setValue(`${result[1]}`) setExampleQ([]) }} > @@ -703,9 +709,7 @@ function Layout (props) { )} {props.collection !== '' && showBar === true && ( - + )} @@ -732,7 +736,7 @@ function Layout (props) { onClick={() => { setPlaceholder(`${result[0]}`) setQuery(`${result[0]}`) - setValue(`${result[0]}`) + setValue(`${result[1]}`) setExampleQ([]) }} > @@ -748,9 +752,7 @@ function Layout (props) { - + )} @@ -1583,6 +1585,7 @@ function Layout (props) { {isSubmitted && results === 'Individuals' && triggerQuery && (
Date: Wed, 14 Feb 2024 16:06:40 +0100 Subject: [PATCH 2/2] show label in the search bar --- frontend/src/App.css | 5 +- .../components/Analyses/AnalysesResults.js | 52 +- .../Biosamples/BiosamplesResults.js | 35 +- .../components/Datasets/ResultsDatasets.css | 6 +- .../GenomicVariations/VariantsResults.js | 429 ++++++----- .../Individuals/IndividualsResults.js | 37 +- .../AnalysesResults/TableResultsAnalyses.js | 380 +++++++--- .../TableResultsBiosamples.js | 14 +- .../TableResultsIndividuals.js | 697 +++++++++--------- .../Results/RunsResults/TableResultsRuns.js | 696 ++++++++--------- .../VariantResults/TableResultsVariant.js | 4 +- frontend/src/components/Runs/RunsResults.js | 65 +- 12 files changed, 1390 insertions(+), 1030 deletions(-) diff --git a/frontend/src/App.css b/frontend/src/App.css index 8069d92..a203dae 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -659,8 +659,9 @@ select { /* justify-content: center; */ align-content: center; align-items: center; - padding-bottom: 10px; - min-height: 630px; + padding-bottom: 55px; + min-height: 280px; + } .resultSet2 { diff --git a/frontend/src/components/Analyses/AnalysesResults.js b/frontend/src/components/Analyses/AnalysesResults.js index 3f46e38..26bc601 100644 --- a/frontend/src/components/Analyses/AnalysesResults.js +++ b/frontend/src/components/Analyses/AnalysesResults.js @@ -94,10 +94,21 @@ function AnalysesResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter2 = { + let filter2 = { id: element, includeDescendantTerms: props.descendantTerm } + props.filteringTerms.data.response.filteringTerms.forEach( + element2 => { + if (element === element2.label) { + filter2 = { + id: element2.id, + includeDescendantTerms: props.descendantTerm + } + } + } + ) + arrayFilter.push(filter2) } }) @@ -133,9 +144,18 @@ function AnalysesResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter = { - id: props.query - } + let filter = { id: props.query } + let labelToOntology = 0 + props.filteringTerms.data.response.filteringTerms.forEach( + element => { + if (props.query === element.label) { + labelToOntology = element.id + filter = { + id: labelToOntology + } + } + } + ) arrayFilter.push(filter) } } @@ -178,7 +198,10 @@ function AnalysesResults (props) { } if (token === null) { - res = await axios.post(configData.API_URL + '/analyses', jsonData1) + res = await axios.post( + configData.API_URL + '/analyses', + jsonData1 + ) } else { const headers = { Authorization: `Bearer ${token}` } @@ -215,7 +238,6 @@ function AnalysesResults (props) { [element.resultsCount] ] let found = false - resultsPerDataset.forEach(element => { if (element[0] === arrayResultsPerDataset[0]) { found = true @@ -233,7 +255,6 @@ function AnalysesResults (props) { [element.exists], [element.resultsCount] ] - resultsPerDataset.push(arrayResultsPerDataset) } } @@ -241,6 +262,7 @@ function AnalysesResults (props) { if (element.id === undefined || element.id === '') { let arrayResultsNoDatasets = [element.beaconId] resultsNotPerDataset.push(arrayResultsNoDatasets) + console.log(arrayResultsNoDatasets) } if (res.data.response.resultSets[index].results) { @@ -273,6 +295,7 @@ function AnalysesResults (props) { } } jsonData2 = JSON.stringify(jsonData2) + console.log(jsonData2) let token = null if (auth.userData === null) { token = getStoredToken() @@ -282,25 +305,28 @@ function AnalysesResults (props) { if (token === null) { console.log('Querying without token') - res = await axios.post(configData.API_URL + '/analyses', jsonData2) + res = await axios.post( + configData.API_URL + '/analyses', + jsonData2 + ) } else { console.log('Querying WITH token') const headers = { Authorization: `Bearer ${token}` } - res = await axios.post( configData.API_URL + '/analyses', jsonData2, { headers: headers } ) } - setTimeOut(true) + setTimeOut(true) + console.log(res.data) if ( (res.data.responseSummary.numTotalResults < 1 || res.data.responseSummary.numTotalResults === undefined) && props.resultSets !== 'MISS' ) { - setError('. Please try another query') + setError('No results. Please try another query') setNumberResults(0) setBoolean(false) } else { @@ -361,9 +387,7 @@ function AnalysesResults (props) { } } } catch (error) { - setError( - 'No results. Please check the query and the connection and retry' - ) + setError('Connection error. Please retry') setTimeOut(true) } } diff --git a/frontend/src/components/Biosamples/BiosamplesResults.js b/frontend/src/components/Biosamples/BiosamplesResults.js index b8a8724..67ecd0f 100644 --- a/frontend/src/components/Biosamples/BiosamplesResults.js +++ b/frontend/src/components/Biosamples/BiosamplesResults.js @@ -94,10 +94,21 @@ function BiosamplesResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter2 = { + let filter2 = { id: element, includeDescendantTerms: props.descendantTerm } + props.filteringTerms.data.response.filteringTerms.forEach( + element2 => { + if (element === element2.label) { + filter2 = { + id: element2.id, + includeDescendantTerms: props.descendantTerm + } + } + } + ) + arrayFilter.push(filter2) } }) @@ -133,9 +144,18 @@ function BiosamplesResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter = { - id: props.query - } + let filter = { id: props.query } + let labelToOntology = 0 + props.filteringTerms.data.response.filteringTerms.forEach( + element => { + if (props.query === element.label) { + labelToOntology = element.id + filter = { + id: labelToOntology + } + } + } + ) arrayFilter.push(filter) } } @@ -242,6 +262,7 @@ function BiosamplesResults (props) { if (element.id === undefined || element.id === '') { let arrayResultsNoDatasets = [element.beaconId] resultsNotPerDataset.push(arrayResultsNoDatasets) + console.log(arrayResultsNoDatasets) } if (res.data.response.resultSets[index].results) { @@ -274,6 +295,7 @@ function BiosamplesResults (props) { } } jsonData2 = JSON.stringify(jsonData2) + console.log(jsonData2) let token = null if (auth.userData === null) { token = getStoredToken() @@ -290,15 +312,15 @@ function BiosamplesResults (props) { } else { console.log('Querying WITH token') const headers = { Authorization: `Bearer ${token}` } - res = await axios.post( configData.API_URL + '/biosamples', jsonData2, { headers: headers } ) } - setTimeOut(true) + setTimeOut(true) + console.log(res.data) if ( (res.data.responseSummary.numTotalResults < 1 || res.data.responseSummary.numTotalResults === undefined) && @@ -324,7 +346,6 @@ function BiosamplesResults (props) { [element.resultsCount] ] let found = false - resultsPerDataset.forEach(element => { if (element[0] === arrayResultsPerDataset[0]) { found = true diff --git a/frontend/src/components/Datasets/ResultsDatasets.css b/frontend/src/components/Datasets/ResultsDatasets.css index 81b66f9..26892ec 100644 --- a/frontend/src/components/Datasets/ResultsDatasets.css +++ b/frontend/src/components/Datasets/ResultsDatasets.css @@ -229,8 +229,10 @@ p a { flex-wrap: wrap; justify-content: center; align-content: center; + width: 100vw; + margin-top: 20px; padding-bottom: 60px; - margin-top: 60px; + min-height: 700px; } @media (max-width: 860px) { @@ -258,7 +260,7 @@ p a { justify-content: center; align-content: center; width: 100vw; - margin-top: 60px; + margin-top: 20px; padding-bottom: 60px; } diff --git a/frontend/src/components/GenomicVariations/VariantsResults.js b/frontend/src/components/GenomicVariations/VariantsResults.js index ff66ab7..05313d1 100644 --- a/frontend/src/components/GenomicVariations/VariantsResults.js +++ b/frontend/src/components/GenomicVariations/VariantsResults.js @@ -115,10 +115,21 @@ function VariantsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter2 = { + let filter2 = { id: element, includeDescendantTerms: props.descendantTerm } + props.filteringTerms.data.response.filteringTerms.forEach( + element2 => { + if (element === element2.label) { + filter2 = { + id: element2.id, + includeDescendantTerms: props.descendantTerm + } + } + } + ) + arrayFilter.push(filter2) } }) @@ -154,231 +165,243 @@ function VariantsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter = { - id: props.query - } + let filter = { id: props.query } + let labelToOntology = 0 + props.filteringTerms.data.response.filteringTerms.forEach( + element => { + if (props.query === element.label) { + labelToOntology = element.id + filter = { + id: labelToOntology + } + } + } + ) arrayFilter.push(filter) } } } - if (props.query === null) { - // show all individuals + try { + if (props.query === null) { + // show all individuals - var jsonData1 = { - meta: { - apiVersion: '2.0' - }, - query: { - requestParameters: {}, - filters: arrayFilter, - includeResultsetResponses: `${props.resultSets}`, - pagination: { - skip: skip, - limit: limit + var jsonData1 = { + meta: { + apiVersion: '2.0' }, - testMode: false, - requestedGranularity: 'record' + query: { + filters: arrayFilter, + includeResultsetResponses: `${props.resultSets}`, + pagination: { + skip: 0, + limit: 0 + }, + testMode: false, + requestedGranularity: 'record' + } } - } - jsonData1 = JSON.stringify(jsonData1) + jsonData1 = JSON.stringify(jsonData1) - let token = null - if (auth.userData === null) { - token = getStoredToken() - } else { - token = auth.userData.access_token - } + let token = null + if (auth.userData === null) { + token = getStoredToken() + } else { + token = auth.userData.access_token + } - if (token === null) { - res = await axios.post( - configData.API_URL + '/g_variants', - jsonData1 - ) - // Object.defineProperty(res.data.response.resultSets[0], 'beaconId', { - // value: 'es.chipdb.cnic.beacon' - //}) - } else { - const headers = { Authorization: `Bearer ${token}` } + if (token === null) { + res = await axios.post( + configData.API_URL + '/g_variants', + jsonData1 + ) + } else { + const headers = { Authorization: `Bearer ${token}` } - res = await axios.post( - configData.API_URL + '/g_variants', - jsonData1, - { headers: headers } - ) - } - setTimeOut(true) + res = await axios.post( + configData.API_URL + '/g_variants', + jsonData1, + { headers: headers } + ) + } + setTimeOut(true) - if ( - (res.data.responseSummary.numTotalResults < 1 || - res.data.responseSummary.numTotalResults === undefined) && - props.resultSets !== 'MISS' - ) { - setError('No results. Please try another query') - setNumberResults(0) - setBoolean(false) - } else { - res.data.response.resultSets.forEach((element, index) => { - if (element.id && element.id !== '') { - 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.resultsCount) - } else { - let arrayResultsPerDataset = [ - element.beaconId, - [element.id], - [element.exists], - [element.resultsCount] - ] - let found = false - resultsPerDataset.forEach(element => { - if (element[0] === arrayResultsPerDataset[0]) { - found = true + if ( + (res.data.responseSummary.numTotalResults < 1 || + res.data.responseSummary.numTotalResults === undefined) && + props.resultSets !== 'MISS' + ) { + setError('No results. Please try another query') + setNumberResults(0) + setBoolean(false) + } else { + res.data.response.resultSets.forEach((element, index) => { + if (element.id && element.id !== '') { + 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.resultsCount) + } else { + let arrayResultsPerDataset = [ + element.beaconId, + [element.id], + [element.exists], + [element.resultsCount] + ] + let found = false + resultsPerDataset.forEach(element => { + if (element[0] === arrayResultsPerDataset[0]) { + found = true + } + }) + if (found === false) { + resultsPerDataset.push(arrayResultsPerDataset) } - }) - if (found === false) { - resultsPerDataset.push(arrayResultsPerDataset) } - } - }) - } else { - let arrayResultsPerDataset = [ - element.beaconId, - [element.id], - [element.exists], - [element.resultsCount] - ] - resultsPerDataset.push(arrayResultsPerDataset) - } - } - - if (element.id === undefined || element.id === '') { - let arrayResultsNoDatasets = [element.beaconId] - resultsNotPerDataset.push(arrayResultsNoDatasets) - } - - if (res.data.response.resultSets[index].results) { - res.data.response.resultSets[index].results.forEach( - (element2, index2) => { - let arrayResult = [ - res.data.response.resultSets[index].beaconId, - res.data.response.resultSets[index].results[index2] + }) + } else { + let arrayResultsPerDataset = [ + element.beaconId, + [element.id], + [element.exists], + [element.resultsCount] ] - results.push(arrayResult) + resultsPerDataset.push(arrayResultsPerDataset) } - ) - } - }) - } - } else { - var jsonData2 = { - meta: { - apiVersion: '2.0' - }, - query: { - requestParameters: {}, - filters: arrayFilter, - includeResultsetResponses: `${props.resultSets}`, - pagination: { - skip: skip, - limit: limit - }, - testMode: false, - requestedGranularity: 'record' - } - } - jsonData2 = JSON.stringify(jsonData2) - let token = null - if (auth.userData === null) { - token = getStoredToken() - } else { - token = auth.userData.access_token - } + } - if (token === null) { - console.log('Querying without token') - res = await axios.post( - configData.API_URL + '/g_variants', - jsonData2 - ) - } else { - console.log('Querying WITH token') - const headers = { Authorization: `Bearer ${token}` } - res = await axios.post( - configData.API_URL + '/g_variants', - jsonData2, - { headers: headers } - ) - } - setTimeOut(true) + if (element.id === undefined || element.id === '') { + let arrayResultsNoDatasets = [element.beaconId] + resultsNotPerDataset.push(arrayResultsNoDatasets) + console.log(arrayResultsNoDatasets) + } - if ( - (res.data.responseSummary.numTotalResults < 1 || - res.data.responseSummary.numTotalResults === undefined) && - props.resultSets !== 'MISS' - ) { - setError('No results. Please try another query') - setNumberResults(0) - setBoolean(false) - } else { - res.data.response.resultSets.forEach((element, index) => { - if (element.id && element.id !== '') { - 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.resultsCount) - } else { - let arrayResultsPerDataset = [ - element.beaconId, - [element.id], - [element.exists], - [element.resultsCount] + if (res.data.response.resultSets[index].results) { + res.data.response.resultSets[index].results.forEach( + (element2, index2) => { + let arrayResult = [ + res.data.response.resultSets[index].beaconId, + res.data.response.resultSets[index].results[index2] ] - let found = false - resultsPerDataset.forEach(element => { - if (element[0] === arrayResultsPerDataset[0]) { - found = true - } - }) - if (found === false) { - resultsPerDataset.push(arrayResultsPerDataset) - } + results.push(arrayResult) } - }) - } else { - let arrayResultsPerDataset = [ - element.beaconId, - [element.id], - [element.exists], - [element.resultsCount] - ] - resultsPerDataset.push(arrayResultsPerDataset) + ) } + }) + } + } else { + var jsonData2 = { + meta: { + apiVersion: '2.0' + }, + query: { + filters: arrayFilter, + includeResultsetResponses: `${props.resultSets}`, + pagination: { + skip: skip, + limit: limit + }, + testMode: false, + requestedGranularity: 'record' } + } + jsonData2 = JSON.stringify(jsonData2) + console.log(jsonData2) + let token = null + if (auth.userData === null) { + token = getStoredToken() + } else { + token = auth.userData.access_token + } - if (element.id === undefined || element.id === '') { - let arrayResultsNoDatasets = [element.beaconId] - resultsNotPerDataset.push(arrayResultsNoDatasets) - } + if (token === null) { + console.log('Querying without token') + res = await axios.post( + configData.API_URL + '/g_variants', + jsonData2 + ) + } else { + console.log('Querying WITH token') + const headers = { Authorization: `Bearer ${token}` } + res = await axios.post( + configData.API_URL + '/g_variants', + jsonData2, + { headers: headers } + ) + } - if (res.data.response.resultSets[index].results) { - res.data.response.resultSets[index].results.forEach( - (element2, index2) => { - let arrayResult = [ - res.data.response.resultSets[index].beaconId, - res.data.response.resultSets[index].results[index2] + setTimeOut(true) + console.log(res.data) + if ( + (res.data.responseSummary.numTotalResults < 1 || + res.data.responseSummary.numTotalResults === undefined) && + props.resultSets !== 'MISS' + ) { + setError('No results. Please try another query') + setNumberResults(0) + setBoolean(false) + } else { + res.data.response.resultSets.forEach((element, index) => { + if (element.id && element.id !== '') { + 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.resultsCount) + } else { + let arrayResultsPerDataset = [ + element.beaconId, + [element.id], + [element.exists], + [element.resultsCount] + ] + let found = false + resultsPerDataset.forEach(element => { + if (element[0] === arrayResultsPerDataset[0]) { + found = true + } + }) + if (found === false) { + resultsPerDataset.push(arrayResultsPerDataset) + } + } + }) + } else { + let arrayResultsPerDataset = [ + element.beaconId, + [element.id], + [element.exists], + [element.resultsCount] ] - results.push(arrayResult) + resultsPerDataset.push(arrayResultsPerDataset) } - ) - } - }) + } + + if (element.id === undefined || element.id === '') { + let arrayResultsNoDatasets = [element.beaconId] + resultsNotPerDataset.push(arrayResultsNoDatasets) + } + + if (res.data.response.resultSets[index].results) { + res.data.response.resultSets[index].results.forEach( + (element2, index2) => { + let arrayResult = [ + res.data.response.resultSets[index].beaconId, + res.data.response.resultSets[index].results[index2] + ] + results.push(arrayResult) + } + ) + } + }) + } } + } catch (error) { + setError('Connection error. Please retry') + setTimeOut(true) } } else { setShowVariantsResults(true) @@ -638,9 +661,11 @@ function VariantsResults (props) { - {props.resultSets !== 'MISS' &&} + {props.resultSets !== 'MISS' && ( + + )}
{show3 && logInRequired === false && !error && ( diff --git a/frontend/src/components/Individuals/IndividualsResults.js b/frontend/src/components/Individuals/IndividualsResults.js index 378cb75..0dca556 100644 --- a/frontend/src/components/Individuals/IndividualsResults.js +++ b/frontend/src/components/Individuals/IndividualsResults.js @@ -94,10 +94,21 @@ function IndividualsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter2 = { + let filter2 = { id: element, includeDescendantTerms: props.descendantTerm } + props.filteringTerms.data.response.filteringTerms.forEach( + element2 => { + if (element === element2.label) { + filter2 = { + id: element2.id, + includeDescendantTerms: props.descendantTerm + } + } + } + ) + arrayFilter.push(filter2) } }) @@ -133,9 +144,18 @@ function IndividualsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter = { - id: props.query - } + let filter = { id: props.query } + let labelToOntology = 0 + props.filteringTerms.data.response.filteringTerms.forEach( + element => { + if (props.query === element.label) { + labelToOntology = element.id + filter = { + id: labelToOntology + } + } + } + ) arrayFilter.push(filter) } } @@ -275,6 +295,7 @@ function IndividualsResults (props) { } } jsonData2 = JSON.stringify(jsonData2) + console.log(jsonData2) let token = null if (auth.userData === null) { token = getStoredToken() @@ -422,9 +443,11 @@ function IndividualsResults (props) { - {props.resultSets !== 'MISS' && } + {props.resultSets !== 'MISS' && ( + + )} )} diff --git a/frontend/src/components/Results/AnalysesResults/TableResultsAnalyses.js b/frontend/src/components/Results/AnalysesResults/TableResultsAnalyses.js index 1ae06ec..aba46d7 100644 --- a/frontend/src/components/Results/AnalysesResults/TableResultsAnalyses.js +++ b/frontend/src/components/Results/AnalysesResults/TableResultsAnalyses.js @@ -379,7 +379,6 @@ function TableResultsAnalyses (props) { }) setShowDatasets(true) - }, []) return ( @@ -391,83 +390,282 @@ function TableResultsAnalyses (props) { <> {props.show !== 'full' && ( <> - {props.resultsPerDataset.map((element, index) => { - return ( - <> - {element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

{result[0].response.organization.name}

+ {props.resultSets === 'MISS' && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ + {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ + {datasetObject.replaceAll('_', ' ')} + +
+ ) + } + )} +
+
+ )} + + ) + })} + + {props.resultSets !== 'MISS' && + props.resultSets !== 'HIT' && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ + {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ {props.resultSets !== 'NONE' && ( + + {datasetObject.replaceAll('_', ' ')} + + )} + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && + element[3][indexDataset] !== 1 && ( +
+ {element[3][indexDataset]} RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]} RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]} RESULT +
+ )} +
+ ) + } + )}
+
+ )} + + ) + })} + {props.resultSets === 'HIT' && + result[2] === true && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ + {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ + {datasetObject.replaceAll('_', ' ')} + + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && + element[3][indexDataset] !== 1 && ( +
+ {element[3][indexDataset]} RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]} RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]} RESULT +
+ )} +
+ ) + } + )} +
+
+ )} + + ) + })} + + {props.resultSets !== 'MISS' && + result[2] === true && + props.resultsNotPerDataset.map((element, index) => { + return ( + <> + {result[2] === true && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
- {element[1].map((datasetObject, indexDataset) => { - return (
-
+
+
+ )} + {result[2] === false && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> +
+ NOT FOUND +
+ +
+
+
+ )} + + {props.show === 'count' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ - - {datasetObject.replaceAll('_', ' ')} - - - {openDatasetArray[[index, indexDataset]] === - true && - triggerArray[[index, indexDataset]] === - true && - element[2][indexDataset] === true && - props.show === 'boolean' && ( -
FOUND
- )} - {openDatasetArray[[index, indexDataset]] === - true && - triggerArray[[index, indexDataset]] === - true && - element[2][indexDataset] === false && - props.show === 'boolean' && - props.resultSets !== 'HIT' && ( -
NOT FOUND
- )} - {props.show === 'count' && - element[3][indexDataset] !== 0 && - triggerArray[[index, indexDataset]] === - true && ( -
- {element[3][indexDataset]} RESULTS + alt={result[0].meta.beaconId} + /> +

+ {result[0].response.organization.name} +

+
+
+ <> + {result[1] !== 0 && ( +
+ {result[1]} results
)} - {props.show === 'count' && - element[3][indexDataset] === 0 && - triggerArray[[index, indexDataset]] === - true && ( -
- {element[3][indexDataset]} RESULTS + {result[1] === 0 && ( +
+ {result[1]} results
)} +
- ) - })} -
-
- )} - - ) - })} - + +
+
+ )} + + ) + })} {props.resultSets !== 'HIT' && - props.resultSets !== 'MISS' && - props.resultSets !== 'ALL' && + result[2] === false && props.resultsNotPerDataset.map((element, index) => { return ( <> @@ -490,11 +688,9 @@ function TableResultsAnalyses (props) {
- {props.resultSets === 'NONE' && ( - <> -
FOUND
- - )} + <> +
FOUND
+
@@ -517,13 +713,11 @@ function TableResultsAnalyses (props) {
- {props.resultSets === 'NONE' && ( - <> -
- NOT FOUND -
- - )} + <> +
+ NOT FOUND +
+
@@ -546,20 +740,18 @@ function TableResultsAnalyses (props) {
- {props.resultSets === 'NONE' && ( - <> - {result[1] !== 0 && ( -
- {result[1]} results -
- )} - {result[1] === 0 && ( -
- {result[1]} results -
- )} - - )} + <> + {result[1] !== 0 && ( +
+ {result[1]} results +
+ )} + {result[1] === 0 && ( +
+ {result[1]} results +
+ )} +
+ + {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ {props.resultSets !== 'NONE' && ( + + {datasetObject.replaceAll( + '_', + ' ' + )} + + )} + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 &&( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULT +
+ )} +
+ ) + } + )} )} - - ) - })} - {props.resultSets !== 'HIT' && - result[2] === false && - props.resultsNotPerDataset.map((element, index) => { - return ( - <> - {result[2] === true && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( + + ) + })} + {props.resultSets === 'HIT' && + result[2] === true && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && (
@@ -682,112 +519,294 @@ function TableResultsIndividuals (props) {
-
- <> -
FOUND
- -
+ {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ + {datasetObject.replaceAll('_', ' ')} + + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULT +
+ )} +
+ ) + } + )}
)} - {result[2] === false && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

+ + ) + })} + + {props.resultSets !== 'MISS' && + result[2] === true && + props.resultsNotPerDataset.map((element, index) => { + return ( + <> + {result[2] === true && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ +
+ <> +
FOUND
+ +
-
- <> -
- NOT FOUND -
- +
+ )} + {result[2] === false && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> +
+ NOT FOUND +
+ +
-
- )} - - {props.show === 'count' && - element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

+ )} + + {props.show === 'count' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> + {result[1] !== 0 && ( +
+ {result[1]} results +
+ )} + {result[1] === 0 && ( +
+ {result[1]} results +
+ )} + +
+ +
+
+ )} + + ) + })} + {props.resultSets !== 'HIT' && + result[2] === false && + props.resultsNotPerDataset.map((element, index) => { + return ( + <> + {result[2] === true && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ +
+ <> +
FOUND
+ +
-
- <> - {result[1] !== 0 && ( -
- {result[1]} results -
- )} - {result[1] === 0 && ( +
+ )} + {result[2] === false && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <>
- {result[1]} results + NOT FOUND
- )} - + +
-
-
- )} - - ) - })} - - )} - {props.show === 'full' && result[2] === true && ( -
-
-
- {result[0].meta.beaconId} -

{result[0].response.organization.name}

-
-
- + )} + + {props.show === 'count' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> + {result[1] !== 0 && ( +
+ {result[1]} results +
+ )} + {result[1] === 0 && ( +
+ {result[1]} results +
+ )} + +
+ +
+
+ )} + + ) + })} + + )} + {props.show === 'full' && result[2] === true && ( +
+
+
+ {result[0].meta.beaconId} +

{result[0].response.organization.name}

+
+
+ +
-
- )} + )} ) })} diff --git a/frontend/src/components/Results/RunsResults/TableResultsRuns.js b/frontend/src/components/Results/RunsResults/TableResultsRuns.js index b4ed2bc..6313f72 100644 --- a/frontend/src/components/Results/RunsResults/TableResultsRuns.js +++ b/frontend/src/components/Results/RunsResults/TableResultsRuns.js @@ -320,187 +320,13 @@ function TableResultsRuns (props) { beaconsArrayResultsOrdered.map(result => { return ( <> - {props.show !== 'full' && ( - <> - {props.resultSets === 'MISS' && - props.resultsPerDataset.map((element, index) => { - return ( - <> - {element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

-
- - {element[1].map( - (datasetObject, indexDataset) => { - return ( -
- - {datasetObject.replaceAll('_', ' ')} - -
- ) - } - )} -
-
- )} - - ) - })} - - {props.resultSets !== 'MISS' && - props.resultSets !== 'HIT' && - props.resultsPerDataset.map((element, index) => { - return ( - <> - {element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

-
- - {element[1].map( - (datasetObject, indexDataset) => { - return ( -
- {props.resultSets !== 'NONE' && ( - - {datasetObject.replaceAll('_', ' ')} - - )} - - {element[2][indexDataset] === true && - props.show === 'boolean' && ( -
FOUND
- )} - {element[2][indexDataset] === false && - props.show === 'boolean' && ( -
NOT FOUND
- )} - {props.show === 'count' && - element[3][indexDataset] !== 0 && ( -
- {element[3][indexDataset]} RESULTS -
- )} - {props.show === 'count' && - element[3][indexDataset] === 0 && ( -
- {element[3][indexDataset]} RESULTS -
- )} - {props.show === 'count' && - element[3][indexDataset] === 1 && ( -
- {element[3][indexDataset]} RESULT -
- )} -
- ) - } - )} -
-
- )} - - ) - })} - {props.resultSets === 'HIT' && - result[2] === true && - props.resultsPerDataset.map((element, index) => { - return ( - <> - {element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

-
- - {element[1].map( - (datasetObject, indexDataset) => { - return ( -
- - {datasetObject.replaceAll('_', ' ')} - - - {element[2][indexDataset] === true && - props.show === 'boolean' && ( -
FOUND
- )} - {element[2][indexDataset] === false && - props.show === 'boolean' && ( -
NOT FOUND
- )} - {props.show === 'count' && - element[3][indexDataset] !== 0 && ( -
- {element[3][indexDataset]} RESULTS -
- )} - {props.show === 'count' && - element[3][indexDataset] === 0 && ( -
- {element[3][indexDataset]} RESULTS -
- )} - {props.show === 'count' && - element[3][indexDataset] === 1 && ( -
- {element[3][indexDataset]} RESULT -
- )} -
- ) - } - )} -
-
- )} - - ) - })} - - {props.resultSets !== 'MISS' && - result[2] === true && - props.resultsNotPerDataset.map((element, index) => { - return ( - <> - {result[2] === true && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( + {props.show !== 'full' && ( + <> + {props.resultSets === 'MISS' && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && (
@@ -516,44 +342,30 @@ function TableResultsRuns (props) {
-
- <> -
FOUND
- -
-
-
- )} - {result[2] === false && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

-
-
- <> -
- NOT FOUND -
- -
+ {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ + {datasetObject.replaceAll('_', ' ')} + +
+ ) + } + )}
)} + + ) + })} - {props.show === 'count' && - element[0] === result[0].meta.beaconId && ( + {props.resultSets !== 'MISS' && + props.resultSets !== 'HIT' && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && (
@@ -568,39 +380,65 @@ function TableResultsRuns (props) { {result[0].response.organization.name}
-
- <> - {result[1] !== 0 && ( -
- {result[1]} results -
- )} - {result[1] === 0 && ( -
- {result[1]} results -
- )} - -
- + + {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ {props.resultSets !== 'NONE' && ( + + {datasetObject.replaceAll( + '_', + ' ' + )} + + )} + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 &&( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULT +
+ )} +
+ ) + } + )}
)} - - ) - })} - {props.resultSets !== 'HIT' && result[2] === false && - props.resultsNotPerDataset.map((element, index) => { - return ( - <> - {result[2] === true && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( + + ) + })} + {props.resultSets === 'HIT' && + result[2] === true && + props.resultsPerDataset.map((element, index) => { + return ( + <> + {element[0] === result[0].meta.beaconId && (
@@ -616,112 +454,294 @@ function TableResultsRuns (props) {
-
- <> -
FOUND
- -
+ {element[1].map( + (datasetObject, indexDataset) => { + return ( +
+ + {datasetObject.replaceAll('_', ' ')} + + + {element[2][indexDataset] === true && + props.show === 'boolean' && ( +
FOUND
+ )} + {element[2][indexDataset] === false && + props.show === 'boolean' && ( +
NOT FOUND
+ )} + {props.show === 'count' && + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 0 && ( +
+ {element[3][indexDataset]}{' '} + RESULTS +
+ )} + {props.show === 'count' && + element[3][indexDataset] === 1 && ( +
+ {element[3][indexDataset]}{' '} + RESULT +
+ )} +
+ ) + } + )}
)} - {result[2] === false && - props.show === 'boolean' && - element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

+ + ) + })} + + {props.resultSets !== 'MISS' && + result[2] === true && + props.resultsNotPerDataset.map((element, index) => { + return ( + <> + {result[2] === true && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ +
+ <> +
FOUND
+ +
-
- <> -
- NOT FOUND -
- +
+ )} + {result[2] === false && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> +
+ NOT FOUND +
+ +
-
- )} - - {props.show === 'count' && - element[0] === result[0].meta.beaconId && ( -
-
-
- {result[0].meta.beaconId} -

- {result[0].response.organization.name} -

+ )} + + {props.show === 'count' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> + {result[1] !== 0 && ( +
+ {result[1]} results +
+ )} + {result[1] === 0 && ( +
+ {result[1]} results +
+ )} + +
+ +
+
+ )} + + ) + })} + {props.resultSets !== 'HIT' && + result[2] === false && + props.resultsNotPerDataset.map((element, index) => { + return ( + <> + {result[2] === true && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+ +
+ <> +
FOUND
+ +
-
- <> - {result[1] !== 0 && ( -
- {result[1]} results -
- )} - {result[1] === 0 && ( +
+ )} + {result[2] === false && + props.show === 'boolean' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <>
- {result[1]} results + NOT FOUND
- )} - + +
-
-
- )} - - ) - })} - - )} - {props.show === 'full' && result[2] === true && ( -
-
-
- {result[0].meta.beaconId} -

{result[0].response.organization.name}

-
-
- + )} + + {props.show === 'count' && + element[0] === result[0].meta.beaconId && ( +
+
+
+ {result[0].meta.beaconId} +

+ {result[0].response.organization.name} +

+
+
+ <> + {result[1] !== 0 && ( +
+ {result[1]} results +
+ )} + {result[1] === 0 && ( +
+ {result[1]} results +
+ )} + +
+ +
+
+ )} + + ) + })} + + )} + {props.show === 'full' && result[2] === true && ( +
+
+
+ {result[0].meta.beaconId} +

{result[0].response.organization.name}

+
+
+ +
-
- )} + )} ) })} diff --git a/frontend/src/components/Results/VariantResults/TableResultsVariant.js b/frontend/src/components/Results/VariantResults/TableResultsVariant.js index de4b64e..e177f12 100644 --- a/frontend/src/components/Results/VariantResults/TableResultsVariant.js +++ b/frontend/src/components/Results/VariantResults/TableResultsVariant.js @@ -205,7 +205,7 @@ function TableResultsVariant (props) {
NOT FOUND
)} {props.show === 'count' && - element[3][indexDataset] !== 0 && ( + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 &&(
{element[3][indexDataset]}{' '} RESULTS @@ -273,7 +273,7 @@ function TableResultsVariant (props) {
NOT FOUND
)} {props.show === 'count' && - element[3][indexDataset] !== 0 && ( + element[3][indexDataset] !== 0 && element[3][indexDataset] !== 1 && (
{element[3][indexDataset]}{' '} RESULTS diff --git a/frontend/src/components/Runs/RunsResults.js b/frontend/src/components/Runs/RunsResults.js index fc505d2..58ffd37 100644 --- a/frontend/src/components/Runs/RunsResults.js +++ b/frontend/src/components/Runs/RunsResults.js @@ -94,10 +94,21 @@ function RunsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter2 = { + let filter2 = { id: element, includeDescendantTerms: props.descendantTerm } + props.filteringTerms.data.response.filteringTerms.forEach( + element2 => { + if (element === element2.label) { + filter2 = { + id: element2.id, + includeDescendantTerms: props.descendantTerm + } + } + } + ) + arrayFilter.push(filter2) } }) @@ -133,9 +144,18 @@ function RunsResults (props) { } arrayFilter.push(alphaNumFilter) } else { - const filter = { - id: props.query - } + let filter = { id: props.query } + let labelToOntology = 0 + props.filteringTerms.data.response.filteringTerms.forEach( + element => { + if (props.query === element.label) { + labelToOntology = element.id + filter = { + id: labelToOntology + } + } + } + ) arrayFilter.push(filter) } } @@ -178,15 +198,21 @@ function RunsResults (props) { } if (token === null) { - res = await axios.post(configData.API_URL + '/runs', jsonData1) + res = await axios.post( + configData.API_URL + '/runs', + jsonData1 + ) } else { const headers = { Authorization: `Bearer ${token}` } - res = await axios.post(configData.API_URL + '/runs', jsonData1, { - headers: headers - }) + res = await axios.post( + configData.API_URL + '/runs', + jsonData1, + { headers: headers } + ) } setTimeOut(true) + if ( (res.data.responseSummary.numTotalResults < 1 || res.data.responseSummary.numTotalResults === undefined) && @@ -236,6 +262,7 @@ function RunsResults (props) { if (element.id === undefined || element.id === '') { let arrayResultsNoDatasets = [element.beaconId] resultsNotPerDataset.push(arrayResultsNoDatasets) + console.log(arrayResultsNoDatasets) } if (res.data.response.resultSets[index].results) { @@ -268,6 +295,7 @@ function RunsResults (props) { } } jsonData2 = JSON.stringify(jsonData2) + console.log(jsonData2) let token = null if (auth.userData === null) { token = getStoredToken() @@ -277,17 +305,22 @@ function RunsResults (props) { if (token === null) { console.log('Querying without token') - res = await axios.post(configData.API_URL + '/runs', jsonData2) + res = await axios.post( + configData.API_URL + '/runs', + jsonData2 + ) } else { console.log('Querying WITH token') const headers = { Authorization: `Bearer ${token}` } - - res = await axios.post(configData.API_URL + '/runs', jsonData2, { - headers: headers - }) + res = await axios.post( + configData.API_URL + '/runs', + jsonData2, + { headers: headers } + ) } - setTimeOut(true) + setTimeOut(true) + console.log(res.data) if ( (res.data.responseSummary.numTotalResults < 1 || res.data.responseSummary.numTotalResults === undefined) && @@ -354,9 +387,7 @@ function RunsResults (props) { } } } catch (error) { - setError( - 'No results. Please check the query and the connection and retry' - ) + setError('Connection error. Please retry') setTimeOut(true) } }