Commit 2307ef65 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Raw file view uses repo files unless user requests all files.

parent 66307d3e
Pipeline #62813 passed with stages
in 22 minutes and 24 seconds
......@@ -5,9 +5,7 @@ import RawFiles from '../entry/RawFiles'
class DFTEntryCards extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
data: PropTypes.object.isRequired,
loading: PropTypes.bool
classes: PropTypes.object.isRequired
}
static styles = theme => ({
......@@ -15,13 +13,13 @@ class DFTEntryCards extends React.Component {
})
render() {
const { classes, data } = this.props
const { classes, ...props } = this.props
return (
<Card className={classes.root}>
<CardHeader title="Raw files" />
<CardContent classes={{root: classes.cardContent}}>
<RawFiles data={data} />
<RawFiles {...props} />
</CardContent>
</Card>
)
......
......@@ -23,6 +23,7 @@ class EntryPage extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
api: PropTypes.object.isRequired,
raiseError: PropTypes.func.isRequired,
uploadId: PropTypes.string,
calcId: PropTypes.string,
location: PropTypes.object,
......@@ -42,19 +43,18 @@ class EntryPage extends React.Component {
}
componentDidUpdate(prevProps) {
if (prevProps.query !== this.props.query
|| prevProps.location.key !== this.props.location.key
|| prevProps.uploadId !== this.props.uploadId
|| prevProps.calcId !== this.props.calcId
|| prevProps.query !== this.props.query
|| prevProps.api !== this.props.api) {
this.setState({...EntryPage.defaultState})
if (prevProps.query !== this.props.query ||
prevProps.location.key !== this.props.location.key ||
prevProps.uploadId !== this.props.uploadId ||
prevProps.calcId !== this.props.calcId ||
prevProps.query !== this.props.query ||
prevProps.api !== this.props.api) {
this.setState({ ...EntryPage.defaultState })
this.update()
}
}
update() {
console.log('update entry page')
const { calcId, uploadId, query, location } = this.props
if (query) {
let queryParams = null
......
import React from 'react'
import PropTypes from 'prop-types'
import { withStyles, FormGroup, FormControlLabel, Checkbox, FormLabel, IconButton, Divider, Typography } from '@material-ui/core'
import { withStyles, FormGroup, FormControlLabel, Checkbox, FormLabel, IconButton, Divider, Typography, Tooltip } from '@material-ui/core'
import DownloadIcon from '@material-ui/icons/CloudDownload'
import { withApi } from '../api'
import { compose } from 'recompose'
import Download from './Download'
import ReloadIcon from '@material-ui/icons/Cached'
class RawFiles extends React.Component {
static propTypes = {
classes: PropTypes.object.isRequired,
data: PropTypes.object.isRequired,
uploadId: PropTypes.string.isRequired,
calcId: PropTypes.string.isRequired,
data: PropTypes.object,
api: PropTypes.object.isRequired,
user: PropTypes.object,
loading: PropTypes.number.isRequired,
......@@ -32,21 +35,16 @@ class RawFiles extends React.Component {
state = {...RawFiles.defaultState}
componentDidMount() {
this.update()
}
componentDidUpdate(prevProps) {
if (prevProps.api !== this.props.api ||
prevProps.data.uploadId !== this.props.data.uploadId ||
prevProps.data.calcId !== this.props.data.calcId) {
prevProps.uploadId !== this.props.uploadId ||
prevProps.calcId !== this.props.calcId) {
this.setState({...RawFiles.defaultState})
this.update()
}
}
update() {
const {data: {uploadId, calcId}} = this.props
const { uploadId, calcId } = this.props
// this might accidentally happen, when the user logs out and the ids aren't
// necessarily available anymore, but the component is still mounted
if (!uploadId || !calcId) {
......@@ -81,10 +79,10 @@ class RawFiles extends React.Component {
}
render() {
const {classes, data: {upload_id, calc_id}, loading} = this.props
const {classes, uploadId, calcId, loading, data} = this.props
const {selectedFiles, files, uploadDirectory, doesNotExist} = this.state
const availableFiles = files ? files.map(file => file.name) : []
const availableFiles = files ? files.map(file => file.name) : data.files || []
const someSelected = selectedFiles.length > 0
const allSelected = availableFiles.length === selectedFiles.length && someSelected
......@@ -108,13 +106,20 @@ class RawFiles extends React.Component {
/>
}
/>
{!files
? <Tooltip title="check for more files">
<IconButton onClick={() => this.update()}>
<ReloadIcon />
</IconButton>
</Tooltip> : ''
}
<FormLabel className={classes.formLabel}>
{selectedFiles.length}/{availableFiles.length} files selected
</FormLabel>
<Download component={IconButton} disabled={selectedFiles.length === 0}
tooltip="download selected files"
url={(selectedFiles.length === 1) ? `raw/${upload_id}/${uploadDirectory}/${selectedFiles[0]}` : `raw/${upload_id}?files=${encodeURIComponent(selectedFiles.map(file => `${uploadDirectory}/${file}`).join(','))}`}
fileName={selectedFiles.length === 1 ? this.label(selectedFiles[0]) : `${calc_id}.zip`}
url={(selectedFiles.length === 1) ? `raw/${uploadId}/${uploadDirectory}/${selectedFiles[0]}` : `raw/${uploadId}?files=${encodeURIComponent(selectedFiles.map(file => `${uploadDirectory}/${file}`).join(','))}`}
fileName={selectedFiles.length === 1 ? this.label(selectedFiles[0]) : `${calcId}.zip`}
>
<DownloadIcon />
</Download>
......
......@@ -59,8 +59,7 @@ class RepoEntryView extends React.Component {
componentDidUpdate(prevProps) {
if (prevProps.api !== this.props.api ||
prevProps.uploadId !== this.props.uploadId ||
prevProps.calcId !== this.props.calcId
) {
prevProps.calcId !== this.props.calcId) {
this.setState({...RepoEntryView.defaultState})
this.update()
}
......@@ -174,7 +173,7 @@ class RepoEntryView extends React.Component {
</Grid>
</Grid>
<domain.EntryCards data={calcData} classes={{root: classes.entryCards}} />
<domain.EntryCards data={calcData} calcId={calcId} uploadId={uploadId} classes={{root: classes.entryCards}} />
<Download
disabled={!mainfile} tooltip="download all raw files for calculation"
......
......@@ -17,7 +17,6 @@ export class Definition extends React.Component {
} else if (schema.isProperty(definition)) {
return <ValueCard {...this.props}/>
} else {
console.log(definition)
return <div>{definition.mType}</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