Commit cfc09a42 authored by David Mendez's avatar David Mendez
Browse files

Add ID Lookup: add last release and resource api url

parent 648791df
......@@ -16,12 +16,20 @@
<div v-if="entityExists">
<p>
<b>ChEMBL ID:</b>
<span v-if="linkToEntity == null">{{ chemblID }}</span>
<ChEMBLLink :href="linkToEntity" :text="chemblID" />
<ChEMBLLink v-if="isActive" :href="linkToEntity" :text="chemblID" />
<span v-else>{{ chemblID }}</span>
</p>
<p><b>ID Status:</b> {{ idStatus }}</p>
<p><b>ID Status Description:</b> {{ idStatusDescription }}</p>
<p><b>Entity Type:</b> {{ entityType }}</p>
<p v-if="!isActive">
<b>Last Active:</b>
<ChEMBLLink :href="releaseDOIsLink" :text="lastReleaseActive" />
</p>
<p v-if="isActive">
<b>Resource API URL:</b>
<ChEMBLLink :href="apiURL" :text="apiURL" />
</p>
</div>
</div>
</v-card-text>
......@@ -45,6 +53,12 @@ export default {
default: () => undefined,
},
},
data() {
return {
releaseDOIsLink:
'https://chembl.gitbook.io/chembl-interface-documentation/downloads#chembl-database-release-dois',
}
},
computed: mapState({
dataLoaded: (state) => state.entity_lookup.single_entity_lookup.dataLoaded,
entityExists: (state) =>
......@@ -55,6 +69,18 @@ export default {
entityType: (state) => state.entity_lookup.single_entity_lookup.entityType,
linkToEntity: (state) =>
state.entity_lookup.single_entity_lookup.linkToEntity,
isActive: (state) => state.entity_lookup.single_entity_lookup.isActive,
lastReleaseActive(state) {
const lastActiveIsKnown =
state.entity_lookup.single_entity_lookup.lastActiveIsKnown
const lastReleaseActive =
state.entity_lookup.single_entity_lookup.lastReleaseActive
const text = lastActiveIsKnown
? `ChEMBL ${lastReleaseActive}`
: `Before ChEMBL 10`
return text
},
apiURL: (state) => state.entity_lookup.single_entity_lookup.apiURL,
}),
mounted() {
this.$store.dispatch(
......
......@@ -65,6 +65,8 @@ export default {
'https://wwwdev.ebi.ac.uk/chembl/g/#browse/<BROWSER_NAME>/full_state/<GENERATED_STATE>',
hastagUrlsBase:
process.env.HASHTAG_URLS_BASE || 'https://wwwdev.ebi.ac.uk/chembl/g/',
wsLookupBaseUrl:
process.env.WS_LOOKUP_BASE_URL || 'https://wwwdev.ebi.ac.uk',
},
/*
** Headers of the page
......
......@@ -10,6 +10,10 @@ export const state = () => ({
idStatusDescription: undefined,
entityType: undefined,
linkToEntity: undefined,
isActive: false,
lastActiveIsKnown: false,
lastReleaseActive: undefined,
apiURL: undefined,
})
const methods = {
......@@ -54,6 +58,18 @@ export const mutations = {
SET_LINK_TO_ENTITY(state, linkToEntity) {
state.linkToEntity = linkToEntity
},
SET_IS_ACTIVE(state, isActive) {
state.isActive = isActive
},
SET_LAST_ACTIVE_IS_KNOWN(state, lastActiveIsKnown) {
state.lastActiveIsKnown = lastActiveIsKnown
},
SET_LAST_RELEASE_ACTIVE(state, lastReleaseActive) {
state.lastReleaseActive = lastReleaseActive
},
SET_API_URL(state, apiURL) {
state.apiURL = apiURL
},
}
export const actions = {
......@@ -73,6 +89,12 @@ export const actions = {
commit('SET_ID_STATUS_DESCRIPTION', idStatusDescription)
const entityType = entityData.entity_type
commit('SET_ENTITY_TYPE', entityType)
const lastActive = entityData.last_active
commit('SET_LAST_RELEASE_ACTIVE', lastActive)
const lastActiveIsKnown = lastActive != null
commit('SET_LAST_ACTIVE_IS_KNOWN', lastActiveIsKnown)
const apiURL = `${process.env.wsLookupBaseUrl}${entityData.resource_url}`
commit('SET_API_URL', apiURL)
if (idStatus === 'ACTIVE') {
const officialIndexName = IndexNames.getIndexNameFromLookupEntityName(
......@@ -81,7 +103,7 @@ export const actions = {
const linkToEntity = LinksToEntities[
officialIndexName
].getLinkToReportCard(chemblID)
commit('SET_IS_ACTIVE', true)
commit('SET_LINK_TO_ENTITY', linkToEntity)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment