Skip to content
Open
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ locales:
msgfmt -o modules/dqt/locale/ja/LC_MESSAGES/dqt.mo modules/dqt/locale/ja/LC_MESSAGES/dqt.po
msgfmt -o modules/electrophysiology_browser/locale/ja/LC_MESSAGES/electrophysiology_browser.mo modules/electrophysiology_browser/locale/ja/LC_MESSAGES/electrophysiology_browser.po
msgfmt -o modules/electrophysiology_uploader/locale/ja/LC_MESSAGES/electrophysiology_uploader.mo modules/electrophysiology_uploader/locale/ja/LC_MESSAGES/electrophysiology_uploader.po
msgfmt -o modules/electrophysiology_uploader/locale/hi/LC_MESSAGES/electrophysiology_uploader.mo modules/electrophysiology_uploader/locale/hi/LC_MESSAGES/electrophysiology_uploader.po
npx i18next-conv -l hi -s modules/electrophysiology_uploader/locale/hi/LC_MESSAGES/electrophysiology_uploader.po -t modules/electrophysiology_uploader/locale/hi/LC_MESSAGES/electrophysiology_uploader.json
msgfmt -o modules/examiner/locale/ja/LC_MESSAGES/examiner.mo modules/examiner/locale/ja/LC_MESSAGES/examiner.po
msgfmt -o modules/genomic_browser/locale/ja/LC_MESSAGES/genomic_browser.mo modules/genomic_browser/locale/ja/LC_MESSAGES/genomic_browser.po
msgfmt -o modules/help_editor/locale/ja/LC_MESSAGES/help_editor.mo modules/help_editor/locale/ja/LC_MESSAGES/help_editor.po
Expand Down
37 changes: 27 additions & 10 deletions modules/electrophysiology_uploader/jsx/ElectrophysiologyUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import {TabPane, Tabs} from 'jsx/Tabs';
import UploadForm from './UploadForm';
import UploadViewer from './UploadViewer';
import {createRoot} from 'react-dom/client';
import i18n from 'I18nSetup';
import {useTranslation} from 'react-i18next';

import hiStrings from
'../locale/hi/LC_MESSAGES/electrophysiology_uploader.json';

/**
* UploadViewer
*
* @param {array} props
* @return {JSX}
*/
export default function ElectrophysiologyUploader(props) {
function ElectrophysiologyUploader(props) {
const {DataURL} = props;
const {t} = useTranslation(['electrophysiology_uploader', 'loris']);
const [isLoaded, setIsLoaded] = useState(false);
const [data, setData] = useState({});

Expand All @@ -29,7 +36,7 @@ export default function ElectrophysiologyUploader(props) {
* for easy access by columnFormatter.
*/
const fetchData = () => {
fetch(`${props.DataURL}/?format=json`, {
fetch(`${DataURL}/?format=json`, {
method: 'GET',
}).then((response) => {
if (!response.ok) {
Expand All @@ -56,30 +63,35 @@ export default function ElectrophysiologyUploader(props) {
}

const tabList = [
{id: 'browse', label: 'Browse'},
{id: 'upload', label: 'Upload'},
{id: 'browse', label: t('Browse', {ns: 'loris'})},
{id: 'upload', label: t('Upload', {ns: 'loris'})},
];

return (
<>
<div className="alert alert-warning" role="alert">
<strong>LORIS 26 Beta Note:</strong> Files uploaded in this module
will not be viewable in the Electrophysiology Browser
module. This feature is under construction for the next release.
Please get in touch with the LORIS team to configure this for your
project.
<strong>{t('LORIS 26 Beta Note:',
{ns: 'electrophysiology_uploader'})}</strong>
{t('Files uploaded in this module will not be viewable'+
' in the Electrophysiology Browser module. ' +
'This feature is under construction for the next release. ' +
'Please get in touch with the LORIS team ' +
'to configure this for your project.',
{ns: 'electrophysiology_uploader'})}
</div>
<Tabs tabs={tabList} defaultTab='browse' updateURL={true}>
<TabPane TabId={tabList[0].id}>
<UploadViewer
data={data.Data}
fieldOptions={data.fieldOptions}
t={t}
/>
</TabPane>
<TabPane TabId={tabList[1].id}>
<UploadForm
uploadURL={`${props.DataURL}/upload`}
uploadURL={`${DataURL}/upload`}
refreshPage={refreshForm}
t={t}
/>
</TabPane>
</Tabs>
Expand All @@ -89,12 +101,17 @@ export default function ElectrophysiologyUploader(props) {

ElectrophysiologyUploader.propTypes = {
DataURL: PropTypes.string.isRequired,
t: PropTypes.func,
};

/**
* Render imaging_uploader on page load
*/
export default ElectrophysiologyUploader;

document.addEventListener('DOMContentLoaded', function() {
i18n.addResourceBundle('hi', 'electrophysiology_uploader', hiStrings);

createRoot(
document.getElementById('lorisworkspace')
).render(
Expand Down
71 changes: 45 additions & 26 deletions modules/electrophysiology_uploader/jsx/UploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
* @return {JSX}
*/
export default function UploadForm(props) {
const {t} = props;
const [formData, setFormData] = useState({});
const [errorMessage, setErrorMessage] = useState({});
const [uploadProgress, setuploadProgress] = useState(-1);
Expand Down Expand Up @@ -77,14 +78,18 @@ export default function UploadForm(props) {
const fileNameConvention = pNameElements.join('_') + '.tar.gz';
if (!fileName.match(properExt)) {
swal.fire({
title: 'Invalid extension for the uploaded file!',
text: 'Filename extension does not match .tar.gz ',
title: t('Invalid extension for the uploaded file!',
{ns: 'electrophysiology_uploader'}),
text: t('Filename extension does not match .tar.gz ',
{ns: 'electrophysiology_uploader'}),
type: 'error',
confirmButtonText: 'OK',
confirmButtonText: t('OK', {ns: 'electrophysiology_uploader'}),
});

setErrorMessage({
eegFile: 'The file ' + fileName + ' must be of type .tar.gz.',
eegFile: t('The file', {ns: 'electrophysiology_uploader'}) +
' ' + fileName + ' ' + t('must be of type .tar.gz.',
{ns: 'electrophysiology_uploader'}),
candID: null,
pscid: null,
visit: null,
Expand All @@ -95,15 +100,17 @@ export default function UploadForm(props) {

if (fileName !== fileNameConvention) {
swal.fire({
title: 'Invalid filename!',
text: 'Filename should be of the form '
+ '[PSCID]_[CandID]_[VisitLabel]_bids.tar.gz',
title: t('Invalid filename!', {ns: 'electrophysiology_uploader'}),
text: t('Filename should be of the form',
{ns: 'electrophysiology_uploader'}) +
' [PSCID]_[CandID]_[VisitLabel]_bids.tar.gz',
type: 'error',
confirmButtonText: 'OK',
confirmButtonText: t('OK', {ns: 'electrophysiology_uploader'}),
});

setErrorMessage({
eegFile: 'The file does not respect name convention',
eegFile: t('The file does not respect name convention',
{ns: 'electrophysiology_uploader'}),
candID: null,
pscid: null,
visit: null,
Expand Down Expand Up @@ -151,15 +158,17 @@ export default function UploadForm(props) {

let text = '';
if (props.autoLaunch === 'true' || props.autoLaunch === '1') {
text = 'Processing of this file by the EEG pipeline has started';
text = t('Processing of this file by the EEG pipeline has started',
{ns: 'electrophysiology_uploader'});
}
swal.fire({
title: 'Upload Successful!',
title: t('Upload Successful!',
{ns: 'electrophysiology_uploader'}),
text: text,
type: 'success',
}).then((result) => {
if (result.value) {
this.props.refreshPage();
props.refreshPage();
}
});

Expand Down Expand Up @@ -197,17 +206,20 @@ export default function UploadForm(props) {
error = resp.error;
}
} else if (xhr.status == 0) {
error = 'Upload failed: a network error occured';
error = t('Upload failed: a network error occured',
{ns: 'electrophysiology_uploader'});
} else if (xhr.status == 413) {
error = 'Please make sure files are not larger than '
+ props.maxUploadSize;
error = t('Please make sure files are not larger than',
{ns: 'electrophysiology_uploader'})
+ ' ' + props.maxUploadSize;
} else {
error = 'Upload failed: received HTTP response code '
+ xhr.status;
error = t('Upload failed: received HTTP response code',
{ns: 'electrophysiology_uploader'})
+ ' ' + xhr.status;
}

swal.fire({
title: 'Submission error!',
title: t('Submission error!', {ns: 'electrophysiology_uploader'}),
text: error,
Comment on lines 221 to 223
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are already one Error: key in the loris.po I think we should use this one instead of creating a new one. Thanks.

type: 'error',
});
Expand All @@ -218,52 +230,57 @@ export default function UploadForm(props) {
return (
<div className='row'>
<div className='col-md-7'>
<h3>Upload an electrophysiology recording session</h3>
<h3>{t('Upload an electrophysiology recording session',
{ns: 'electrophysiology_uploader'})}</h3>
<br/>
<FormElement
name='upload_form'
fileUpload={true}
>
<FileElement
name='eegFile'
label='File to Upload'
label={t('File to Upload',
{ns: 'electrophysiology_uploader'})}
onUserInput={onFormChange}
required={true}
errorMessage={errorMessage.eegFile}
value={formData.eegFile}
/>
<TextboxElement
name='candID'
label='CandID'
label={t('CandID', {ns: 'loris'})}
Comment on lines 249 to +251
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SKADE2303 , please remmenber we're not longuer using CandID we are using "DCCID"

disabled={true}
required={false}
errorMessage={errorMessage.candID}
value={formData.candID}
/>
<TextboxElement
name='pscid'
label='PSCID'
label={t('PSCID', {ns: 'loris'})}
disabled={true}
required={false}
errorMessage={errorMessage.pscid}
value={formData.pscid}
/>
<TextboxElement
name='visit'
label='Visit Label'
label={t('Visit Label', {ns: 'loris'})}
disabled={true}
required={false}
errorMessage={errorMessage.visit}
value={formData.visit}
/>
<StaticElement
label='Notes'
label={t('Notes', {ns: 'electrophysiology_uploader'})}
text={
<span>
{props.maxUploadSize &&
`File cannot exceed ${props.maxUploadSize}<br/>x`
t('File cannot exceed',
{ns: 'electrophysiology_uploader'}) +
` ${props.maxUploadSize}<br/>x`
}
File name must match the following convention:<br/>
{t('File name must match the following convention:',
{ns: 'electrophysiology_uploader'})}<br/>
<b>[PSCID]_[CandID]_[Visit Label]_bids.tar.gz</b>
</span>
}
Expand All @@ -289,4 +306,6 @@ UploadForm.propTypes = {
autoLaunch: PropTypes.string,
uploadURL: PropTypes.string.isRequired,
maxUploadSize: PropTypes.number,
refreshPage: PropTypes.func,
t: PropTypes.func,
};
24 changes: 14 additions & 10 deletions modules/electrophysiology_uploader/jsx/UploadViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ export default function UploadViewer(props) {
* @param {object} row - row content indexed by column
* @return {JSX} a formated table cell for a given column
*/
const {t} = props;
const formatColumn = (column, cell, row) => {
switch (column) {
case 'Upload Location':
case t('Upload Location', {ns: 'electrophysiology_uploader'}):
const downloadURL =
loris.BaseURL
+ '/electrophysiology_uploader/upload?'
+ `upload_id=${row['Upload ID']}`;
return (
<td>
<a href={downloadURL} target="_blank" download={row['File Name']}>
<a href={downloadURL} target="_blank"
download={row[t('File Name',
{ns: 'electrophysiology_uploader'})]}>
{cell}
</a>
</td>
Expand All @@ -38,11 +41,11 @@ export default function UploadViewer(props) {

const fields = [
{
label: 'Upload ID',
label: t('Upload ID', {ns: 'electrophysiology_uploader'}),
show: true,
},
{
label: 'Site',
label: t('Site', {ns: 'loris'}),
show: true,
filter: {
name: 'site',
Expand All @@ -51,15 +54,15 @@ export default function UploadViewer(props) {
},
},
{
label: 'PSCID',
label: t('PSCID', {ns: 'loris'}),
show: true,
filter: {
name: 'pscid',
type: 'text',
},
},
{
label: 'Visit',
label: t('Visit Label', {ns: 'loris'}),
show: true,
filter: {
name: 'visitLabel',
Expand All @@ -68,19 +71,19 @@ export default function UploadViewer(props) {
},
},
{
label: 'Upload Location',
label: t('Upload Location', {ns: 'electrophysiology_uploader'}),
show: true,
},
{
label: 'Upload Time',
label: t('Upload Time', {ns: 'electrophysiology_uploader'}),
show: false,
},
{
label: 'Status',
label: t('Status', {ns: 'electrophysiology_uploader'}),
show: true,
},
{
label: 'Uploaded By',
label: t('Uploaded By', {ns: 'electrophysiology_uploader'}),
show: true,
},
];
Expand All @@ -98,4 +101,5 @@ export default function UploadViewer(props) {
UploadViewer.propTypes = {
data: PropTypes.array.isRequired,
fieldOptions: PropTypes.object.isRequired,
t: PropTypes.func,
};
Loading
Loading