|
52 | 52 |
|
53 | 53 | <script> |
54 | 54 | import axios from "axios"; |
55 | | -import YAML from "yamljs"; |
56 | | -import Papa from "papaparse"; |
57 | 55 | export default { |
58 | 56 | name: "App", |
59 | 57 | components: {}, |
@@ -107,72 +105,16 @@ export default { |
107 | 105 | // } |
108 | 106 | // }, |
109 | 107 | mounted() { |
110 | | - const papaConf = { |
111 | | - header: true, |
112 | | - delimiter: "\t", |
113 | | - skipEmptyLines: true |
114 | | - }; |
115 | | - const startByValue = (path, obj = self, prefix = "") => { |
116 | | - try { |
117 | | - const properties = Array.isArray(path) ? path : path.split("."); |
118 | | - const ret = properties.reduce((prev, curr) => { |
119 | | - return obj.filter(e => { |
120 | | - const values = Object.values(e)[0]; |
121 | | - const x = values.startsWith(prev) || values.startsWith(curr); |
122 | | - return x; |
123 | | - }); |
124 | | - }); |
125 | | - return Object.values(ret[ret.length - 1])[0].replace(prefix, ""); |
126 | | - } catch (err) { |
127 | | - return ""; |
128 | | - } |
129 | | - }; |
130 | 108 | axios |
131 | 109 | .get( |
132 | | - "https://raw.githubusercontent.com/mapping-commons/mapping-commons.github.io/main/mapping-server.yml" |
| 110 | + "https://raw.githubusercontent.com/mapping-commons/mapping-commons.github.io/refs/heads/main/data/mapping-data.json" |
133 | 111 | ) |
134 | 112 | .then(response => { |
135 | | - const registryList = YAML.parse(response.data); |
136 | | - registryList.registries = registryList.registries || []; |
137 | | - registryList.registries.forEach(registryEntry => { |
138 | | - axios.get(registryEntry.uri).then(response => { |
139 | | - const registry = YAML.parse(response.data); |
140 | | - registry.mappings = registry.mappings || []; |
141 | | - registry.mapping_set_references.forEach(mapping => { |
142 | | - axios.get(mapping.mapping_set_id).then(response => { |
143 | | - Papa.parse(response.data, { |
144 | | - ...papaConf, |
145 | | - complete: tsv => { |
146 | | - const tsvparsed = { |
147 | | - license: startByValue( |
148 | | - "# curie_map.# license: ", |
149 | | - tsv.data, |
150 | | - "# license: " |
151 | | - ), |
152 | | - creator_id: startByValue( |
153 | | - "# creator_id:.", |
154 | | - tsv.data, |
155 | | - "# creator_id: " |
156 | | - ), |
157 | | - mapping_provider: startByValue( |
158 | | - "# curie_map.# mapping_provider:", |
159 | | - tsv.data, |
160 | | - "# mapping_provider: " |
161 | | - ), |
162 | | - mapping_set_description: startByValue( |
163 | | - "# curie_map.# mapping_set_description:", |
164 | | - tsv.data, |
165 | | - "# mapping_set_description: " |
166 | | - ) |
167 | | - }; |
168 | | - const obj = Object.assign({}, tsvparsed, mapping, registry); |
169 | | - this.mappings.push(obj); |
170 | | - } |
171 | | - }); |
172 | | - }); |
173 | | - }); |
174 | | - }); |
| 113 | + const registries = []; |
| 114 | + response.data.registries.forEach(registry => { |
| 115 | + registries.push(registry?.mapping_sets); |
175 | 116 | }); |
| 117 | + this.mappings = registries.flat(); |
176 | 118 | }); |
177 | 119 | } |
178 | 120 | }; |
|
0 commit comments