Commit 0d03b27a authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added all repo information to the GUI (and metadata).

parent 02ee02c1
Subproject commit 984554298d67178210631b38eee03ca839f9f427
Subproject commit 9056d2ac9586ee12f05fa76cdb8b09cc422c4af1
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles, IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@material-ui/core'
import CodeIcon from '@material-ui/icons/Code'
import ReactJson from 'react-json-view'
class ApiDialogButtonUnstyled extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
data: PropTypes.any.isRequired,
title: PropTypes.string
}
static styles = theme => ({
root: {}
})
state = {
showDialog: false
}
render() {
const { classes, title, data } = this.props
const { showDialog } = this.state
return (
<div className={classes.root}>
<IconButton onClick={() => this.setState({showDialog: true})}>
<CodeIcon />
</IconButton>
<Dialog open={showDialog}>
<DialogTitle>{title || 'API'}</DialogTitle>
<DialogContent>
<ReactJson
src={data}
enableClipboard={false}
collapsed={2}
displayObjectSize={false}
/>
</DialogContent>
<DialogActions>
<Button onClick={() => this.setState({showDialog: false})} color="primary">
Close
</Button>
</DialogActions>
</Dialog>
</div>
)
}
}
export default withStyles(ApiDialogButtonUnstyled.styles)(ApiDialogButtonUnstyled)
......@@ -6,6 +6,7 @@ import { compose } from 'recompose'
import RawFiles from './RawFiles'
import Download from './Download'
import DownloadIcon from '@material-ui/icons/CloudDownload'
import ApiDialogButton from './ApiDialogButton'
function CalcQuantity(props) {
const {children, label, typography, loading, placeholder, noWrap} = props
......@@ -118,7 +119,10 @@ class RepoCalcView extends React.Component {
<Grid container spacing={24}>
<Grid item xs={7}>
<Card>
<CardHeader title="Metadata" />
<CardHeader
title="Metadata"
action={<ApiDialogButton title="Repository JSON" data={calcData} />}
/>
<CardContent classes={{root: classes.cardContent}}>
<div className={classes.quantityColumn}>
<div className={classes.quantityRow}>
......@@ -164,7 +168,7 @@ class RepoCalcView extends React.Component {
{authors ? authors.map(author => author.name) : null}
</CalcQuantity>
<CalcQuantity label='datasets' loading={loading} placeholder='no datasets'>
{calcData.datasets ? calcData.datasets.map(ds => ds.name).join(', ') : null}
{calcData.datasets ? calcData.datasets.map(ds => `${ds.name}${ds.doi ? ` (${ds.doi})` : ''}`).join(', ') : null}
</CalcQuantity>
</div>
</div>
......@@ -174,7 +178,7 @@ class RepoCalcView extends React.Component {
<Grid item xs={5}>
<Card>
<CardHeader title="Identification" />
<CardHeader title="Id / Processing" />
<CardContent classes={{root: classes.cardContent}}>
<div className={classes.quantityColumn} style={{maxWidth: 350}}>
<CalcQuantity label='PID' loading={loading} noWrap>
......@@ -183,6 +187,9 @@ class RepoCalcView extends React.Component {
<CalcQuantity label='upload id' noWrap>
{calcData.upload_id}
</CalcQuantity>
<CalcQuantity label='upload time' noWrap>
{new Date(calcData.upload_time * 1000).toLocaleString()}
</CalcQuantity>
<CalcQuantity label='calculation id' noWrap>
{calcData.calc_id}
</CalcQuantity>
......@@ -192,6 +199,12 @@ class RepoCalcView extends React.Component {
<CalcQuantity label='calculation hash' loading={loading} noWrap>
{calcData.calc_hash}
</CalcQuantity>
<CalcQuantity label='last processing' loading={loading} noWrap>
{calcData.last_processing ? new Date(calcData.last_processing * 1000).toLocaleString() : <i>not processed</i>}
</CalcQuantity>
<CalcQuantity label='processing version' loading={loading} noWrap>
{calcData.last_processing ? `${calcData.nomad_version}/${calcData.nomad_commit}` : <i>not processed</i>}
</CalcQuantity>
</div>
</CardContent>
</Card>
......
......@@ -154,6 +154,7 @@ class Calc(Proc):
mainfile=self.mainfile)
calc_with_metadata.published = False
calc_with_metadata.uploader = self.upload.uploader.to_popo()
calc_with_metadata.upload_time = self.upload.upload_time
calc_with_metadata.nomad_version = config.version
calc_with_metadata.nomad_commit = config.commit
calc_with_metadata.last_processing = datetime.now()
......
......@@ -92,7 +92,11 @@ class Entry(Document, metaclass=WithDomain):
with_embargo = Boolean()
published = Boolean()
processed = Boolean()
last_processing = Date()
nomad_version = Keyword()
nomad_commit = Keyword()
authors = Object(User, multi=True)
owners = Object(User, multi=True)
......@@ -112,7 +116,11 @@ class Entry(Document, metaclass=WithDomain):
self.calc_id = source.calc_id
self.calc_hash = source.calc_hash
self.pid = None if source.pid is None else str(source.pid)
self.processed = source.processed
self.last_processing = source.last_processing
self.nomad_version = source.nomad_version
self.nomad_commit = source.nomad_commit
self.mainfile = source.mainfile
if source.files is None:
......
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