-
Notifications
You must be signed in to change notification settings - Fork 186
[electrophysiology_uploader] Translate electrophysiology uploader module #9988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SKADE2303
wants to merge
5
commits into
aces:main
Choose a base branch
from
SKADE2303:TranslateElectrophysiologyUploader
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
|
@@ -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, | ||
|
|
@@ -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, | ||
|
|
@@ -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(); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -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, | ||
| type: 'error', | ||
| }); | ||
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SKADE2303 , please remmenber we're not longuer using |
||
| 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> | ||
| } | ||
|
|
@@ -289,4 +306,6 @@ UploadForm.propTypes = { | |
| autoLaunch: PropTypes.string, | ||
| uploadURL: PropTypes.string.isRequired, | ||
| maxUploadSize: PropTypes.number, | ||
| refreshPage: PropTypes.func, | ||
| t: PropTypes.func, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.