PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.3.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.3.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Gutenberg / src / Components / Import / FileImport.js

FileImport.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.3.1, at classes/Visualizer/Gutenberg/src/Components/Import/FileImport.js

73 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5
6 const { Component } = wp.element;
7
8 const {
9 Button,
10 ExternalLink,
11 PanelBody
12 } = wp.components;
13
14 class FileImport extends Component {
15 constructor() {
16 super( ...arguments );
17
18 this.uploadInput = React.createRef();
19 this.fileUploaded = this.fileUploaded.bind( this );
20 this.uploadImport = this.uploadImport.bind( this );
21
22 this.state = {
23 uploadLabel: __( 'Upload' )
24 };
25 }
26
27 fileUploaded( e ) {
28 if ( 'text/csv' === e.target.files[0].type ) {
29 this.setState({ uploadLabel: __( 'Upload' ) });
30 }
31 }
32
33 uploadImport() {
34 this.props.readUploadedFile( this.uploadInput );
35 this.setState({ uploadLabel: __( 'Uploaded' ) });
36 }
37
38 render() {
39 return (
40 <PanelBody
41 title={ __( 'Import data from file' ) }
42 initialOpen={ false }
43 >
44
45 <p>{ __( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).' ) }</p>
46 <p>
47 { __( 'If you are unsure about how to format your data CSV then please take a look at this sample: ' ) }
48 <ExternalLink href={ `${visualizerLocalize.absurl}samples/${this.props.chart['visualizer-chart-type']}.csv` }>
49 { `${this.props.chart['visualizer-chart-type']}.csv` }
50 </ExternalLink>
51 </p>
52
53 <input
54 type="file"
55 accept="text/csv"
56 ref={ this.uploadInput }
57 onChange={ this.fileUploaded }
58 />
59
60 <Button
61 isPrimary
62 onClick={ this.uploadImport }
63 >
64 { this.state.uploadLabel }
65 </Button>
66
67 </PanelBody>
68 );
69 }
70 }
71
72 export default FileImport;
73