Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Made additional tweaks such as resetting state on no longer valid selectedLayer and added message for when no layers are available for downloading.

Stephan Wlodarczyk0d98b82b064e
diff --git a/web/css/smart-handoff.css b/web/css/smart-handoff.css
index f6b26cdcf..7728de5fe 100644
--- a/web/css/smart-handoff.css
+++ b/web/css/smart-handoff.css
@@ -2,6 +2,7 @@
/** Smart handoff side panel **/
#smart-handoff-side-panel {
overflow-y: scroll;
+ min-height: 40px;
max-height: calc(var(--vh, 1vh) * 100 - 200px);
}
#smart-handoff-side-panel h1 {
diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.js
index b7ebb8f14..cf9ae211f 100644
--- a/web/js/containers/sidebar/smart-handoff.js
+++ b/web/js/containers/sidebar/smart-handoff.js
@@ -50,20 +50,32 @@ class SmartHandoff extends Component {
coordinates: {},
};
-
+ this.baseState = this.state;
this.onBoundaryChange = this.onBoundaryChange.bind(this);
this.updateExtent = this.updateExtent.bind(this);
this.debouncedUpdateExtent = lodashDebounce(this.updateExtent, 250);
}
componentDidUpdate(prevProps) {
- const { selectedDate } = this.props;
- const { currentExtent } = this.state;
+ const { selectedDate, activeLayers } = this.props;
+ const { currentExtent, selectedLayer } = this.state;
+
+ // Determine if existing selected layer is active still and visibility toggle is 'ON'
+ const isLayerStillActive = activeLayers.find((layer) => selectedLayer.conceptId === layer.conceptId);
+
+ if (!isLayerStillActive) {
+ console.log('no longer active');
+ this.resetState();
+ }
const didDateChange = selectedDate !== prevProps.selectedDate;
if (didDateChange) this.updateGranuleCount(currentExtent);
}
+ resetState() {
+ this.setState(this.baseState);
+ }
+
updateExtent() {
const { currentExtent, selectedLayer } = this.state;
if (selectedLayer && currentExtent) {
@@ -197,121 +209,118 @@ class SmartHandoff extends Component {
let showModal = safeLocalStorage.getItem(HIDE_EDS_WARNING);
showModal = true;
- // Determine if existing selected layer is active still and visibility toggle is 'ON'
- const isLayerStillActive = activeLayers.find((layer) => selectedLayer === layer && layer.visible);
+ const availableLayers = activeLayers.filter((layer) => layer.conceptId !== undefined).length;
+ const areThereLayersToDownload = availableLayers > 0;
- // Determine if any hidden layers are available for download; if so, displays hidden layers */
- const areHiddenLayersAvailable = activeLayers.filter((layer) => layer.conceptId !== undefined && !layer.visible).length;
+ if (areThereLayersToDownload) {
+ return (
+ <div id="smart-handoff-side-panel">
- if (!isLayerStillActive) {
- // Need to handle cases here when a layer has been toggled to 'hidden'.
- }
+ <h1>Select an available layer to download:</h1>
- return (
- <div id="smart-handoff-side-panel">
-
- {/** Listing of layers that are available to download via Earthdata Search */}
- <h1>Select an available layer to download:</h1>
-
- <div id="esd-notification">
- Downloading data will be performed using NASA's Earthdata Search application.
- <br />
- {' '}
- <br />
- <a href="https://search.earthdata.nasa.gov" target="_blank" rel="noopener noreferrer">search.earthdata.nasa.gov</a>
- </div>
-
- <hr />
-
- <div id="smart-handoff-layer-list">
- {activeLayers.map((layer, index) => {
- if (layer.conceptId) {
- return (
- <div className="layer-item">
- <input
- id={layer.id}
- type="radio"
- value={layer.conceptId}
- name="smart-handoff-layer-radio"
- checked={selectedLayer && selectedLayer.id === layer.id}
- onChange={() => this.onLayerChange(layer, currentExtent)}
- />
- <label htmlFor={layer.id}>{layer.title}</label>
- <span>{layer.subtitle}</span>
- </div>
- );
- }
- return null;
- })}
- </div>
-
- <hr />
-
- <div id="crop-toggle">
- <Checkbox
- id="chk-crop-toggle"
- label="Toggle Bounding Box"
- text="Toggle boundary selection."
- checked={showBoundingBox}
- onCheck={() => {
- this.setState({ showBoundingBox: !showBoundingBox }, () => {
- if (selectedLayer) this.updateGranuleCount(currentExtent);
- });
+ <div id="esd-notification">
+ Downloading data will be performed using NASA's Earthdata Search application.
+ <br />
+ {' '}
+ <br />
+ <a href="https://search.earthdata.nasa.gov" target="_blank" rel="noopener noreferrer">search.earthdata.nasa.gov</a>
+ </div>
+
+ <hr />
+
+ <div id="smart-handoff-layer-list">
+ {activeLayers.map((layer, index) => {
+ if (layer.conceptId) {
+ return (
+ <div className="layer-item">
+ <input
+ id={layer.id}
+ type="radio"
+ value={layer.conceptId}
+ name="smart-handoff-layer-radio"
+ checked={selectedLayer && selectedLayer.id === layer.id}
+ onChange={() => this.onLayerChange(layer, currentExtent)}
+ />
+ <label htmlFor={layer.id}>{layer.title}</label>
+ <span>{layer.subtitle}</span>
+ </div>
+ );
+ }
+ return null;
+ })}
+ </div>
+
+ <hr />
+
+ <div id="crop-toggle">
+ <Checkbox
+ id="chk-crop-toggle"
+ label="Toggle Bounding Box"
+ text="Toggle boundary selection."
+ checked={showBoundingBox}
+ onCheck={() => {
+ this.setState({ showBoundingBox: !showBoundingBox }, () => {
+ if (selectedLayer) this.updateGranuleCount(currentExtent);
+ });
+ }}
+ />
+ </div>
+
+ <hr />
+
+ <div id="granule-count">
+ <h1>
+ Granules available:
+ {' '}
+ { showBoundingBox && !isSearchingForGranules && (<span className="fade-in constant-width">{`${selectedGranules} of ${totalGranules}`}</span>)}
+ { !showBoundingBox && !isSearchingForGranules && (<span className="fade-in constant-width">{totalGranules}</span>)}
+ { isSearchingForGranules && (<span className="loading-granule-count fade-in constant-width" />)}
+ </h1>
+ </div>
+
+ <Button
+ onClick={() => {
+ if (showModal) showWarningModal(selectedDate, selectedLayer, currentExtent, showBoundingBox);
+ else openEarthDataSearch(selectedDate, selectedLayer, currentExtent, showBoundingBox)();
}}
+ id="download-btn"
+ text="GO TO EARTHDATA SEARCH"
+ className="red"
+ valid={selectedLayer && (totalGranules !== 0)}
/>
- </div>
-
- <hr />
- <div id="granule-count">
- <h1>
- Granules available:
- {' '}
- { showBoundingBox && !isSearchingForGranules && (<span className="fade-in constant-width">{`${selectedGranules} of ${totalGranules}`}</span>)}
- { !showBoundingBox && !isSearchingForGranules && (<span className="fade-in constant-width">{totalGranules}</span>)}
- { isSearchingForGranules && (<span className="loading-granule-count fade-in constant-width" />)}
- </h1>
+ { showBoundingBox && (
+ <Crop
+ className="download-extent"
+ x={x}
+ y={y}
+ width={x2 - x}
+ height={y2 - y}
+ maxHeight={screenHeight}
+ maxWidth={screenWidth}
+ onChange={this.onBoundaryChange}
+ onClose={onClose}
+ keepSelection
+ bottomLeftStyle={{
+ left: x,
+ top: y2 + 5,
+ width: x2 - x,
+ }}
+ topRightStyle={{
+ left: x,
+ top: y - 20,
+ width: x2 - x,
+ }}
+ coordinates={coordinates}
+ showCoordinates
+ />
+ )}
</div>
-
- { /** Download button that transfers user to NASA's Earthdata Search */ }
- <Button
- onClick={() => {
- if (showModal) showWarningModal(selectedDate, selectedLayer, currentExtent, showBoundingBox);
- else openEarthDataSearch(selectedDate, selectedLayer, currentExtent, showBoundingBox)();
- }}
- id="download-btn"
- text="GO TO EARTHDATA SEARCH"
- className="red"
- valid={selectedLayer && (totalGranules !== 0)}
- />
-
- { /** Image crop overlay used to determine user's area of interest */ }
- { showBoundingBox && (
- <Crop
- className="download-extent"
- x={x}
- y={y}
- width={x2 - x}
- height={y2 - y}
- maxHeight={screenHeight}
- maxWidth={screenWidth}
- onChange={this.onBoundaryChange}
- onClose={onClose}
- keepSelection
- bottomLeftStyle={{
- left: x,
- top: y2 + 5,
- width: x2 - x,
- }}
- topRightStyle={{
- left: x,
- top: y - 20,
- width: x2 - x,
- }}
- coordinates={coordinates}
- showCoordinates
- />
- )}
+ );
+ }
+ return (
+ <div id="smart-handoff-side-panel">
+ <h1>None of your currently listed layers are available for data download.</h1>
</div>
);
}