Skip to content

Commit

Permalink
Merge branch 'main' into abcdj
Browse files Browse the repository at this point in the history
  • Loading branch information
jsheunis committed Dec 12, 2023
2 parents 7f37391 + 7e85f00 commit 3d3e703
Show file tree
Hide file tree
Showing 16 changed files with 645 additions and 67 deletions.
33 changes: 33 additions & 0 deletions datalad_catalog/catalog/assets/app_component_contexttab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Component definition: an "additional tab" with context
Vue.component('context-tab-body', function (resolve, reject) {
url = template_dir + "/context-tab-template.html"
fetch(url).
then(response => {
return response.text();
}).
then(text => {
resolve(
{
template: text,
props: {
tabby: Object,
},
data: function () {
return {
context_tab_ready: false,
};
},
computed: {},
methods: {
toUpperString(str_in) {
return str_in.charAt(0).toUpperCase() + str_in.slice(1)
}
},
async created() {
this.context_tab_ready = true;
// console.log(new_tab)
}
}
)
});
});
5 changes: 3 additions & 2 deletions datalad_catalog/catalog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<link type="text/css" rel="stylesheet" href="assets/bootstrap-vue.2.21.2.min.css"/>

<!-- Required scripts -->
<!-- <script src="https://unpkg.com/[email protected]/dist/vue.js"></script> -->
<script src="assets/vue.2.6.14.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<!-- <script src="assets/vue.2.6.14.min.js"></script> -->
<script src="assets/bootstrap-vue.2.21.2.min.js"></script>
<script src="assets/vue-router.3.5.3.min.js"></script>
<script src="assets/md5-2.3.0.js"></script>
Expand Down Expand Up @@ -72,6 +72,7 @@
<!-- Run the Vue app scripts - DO NOT CHANGE ORDER -->
<script src="assets/app_globals.js"></script>
<script src="assets/app_component_item.js"></script>
<script src="assets/app_component_contexttab.js"></script>
<script src="assets/app_component_dataset.js"></script>
<script src="assets/app_component_about.js"></script>
<script src="assets/app_component_notfound.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "directory", "dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222", "dataset_version": "0.1.0", "children": [{"type": "file", "dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222", "dataset_version": "0.1.0", "metadata_sources": {"key_source_map": {}, "sources": [{"source_name": "tabby", "source_version": "0.1.0", "source_parameter": {}, "source_time": 1702323824.80198, "agent_name": "Stephan Heunis", "agent_email": "[email protected]"}]}, "path": "raw/adelie.csv", "contentbytesize": 23755, "url": "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.219.3&entityid=002f3893385f710df69eeebe893144ff", "name": "adelie.csv"}, {"type": "file", "dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222", "dataset_version": "0.1.0", "metadata_sources": {"key_source_map": {}, "sources": [{"source_name": "tabby", "source_version": "0.1.0", "source_parameter": {}, "source_time": 1702323824.80198, "agent_name": "Stephan Heunis", "agent_email": "[email protected]"}]}, "path": "raw/gentoo.csv", "contentbytesize": 11263, "url": "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.220.3&entityid=e03b43c924f226486f2f0ab6709d2381", "name": "gentoo.csv"}, {"type": "file", "dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222", "dataset_version": "0.1.0", "metadata_sources": {"key_source_map": {}, "sources": [{"source_name": "tabby", "source_version": "0.1.0", "source_parameter": {}, "source_time": 1702323824.80198, "agent_name": "Stephan Heunis", "agent_email": "[email protected]"}]}, "path": "raw/chinstrap.csv", "contentbytesize": 18872, "url": "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.221.2&entityid=fe853aa8f7a59aa84cdd3197619ef462", "name": "chinstrap.csv"}], "path": "raw", "name": "raw"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
{
"type": "dataset",
"dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222",
"dataset_version": "0.1.0",
"children": [
{
"type": "directory",
"name": "raw",
"path": "raw",
"dataset_id": "c475969b-2919-57b1-a3e6-71770acaa222",
"dataset_version": "0.1.0"
}
],
"metadata_sources": {
"key_source_map": {
"license": [
"tabby"
],
"doi": [
"tabby"
],
"authors": [
"tabby"
],
"keywords": [
"tabby"
],
"funding": [
"tabby"
],
"publications": [
"tabby"
],
"access_request_contact": [
"tabby"
],
"additional_display": [
"tabby"
]
},
"sources": [
{
"source_name": "tabby",
"source_version": "0.1.0",
"source_parameter": {},
"source_time": 1702323824.737152,
"agent_name": "Stephan Heunis",
"agent_email": "[email protected]"
}
]
},
"name": null,
"license": {
"name": "https://creativecommons.org/publicdomain/zero/1.0/",
"url": "https://creativecommons.org/publicdomain/zero/1.0/"
},
"description": null,
"doi": "https://doi.org/10.5281/zenodo.3960218",
"authors": [
{
"email": "[email protected]",
"name": "Allison Horst",
"identifiers": [
{
"name": "ORCID",
"identifier": "0000-0002-6047-5564"
}
]
},
{
"email": "[email protected]",
"name": "Alison Hill",
"identifiers": [
{
"name": "ORCID",
"identifier": "0000-0002-8082-1890"
}
]
},
{
"email": "[email protected]",
"name": "Kristen Gorman",
"identifiers": [
{
"name": "ORCID",
"identifier": "0000-0002-0258-9264"
}
]
}
],
"keywords": [
"penguins",
"sea ice",
"foraging",
"ecological niches",
"islands",
"antarctica",
"animal sexual behavior",
"isotopes"
],
"funding": [
{
"@type": "schema:Grant",
"name": "DFG",
"identifier": "431549029-INF",
"schema:url": "https://gepris.dfg.de/gepris/projekt/431549029?context=projekt&task=showDetail&id=431549029&"
},
{
"@type": "schema:Grant",
"name": "NSF-OPP",
"identifier": "#0217282",
"schema:url": "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0217282&HistoricalAwards=false"
},
{
"@type": "schema:Grant",
"name": "NSF-OPP",
"identifier": "#0823101",
"schema:url": "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0823101&HistoricalAwards=false"
},
{
"@type": "schema:Grant",
"name": "NSF-OPP",
"identifier": "#0741351",
"schema:url": "https://www.nsf.gov/awardsearch/showAward?AWD_ID=0741351&HistoricalAwards=false"
}
],
"publications": [
{
"@type": "schema:CreativeWork",
"datePublished": "2014",
"doi": "https://doi.org/10.1371/journal.pone.0090081",
"title": "Gorman KB, Williams TD, Fraser WR (2014) Ecological Sexual Dimorphism and Environmental Variability within a Community of Antarctic Penguins (Genus Pygoscelis). PLoS ONE 9(3): e90081.",
"authors": []
}
],
"access_request_contact": {
"givenName": "Allison",
"familyName": "Horst",
"email": "[email protected]"
},
"additional_display": [
{
"name": "ABCD-J",
"icon": "fa-solid fa-graduation-cap",
"content": {
"@context": {
"homepage": "https://schema.org/mainEntityOfPage",
"data controller": "https://w3id.org/dpv#hasDataController",
"sample (organism)": "https://openminds.ebrains.eu/controlledTerms/Species",
"sample (organism part)": "https://openminds.ebrains.eu/controlledTerms/UBERONParcellation",
"used for": "http://www.w3.org/ns/prov#hadUsage"
},
"sample (organism)": [
{
"@type": "https://openminds.ebrains.eu/controlledTerms/Species",
"name": "Pygoscelis adeliae",
"preferredOntologyIdentifier": "http://purl.obolibrary.org/obo/NCBITaxon_9238",
"synonym": "Adelie penguin"
},
{
"@type": "https://openminds.ebrains.eu/controlledTerms/Species",
"name": "Pygoscelis papua",
"preferredOntologyIdentifier": "http://purl.obolibrary.org/obo/NCBITaxon_30457",
"synonym": "Gentoo penguin"
},
{
"@type": "https://openminds.ebrains.eu/controlledTerms/Species",
"name": "Pygoscelis antarcticus",
"preferredOntologyIdentifier": "http://purl.obolibrary.org/obo/NCBITaxon_79643",
"synonym": "chinstrap penguin"
}
],
"sample (organism part)": {
"@type": "https://openminds.ebrains.eu/controlledTerms/UBERONParcellation",
"name": "body proper",
"preferredOntologyIdentifier": "http://purl.obolibrary.org/obo/UBERON_0013702"
},
"homepage": {
"@type": "https://schema.org/URL",
"@value": "https://github.com/allisonhorst/palmerpenguins"
},
"data controller": {
"@type": "https://schema.org/Person",
"email": "[email protected]",
"name": "Allison Horst"
},
"used for": {
"@type": "https://schema.org/Thing",
"name": "Testing effort for DBI backends",
"url": "https://dbitest.r-dbi.org/",
"description": "The dataset is used as example data for testing data base backend features in automated tests"
}
}
}
]
}
70 changes: 70 additions & 0 deletions datalad_catalog/catalog/templates/context-tab-template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<tbody v-if="context_tab_ready">
<tr v-for="content_key in Object.keys(tabby.content).filter((k) => !k.startsWith('@'))">
<!-- PROPERTY NAME -->
<td width="30%">
<strong>
<!-- name -->
<span :id="tabby.name + '_' + content_key">{{ toUpperString(content_key) }}</span>
<!-- popover -->
<span v-if="tabby.content?.['@context']?.[content_key]">
&nbsp;<sup><i :id="tabby.name + '_' + content_key + '_info'" class="fas fa-circle-info"></i></sup>
<b-popover triggers="hover" :target="tabby.name + '_' + content_key + '_info'" placement="topleft">
<a :href="tabby.content?.['@context']?.[content_key]">{{ tabby.content?.['@context']?.[content_key] }}</a>
</b-popover>
</span>
</strong>
</td>
<!-- PROPERTY VALUE -->
<td>
<!-- Always work with an array; if single value given create a one-element array out of it -->
<span v-for="(val, idx) in Array.isArray(tabby.content[content_key]) ? tabby.content[content_key] : Array.of(tabby.content[content_key])">
<template v-if="typeof val === 'object'">
<!-- URL -->
<template v-if="val?.['@type'] == 'https://schema.org/URL'">
<a :href="val['@value']"> {{val['@value']}}</a><br>
</template>
<!-- Person -->
<template v-else-if="val?.['@type'] == 'https://schema.org/Person'">
<template v-if="Object.hasOwn(val, 'email')">
<!-- with e-mail -->
<a :href="'mailto:' + val.email"> {{val.name}}</a><br>
</template>
<template v-else>
<!-- without e-mail -->
{{val.name}}
</template>
</template>
<!-- Thing (name, url, description) -->
<template v-else-if="val?.['@type'] == 'https://schema.org/Thing'">
<template v-if="Object.hasOwn(val, 'name') && Object.hasOwn(val, 'url')">
<!-- with url -->
<a :href="val.url">{{val.name}}</a> {{val?.description}}
</template>
<template v-else>
<!-- without url -->
{{val?.name}} {{val?.description}}
</template>
</template>
<!-- OpenMINDS Species -->
<template v-else-if="val?.['@type'] == 'https://openminds.ebrains.eu/controlledTerms/Species'">
<a :href="val.preferredOntologyIdentifier">{{val.name}} ({{val?.synonym}})</a><br>
</template>
<!-- OpenMINDS UBERONParcellation -->
<template v-else-if="val?.['@type'] == 'https://openminds.ebrains.eu/controlledTerms/UBERONParcellation'">
<a :href="val.preferredOntologyIdentifier">{{val.name}}</a><br>
</template>
<!-- Anything else - type unknown or not declared -->
<template v-else>
{{val}}
</template>
</template>

<template v-else>
<!-- Primitive value, presumably text or number but we take any -->
{{val}}
</template>

</span>
</td>
</tr>
</tbody>
11 changes: 7 additions & 4 deletions datalad_catalog/catalog/templates/dataset-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ <h5><span v-if="fund.name">{{fund.name}}</span><span v-else><em>(fund name not s
</span>
<!-- EXTRA TABS -->
<span v-if="selectedDataset.additional_display && selectedDataset.additional_display.length">
<span v-for="new_tab in selectedDataset.additional_display">
<span v-for="(new_tab, index) in selectedDataset.additional_display">
<b-tab :key="new_tab.name" ref="tabelement">
<template v-slot:title>
<span v-if="new_tab.icon"><i :class="new_tab.icon"></i></span><span v-else><i class="fas fa-bars"></i></span> {{new_tab.name}}
Expand All @@ -480,7 +480,10 @@ <h5><span v-if="fund.name">{{fund.name}}</span><span v-else><em>(fund name not s
<th>Value(s)</th>
</tr>
</thead>
<tbody>
<!-- If the tab has @context, treat it as a semantic tab and try to look up each object's @type for custom rendering -->
<context-tab-body v-if="new_tab.content?.['@context']" :tabby="new_tab" ></context-tab-body>
<!-- If the tab has NO @context: standard additional tab rendering with no customizations -->
<tbody v-else>
<tr v-for="content_key in Object.keys(new_tab.content)">
<td><strong>{{ content_key.charAt(0).toUpperCase() + content_key.slice(1) }}</strong></td>
<td>
Expand All @@ -494,9 +497,9 @@ <h5><span v-if="fund.name">{{fund.name}}</span><span v-else><em>(fund name not s
</span>
</span>
<span v-else>{{ new_tab.content[content_key] }}</span>
</td>
</td>
</tr>
</tbody>
</tbody>
</table>
</span>
</b-tab>
Expand Down
8 changes: 8 additions & 0 deletions datalad_catalog/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
WithDescription,
)

from datalad_next.constraints.basic import (
EnsureDType,
)

__docformat__ = "restructuredtext"


Expand All @@ -31,6 +35,10 @@
# - a JSON serialized string
metadata_constraint = WithDescription(
AnyOf(
WithDescription(
EnsureDType(dict),
error_message="not a valid Python dictionary",
),
WithDescription(
EnsureJSON(),
error_message="not valid JSON content",
Expand Down
Loading

0 comments on commit 3d3e703

Please sign in to comment.