Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 0f978ff

Browse files
authored
Merge pull request #139 from CCI-Tools/forman-xxx-veri_flags_2
Verification Flags II
2 parents 4ca998b + 73a2dcb commit 0f978ff

File tree

7 files changed

+138
-117
lines changed

7 files changed

+138
-117
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414
# misc
1515
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
16+
.env.*
2017

2118
npm-debug.log*
2219
yarn-debug.log*

CHANGES.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
#### In current
44

55
* The DATA SOURCES panel has been updated:
6-
- Fixed deferred effect of checkbox "Show identifiers"
7-
- Added checkbox "All data sources" that will display all ODP datasets
6+
- Fixed deferred effect of checkbox "Show identifiers".
7+
- Added checkbox "All data sources" that will display all ODP datasets.
88
- Added warn icon to those datasets that cannot be opened from store.
99
Such data sources disable the "Open" button and display a popup
1010
instead. The popup informs the user how to manually download and open
11-
the datasets.
12-
* Using term "sandboxed file system" instead of "user root" in about box
11+
the datasets.
12+
- The data Open Dialog no longer displays
13+
+ the region constraint, if a dataset has no spatial coordinates;
14+
+ the cached option, if a dataset cannot be cached.
15+
- Displaying a data source's data type, if given, in its list item.
16+
- Fixed crash on double-clicking a list item with no selection.
17+
* Using term "sandboxed file system" instead of "user root" in about box.
1318

1419
#### From previous
1520

src/renderer/containers/DataAccessComponent.tsx

Lines changed: 87 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
4850
export 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
}

src/renderer/containers/DataSourcesPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class DataSourcesPanel extends React.Component<IDataSourcesPanelProps & IDataSou
241241
: null}
242242
setSelectedDataSourceId={this.props.setSelectedDataSourceId}
243243
showDataSourceIDs={this.props.showDataSourceIDs}
244-
doubleClickAction={this.handleShowOpenDatasetDialog}
244+
doubleClickAction={canOpen ? this.handleShowOpenDatasetDialog : undefined}
245245
/>)
246246
: this.renderNoDataSourcesMessage()
247247
}
@@ -260,6 +260,7 @@ class DataSourcesPanel extends React.Component<IDataSourcesPanelProps & IDataSou
260260
}
261261

262262
private handleShowOpenDatasetDialog() {
263+
const canOpen = this.props.selectedDataSource;
263264
this.maybeLoadTemporalCoverage();
264265
this.props.showDialog('openDatasetDialog');
265266
}

src/renderer/containers/OpenDatasetDialog.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface IOpenDatasetDialogProps {
1616
dataStore: DataStoreState | null;
1717
dataSource: DataSourceState | null;
1818
temporalCoverage: TimeRangeValue | null;
19+
canMap: boolean;
20+
canCache: boolean;
1921
options: IDataAccessComponentOptions;
2022
}
2123

@@ -30,6 +32,8 @@ function mapStateToProps(state: State): IOpenDatasetDialogProps {
3032
dataStore: selectors.selectedDataStoreSelector(state),
3133
dataSource: selectors.selectedDataSourceSelector(state),
3234
temporalCoverage: selectors.selectedDataSourceTemporalCoverageSelector(state),
35+
canMap: selectors.canMapDataSourceSelector(state),
36+
canCache: selectors.canCacheDataSourceSelector(state),
3337
options: (dialogState as any).options as IDataAccessComponentOptions,
3438
};
3539
}
@@ -52,10 +56,12 @@ class OpenDatasetDialog extends React.Component<IOpenDatasetDialogProps & Dispat
5256
}
5357

5458
static mapPropsToState(nextProps: IOpenDatasetDialogProps): IOpenDatasetDialogState {
55-
let options = nextProps.options
59+
let options: IDataAccessComponentOptions = nextProps.options
5660
|| DataAccessComponent.defaultOptions(isLocalDataStore(nextProps.dataStore),
5761
nextProps.temporalCoverage);
62+
const isCacheDataSourceSelected = nextProps.canCache && options.isCacheDataSourceSelected;
5863
options = DataAccessComponent.ensureDateRangeIsValidated(options, nextProps.temporalCoverage);
64+
options = {...options, isCacheDataSourceSelected}
5965
return {options};
6066
}
6167

@@ -68,7 +74,8 @@ class OpenDatasetDialog extends React.Component<IOpenDatasetDialogProps & Dispat
6874
}
6975

7076
private onConfirm() {
71-
const options = this.state.options;
77+
const isCacheDataSourceSelected = this.props.canCache && this.state.options.isCacheDataSourceSelected;
78+
const options: IDataAccessComponentOptions = {...this.state.options, isCacheDataSourceSelected};
7279
// Clear cachedDataSourceId, so on next props, we can create a new default from selected data source
7380
// clear cachedDataSourceTitle, hasVariablesConstraint, variableNames, too
7481
// keep time and geo constraint
@@ -87,7 +94,7 @@ class OpenDatasetDialog extends React.Component<IOpenDatasetDialogProps & Dispat
8794
this.props.dispatch(actions.openDataset(
8895
this.props.dataSource.id,
8996
DataAccessComponent.optionsToOperationArguments(this.state.options),
90-
this.isRemoteDataStore && this.state.options.isCacheDataSourceSelected
97+
this.isRemoteDataStore && isCacheDataSourceSelected
9198
) as any);
9299
// Save modified state
93100
this.setState(dialogState);
@@ -140,7 +147,10 @@ class OpenDatasetDialog extends React.Component<IOpenDatasetDialogProps & Dispat
140147
onChange={this.onOptionsChange}
141148
dataSource={this.props.dataSource}
142149
isLocalDataSource={this.isLocalDataStore}
143-
temporalCoverage={this.props.temporalCoverage}/>
150+
temporalCoverage={this.props.temporalCoverage}
151+
canCache={this.props.canCache}
152+
canMap={this.props.canMap}
153+
/>
144154
);
145155
}
146156

src/renderer/selectors.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { createSelector, Selector } from 'reselect';
22
import * as Cesium from 'cesium';
33

44
import { requireElectron } from './electron';
5-
import { canOpenDataSource, DEFAULT_BASE_MAP, DEFAULT_BASE_MAP_ID } from './state-util';
5+
import {
6+
canCacheDataSource,
7+
canMapDataSource,
8+
canOpenDataSource,
9+
DEFAULT_BASE_MAP,
10+
DEFAULT_BASE_MAP_ID
11+
} from './state-util';
612
import {
713
BaseMapState,
814
ColorMapCategoryState,
@@ -443,6 +449,20 @@ export const selectedDataSourceTemporalCoverageSelector = createSelector<State,
443449
}
444450
);
445451

452+
export const canCacheDataSourceSelector = createSelector<State, boolean, DataSourceState | null>(
453+
selectedDataSourceSelector,
454+
(selectedDataSource: DataSourceState | null): boolean => {
455+
return selectedDataSource ? canCacheDataSource(selectedDataSource) : false;
456+
}
457+
);
458+
459+
export const canMapDataSourceSelector = createSelector<State, boolean, DataSourceState | null>(
460+
selectedDataSourceSelector,
461+
(selectedDataSource: DataSourceState | null): boolean => {
462+
return selectedDataSource ? canMapDataSource(selectedDataSource) : false;
463+
}
464+
);
465+
446466
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
447467
// Workspace, resource, step, and variable selectors
448468

src/renderer/state-util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export function canCacheDataSource(dataSource: DataSourceState) {
109109
return _checkDataSource(dataSource, 'cache');
110110
}
111111

112+
export function canMapDataSource(dataSource: DataSourceState) {
113+
return _checkDataSource(dataSource, 'map');
114+
}
115+
112116
function _checkDataSource(dataSource: DataSourceState, ...flags: DataSourceVerificationFlags[]): boolean {
113117
if (Array.isArray(dataSource.verificationFlags)) {
114118
// dataSource.verificationFlags have been introduced for ESA CCI datasets only

0 commit comments

Comments
 (0)