Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
matentzn committed Nov 21, 2024
2 parents 4f98ff1 + 373210f commit 714b7c3
Showing 1 changed file with 5 additions and 63 deletions.
68 changes: 5 additions & 63 deletions table-component/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

<script>
import axios from "axios";
import YAML from "yamljs";
import Papa from "papaparse";
export default {
name: "App",
components: {},
Expand Down Expand Up @@ -107,72 +105,16 @@ export default {
// }
// },
mounted() {
const papaConf = {
header: true,
delimiter: "\t",
skipEmptyLines: true
};
const startByValue = (path, obj = self, prefix = "") => {
try {
const properties = Array.isArray(path) ? path : path.split(".");
const ret = properties.reduce((prev, curr) => {
return obj.filter(e => {
const values = Object.values(e)[0];
const x = values.startsWith(prev) || values.startsWith(curr);
return x;
});
});
return Object.values(ret[ret.length - 1])[0].replace(prefix, "");
} catch (err) {
return "";
}
};
axios
.get(
"https://raw.githubusercontent.com/mapping-commons/mapping-commons.github.io/main/mapping-server.yml"
"https://raw.githubusercontent.com/mapping-commons/mapping-commons.github.io/refs/heads/main/data/mapping-data.json"
)
.then(response => {
const registryList = YAML.parse(response.data);
registryList.registries = registryList.registries || [];
registryList.registries.forEach(registryEntry => {
axios.get(registryEntry.uri).then(response => {
const registry = YAML.parse(response.data);
registry.mappings = registry.mappings || [];
registry.mapping_set_references.forEach(mapping => {
axios.get(mapping.mapping_set_id).then(response => {
Papa.parse(response.data, {
...papaConf,
complete: tsv => {
const tsvparsed = {
license: startByValue(
"# curie_map.# license: ",
tsv.data,
"# license: "
),
creator_id: startByValue(
"# creator_id:.",
tsv.data,
"# creator_id: "
),
mapping_provider: startByValue(
"# curie_map.# mapping_provider:",
tsv.data,
"# mapping_provider: "
),
mapping_set_description: startByValue(
"# curie_map.# mapping_set_description:",
tsv.data,
"# mapping_set_description: "
)
};
const obj = Object.assign({}, tsvparsed, mapping, registry);
this.mappings.push(obj);
}
});
});
});
});
const registries = [];
response.data.registries.forEach(registry => {
registries.push(registry?.mapping_sets);
});
this.mappings = registries.flat();
});
}
};
Expand Down

0 comments on commit 714b7c3

Please sign in to comment.