mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 23:20:51 +00:00
[eslint] updated eslintrc and improved the code (#4702)
This commit is contained in:
@@ -94,8 +94,8 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
|
||||
onbeforeunload = () => {
|
||||
if (window.uploader &&
|
||||
window.uploader.isUploadProgressDialogShow &&
|
||||
if (window.uploader &&
|
||||
window.uploader.isUploadProgressDialogShow &&
|
||||
window.uploader.totalProgress !== 100) {
|
||||
return '';
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class FileUploader extends React.Component {
|
||||
let allFilesUploaded = this.state.allFilesUploaded;
|
||||
if (allFilesUploaded === true) {
|
||||
this.setState({allFilesUploaded: false});
|
||||
}
|
||||
}
|
||||
|
||||
//get parent_dir relative_path
|
||||
let path = this.props.path === '/' ? '/' : this.props.path + '/';
|
||||
@@ -208,7 +208,7 @@ class FileUploader extends React.Component {
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
this.setUploadFileList(this.resumable.files);
|
||||
if (!this.isUploadLinkLoaded) {
|
||||
this.isUploadLinkLoaded = true;
|
||||
@@ -288,7 +288,7 @@ class FileUploader extends React.Component {
|
||||
if (this.timestamp) {
|
||||
let timeDiff = (now - this.timestamp);
|
||||
if (timeDiff < this.bitrateInterval) {
|
||||
return this.state.uploadBitrate;
|
||||
return this.state.uploadBitrate;
|
||||
}
|
||||
|
||||
// 1. Cancel will produce loaded greater than this.loaded
|
||||
@@ -302,10 +302,10 @@ class FileUploader extends React.Component {
|
||||
|
||||
this.timestamp = now;
|
||||
this.loaded = loaded;
|
||||
|
||||
|
||||
return uploadBitrate;
|
||||
}
|
||||
|
||||
|
||||
onProgress = () => {
|
||||
let progress = Math.round(this.resumable.progress() * 100);
|
||||
this.setState({totalProgress: progress});
|
||||
@@ -395,7 +395,7 @@ class FileUploader extends React.Component {
|
||||
} else {
|
||||
// eg: '{"error": "Internal error" \n }'
|
||||
let errorMessage = message.replace(/\n/g, '');
|
||||
errorMessage = JSON.parse(errorMessage);
|
||||
errorMessage = JSON.parse(errorMessage);
|
||||
error = errorMessage.error;
|
||||
if (error === 'File locked by others.') {
|
||||
error = gettext('File is locked by others.');
|
||||
@@ -489,12 +489,12 @@ class FileUploader extends React.Component {
|
||||
onFileUpload = () => {
|
||||
this.uploadInput.current.removeAttribute('webkitdirectory');
|
||||
|
||||
this.uploadInput.current.click();
|
||||
this.uploadInput.current.click();
|
||||
}
|
||||
|
||||
onFolderUpload = () => {
|
||||
this.uploadInput.current.setAttribute('webkitdirectory', 'webkitdirectory');
|
||||
this.uploadInput.current.click();
|
||||
this.uploadInput.current.click();
|
||||
}
|
||||
|
||||
onDragStart = () => {
|
||||
@@ -534,7 +534,7 @@ class FileUploader extends React.Component {
|
||||
onCancelAllUploading = () => {
|
||||
let uploadFileList = this.state.uploadFileList.filter(item => {
|
||||
if (Math.round(item.progress() !== 1)) {
|
||||
item.cancel();
|
||||
item.cancel();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -555,7 +555,7 @@ class FileUploader extends React.Component {
|
||||
|
||||
seafileAPI.getFileServerUploadLink(this.props.repoID, this.props.path).then(res => {
|
||||
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||
|
||||
|
||||
let retryFileList = this.state.retryFileList.filter(item => {
|
||||
return item.uniqueIdentifier !== resumableFile.uniqueIdentifier;
|
||||
});
|
||||
@@ -566,7 +566,7 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
|
||||
this.setState({
|
||||
retryFileList: retryFileList,
|
||||
uploadFileList: uploadFileList
|
||||
@@ -585,7 +585,7 @@ class FileUploader extends React.Component {
|
||||
item.error = false;
|
||||
this.retryUploadFile(item);
|
||||
});
|
||||
|
||||
|
||||
let uploadFileList = this.state.uploadFileList.slice(0);
|
||||
this.setState({
|
||||
retryFileList: [],
|
||||
@@ -607,7 +607,7 @@ class FileUploader extends React.Component {
|
||||
let prefix = path === '/' ? (path + relative_path) : (path + '/' + relative_path);
|
||||
fileName = prefix + fileName;
|
||||
}
|
||||
|
||||
|
||||
resumableFile.bootstrap();
|
||||
var firedRetry = false;
|
||||
resumableFile.resumableObj.on('chunkingComplete', () => {
|
||||
@@ -617,9 +617,9 @@ class FileUploader extends React.Component {
|
||||
let blockSize = parseInt(resumableUploadFileBlockSize) * 1024 * 1024 || 1024 * 1024;
|
||||
let offset = Math.floor(uploadedBytes / blockSize);
|
||||
resumableFile.markChunksCompleted(offset);
|
||||
|
||||
|
||||
resumableFile.resumableObj.upload();
|
||||
|
||||
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
@@ -627,7 +627,7 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
firedRetry = true;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
replaceRepetitionFile = () => {
|
||||
@@ -646,7 +646,7 @@ class FileUploader extends React.Component {
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uploadFile = () => {
|
||||
let resumableFile = this.resumable.files[this.resumable.files.length - 1];
|
||||
let { repoID, path } = this.props;
|
||||
|
@@ -33,7 +33,7 @@ class UploadListItem extends React.Component {
|
||||
if (resumableFile.remainingTime === 0 && !resumableFile.isSaved) {
|
||||
uploadState = UPLOAD_ISSAVING;
|
||||
}
|
||||
|
||||
|
||||
if (resumableFile.isSaved) {
|
||||
uploadState = UPLOAD_UPLOADED;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ class UploadProgressDialog extends React.Component {
|
||||
|
||||
render() {
|
||||
|
||||
let uploadBitrate = Utils.formatBitRate(this.props.uploadBitrate)
|
||||
let uploadBitrate = Utils.formatBitRate(this.props.uploadBitrate);
|
||||
let uploadedMessage = gettext('File Upload');
|
||||
let uploadingMessage = gettext('File Uploading...') + ' ' + this.props.totalProgress + '%' + ' (' + uploadBitrate + ')';
|
||||
|
||||
@@ -82,7 +82,7 @@ class UploadProgressDialog extends React.Component {
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className="text-right" colSpan={3}>
|
||||
{retryFileList.length > 0 ?
|
||||
{retryFileList.length > 0 ?
|
||||
<span className="cursor-pointer" onClick={this.props.onUploadRetryAll}>{gettext('Retry All')}</span>
|
||||
:
|
||||
<span className="cursor-pointer disabled-link">{gettext('Retry All')}</span>
|
||||
@@ -104,9 +104,9 @@ class UploadProgressDialog extends React.Component {
|
||||
{
|
||||
this.props.uploadFileList.map((resumableFile, index) => {
|
||||
return (
|
||||
<UploadListItem
|
||||
key={index}
|
||||
resumableFile={resumableFile}
|
||||
<UploadListItem
|
||||
key={index}
|
||||
resumableFile={resumableFile}
|
||||
onUploadCancel={this.props.onUploadCancel}
|
||||
onUploadRetry={this.props.onUploadRetry}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user