Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sample metadata author and year #221

Merged
merged 6 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions app/src/pages/explorer/sample/sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,65 @@
<spinner :loading="loading" :text="'Loading sample page'" />
</div>
<div v-else>
<div v-if="header" data-test="header">
<h1 class="visualize_header-h1 article_title u_centralize_text">Sample ID: {{ this.$route.params.label.toUpperCase() }}</h1>
<div class="u_centralize_text utility-color utility-line-height-sm">
<span class="utility-navfonticon">{{ header.sample_label.toUpperCase() }}</span>
<span class="utility-navfonticon">{{ header.process_label.toUpperCase() }}</span>
<div>DOI: {{ header.DOI }}</div>
</div>
</div>
<div style="max-width: 99%;">
<div style="max-width: 99%">
<div class="md-layout md-gutter" :class="`md-alignment-top-center`">
<div class="md-layout-item md-size-50">
<div v-if="header" data-test="header">
<h1 class="md-headline article_title u_centralize_text">
{{`${header.sample_label.toUpperCase()} ${header.process_label.toUpperCase()}`}}
</h1>
</div>
<template v-if="header">
aswallace marked this conversation as resolved.
Show resolved Hide resolved
<h2 class="sample-page_header">Metadata:</h2>
<div class="utility-color utility-line-height-sm">
<p style="text-transform: capitalize">Author: {{ sampleAuthor }}</p>
<p>Year: {{ sampleYear }}</p>
<p>DOI: {{ header.DOI }}</p>
<p>{{`Sample ID: ${this.sampleId.toUpperCase()}`}}</p>
</div>
</template>
<div v-if="materialComponents" data-test="materialComponents">
<h2 class="sample-page_header">Material Components and Attributes:</h2>
<ul v-for="(material, index) in materialComponents" :key="index">
<li>Class: {{ material.class }}</li>
<li>Role: {{ material.role }}</li>
<li v-for="(property, index) in material.materialProperties" :key="index">
<span>{{ property.type }}</span>:
<span>{{ property.value }}</span>
<span>{{ property.units }}</span>
{{`${property.type}: ${property.value} ${property.units.toLowerCase()}`}}
kevinzunigacuellar marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</div>

<div v-if="sampleImages" data-test="sampleImages">
<h2 class="sample-page_header">Sample Images</h2>
<img v-for="(image,index) in sampleImages" :key="index" :src="image.src" :alt="image.alt" />
<img
v-for="(image,index) in sampleImages"
:key="index"
:src="image.src"
:alt="image.alt"
/>
</div>

<div v-if="curatedProperties" data-test="curatedProperties">
<h2 class="sample-page_header">Curated Properties of Nanocomposite Sample</h2>
<div>Scalar attributes:</div>
<ul>
<li v-for="(property, index) in curatedProperties" :key="index">
<span>{{ property.type }}:</span>
<span>{{ property.value }}</span>
<span>{{ property.units }}</span>
{{`${property.type}: ${property.value} ${property.units.toLowerCase()}` }}
</li>
</ul>
</div>

<div v-if="processingSteps && processLabel">
<h2 class="sample-page_header">Curated Processing Steps and Parameters</h2>
<div data-test="processLabel">Class: {{ processLabel }}</div>
<div>Processing Steps:</div>
<ul>
<li v-for="(step, index) in processingSteps" :key="index" data-test="processingSteps">
<span>{{ step.parameterLabel }}</span>
{{ step.description }}
<span class="md-body-2">{{ step.parameterLabel }} </span> | {{ step.description }}
kevinzunigacuellar marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</div>

<div v-if="otherSamples" data-test="otherSamples">
<h2 class="sample-page_header">Other Samples from this Research Article</h2>
<div>
Expand Down
45 changes: 31 additions & 14 deletions app/src/pages/explorer/sample/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default {
},
methods: {
async fetchData (query) {
const sampleId = this.$route.params.label
return await querySparql(query(sampleId))
return await querySparql(query(this.sampleId))
},
parseHeader (data) {
if (!data) return null
Expand Down Expand Up @@ -68,13 +67,15 @@ export default {
const materialProperties = parsedData
.filter((item) => item.std_name === element.class)
.map((item) => {
const { attrUnits, attrValue: value, attrType } = item
const units = attrUnits || ''
const type = attrType
.split('/')
.pop()
.match(/[A-Z][a-z]+|[0-9]+/g)
.join(' ')
const { attrUnits, attrValue, attrType } = item
const units = attrUnits ?? ''
const value = attrValue ?? ''
const type =
attrType
.split('/')
.pop()
.match(/[A-Z][a-z]+|[0-9]+/g)
.join(' ') ?? ''
return {
type,
units,
Expand All @@ -90,11 +91,15 @@ export default {
const parseData = parseSparql(data)
if (!parseData || parseData.length === 0) return null
const curatedProperties = parseData.map((property) => {
const { AttrType, value, Units: units } = property
const type = AttrType.split('/')
.pop()
.match(/[A-Z][a-z]+|[0-9]+/g)
.join(' ')
let { AttrType, value, Units: units } = property
value = value ?? '' // check for empty values
units = units ?? ''
const type =
AttrType.split('/')
.pop()
.match(/[A-Z][a-z]+|[0-9]+/g)
.join(' ') ?? ''

return {
type,
units,
Expand Down Expand Up @@ -163,6 +168,18 @@ export default {
}
},

computed: {
sampleId () {
return this.$route.params.label ?? ''
},
sampleYear () {
return this.$route.params.label.split('-').pop() ?? ''
},
sampleAuthor () {
return this.$route.params.label.split('-').slice(0, -1).pop() ?? ''
}
},
aswallace marked this conversation as resolved.
Show resolved Hide resolved

watch: {
$route: 'fetchSamplePageData'
},
Expand Down