| 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 |
SelectControl, |
| 13 |
TextControl |
| 14 |
} = wp.components; |
| 15 |
|
| 16 |
class RemoteImport extends Component { |
| 17 |
constructor() { |
| 18 |
super( ...arguments ); |
| 19 |
} |
| 20 |
|
| 21 |
render() { |
| 22 |
return ( |
| 23 |
<PanelBody |
| 24 |
title={ __( 'Import data from URL' ) } |
| 25 |
initialOpen={ false } |
| 26 |
className="visualizer-advanced-panel" |
| 27 |
> |
| 28 |
|
| 29 |
<PanelBody |
| 30 |
title={ __( 'One Time Import' ) } |
| 31 |
className="visualizer-inner-sections" |
| 32 |
initialOpen={ false } |
| 33 |
> |
| 34 |
|
| 35 |
<p>{ __( 'You can use this to import data from a remote CSV file. 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> |
| 36 |
<p> |
| 37 |
{ __( 'If you are unsure about how to format your data CSV then please take a look at this sample: ' ) } |
| 38 |
<ExternalLink href={ `${visualizerLocalize.absurl}samples/${this.props.chart['visualizer-chart-type']}.csv` }> |
| 39 |
{ `${this.props.chart['visualizer-chart-type']}.csv` } |
| 40 |
</ExternalLink> |
| 41 |
</p> |
| 42 |
<p>{ __( 'You can also import data from Google Spreadsheet.' ) }</p> |
| 43 |
|
| 44 |
<TextControl |
| 45 |
placeholder={ __( 'Please enter the URL of your CSV file' ) } |
| 46 |
value={ this.props.chart['visualizer-chart-url'] ? this.props.chart['visualizer-chart-url'] : '' } |
| 47 |
onChange={ this.props.editURL } |
| 48 |
/> |
| 49 |
|
| 50 |
<Button |
| 51 |
isPrimary |
| 52 |
isLarge |
| 53 |
isBusy={ 'uploadData' === this.props.isLoading } |
| 54 |
disabled={ 'uploadData' === this.props.isLoading } |
| 55 |
onClick={ () => this.props.uploadData( false ) } |
| 56 |
> |
| 57 |
{ __( 'Import Data' ) } |
| 58 |
</Button> |
| 59 |
|
| 60 |
</PanelBody> |
| 61 |
|
| 62 |
{ ( 'business' === visualizerLocalize.isPro ) ? |
| 63 |
<PanelBody |
| 64 |
title={ __( 'Schedule Import' ) } |
| 65 |
className="visualizer-inner-sections" |
| 66 |
initialOpen={ false } |
| 67 |
> |
| 68 |
|
| 69 |
<p>{ __( 'You can choose here to synchronize your chart data with a remote CSV file. ' ) }</p> |
| 70 |
<p>{ __( 'You can also synchronize with your Google Spreadsheet file.' ) }</p> |
| 71 |
<p>{ __( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.' ) }</p> |
| 72 |
|
| 73 |
<TextControl |
| 74 |
placeholder={ __( 'Please enter the URL of your CSV file' ) } |
| 75 |
value={ this.props.chart['visualizer-chart-url'] ? this.props.chart['visualizer-chart-url'] : '' } |
| 76 |
onChange={ this.props.editURL } |
| 77 |
/> |
| 78 |
|
| 79 |
<SelectControl |
| 80 |
label={ __( 'How often do you want to check the url?' ) } |
| 81 |
value={ this.props.chart['visualizer-chart-schedule'] ? this.props.chart['visualizer-chart-schedule'] : 1 } |
| 82 |
options={ [ |
| 83 |
{ label: __( 'Each hour' ), value: '1' }, |
| 84 |
{ label: __( 'Each 12 hours' ), value: '12' }, |
| 85 |
{ label: __( 'Each day' ), value: '24' }, |
| 86 |
{ label: __( 'Each 3 days' ), value: '72' } |
| 87 |
] } |
| 88 |
onChange={ this.props.editSchedule } |
| 89 |
/> |
| 90 |
|
| 91 |
<Button |
| 92 |
isPrimary |
| 93 |
isLarge |
| 94 |
isBusy={ 'uploadData' === this.props.isLoading } |
| 95 |
disabled={ 'uploadData' === this.props.isLoading } |
| 96 |
onClick={ () => this.props.uploadData( true ) } |
| 97 |
> |
| 98 |
{ __( 'Save Schedule' ) } |
| 99 |
</Button> |
| 100 |
|
| 101 |
</PanelBody> : |
| 102 |
<PanelBody |
| 103 |
title={ __( 'Schedule Import' ) } |
| 104 |
icon="lock" |
| 105 |
className="visualizer-inner-sections" |
| 106 |
initialOpen={ false } |
| 107 |
> |
| 108 |
|
| 109 |
<p>{ __( 'Enable this feature in BUSINESS version!' ) }</p> |
| 110 |
|
| 111 |
<Button |
| 112 |
isPrimary |
| 113 |
href={ visualizerLocalize.proTeaser } |
| 114 |
target="_blank" |
| 115 |
> |
| 116 |
{ __( 'Buy Now' ) } |
| 117 |
</Button> |
| 118 |
|
| 119 |
</PanelBody> |
| 120 |
} |
| 121 |
|
| 122 |
</PanelBody> |
| 123 |
); |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
export default RemoteImport; |
| 128 |
|