mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 22:01:06 +00:00
console log upload message (#3083)
* console log upload message * add error message prompt
This commit is contained in:
@@ -5,6 +5,7 @@ import MD5 from 'MD5';
|
|||||||
import { enableResumableFileUpload } from '../../utils/constants';
|
import { enableResumableFileUpload } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
|
import { gettext } from '../../utils/constants';
|
||||||
import UploadProgressDialog from './upload-progress-dialog';
|
import UploadProgressDialog from './upload-progress-dialog';
|
||||||
import UploadRemindDialog from '../dialog/upload-remind-dialog';
|
import UploadRemindDialog from '../dialog/upload-remind-dialog';
|
||||||
import '../../css/file-uploader.css';
|
import '../../css/file-uploader.css';
|
||||||
@@ -40,7 +41,8 @@ class FileUploader extends React.Component {
|
|||||||
isUploadProgressDialogShow: false,
|
isUploadProgressDialogShow: false,
|
||||||
isUploadRemindDialogShow: false,
|
isUploadRemindDialogShow: false,
|
||||||
currentResumableFile: null,
|
currentResumableFile: null,
|
||||||
uploadBitrate: '0'
|
uploadBitrate: '0',
|
||||||
|
allFilesUploaded: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.uploadInput = React.createRef();
|
this.uploadInput = React.createRef();
|
||||||
@@ -68,6 +70,7 @@ class FileUploader extends React.Component {
|
|||||||
fileParameterName: this.props.fileParameterName,
|
fileParameterName: this.props.fileParameterName,
|
||||||
generateUniqueIdentifier: this.generateUniqueIdentifier,
|
generateUniqueIdentifier: this.generateUniqueIdentifier,
|
||||||
forceChunkSize: true,
|
forceChunkSize: true,
|
||||||
|
maxChunkRetries: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resumable.assignBrowse(this.uploadInput.current, true);
|
this.resumable.assignBrowse(this.uploadInput.current, true);
|
||||||
@@ -331,19 +334,34 @@ class FileUploader extends React.Component {
|
|||||||
this.setState({uploadFileList: uploadFileList});
|
this.setState({uploadFileList: uploadFileList});
|
||||||
}
|
}
|
||||||
|
|
||||||
onFileError = (file) => {
|
onFileError = (resumableFile, message) => {
|
||||||
|
let error = '';
|
||||||
|
if (!message) {
|
||||||
|
error = gettext('Network error');
|
||||||
|
} else {
|
||||||
|
error = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
let uploadFileList = this.state.uploadFileList.map(item => {
|
||||||
|
if (item.resumableFile.uniqueIdentifier === resumableFile.uniqueIdentifier) {
|
||||||
|
item.resumableFile.error = error;
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
this.setState({uploadFileList: uploadFileList});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onComplete = () => {
|
onComplete = () => {
|
||||||
this.notifiedFolders = [];
|
this.notifiedFolders = [];
|
||||||
|
this.setState({allFilesUploaded: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
onPause = () => {
|
onPause = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onError = () => {
|
onError = (message) => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,10 +531,11 @@ class FileUploader extends React.Component {
|
|||||||
<UploadProgressDialog
|
<UploadProgressDialog
|
||||||
uploadFileList={this.state.uploadFileList}
|
uploadFileList={this.state.uploadFileList}
|
||||||
totalProgress={this.state.totalProgress}
|
totalProgress={this.state.totalProgress}
|
||||||
|
uploadBitrate={this.state.uploadBitrate}
|
||||||
|
allFilesUploaded={this.state.allFilesUploaded}
|
||||||
onCloseUploadDialog={this.onCloseUploadDialog}
|
onCloseUploadDialog={this.onCloseUploadDialog}
|
||||||
onCancelAllUploading={this.onCancelAllUploading}
|
onCancelAllUploading={this.onCancelAllUploading}
|
||||||
onUploadCancel={this.onUploadCancel}
|
onUploadCancel={this.onUploadCancel}
|
||||||
uploadBitrate={this.state.uploadBitrate}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext } from '../../utils/constants';
|
import { gettext } from '../../utils/constants';
|
||||||
|
|
||||||
@@ -33,26 +33,35 @@ class UploadListItem extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
let { item } = this.props;
|
let { item } = this.props;
|
||||||
let progress = Math.round(item.resumableFile.progress() * 100);
|
let progress = Math.round(item.resumableFile.progress() * 100);
|
||||||
|
let error = item.resumableFile.error;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr className="file-upload-item">
|
<tr className="file-upload-item">
|
||||||
<td className="upload-name ellipsis">{item.resumableFile.relativePath}</td>
|
<td className="upload-name">
|
||||||
|
<div className="ellipsis">{item.resumableFile.relativePath}</div>
|
||||||
|
<div className="message err-message ml-0">{error}</div>
|
||||||
|
</td>
|
||||||
<td className="upload-progress">
|
<td className="upload-progress">
|
||||||
<span className="file-size">{this.formatFileSize(item.resumableFile.size)}</span>
|
<span className="file-size">{this.formatFileSize(item.resumableFile.size)}</span>
|
||||||
{progress !== 100 &&
|
{!item.resumableFile.error && progress !== 100 &&
|
||||||
<div className="progress">
|
<div className="progress">
|
||||||
<div className="progress-bar" role="progressbar" style={{width: `${progress}%`}} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
<div className="progress-bar" role="progressbar" style={{width: `${progress}%`}} aria-valuenow={progress} aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td className="upload-operation">
|
<td className="upload-operation">
|
||||||
{(!item.isSaved && progress !== 100) && (
|
{!item.resumableFile.error && (
|
||||||
<a href="#" onClick={this.onUploadCancel}>{gettext('cancel')}</a>
|
<Fragment>
|
||||||
)}
|
{(!item.isSaved && progress !== 100) && (
|
||||||
{(!item.isSaved && progress === 100) && (
|
<a href="#" onClick={this.onUploadCancel}>{gettext('cancel')}</a>
|
||||||
<span className="saving">{gettext('saving...')}</span>
|
)}
|
||||||
)}
|
{(!item.isSaved && progress === 100) && (
|
||||||
{item.isSaved && (
|
<span className="saving">{gettext('saving...')}</span>
|
||||||
<span className="uploaded">{gettext('uploaded')}</span>
|
)}
|
||||||
|
{item.isSaved && (
|
||||||
|
<span className="uploaded">{gettext('uploaded')}</span>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -10,6 +10,7 @@ const propTypes = {
|
|||||||
onCloseUploadDialog: PropTypes.func.isRequired,
|
onCloseUploadDialog: PropTypes.func.isRequired,
|
||||||
onCancelAllUploading: PropTypes.func.isRequired,
|
onCancelAllUploading: PropTypes.func.isRequired,
|
||||||
onUploadCancel: PropTypes.func.isRequired,
|
onUploadCancel: PropTypes.func.isRequired,
|
||||||
|
allFilesUploaded: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class UploadProgressDialog extends React.Component {
|
class UploadProgressDialog extends React.Component {
|
||||||
@@ -70,7 +71,7 @@ class UploadProgressDialog extends React.Component {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{(this.props.totalProgress !== 100) &&
|
{(!this.props.allFilesUploaded) &&
|
||||||
<tr><td className="text-right" colSpan={3}><span className="cursor-pointer" onClick={this.onCancelAllUploading}>{gettext('Cancel All')}</span></td></tr>
|
<tr><td className="text-right" colSpan={3}><span className="cursor-pointer" onClick={this.onCancelAllUploading}>{gettext('Cancel All')}</span></td></tr>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user