2018-11-14 02:55:11 +00:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { gettext } from '../../utils/constants';
|
|
|
|
import UploadListItem from './upload-list-item';
|
|
|
|
|
|
|
|
const propTypes = {
|
2019-01-08 03:26:20 +00:00
|
|
|
uploadBitrate: PropTypes.number.isRequired,
|
2018-11-14 02:55:11 +00:00
|
|
|
totalProgress: PropTypes.number.isRequired,
|
|
|
|
uploadFileList: PropTypes.array.isRequired,
|
|
|
|
onCloseUploadDialog: PropTypes.func.isRequired,
|
2019-01-08 03:26:20 +00:00
|
|
|
onCancelAllUploading: PropTypes.func.isRequired,
|
2018-11-14 02:55:11 +00:00
|
|
|
onUploadCancel: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
class UploadProgressDialog extends React.Component {
|
|
|
|
|
2019-01-08 03:26:20 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isMinimized: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelAllUploading = () => {
|
|
|
|
this.props.onCancelAllUploading();
|
|
|
|
}
|
|
|
|
|
2018-11-14 02:55:11 +00:00
|
|
|
onMinimizeUpload = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
2019-01-08 03:26:20 +00:00
|
|
|
this.setState({isMinimized: !this.state.isMinimized});
|
2018-11-14 02:55:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onCloseUpload = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
|
|
this.props.onCloseUploadDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let uploadedMessage = gettext('File Upload');
|
2019-01-08 03:26:20 +00:00
|
|
|
let uploadingMessage = gettext('File Uploading...') + ' ' + this.props.totalProgress + '%' + ' (' + this.props.uploadBitrate + ')';
|
2018-11-14 02:55:11 +00:00
|
|
|
|
|
|
|
let uploadingOptions = (<span className="sf2-icon-minus" onClick={this.onMinimizeUpload}></span>);
|
|
|
|
|
|
|
|
let uploadedOptions = (
|
|
|
|
<Fragment>
|
|
|
|
<span className="sf2-icon-minus" onClick={this.onMinimizeUpload}></span>
|
|
|
|
<span className="sf2-icon-x1" onClick={this.onCloseUpload}></span>
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
|
|
|
|
let totalProgress = this.props.totalProgress;
|
|
|
|
|
|
|
|
return (
|
2019-01-08 03:26:20 +00:00
|
|
|
<div className="uploader-list-view" style={{height: this.state.isMinimized ? '2.25rem' : '20rem'}}>
|
2018-11-14 02:55:11 +00:00
|
|
|
<div className="uploader-list-header">
|
|
|
|
<div className="title">
|
|
|
|
{totalProgress === 100 ? uploadedMessage : uploadingMessage}
|
|
|
|
</div>
|
|
|
|
<div className="uploader-options">
|
|
|
|
{totalProgress === 100 ? uploadedOptions : uploadingOptions}
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-28 00:57:42 +00:00
|
|
|
<div className="uploader-list-content">
|
2019-01-08 03:26:20 +00:00
|
|
|
<table className="table-thead-hidden">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th width="50%">{gettext('name')}</th>
|
|
|
|
<th width="40%">{gettext('progress')}</th>
|
|
|
|
<th width="10%">{gettext('state')}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
2018-11-14 02:55:11 +00:00
|
|
|
<tbody>
|
2019-01-08 03:26:20 +00:00
|
|
|
{(this.props.totalProgress !== 100) &&
|
|
|
|
<tr><td className="text-right" colSpan={3}><span className="cursor-pointer" onClick={this.onCancelAllUploading}>{gettext('Cancel All')}</span></td></tr>
|
|
|
|
}
|
2018-11-14 02:55:11 +00:00
|
|
|
{
|
|
|
|
this.props.uploadFileList.map((item, index) => {
|
|
|
|
return (
|
|
|
|
<UploadListItem key={index} item={item} onUploadCancel={this.props.onUploadCancel}/>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UploadProgressDialog.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default UploadProgressDialog;
|