1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/components/ascribe_uploader/file_drag_and_drop_preview_image.js

71 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-06-25 13:28:49 +02:00
'use strict';
2015-06-23 10:16:53 +02:00
import React from 'react';
import ProgressBar from 'react-progressbar';
let FileDragAndDropPreviewImage = React.createClass({
propTypes: {
progress: React.PropTypes.number,
2015-06-25 13:46:10 +02:00
url: React.PropTypes.string,
2015-06-29 16:57:31 +02:00
toggleUploadProcess: React.PropTypes.func,
downloadFile: React.PropTypes.func
2015-06-23 10:16:53 +02:00
},
2015-06-29 14:36:55 +02:00
getInitialState() {
return {
2015-06-29 16:57:31 +02:00
paused: true
2015-06-29 14:36:55 +02:00
};
},
2015-06-29 16:46:12 +02:00
/*onClick(e) {
2015-06-29 16:00:26 +02:00
e.preventDefault();
e.stopPropagation();
2015-06-29 14:36:55 +02:00
this.setState({
loading: true
});
this.props.onClick(e);
2015-06-29 16:46:12 +02:00
},*/
toggleUploadProcess(e) {
e.preventDefault();
e.stopPropagation();
this.setState({
paused: true
});
2015-06-29 14:36:55 +02:00
},
2015-06-29 16:57:31 +02:00
downloadFile() {
},
2015-06-23 10:16:53 +02:00
render() {
let imageStyle = {
backgroundImage: 'url("' + this.props.url + '")',
backgroundSize: 'cover'
};
2015-06-29 16:57:31 +02:00
let actionSymbol;
if(this.props.progress !== 100 && this.state.paused) {
actionSymbol = <span className="glyphicon glyphicon-pause action-file" aria-hidden="true" title="Pause upload" onClick={this.toggleUploadProcess}/>;
} else if(this.props.progress !== 100 && !this.state.paused) {
actionSymbol = <span className="glyphicon glyphicon-play action-file" aria-hidden="true" title="Resume uploading" onClick={this.toggleUploadProcess}/>;
} else {
actionSymbol = <span className="glyphicon glyphicon-download action-file" aria-hidden="true" title="Download file" onClick={this.props.downloadFile}/>;
}
2015-06-23 10:16:53 +02:00
return (
<div
className="file-drag-and-drop-preview-image"
style={imageStyle}>
<ProgressBar completed={this.props.progress} color="black"/>
2015-06-29 16:57:31 +02:00
{actionSymbol}
2015-06-23 10:16:53 +02:00
</div>
);
}
});
export default FileDragAndDropPreviewImage;