1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

improve upload interactive (#3941)

* improve upload interactive

* improve code
This commit is contained in:
杨顺强
2019-08-02 20:53:39 +08:00
committed by Daniel Pan
parent d62a5584b7
commit 067b17b013
4 changed files with 59 additions and 20 deletions

View File

@@ -53,6 +53,7 @@ class FileUploader extends React.Component {
this.timestamp = null;
this.loaded = 0;
this.bitrateInterval = 500; // Interval in milliseconds to calculate the bitrate
window.onbeforeunload = this.onbeforeunload;
}
componentDidMount() {
@@ -86,11 +87,20 @@ class FileUploader extends React.Component {
}
componentWillUnmount = () => {
window.onbeforeunload = null;
if (this.props.dragAndDrop === true) {
this.resumable.disableDropOnDocument();
}
}
onbeforeunload = () => {
if (window.uploader &&
window.uploader.isUploadProgressDialogShow &&
window.uploader.totalProgress !== 100) {
return '';
}
}
bindCallbackHandler = () => {
let {maxFilesErrorCallback, minFileSizeErrorCallback, maxFileSizeErrorCallback, fileTypeErrorCallback } = this.props;
@@ -207,6 +217,7 @@ class FileUploader extends React.Component {
isUploadProgressDialogShow: true,
uploadFileList: uploadFileList,
});
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', true);
}
buildCustomFileObj = (resumableFile) => {
@@ -261,6 +272,7 @@ class FileUploader extends React.Component {
totalProgress: progress,
uploadBitrate: uploadBitrate
});
Utils.registerGlobalVariable('uploader', 'totalProgress', progress);
}
onFileUploadSuccess = (resumableFile, message) => {
@@ -466,6 +478,7 @@ class FileUploader extends React.Component {
onCloseUploadDialog = () => {
this.resumable.files = [];
this.setState({isUploadProgressDialogShow: false, uploadFileList: []});
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', false);
}
onUploadCancel = (uploadingItem) => {
@@ -529,6 +542,7 @@ class FileUploader extends React.Component {
}, () => {
this.resumable.upload();
});
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', true);
}
cancelFileUpload = () => {