2016-09-25 00:27:04 +08:00
|
|
|
import React, { PropTypes, Component } from 'react'
|
|
|
|
import Dropzone from 'react-dropzone'
|
|
|
|
|
|
|
|
class ImportDialogBox extends Component {
|
2016-11-07 15:25:08 -05:00
|
|
|
constructor(props) {
|
2016-09-25 00:27:04 +08:00
|
|
|
super(props)
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleExport = format => () => {
|
|
|
|
window.open(`${window.location.pathname}/export.${format}`, '_blank')
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFile = (files, e) => {
|
2016-10-14 14:29:16 +08:00
|
|
|
this.props.onFileAdded(files[0])
|
2016-09-25 00:27:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
render = () => {
|
|
|
|
return (
|
|
|
|
<div className="import-dialog">
|
|
|
|
<h3>EXPORT</h3>
|
|
|
|
<div className="import-blue-button" onClick={this.handleExport('csv')}>
|
|
|
|
Export as CSV
|
|
|
|
</div>
|
|
|
|
<div className="import-blue-button" onClick={this.handleExport('json')}>
|
|
|
|
Export as JSON
|
|
|
|
</div>
|
|
|
|
<h3>IMPORT</h3>
|
|
|
|
<p>To upload a file, drop it here:</p>
|
|
|
|
<Dropzone onDropAccepted={this.handleFile}
|
2016-10-08 00:16:37 +08:00
|
|
|
className="fileupload"
|
2016-09-25 00:27:04 +08:00
|
|
|
>
|
|
|
|
Drop files here!
|
|
|
|
</Dropzone>
|
2017-01-11 13:50:37 -05:00
|
|
|
<p>See <a href="https://docs.metamaps.cc/importing_and_exporting_data.html">docs.metamaps.cc</a> for instructions.</p>
|
2016-09-25 00:27:04 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImportDialogBox.propTypes = {
|
|
|
|
onFileAdded: PropTypes.func,
|
|
|
|
exampleImageUrl: PropTypes.string
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ImportDialogBox
|