Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import RequestNotifications from '@/web-components-submodule/utils/RequestNotifications.js'
import IndexNames from '~/web-components-submodule/standardisation/IndexNames.js'
import EntityNames from '~/web-components-submodule/standardisation/EntityNames.js'
import ESProxyService from '~/web-components-submodule/services/ESProxyService.js'
export const state = () => ({
nameAndClassificationData: {},
dataLoaded: false,
})
export const mutations = {
SET_DATA_LOADED(state, dataLoaded) {
state.dataLoaded = dataLoaded
},
SET_NAME_AND_CLASSIFICATION_DATA(state, nameAndClassificationData) {
state.nameAndClassificationData = nameAndClassificationData
},
}
export const actions = {
loadData({ commit, state, dispatch }, itemID) {
const docSource = [
'target_type',
'pref_name',
'target_components',
'organism',
'species_group_flag',
'_metadata.protein_classification',
]
const entityID = EntityNames.EubopenTarget.entityID
const indexName = IndexNames.getIndexNameFromEntityID(entityID)
ESProxyService.getESDocument(indexName, itemID, docSource)
.then((response) => {
commit('SET_NAME_AND_CLASSIFICATION_DATA', response.data._source)
commit('SET_DATA_LOADED', true)
})
.catch((error) => {
RequestNotifications.dispatchRequestErrorNotification(
error,
dispatch,
`There was an error while loading the name and classification!`
)
})
},
}