Skip to content

Commit cd136db

Browse files
adding aditional info to mapping
1 parent 2ef2bff commit cd136db

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

table-component/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
"@vue/cli-service": "~4.5.0",
2727
"@vue/eslint-config-standard": "^5.1.2",
2828
"babel-eslint": "^10.1.0",
29+
"chokidar": "^3.5.3",
2930
"eslint": "^6.7.2",
3031
"eslint-plugin-import": "^2.20.2",
3132
"eslint-plugin-node": "^11.1.0",
3233
"eslint-plugin-promise": "^4.2.1",
3334
"eslint-plugin-standard": "^4.0.0",
3435
"eslint-plugin-vue": "^6.2.2",
36+
"papaparse": "^5.3.2",
3537
"vue-cli-plugin-yaml-loader": "~1.0.0",
3638
"vue-template-compiler": "^2.6.11"
3739
}

table-component/src/App.vue

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script>
2424
import axios from 'axios'
2525
import YAML from 'yamljs'
26-
26+
import Papa from 'papaparse'
2727
export default {
2828
name: 'App',
2929
components: {
@@ -44,12 +44,12 @@ export default {
4444
sortable: true
4545
},
4646
{
47-
key: 'mapping_set_title',
47+
key: 'registry_title',
4848
label: 'Title',
4949
sortable: true
5050
},
5151
{
52-
key: 'mapping_set_description',
52+
key: 'registry_description',
5353
label: 'Description',
5454
sortable: true
5555
},
@@ -71,19 +71,60 @@ export default {
7171
key: 'mapping_provider',
7272
title: 'Mapping Provider',
7373
sortable: true
74+
},
75+
{
76+
key: 'mapping_set_description',
77+
title: 'Mapping Set Description',
78+
sortable: true
7479
}
7580
]
7681
}
7782
},
7883
mounted () {
84+
const papaConf = {
85+
header: true,
86+
delimiter: '\t',
87+
skipEmptyLines: true
88+
}
89+
const startByValue = (path, obj = self, prefix = '') => {
90+
try {
91+
const properties = Array.isArray(path) ? path : path.split('.')
92+
const ret = properties.reduce((prev, curr) => {
93+
return obj.filter((e) => {
94+
const values = Object.values(e)[0]
95+
const x = (values.startsWith(prev) || values.startsWith(curr))
96+
return x
97+
})
98+
})
99+
return Object.values(ret[ret.length - 1])[0].replace(prefix, '')
100+
} catch (err) {
101+
return ''
102+
}
103+
}
79104
axios.get('https://raw.githubusercontent.com/mapping-commons/mapping-commons.github.io/main/mapping-server.yml')
80105
.then(response => {
81106
const registryList = YAML.parse(response.data)
107+
registryList.registries = registryList.registries || []
82108
registryList.registries.forEach(registryEntry => {
83109
axios.get(registryEntry.uri).then(response => {
84110
const registry = YAML.parse(response.data)
85-
registry.mappings.forEach(mapping => {
86-
this.mappings.push(mapping)
111+
registry.mappings = registry.mappings || []
112+
registry.mapping_set_references.forEach(mapping => {
113+
axios.get(mapping.mapping_set_id).then(response => {
114+
Papa.parse(response.data, {
115+
...papaConf,
116+
complete: (tsv) => {
117+
const tsvparsed = {
118+
license: startByValue('# curie_map.# license: ', tsv.data, '# license: '),
119+
creator_id: startByValue('# creator_id:.', tsv.data, '# creator_id: '),
120+
mapping_provider: startByValue('# curie_map.# mapping_provider:', tsv.data, '# mapping_provider: '),
121+
mapping_set_description: startByValue('# curie_map.# mapping_set_description:', tsv.data, '# mapping_set_description: ')
122+
}
123+
const obj = Object.assign({}, tsvparsed, mapping, registry)
124+
this.mappings.push(obj)
125+
}
126+
})
127+
})
87128
})
88129
})
89130
})

0 commit comments

Comments
 (0)