Skip to content

Commit

Permalink
Merge branch 'develop' into 141-name-of-the-vp-portal-and-landing-pag…
Browse files Browse the repository at this point in the history
…e-wording

# Conflicts:
#	components/search/DiscoverySearchResults.vue
  • Loading branch information
vabishaa committed Sep 26, 2024
2 parents 5ae4455 + ef54b83 commit 46d0bcf
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 115 deletions.
2 changes: 1 addition & 1 deletion components/DiscoverySourcesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<li>Catalogues</li>
<li>Biobanks</li>
</ul>
<p> Interested in more Rare Disease resources? <a href="https://resourcemap.ejprarediseases.org/#/" class="text-decoration-underline mr-16" style="margin-left: 8px;"><v-icon large color="#1976D2">mdi-launch</v-icon>Explore Rare Disease resources with the EJP RD Mind Map.</a> </p>
<p> Interested in more Rare Disease resources? <a href="https://resourcemap.ejprarediseases.org/#/" target="_blank" class="text-decoration-underline mr-16" style="margin-left: 8px;"><v-icon large color="#1976D2">mdi-launch</v-icon>Explore Rare Disease resources with the EJP RD Mind Map.</a> </p>
</div>
<v-row no-gutters justify="center" align="center">
<v-col cols="12" v-for="(source, index) in sources" :key="index">
Expand Down
50 changes: 28 additions & 22 deletions components/search/DiscoverySearchResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
},
methods: {
async fetchResults (orphaCodes) {
if(!orphaCodes || orphaCodes.length < 1) {
if(!orphaCodes || orphaCodes.length < 1) {
return
}
this.loading = true
Expand All @@ -46,7 +46,6 @@ export default {
if(!this.loggedIn) {
this.searchParams = this.discardFiltersNeedingAuthorization(this.searchParams)
}
console.log('Query sent to backend:', JSON.stringify(this.searchParams,null, 2)); // Log the query parameters before the request
this.$axios.$get('/api/v1/search',
{ params: this.searchParams, paramsSerializer (params) { return Common.paramsSerializer(params) } })
.then(function (res) {
Expand Down Expand Up @@ -92,38 +91,45 @@ export default {
resourceHasResponseToBeListed (result) {
return !result || !result.content || !result.content.response || !result.content.response.resultSets[0].results;
},
fetchNegotiator () {
async fetchNegotiator() {
const url = 'https://negotiator.acc.bbmri-eric.eu/api/v3/requests';
let idObjects = '';
this.searchResults.forEach((resource) => {
if (resource.resourceName === "BBMRI-ERIC Directory"){
if (resource.resourceName === "BBMRI-ERIC Directory") {
resource.content.response.resultSets[0].results.forEach(result => {
let idObject = '{"id": "' + result.id + '"},';
idObjects = idObjects + idObject;
idObjects += idObject;
});
}
});
//final solution
const data = '{ "url": "https://vp.ejprarediseases.org/", "humanReadable": "", "resources": [' + idObjects.substring(0,idObjects.length-1) + '] }';
// Create headers object
const headers = {};
if (this.loggedIn) {
headers['Authorization'] = `Bearer ${this.auth.user.token }`; // 'auth.user.token' contains the token for the logged-in user
}
const data = '{ "url": "https://vp.ejprarediseases.org/", "humanReadable": "", "resources": [' + idObjects.substring(0, idObjects.length - 1) + '] }';
this.$axios.$post(url, JSON.parse(data), { headers })
.then(response => {
this.negotiatorRedirectUrl = response.redirectUrl;
//console.log(this.negotiatorUrl)
window.open(this.negotiatorRedirectUrl, '_blank');
})
.catch((error) => {
if( error.response ){
alert(error.response.data.status + " " + error.response.data.title + " : " + error.response.data.detail); // => the response payload
}
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(JSON.parse(data))
});
// Check if the response is not correct
if (!response.ok) {
const errorData = await response.json();
throw new Error(`${errorData.status} ${errorData.title}: ${errorData.detail}`);
}
const responseData = await response.json();
this.negotiatorRedirectUrl = responseData.redirectUrl;
window.open(this.negotiatorRedirectUrl, '_blank');
} catch (error) {
console.error('Error:', error.message || error);
alert(error.message || 'An error occurred');
}
}
}
}
Expand Down
Loading

0 comments on commit 46d0bcf

Please sign in to comment.