mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
fix code format (#6365)
This commit is contained in:
@@ -2,10 +2,9 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Resumablejs from '@seafile/resumablejs';
|
||||
import MD5 from 'MD5';
|
||||
import { resumableUploadFileBlockSize, maxUploadFileSize, maxNumberOfFilesForFileupload } from '../../utils/constants';
|
||||
import { gettext, resumableUploadFileBlockSize, maxUploadFileSize, maxNumberOfFilesForFileupload } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import UploadProgressDialog from './upload-progress-dialog';
|
||||
import UploadRemindDialog from '../dialog/upload-remind-dialog';
|
||||
import toaster from '../toast';
|
||||
@@ -81,7 +80,7 @@ class FileUploader extends React.Component {
|
||||
|
||||
this.resumable.assignBrowse(this.uploadInput.current, true);
|
||||
|
||||
//Enable or Disable DragAnd Drop
|
||||
// Enable or Disable DragAnd Drop
|
||||
if (this.props.dragAndDrop === true) {
|
||||
this.resumable.enableDropOnDocument();
|
||||
}
|
||||
@@ -153,26 +152,26 @@ class FileUploader extends React.Component {
|
||||
maxFileSizeErrorCallback = (file) => {
|
||||
let { forbidUploadFileList } = this.state;
|
||||
forbidUploadFileList.push(file);
|
||||
this.setState({forbidUploadFileList: forbidUploadFileList});
|
||||
this.setState({ forbidUploadFileList: forbidUploadFileList });
|
||||
};
|
||||
|
||||
onChunkingComplete = (resumableFile) => {
|
||||
|
||||
//get parent_dir relative_path
|
||||
// get parent_dir relative_path
|
||||
let path = this.props.path === '/' ? '/' : this.props.path + '/';
|
||||
let fileName = resumableFile.fileName;
|
||||
let relativePath = resumableFile.relativePath;
|
||||
let isFile = fileName === relativePath;
|
||||
|
||||
//update formdata
|
||||
// update formdata
|
||||
resumableFile.formData = {};
|
||||
if (isFile) { // upload file
|
||||
resumableFile.formData = {
|
||||
resumableFile.formData = {
|
||||
parent_dir: path,
|
||||
};
|
||||
} else { // upload folder
|
||||
let relative_path = relativePath.slice(0, relativePath.lastIndexOf('/') + 1);
|
||||
resumableFile.formData = {
|
||||
resumableFile.formData = {
|
||||
parent_dir: path,
|
||||
relative_path: relative_path
|
||||
};
|
||||
@@ -310,7 +309,7 @@ class FileUploader extends React.Component {
|
||||
|
||||
onProgress = () => {
|
||||
let progress = Math.round(this.resumable.progress() * 100);
|
||||
this.setState({totalProgress: progress});
|
||||
this.setState({ totalProgress: progress });
|
||||
Utils.registerGlobalVariable('uploader', 'totalProgress', progress);
|
||||
};
|
||||
|
||||
@@ -343,7 +342,7 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -365,7 +364,7 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -387,17 +386,17 @@ class FileUploader extends React.Component {
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
};
|
||||
|
||||
getFileServerErrorMessage = (key) => {
|
||||
const errorMessage = {
|
||||
'File locked by others.': gettext('File is locked by others.'), // 403
|
||||
'Invalid filename.': gettext('Invalid filename.'), // 440
|
||||
'File already exists.': gettext('File already exists.'), // 441
|
||||
'File size is too large.': gettext('File size is too large.'), // 442
|
||||
'Out of quota.': gettext('Out of quota.'), // 443
|
||||
'Internal error.': gettext('Internal Server Error'), // 500
|
||||
'File locked by others.': gettext('File is locked by others.'), // 403
|
||||
'Invalid filename.': gettext('Invalid filename.'), // 440
|
||||
'File already exists.': gettext('File already exists.'), // 441
|
||||
'File size is too large.': gettext('File size is too large.'), // 442
|
||||
'Out of quota.': gettext('Out of quota.'), // 443
|
||||
'Internal error.': gettext('Internal Server Error'), // 500
|
||||
};
|
||||
return errorMessage[key] || key;
|
||||
};
|
||||
@@ -409,7 +408,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 = this.getFileServerErrorMessage(errorMessage.error);
|
||||
}
|
||||
|
||||
@@ -421,7 +420,7 @@ class FileUploader extends React.Component {
|
||||
return item;
|
||||
});
|
||||
|
||||
this.loaded = 0; // reset loaded data;
|
||||
this.loaded = 0; // reset loaded data;
|
||||
this.setState({
|
||||
retryFileList: this.state.retryFileList,
|
||||
uploadFileList: uploadFileList
|
||||
@@ -483,7 +482,7 @@ class FileUploader extends React.Component {
|
||||
};
|
||||
|
||||
generateUniqueIdentifier = (file) => {
|
||||
let relativePath = file.webkitRelativePath||file.relativePath||file.fileName||file.name;
|
||||
let relativePath = file.webkitRelativePath || file.relativePath || file.fileName || file.name;
|
||||
return MD5(relativePath + new Date()) + relativePath;
|
||||
};
|
||||
|
||||
@@ -512,7 +511,7 @@ class FileUploader extends React.Component {
|
||||
this.resumable.files = [];
|
||||
// reset upload link loaded
|
||||
this.isUploadLinkLoaded = false;
|
||||
this.setState({isUploadProgressDialogShow: false, uploadFileList: [], forbidUploadFileList: []});
|
||||
this.setState({ isUploadProgressDialogShow: false, uploadFileList: [], forbidUploadFileList: [] });
|
||||
Utils.registerGlobalVariable('uploader', 'isUploadProgressDialogShow', false);
|
||||
};
|
||||
|
||||
@@ -533,7 +532,7 @@ class FileUploader extends React.Component {
|
||||
this.loaded = 0;
|
||||
}
|
||||
|
||||
this.setState({uploadFileList: uploadFileList});
|
||||
this.setState({ uploadFileList: uploadFileList });
|
||||
};
|
||||
|
||||
onCancelAllUploading = () => {
|
||||
@@ -642,7 +641,7 @@ class FileUploader extends React.Component {
|
||||
let resumableFile = this.resumable.files[this.resumable.files.length - 1];
|
||||
resumableFile.formData['replace'] = 1;
|
||||
resumableFile.formData['target_file'] = resumableFile.formData.parent_dir + resumableFile.fileName;
|
||||
this.setState({isUploadRemindDialogShow: false});
|
||||
this.setState({ isUploadRemindDialogShow: false });
|
||||
this.setUploadFileList(this.resumable.files);
|
||||
this.resumable.upload();
|
||||
}).catch(error => {
|
||||
@@ -654,7 +653,7 @@ class FileUploader extends React.Component {
|
||||
uploadFile = () => {
|
||||
let resumableFile = this.resumable.files[this.resumable.files.length - 1];
|
||||
let { repoID, path } = this.props;
|
||||
seafileAPI.getFileServerUploadLink(repoID, path).then((res) => { // get upload link
|
||||
seafileAPI.getFileServerUploadLink(repoID, path).then((res) => { // get upload link
|
||||
this.resumable.opts.target = res.data + '?ret-json=1';
|
||||
this.setState({
|
||||
isUploadRemindDialogShow: false,
|
||||
@@ -672,8 +671,8 @@ class FileUploader extends React.Component {
|
||||
};
|
||||
|
||||
cancelFileUpload = () => {
|
||||
this.resumable.files.pop(); //delete latest file;
|
||||
this.setState({isUploadRemindDialogShow: false});
|
||||
this.resumable.files.pop(); // delete latest file;
|
||||
this.setState({ isUploadRemindDialogShow: false });
|
||||
};
|
||||
|
||||
render() {
|
||||
|
Reference in New Issue
Block a user