1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

add getLangText for reactfineuploader

This commit is contained in:
Tim Daubenschütz 2015-07-23 17:17:48 +02:00
parent 2f24ad8352
commit 01b34ec1fb
5 changed files with 22 additions and 13 deletions

View File

@ -2,6 +2,8 @@
import React from 'react'; import React from 'react';
import { getLangText } from '../../utils/lang_utils';
let FileDragAndDropDialog = React.createClass({ let FileDragAndDropDialog = React.createClass({
propTypes: { propTypes: {
hasFiles: React.PropTypes.bool, hasFiles: React.PropTypes.bool,
@ -15,17 +17,19 @@ let FileDragAndDropDialog = React.createClass({
} else { } else {
if(this.props.multipleFiles) { if(this.props.multipleFiles) {
return ( return (
<span className="file-drag-and-drop-dialog">Click or drag to add files</span> <span className="file-drag-and-drop-dialog">
{getLangText('Click or drag to add files')}
</span>
); );
} else { } else {
return ( return (
<span className="file-drag-and-drop-dialog"> <span className="file-drag-and-drop-dialog">
<p>Drag a file here</p> <p>{getLangText('Drag a file here')}</p>
<p>or</p> <p>{getLangText('or')}</p>
<span <span
className="btn btn-default" className="btn btn-default"
onClick={this.props.onClick}> onClick={this.props.onClick}>
choose a file to upload {getLangText('choose a file to upload')}
</span> </span>
</span> </span>
); );

View File

@ -4,7 +4,7 @@ import React from 'react';
import FileDragAndDropPreviewImage from './file_drag_and_drop_preview_image'; import FileDragAndDropPreviewImage from './file_drag_and_drop_preview_image';
import FileDragAndDropPreviewOther from './file_drag_and_drop_preview_other'; import FileDragAndDropPreviewOther from './file_drag_and_drop_preview_other';
import { getLangText } from '../../utils/lang_utils.js' import { getLangText } from '../../utils/lang_utils.js';
let FileDragAndDropPreview = React.createClass({ let FileDragAndDropPreview = React.createClass({

View File

@ -4,7 +4,7 @@ import React from 'react';
import ProgressBar from 'react-progressbar'; import ProgressBar from 'react-progressbar';
import AppConstants from '../../constants/application_constants'; import AppConstants from '../../constants/application_constants';
import { getLangText } from '../../utils/lang_utils.js' import { getLangText } from '../../utils/lang_utils.js';
let FileDragAndDropPreviewOther = React.createClass({ let FileDragAndDropPreviewOther = React.createClass({
propTypes: { propTypes: {

View File

@ -142,7 +142,7 @@ var ReactS3FineUploader = React.createClass({
endpoint: null endpoint: null
}, },
messages: { messages: {
unsupportedBrowser: '<h3>Upload is not functional in IE7 as IE7 has no support for CORS!</h3>' unsupportedBrowser: '<h3>' + getLangText('Upload is not functional in IE7 as IE7 has no support for CORS!') + '</h3>'
}, },
formatFileName: function(name){// fix maybe formatFileName: function(name){// fix maybe
if (name !== undefined && name.length > 26) { if (name !== undefined && name.length > 26) {
@ -151,7 +151,7 @@ var ReactS3FineUploader = React.createClass({
return name; return name;
}, },
multiple: false, multiple: false,
defaultErrorMessage: 'Unexpected error. Please contact us if this happens repeatedly.' defaultErrorMessage: getLangText('Unexpected error. Please contact us if this happens repeatedly.')
}; };
}, },
@ -278,7 +278,7 @@ var ReactS3FineUploader = React.createClass({
file.s3Url = res.digitalwork.url_safe; file.s3Url = res.digitalwork.url_safe;
file.s3UrlSafe = res.digitalwork.url_safe; file.s3UrlSafe = res.digitalwork.url_safe;
} else { } else {
throw new Error('Could not find a url to download.'); throw new Error(getLangText('Could not find a url to download.'));
} }
defer.success(res.key); defer.success(res.key);
}) })
@ -334,7 +334,9 @@ var ReactS3FineUploader = React.createClass({
onValidate(data) { onValidate(data) {
if(data.size > this.props.validation.sizeLimit) { if(data.size > this.props.validation.sizeLimit) {
this.state.uploader.cancelAll(); this.state.uploader.cancelAll();
let notification = new GlobalNotificationModel('Your file is bigger than ' + this.props.validation.sizeLimit / 1000000 + 'MB', 'danger', 5000);
let fileSizeInMegaBytes = this.props.validation.sizeLimit / 1000000;
let notification = new GlobalNotificationModel(getLangText('Your file is bigger than %d MB', fileSizeInMegaBytes), 'danger', 5000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
} }
}, },
@ -342,7 +344,7 @@ var ReactS3FineUploader = React.createClass({
onCancel(id) { onCancel(id) {
this.removeFileWithIdFromFilesToUpload(id); this.removeFileWithIdFromFilesToUpload(id);
let notification = new GlobalNotificationModel('File upload canceled', 'success', 5000); let notification = new GlobalNotificationModel(getLangText('File upload canceled'), 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
// since the form validation props isReadyForFormSubmission, setIsUploadReady and submitKey // since the form validation props isReadyForFormSubmission, setIsUploadReady and submitKey
@ -459,7 +461,7 @@ var ReactS3FineUploader = React.createClass({
if(this.state.uploader.pauseUpload(fileId)) { if(this.state.uploader.pauseUpload(fileId)) {
this.setStatusOfFile(fileId, 'paused'); this.setStatusOfFile(fileId, 'paused');
} else { } else {
throw new Error('File upload could not be paused.'); throw new Error(getLangText('File upload could not be paused.'));
} }
}, },
@ -468,7 +470,7 @@ var ReactS3FineUploader = React.createClass({
if(this.state.uploader.continueUpload(fileId)) { if(this.state.uploader.continueUpload(fileId)) {
this.setStatusOfFile(fileId, 'uploading'); this.setStatusOfFile(fileId, 'uploading');
} else { } else {
throw new Error('File upload could not be resumed.'); throw new Error(getLangText('File upload could not be resumed.'));
} }
}, },

View File

@ -37,6 +37,9 @@ export function computeHashOfFile(file) {
let fileReader = new FileReader(); let fileReader = new FileReader();
let startTime = new Date(); let startTime = new Date();
// comment: We should convert this to es6 at some point, however if so please consider that
// an arrow function will get rid of the function's scope...
fileReader.onload = function(e) { fileReader.onload = function(e) {
//console.log('read chunk nr', currentChunk + 1, 'of', chunks); //console.log('read chunk nr', currentChunk + 1, 'of', chunks);
spark.append(e.target.result); // Append array buffer spark.append(e.target.result); // Append array buffer