@@ -37,6 +37,8 @@ export interface IDataAccessComponentProps {
3737 dataSource : DataSourceState | null ;
3838 isLocalDataSource : boolean ;
3939 temporalCoverage : TimeRangeValue | null ;
40+ canMap : boolean ;
41+ canCache : boolean ;
4042}
4143
4244
@@ -47,6 +49,7 @@ export interface IDataAccessComponentProps {
4749 */
4850export class DataAccessComponent extends React . Component < IDataAccessComponentProps , null > {
4951 static readonly VAR_NAMES_INPUT = { name : 'varNames' , dataType : 'string' , description : null , nullable : true } ;
52+ static readonly SUB_PANEL_STYLE = { marginTop : '1em' } ;
5053 static readonly OPTION_CHECK_STYLE = { marginTop : '1em' } ;
5154 static readonly OPTION_DIV_STYLE = { marginLeft : '2em' } ;
5255
@@ -144,116 +147,97 @@ export class DataAccessComponent extends React.Component<IDataAccessComponentPro
144147
145148 const res = DataAccessComponent . dataSourceToResource ( this . props . dataSource ) ;
146149
147- let headerText ;
148- let cacheDataSourceCheck ;
149- let cacheDataSourcePanel ;
150- // let openDatasetResourceNamePanel = (
151- // <div style={DataAccessComponent.OPTION_DIV_STYLE}>
152- // <Label>
153- // Unique name for the new dataset resource
154- // <span className="bp3-text-muted"> (required)</span>
155- // <input className="bp3-input"
156- // style={{width: '100%'}}
157- // type="text"
158- // value={options.openDatasetResourceName}
159- // onChange={this.onOpenDatasetResourceNameChange}/>
160- // </Label>
161- // </div>
162- // );
163- if ( isLocalDataSource ) {
164- headerText = ( < LongIdLabel label = 'File data source:' longId = { this . props . dataSource . title } /> ) ;
165- } else {
166- headerText = ( < LongIdLabel label = 'Remote data source:' longId = { this . props . dataSource . title } /> ) ;
167- cacheDataSourceCheck = (
168- < Tooltip
169- content = "If unchecked, remote data will be accessed using an available protocol, e.g. OPeNDAP." >
150+ return (
151+ < div >
152+ { isLocalDataSource
153+ ? ( < LongIdLabel label = 'File data source:' longId = { this . props . dataSource . title } /> )
154+ : ( < LongIdLabel label = 'Remote data source:' longId = { this . props . dataSource . title } /> )
155+ }
156+
157+ < div style = { DataAccessComponent . SUB_PANEL_STYLE } >
170158 < Checkbox
171- style = { DataAccessComponent . OPTION_CHECK_STYLE }
172- checked = { isMakeLocalSelected }
173- label = "Cache data source (allocates space on disk) "
174- onChange = { this . onMakeLocalSelectedChange }
159+ disabled = { ! temporalCoverage }
160+ checked = { hasTimeConstraint }
161+ label = "Time constraint "
162+ onChange = { this . onHasTimeConstraintChange }
175163 />
176- </ Tooltip >
177- ) ;
178- cacheDataSourcePanel = (
179- < Collapse isOpen = { isMakeLocalSelected } >
180- < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
181- < Label >
182- Unique identifier for the new local data source
183- < span className = "bp3-text-muted" > (optional)</ span >
184- < InputGroup
185- style = { { width : '100%' } }
186- type = "text"
187- value = { options . cachedDataSourceId }
188- onChange = { this . onMakeLocalDataSourceIdChange }
164+ < Collapse isOpen = { hasTimeConstraint } >
165+ < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
166+ < DateRangeField
167+ nullable = { true }
168+ min = { minDate }
169+ max = { maxDate }
170+ value = { dateRange }
171+ onChange = { this . onDateRangeChange }
189172 />
190- </ Label >
191- </ div >
192- </ Collapse >
193- ) ;
194- /*
195- openDatasetResourceNamePanel = (
196- <Collapse isOpen={isOpenDatasetSelected}>
197- {openDatasetResourceNamePanel}
198- </Collapse>
199- );
200- */
201- }
202-
203- return (
204- < div >
205- { headerText }
206-
207- < Checkbox
208- style = { DataAccessComponent . OPTION_CHECK_STYLE }
209- disabled = { ! temporalCoverage }
210- checked = { hasTimeConstraint }
211- label = "Time constraint"
212- onChange = { this . onHasTimeConstraintChange }
213- />
214- < Collapse isOpen = { hasTimeConstraint } >
215- < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
216- < DateRangeField
217- nullable = { true }
218- min = { minDate }
219- max = { maxDate }
220- value = { dateRange }
221- onChange = { this . onDateRangeChange }
173+ { temporalCoverageText }
174+ </ div >
175+ </ Collapse >
176+ </ div >
177+
178+ { this . props . canMap && (
179+ < div style = { DataAccessComponent . SUB_PANEL_STYLE } >
180+ < Checkbox
181+ checked = { hasRegionConstraint }
182+ label = "Region constraint"
183+ onChange = { this . onHasRegionConstraintChange }
222184 />
223- { temporalCoverageText }
185+ < Collapse isOpen = { hasRegionConstraint } >
186+ < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
187+ < Region
188+ value = { region }
189+ disabled = { ! hasRegionConstraint }
190+ onChange = { this . onRegionChange }
191+ />
192+ </ div >
193+ </ Collapse >
224194 </ div >
225- </ Collapse >
226-
227- < Checkbox style = { DataAccessComponent . OPTION_CHECK_STYLE }
228- checked = { hasRegionConstraint }
229- label = "Region constraint"
230- onChange = { this . onHasRegionConstraintChange } />
231- < Collapse isOpen = { hasRegionConstraint } >
232- < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
233- < Region value = { region }
234- disabled = { ! hasRegionConstraint }
235- onChange = { this . onRegionChange } />
236- </ div >
237- </ Collapse >
238-
239- < Checkbox style = { DataAccessComponent . OPTION_CHECK_STYLE }
240- checked = { hasVariablesConstraint }
241- label = "Variables constraint"
242- onChange = { this . onHasVariablesConstraintChange } />
243- < Collapse isOpen = { hasVariablesConstraint } >
244- < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
245- < VarNameValueEditor input = { DataAccessComponent . VAR_NAMES_INPUT }
246- value = { options . variableNames }
247- onChange = { this . onVariableNamesChange }
248- resource = { res }
249- multi = { true } />
250- </ div >
251- </ Collapse >
195+ ) }
252196
253- { cacheDataSourceCheck }
254- { cacheDataSourcePanel }
197+ < div style = { DataAccessComponent . SUB_PANEL_STYLE } >
198+ < Checkbox
199+ checked = { hasVariablesConstraint }
200+ label = "Variables constraint"
201+ onChange = { this . onHasVariablesConstraintChange }
202+ />
203+ < Collapse isOpen = { hasVariablesConstraint } >
204+ < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
205+ < VarNameValueEditor input = { DataAccessComponent . VAR_NAMES_INPUT }
206+ value = { options . variableNames }
207+ onChange = { this . onVariableNamesChange }
208+ resource = { res }
209+ multi = { true } />
210+ </ div >
211+ </ Collapse >
212+ </ div >
213+
214+ { this . props . canCache && (
215+ < div style = { DataAccessComponent . SUB_PANEL_STYLE } >
216+ < Tooltip content = { "If unchecked, remote data will be accessed " +
217+ "using an available protocol, e.g. OPeNDAP." } >
218+ < Checkbox
219+ checked = { isMakeLocalSelected }
220+ label = "Cache data source (allocates space on disk)"
221+ onChange = { this . onMakeLocalSelectedChange }
222+ />
223+ </ Tooltip >
224+ < Collapse isOpen = { isMakeLocalSelected } >
225+ < div style = { DataAccessComponent . OPTION_DIV_STYLE } >
226+ < Label >
227+ Unique identifier for the new local data source
228+ < span className = "bp3-text-muted" > (optional)</ span >
229+ < InputGroup
230+ style = { { width : '100%' } }
231+ type = "text"
232+ value = { options . cachedDataSourceId }
233+ onChange = { this . onMakeLocalDataSourceIdChange }
234+ />
235+ </ Label >
236+ </ div >
237+ </ Collapse >
238+ </ div >
239+ ) }
255240 { /*{openDatasetResourceNamePanel}*/ }
256-
257241 </ div >
258242 ) ;
259243 }
0 commit comments