2323<script >
2424import axios from ' axios'
2525import YAML from ' yamljs'
26-
26+ import Papa from ' papaparse '
2727export 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