diff --git a/nuxt.config.js b/nuxt.config.js index 4bf0991712f13382390f3cc7f4a49da14fcdaa5e..f80d7e76effbede5b1cdc871e04d547eae43ec29 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -46,6 +46,9 @@ export default { process.env.EUBOPEN_TARGET_REPORT_CARDS_BASE_URL || '/target', eubopenTextSearchBaseUrl: process.env.EUBOPEN_TEXT_SEARCH_BASE_URL || '/search', + assayReportCardsBaseUrl: + process.env.ASSAY_REPORT_CARDS_BASE_URL || + 'https://wwwdev.ebi.ac.uk/chembl/assay_report_card', }, // Global CSS: https://go.nuxtjs.dev/config-css diff --git a/package-lock.json b/package-lock.json index e5510c628d9a7771669530c117e912e7782c24cf..1eefb0dda0f0ecc259d05dbf01555e20d5a53c8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3479,8 +3479,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "at-least-node": { "version": "1.0.0", @@ -4706,7 +4705,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -5776,8 +5774,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "depd": { "version": "1.1.2", @@ -7566,6 +7563,16 @@ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", "dev": true }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", diff --git a/package.json b/package.json index 7b9c10566d4db6bfe1509cc1a02e1e429bda16bc..2be231310bc055681a0f396a169849544be058d5 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "core-js": "^3.8.3", "d3": "^6.7.0", "dotenv": "^8.2.0", + "form-data": "^4.0.0", "nuxt": "^2.14.12", "vue-apexcharts": "^1.6.1" }, diff --git a/pages/target/_id.vue b/pages/target/_id.vue index 530329e16d4b516fb84ee9e531836ee3194e4de7..6fd126d3df15e21326dce6819e84d86fddaddb7d 100644 --- a/pages/target/_id.vue +++ b/pages/target/_id.vue @@ -3,31 +3,70 @@ </template> <script> +import IndexNames from '~/web-components-submodule/standardisation/IndexNames.js' import TargetReportCard from '~/components/report_cards/target/TargetReportCard.vue' import MetadataLoader from '~/web-components-submodule/metadata/MetadataLoader.js' import EntityNames from '~/web-components-submodule/standardisation/EntityNames.js' +import ESProxyService from '~/web-components-submodule/services/ESProxyService.js' +import LinksToEntities from '~/web-components-submodule/standardisation/LinksToEntities.js' export default { components: { TargetReportCard, }, layout: 'reportCard', - async asyncData({ $axios, error, params }) { - try { - const docSource = ['pref_name'] - const result = await MetadataLoader.getMetadataForEntity( - EntityNames.EubopenTarget.entityID, - params.id, - docSource - ) - return { - rawMetadata: result.data._source, + async asyncData({ $axios, error, params, redirect }) { + const entityID = EntityNames.EubopenTarget.entityID + const receivedID = params.id + let itemID = receivedID + + const isChemblID = /^CHEMBL\d+$/.test(receivedID) + + // If it is a chembl id, get the eubopen id and redirect + if (isChemblID) { + try { + const indexName = IndexNames.getIndexNameFromEntityID(entityID) + const docSource = ['_id'] + const customIDProperty = 'target_chembl_id' + + const docResponse = await ESProxyService.getESDocument( + indexName, + receivedID, + docSource, + customIDProperty + ) + + itemID = docResponse.data._id + const reportCardURL = LinksToEntities[entityID].getLinkToReportCard( + itemID + ) + console.log('going to redirect: ', reportCardURL) + redirect(reportCardURL) + return + } catch (e) { + error({ + statusCode: 404, + message: `No ${EntityNames.EubopenTarget.singularEntityName} found with target_chembl_id ${params.id}`, + }) + } + } else { + console.log('show report card for : ', itemID) + try { + const docSource = ['pref_name'] + const result = await MetadataLoader.getMetadataForEntity( + entityID, + itemID, + docSource + ) + return { + rawMetadata: result.data._source, + } + } catch (e) { + error({ + statusCode: 404, + message: `No ${EntityNames.EubopenTarget.singularEntityName} found with id ${params.id}`, + }) } - } catch (e) { - error({ - statusCode: 404, - message: `No ${EntityNames.EubopenTarget.singularEntityName} found with id ${params.id}`, - }) } }, head() { diff --git a/web-components-submodule b/web-components-submodule index 11257a066e00627de771f1aa223e4325197e75a1..6caa04a10333c2bc750b89d8cafd7d3951acc16a 160000 --- a/web-components-submodule +++ b/web-components-submodule @@ -1 +1 @@ -Subproject commit 11257a066e00627de771f1aa223e4325197e75a1 +Subproject commit 6caa04a10333c2bc750b89d8cafd7d3951acc16a