Commit 50a60bbf authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed the processing table and its sorting.

parent 9f473dfa
......@@ -255,6 +255,14 @@ const DatatableHeader = React.memo(function DatatableHeader({actions}) {
}
}
const sortableColumns = useMemo(() => {
if (sortingColumns) {
return sortingColumns
} else {
return columns.filter(column => column.sortable).map(column => column.key)
}
}, [sortingColumns, columns])
return <TableHead>
<TableRow>
{withSelectionFeature && <TableCell padding="checkbox" classes={{stickyHeader: classes.stickyHeader}}>
......@@ -271,7 +279,7 @@ const DatatableHeader = React.memo(function DatatableHeader({actions}) {
align={column.align || 'right'}
sortDirection={order_by === column.key ? order : false}
>
{withSorting && sortingColumns?.includes(column.key) ? <TableSortLabel
{withSorting && sortableColumns.includes(column.key) ? <TableSortLabel
active={order_by === column.key}
direction={order_by === column.key ? order : 'asc'}
onClick={createSortHandler(column)}
......
......@@ -32,18 +32,19 @@ import {pluralize} from '../../utils'
const columns = [
{
key: 'entry_id',
key: 'mainfile',
align: 'left',
render: entry => <Quantity quantity={'entry_id'} noLabel noWrap withClipboard data={entry}/>
render: entry => <Quantity quantity={'mainfile'} noLabel noWrap withClipboard data={entry}/>
},
{
key: 'mainfile',
key: 'entry_id',
align: 'left',
style: {maxWidth: '150px', width: '150px', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}
sortable: false,
render: entry => <Quantity quantity={'entry_id'} noLabel noWrap withClipboard data={entry}/>
},
{key: 'parser_name', align: 'left'},
{key: 'process_status', align: 'left'},
{key: 'complete_time', align: 'left'},
{key: 'complete_time', align: 'left', sortable: false},
{key: 'comment', sortable: false, align: 'left'},
{
key: 'references',
......@@ -67,6 +68,7 @@ const columns = [
{
key: 'datasets',
align: 'left',
sortable: false,
render: entry => {
const datasets = entry.datasets || []
if (datasets.length > 0) {
......@@ -81,9 +83,9 @@ const columns = [
addColumnDefaults(columns)
const defaultSelectedColumns = [
'entry_id',
'mainfile',
'parser_name']
'parser_name',
'process_status']
export default function ProcessingTable(props) {
const [selected, setSelected] = useState([])
......
......@@ -325,7 +325,7 @@ function UploadPage() {
const classes = useStyles()
const { uploadId } = useParams()
const {api, user} = useApi()
const errors = useErrors()
const {raiseError} = useErrors()
const history = useHistory()
const location = useLocation()
......@@ -336,8 +336,9 @@ function UploadPage() {
const [data, setData] = useState(null)
const [apiData, setApiData] = useState(null)
const [uploading, setUploading] = useState(null)
const [err, setErr] = useState(null)
const [error, setError] = useState(null)
const upload = data?.upload
const hasUpload = !!upload
const setUpload = useMemo(() => (upload) => {
setData(data => ({...data, upload: upload}))
}, [setData])
......@@ -353,11 +354,16 @@ function UploadPage() {
setData(apiData.response)
})
.catch((error) => {
if (!(error instanceof DoesNotExist && deleteClicked)) {
(error.apiMessage ? setErr(error.apiMessage) : errors.raiseError(error))
if (error instanceof DoesNotExist && deleteClicked) {
return
}
if (!hasUpload && error.apiMessage) {
setError(error.apiMessage)
} else {
raiseError(error)
}
})
}, [api, uploadId, pagination, deleteClicked, errors, setData, setApiData])
}, [api, hasUpload, uploadId, pagination, deleteClicked, raiseError, setData, setApiData])
// constant fetching of upload data when necessary
useEffect(() => {
......@@ -383,7 +389,7 @@ function UploadPage() {
}
})
.then(results => setUpload(results.data))
.catch(errors.raiseError)
.catch(raiseError)
.finally(() => {
setUploading(null)
})
......@@ -392,26 +398,26 @@ function UploadPage() {
const handleNameChange = (upload_name) => {
api.post(`/uploads/${uploadId}/edit`, {metadata: {upload_name: upload_name}})
.then(fetchData())
.catch(errors.raiseError)
.catch(raiseError)
}
const handlePublish = ({embargo_length}) => {
api.post(`/uploads/${uploadId}/action/publish?embargo_length=${embargo_length}`)
.then(results => setUpload(results.data))
.catch(errors.raiseError)
.catch(raiseError)
}
const handleLiftEmbargo = () => {
setOpenEmbargoConfirmDialog(false)
api.post(`/uploads/${uploadId}/edit`, {metadata: {embargo_length: 0}})
.then(fetchData())
.catch(errors.raiseError)
.catch(raiseError)
}
const handleReprocess = () => {
api.post(`/uploads/${uploadId}/action/process`)
.then(results => setUpload(results.data))
.catch(errors.raiseError)
.catch(raiseError)
}
const handleDelete = () => {
......@@ -419,7 +425,7 @@ function UploadPage() {
setDeleteClicked(true)
api.delete(`/uploads/${uploadId}`)
.then(results => setUpload(results.data))
.catch(errors.raiseError)
.catch(raiseError)
}
const viewers = upload?.viewers
......@@ -435,9 +441,9 @@ function UploadPage() {
isWriter: isWriter
}), [upload, setUpload, data, isViewer, isWriter])
if (!upload) {
if (!hasUpload) {
return <Page limitedWidth>
{(err ? <Typography> {err} </Typography> : <Typography>loading ...</Typography>)}
{(error ? <Typography> {error} </Typography> : <Typography>loading ...</Typography>)}
</Page>
}
......
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