mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Merge branch 'AD-812-cannot-reupload-video-without-refresh' into AD-1340-add-details-video-upload-errors
This commit is contained in:
commit
66a38314e3
@ -45,6 +45,10 @@ let FileDragAndDrop = React.createClass({
|
|||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearSelection() {
|
||||||
|
this.refs.fileSelector.getDOMNode().value = '';
|
||||||
|
},
|
||||||
|
|
||||||
handleDragOver(event) {
|
handleDragOver(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
@ -81,30 +85,30 @@ let FileDragAndDrop = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleDeleteFile(fileId) {
|
handleDeleteFile(fileId) {
|
||||||
// input's value is not change the second time someone
|
// input's value is not changed the second time someone
|
||||||
// inputs the same file again, therefore we need to reset its value
|
// inputs the same file again, therefore we need to reset its value
|
||||||
this.refs.fileinput.getDOMNode().value = '';
|
this.clearSelection();
|
||||||
this.props.handleDeleteFile(fileId);
|
this.props.handleDeleteFile(fileId);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleCancelFile(fileId) {
|
handleCancelFile(fileId) {
|
||||||
// input's value is not change the second time someone
|
// input's value is not changed the second time someone
|
||||||
// inputs the same file again, therefore we need to reset its value
|
// inputs the same file again, therefore we need to reset its value
|
||||||
this.refs.fileinput.getDOMNode().value = '';
|
this.clearSelection();
|
||||||
this.props.handleCancelFile(fileId);
|
this.props.handleCancelFile(fileId);
|
||||||
},
|
},
|
||||||
|
|
||||||
handlePauseFile(fileId) {
|
handlePauseFile(fileId) {
|
||||||
// input's value is not change the second time someone
|
// input's value is not changed the second time someone
|
||||||
// inputs the same file again, therefore we need to reset its value
|
// inputs the same file again, therefore we need to reset its value
|
||||||
this.refs.fileinput.getDOMNode().value = '';
|
this.clearSelection();
|
||||||
this.props.handlePauseFile(fileId);
|
this.props.handlePauseFile(fileId);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleResumeFile(fileId) {
|
handleResumeFile(fileId) {
|
||||||
// input's value is not change the second time someone
|
// input's value is not changed the second time someone
|
||||||
// inputs the same file again, therefore we need to reset its value
|
// inputs the same file again, therefore we need to reset its value
|
||||||
this.refs.fileinput.getDOMNode().value = '';
|
this.clearSelection();
|
||||||
this.props.handleResumeFile(fileId);
|
this.props.handleResumeFile(fileId);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -133,7 +137,7 @@ let FileDragAndDrop = React.createClass({
|
|||||||
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
|
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refs.fileinput.getDOMNode().dispatchEvent(evt);
|
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
@ -206,7 +210,7 @@ let FileDragAndDrop = React.createClass({
|
|||||||
*/}
|
*/}
|
||||||
<input
|
<input
|
||||||
multiple={multiple}
|
multiple={multiple}
|
||||||
ref="fileinput"
|
ref="fileSelector"
|
||||||
type="file"
|
type="file"
|
||||||
style={{
|
style={{
|
||||||
visibility: 'hidden',
|
visibility: 'hidden',
|
||||||
|
@ -192,11 +192,11 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
filesToUpload: [],
|
filesToUpload: [],
|
||||||
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
uploader: new fineUploader.s3.FineUploaderBasic(this.propsToConfig()),
|
||||||
csrfToken: getCookie(AppConstants.csrftoken),
|
csrfToken: getCookie(AppConstants.csrftoken),
|
||||||
|
|
||||||
// -1: aborted
|
// -1: aborted
|
||||||
// -2: uninitialized
|
// -2: uninitialized
|
||||||
hashingProgress: -2,
|
hashingProgress: -2,
|
||||||
|
|
||||||
// this is for logging
|
// this is for logging
|
||||||
chunks: {}
|
chunks: {}
|
||||||
};
|
};
|
||||||
@ -259,7 +259,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
// Resets the whole react fineuploader component to its initial state
|
// Resets the whole react fineuploader component to its initial state
|
||||||
reset() {
|
reset() {
|
||||||
// Cancel all currently ongoing uploads
|
// Cancel all currently ongoing uploads
|
||||||
this.state.uploader.cancelAll();
|
this.cancelUploads();
|
||||||
|
|
||||||
// and reset component in general
|
// and reset component in general
|
||||||
this.state.uploader.reset();
|
this.state.uploader.reset();
|
||||||
@ -271,6 +271,22 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
this.setState(this.getInitialState());
|
this.setState(this.getInitialState());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Cancel uploads and clear previously selected files on the input element
|
||||||
|
cancelUploads(id) {
|
||||||
|
!!id ? this.state.uploader.cancel(id) : this.state.uploader.cancelAll();
|
||||||
|
|
||||||
|
// Reset the file input element to clear the previously selected files so that
|
||||||
|
// the user can reselect them again.
|
||||||
|
this.clearFileSelection();
|
||||||
|
},
|
||||||
|
|
||||||
|
clearFileSelection() {
|
||||||
|
const { fileInput } = this.refs;
|
||||||
|
if (fileInput && typeof fileInput.clearSelection === 'function') {
|
||||||
|
fileInput.clearSelection();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
requestKey(fileId) {
|
requestKey(fileId) {
|
||||||
let filename = this.state.uploader.getName(fileId);
|
let filename = this.state.uploader.getName(fileId);
|
||||||
let uuid = this.state.uploader.getUuid(fileId);
|
let uuid = this.state.uploader.getUuid(fileId);
|
||||||
@ -373,7 +389,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
|
|
||||||
let chunks = this.state.chunks;
|
let chunks = this.state.chunks;
|
||||||
let chunkKey = id + '-' + chunkData.startByte + '-' + chunkData.endByte;
|
let chunkKey = id + '-' + chunkData.startByte + '-' + chunkData.endByte;
|
||||||
|
|
||||||
if(chunks[chunkKey]) {
|
if(chunks[chunkKey]) {
|
||||||
chunks[chunkKey].completed = true;
|
chunks[chunkKey].completed = true;
|
||||||
chunks[chunkKey].responseJson = responseJson;
|
chunks[chunkKey].responseJson = responseJson;
|
||||||
@ -414,7 +430,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
console.warn('You didn\'t define submitFile in as a prop in react-s3-fine-uploader');
|
console.warn('You didn\'t define submitFile in as a prop in react-s3-fine-uploader');
|
||||||
}
|
}
|
||||||
|
|
||||||
// for explanation, check comment of if statement above
|
// for explanation, check comment of if statement above
|
||||||
if(this.props.isReadyForFormSubmission && this.props.setIsUploadReady) {
|
if(this.props.isReadyForFormSubmission && this.props.setIsUploadReady) {
|
||||||
// also, lets check if after the completion of this upload,
|
// also, lets check if after the completion of this upload,
|
||||||
@ -445,7 +461,8 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
files: this.state.filesToUpload,
|
files: this.state.filesToUpload,
|
||||||
chunks: this.state.chunks
|
chunks: this.state.chunks
|
||||||
});
|
});
|
||||||
this.state.uploader.cancelAll();
|
|
||||||
|
this.cancelUploads();
|
||||||
|
|
||||||
let notification = new GlobalNotificationModel(errorReason || this.props.defaultErrorMessage, 'danger', 5000);
|
let notification = new GlobalNotificationModel(errorReason || this.props.defaultErrorMessage, 'danger', 5000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
@ -588,7 +605,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleCancelFile(fileId) {
|
handleCancelFile(fileId) {
|
||||||
this.state.uploader.cancel(fileId);
|
this.cancelUploads(fileId);
|
||||||
},
|
},
|
||||||
|
|
||||||
handlePauseFile(fileId) {
|
handlePauseFile(fileId) {
|
||||||
@ -597,7 +614,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
throw new Error(getLangText('File upload could not be paused.'));
|
throw new Error(getLangText('File upload could not be paused.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleResumeFile(fileId) {
|
handleResumeFile(fileId) {
|
||||||
@ -612,6 +629,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
// If multiple set and user already uploaded its work,
|
// If multiple set and user already uploaded its work,
|
||||||
// cancel upload
|
// cancel upload
|
||||||
if(!this.props.multiple && this.state.filesToUpload.filter(displayValidFilesFilter).length > 0) {
|
if(!this.props.multiple && this.state.filesToUpload.filter(displayValidFilesFilter).length > 0) {
|
||||||
|
this.clearFileSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -823,7 +841,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
changeSet.status = { $set: status };
|
changeSet.status = { $set: status };
|
||||||
|
|
||||||
let filesToUpload = React.addons.update(this.state.filesToUpload, { [fileId]: changeSet });
|
let filesToUpload = React.addons.update(this.state.filesToUpload, { [fileId]: changeSet });
|
||||||
|
|
||||||
this.setState({ filesToUpload });
|
this.setState({ filesToUpload });
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -850,7 +868,7 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let {
|
const {
|
||||||
multiple,
|
multiple,
|
||||||
areAssetsDownloadable,
|
areAssetsDownloadable,
|
||||||
areAssetsEditable,
|
areAssetsEditable,
|
||||||
@ -858,13 +876,10 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
enableLocalHashing,
|
enableLocalHashing,
|
||||||
fileClassToUpload,
|
fileClassToUpload,
|
||||||
validation,
|
validation,
|
||||||
fileInputElement,
|
fileInputElement: FileInputElement,
|
||||||
location
|
location } = this.props;
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
// Here we initialize the template that has been either provided from the outside
|
const props = {
|
||||||
// or the default input that is FileDragAndDrop.
|
|
||||||
return React.createElement(fileInputElement, {
|
|
||||||
multiple,
|
multiple,
|
||||||
areAssetsDownloadable,
|
areAssetsDownloadable,
|
||||||
areAssetsEditable,
|
areAssetsEditable,
|
||||||
@ -882,10 +897,14 @@ let ReactS3FineUploader = React.createClass({
|
|||||||
dropzoneInactive: this.isDropzoneInactive(),
|
dropzoneInactive: this.isDropzoneInactive(),
|
||||||
hashingProgress: this.state.hashingProgress,
|
hashingProgress: this.state.hashingProgress,
|
||||||
allowedExtensions: this.getAllowedExtensions()
|
allowedExtensions: this.getAllowedExtensions()
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FileInputElement
|
||||||
|
ref="fileInput"
|
||||||
|
{...props} />
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export default ReactS3FineUploader;
|
export default ReactS3FineUploader;
|
||||||
|
@ -4399,7 +4399,9 @@ qq.UploadHandlerController = function(o, namespace) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.done(function() {
|
.done(function() {
|
||||||
handler.clearXhr(id, chunkIdx);
|
if (handler._getFileState(id)) {
|
||||||
|
handler.clearXhr(id, chunkIdx);
|
||||||
|
}
|
||||||
}) ;
|
}) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user