Commit 2c01e46d authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Support multiple domains in repo view.

parent 42beefe5
......@@ -81,7 +81,7 @@ class Quantity extends React.Component {
if (!loading) {
const value = data && quantity && _.get(data, quantity)
if (value && children && children.length !== 0) {
if (children && children.length !== 0) {
content = children
} else if (value) {
clipboardContent = value
......
......@@ -24,6 +24,7 @@ export class DomainProvider extends React.Component {
about: 'This include data from many computational material science codes',
entryLabel: 'entry',
entryLabelPlural: 'entries',
entryTitle: data => data.dft && data.dft.code_name ? data.dft.code_name + ' run' : 'Code run',
searchPlaceholder: 'enter atoms, codes, functionals, or other quantity values',
/**
* A component that is used to render the search aggregations. The components needs
......@@ -147,8 +148,9 @@ export class DomainProvider extends React.Component {
ems: {
name: 'EMS',
about: 'This is metadata from material science experiments',
entryLabel: 'experiment',
entryLabelPlural: 'experiments',
entryLabel: 'entry',
entryLabelPlural: 'entries',
entryTitle: () => 'Experiment',
searchPlaceholder: 'enter atoms, experimental methods, or other quantity values',
/**
* A component that is used to render the search aggregations. The components needs
......
......@@ -19,7 +19,7 @@ class EMSEntryCards extends React.Component {
})
render() {
const { classes, data } = this.props
const { classes, data, ...props } = this.props
return (
<Card className={classes.root}>
......@@ -28,12 +28,12 @@ class EMSEntryCards extends React.Component {
<Markdown classes={{root: classes.description}}>{`
The data for this experiment was uploaded to [zenodo.org](https://zenodo.org).
Visit the zenodo entry to download the raw experiment data:
[${data.repository_url}](${data.repository_url}).
[${data.ems.repository_url}](${data.ems.repository_url}).
The meta data describing this experiment in its original format, can be
downloaded here directly:
`}</Markdown>
<RawFiles data={data} />
<RawFiles data={data} {...props} />
</CardContent>
</Card>
)
......
......@@ -12,7 +12,7 @@ export default class EMSEntryOverview extends React.Component {
render() {
const { data } = this.props
const { preview_url } = data
const { ems: { preview_url } } = data
let relative_preview_url = null
if (!preview_url) {
......@@ -26,25 +26,25 @@ export default class EMSEntryOverview extends React.Component {
return (
<Quantity column>
<Quantity quantity="experiment_summary" label="summary" {...this.props} />
<Quantity quantity="ems.experiment_summary" label="summary" {...this.props} />
<Quantity row>
<Quantity column>
<Quantity row>
<Quantity quantity="formula" label="sample formula" noWrap {...this.props} />
{data.chemical !== 'unavailable'
? <Quantity quantity="chemical" label="sample chemical" noWrap {...this.props} />
<Quantity quantity="ems.formula" label="sample formula" noWrap {...this.props} />
{data.ems.chemical !== 'unavailable'
? <Quantity quantity="ems.chemical" label="sample chemical" noWrap {...this.props} />
: ''}
</Quantity>
<Quantity quantity="method" label="experimental method" noWrap {...this.props} />
<Quantity quantity="experiment_location" label="experiment location" noWrap {...this.props} />
<Quantity quantity="ems.method" label="experimental method" noWrap {...this.props} />
<Quantity quantity="ems.experiment_location" label="experiment location" noWrap {...this.props} />
<Quantity label="experiment time" {...this.props}>
<Typography noWrap>{
data.experiment_time !== 'unavailable' ? new Date(data.experiment_time * 1000).toLocaleString() : 'unavailable'
data.ems.experiment_time !== 'unavailable' ? new Date(data.ems.experiment_time * 1000).toLocaleString() : 'unavailable'
}</Typography>
</Quantity>
<Quantity label="data" {...this.props}>
<Typography noWrap>
<a href={data.repository_url}>{data.repository_name}</a>
<a href={data.ems.repository_url}>{data.ems.repository_name}</a>
</Typography>
</Quantity>
</Quantity>
......
......@@ -76,9 +76,12 @@ class RepoEntryView extends React.Component {
const quantityProps = {data: calcData, loading: loading}
const authors = loading ? null : calcData.authors
const domain = calcData.domain && domains[calcData.domain]
const domain = domains.dft // TODO this should be chosen based on the domain of the data
let entryHeader = 'Entry metadata'
if (domain) {
entryHeader = domain.entryTitle(calcData)
}
if (this.state.doesNotExist) {
return <Typography className={classes.error}>
......@@ -92,22 +95,23 @@ class RepoEntryView extends React.Component {
<Grid item xs={7}>
<Card>
<CardHeader
title="Metadata"
title={entryHeader}
action={<ApiDialogButton title="Repository JSON" data={calcData} />}
/>
<CardContent classes={{root: classes.cardContent}}>
<domain.EntryOverview data={calcData} loading={loading} />
{domain && <domain.EntryOverview data={calcData} loading={loading} />}
</CardContent>
<Divider />
<CardContent>
<Quantity column>
<Quantity quantity='comment' placeholder='no comment' {...quantityProps} />
<Quantity quantity='references' placeholder='no references' {...quantityProps}>
<div style={{display: 'inline-grid'}}>
{(calcData.references || []).map(ref => <Typography key={ref} noWrap>
<a href={ref}>{ref}</a>
</Typography>)}
</div>
{calcData.references &&
<div style={{display: 'inline-grid'}}>
{calcData.references.map(ref => <Typography key={ref} noWrap>
<a href={ref}>{ref}</a>
</Typography>)}
</div>}
</Quantity>
<Quantity quantity='authors' {...quantityProps}>
<Typography>
......@@ -115,13 +119,14 @@ class RepoEntryView extends React.Component {
</Typography>
</Quantity>
<Quantity quantity='datasets' placeholder='no datasets' {...quantityProps}>
<div>
{(calcData.datasets || []).map(ds => (
<Typography key={ds.id}>
<Link component={RouterLink} to={`/dataset/id/${ds.id}`}>{ds.name}</Link>
{ds.doi ? <span>&nbsp; (<DOI doi={ds.doi}/>)</span> : ''}
</Typography>))}
</div>
{calcData.datasets &&
<div>
{calcData.datasets.map(ds => (
<Typography key={ds.id}>
<Link component={RouterLink} to={`/dataset/id/${ds.id}`}>{ds.name}</Link>
{ds.doi ? <span>&nbsp; (<DOI doi={ds.doi}/>)</span> : ''}
</Typography>))}
</div>}
</Quantity>
</Quantity>
</CardContent>
......@@ -133,12 +138,12 @@ class RepoEntryView extends React.Component {
<CardHeader title="Ids / processing" />
<CardContent classes={{root: classes.cardContent}}>
<Quantity column style={{maxWidth: 350}}>
<Quantity quantity="calc_id" label={`${domain.entryLabel} id`} noWrap withClipboard {...quantityProps} />
<Quantity quantity="calc_id" label={`${domain ? domain.entryLabel : 'entry'} id`} noWrap withClipboard {...quantityProps} />
<Quantity quantity="pid" label='PID' loading={loading} placeholder="not yet assigned" noWrap {...quantityProps} withClipboard />
<Quantity quantity="raw_id" label='raw id' loading={loading} noWrap {...quantityProps} withClipboard />
<Quantity quantity="external_id" label='external id' loading={loading} noWrap {...quantityProps} withClipboard />
<Quantity quantity="mainfile" loading={loading} noWrap ellipsisFront {...quantityProps} withClipboard />
<Quantity quantity="calc_hash" label={`${domain.entryLabel} hash`} loading={loading} noWrap {...quantityProps} />
<Quantity quantity="calc_hash" label={`${domain ? domain.entryLabel : 'entry'} hash`} loading={loading} noWrap {...quantityProps} />
<Quantity quantity="upload_id" label='upload id' {...quantityProps} noWrap withClipboard />
<Quantity quantity="upload_time" label='upload time' noWrap {...quantityProps} >
<Typography noWrap>
......@@ -161,7 +166,7 @@ class RepoEntryView extends React.Component {
</Grid>
</Grid>
<domain.EntryCards data={calcData} calcId={calcId} uploadId={uploadId} classes={{root: classes.entryCards}} />
{domain && <domain.EntryCards data={calcData} calcId={calcId} uploadId={uploadId} classes={{root: classes.entryCards}} />}
</div>
)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment