Interactive interface for browsing global, full-resolution satellite imagery
Added additional UI hints for loading granule counts. Fixed bug with not be able to click on the checkbox directly for toggling bounding box. Added logic for refreshing granule count on layer changes and date selections.
Stephan Wlodarczyk8db2374724b1
diff --git a/web/css/smart-handoff.css b/web/css/smart-handoff.cssindex 72cb7d61c..9f18e5a3f 100644--- a/web/css/smart-handoff.css+++ b/web/css/smart-handoff.css@@ -73,8 +73,9 @@}#crop-toggle {- text-align: center;+ display: inline-block;margin-top: 15px;+ margin-left: 65px;}label[for=chk-crop-toggle] {@@ -215,5 +216,67 @@ label[for=chk-crop-toggle] {border-bottom: 1px solid #444 !important;}+.constant-width {+ display: inline-block;+ width: 60px;+}++.loading-granule-count {+ font-size: 30px;+ }++ .loading-granule-count:after {+ overflow: hidden;+ display: inline-block;+ vertical-align: bottom;+ -webkit-animation: ellipsis steps(4,end) 900ms infinite;+ animation: ellipsis steps(4,end) 900ms infinite;+ content: "\2026"; /* ascii code for the ellipsis character */+ width: 0px;+ }++ @keyframes ellipsis {+ to {+ width: 1.25em;+ }+ }++ @-webkit-keyframes ellipsis {+ to {+ width: 1.25em;+ }+ }++ .fade-in {+ animation: fadeIn ease 1s;+ -webkit-animation: fadeIn ease 1s;+ -moz-animation: fadeIn ease 1s;+ -o-animation: fadeIn ease 1s;+ -ms-animation: fadeIn ease 1s;+ }+ @keyframes fadeIn {+ 0% {opacity:0;}+ 100% {opacity:1;}+ }++ @-moz-keyframes fadeIn {+ 0% {opacity:0;}+ 100% {opacity:1;}+ }++ @-webkit-keyframes fadeIn {+ 0% {opacity:0;}+ 100% {opacity:1;}+ }++ @-o-keyframes fadeIn {+ 0% {opacity:0;}+ 100% {opacity:1;}+ }++ @-ms-keyframes fadeIn {+ 0% {opacity:0;}+ 100% {opacity:1;}+ }diff --git a/web/css/timeline.css b/web/css/timeline.cssindex 02c791fd9..2c734666f 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -5,6 +5,7 @@ button:focus {#timeline {left: 0;+ z-index: 1;}.timeline-inner {diff --git a/web/js/containers/sidebar/smart-handoff.js b/web/js/containers/sidebar/smart-handoff.jsindex 1faa6d31d..1f062e820 100644--- a/web/js/containers/sidebar/smart-handoff.js+++ b/web/js/containers/sidebar/smart-handoff.js@@ -43,6 +43,7 @@ class SmartHandoff extends Component {},selectedLayer: {},showBoundingBox: false,+ isSearchingForGranules: false,selectedGranules: 0,totalGranules: 0,currentExtent: {},@@ -52,7 +53,15 @@ class SmartHandoff extends Component {this.onBoundaryChange = this.onBoundaryChange.bind(this);this.updateExtent = this.updateExtent.bind(this);- this.debouncedUpdateExtent = lodashDebounce(this.updateExtent, 500);+ this.debouncedUpdateExtent = lodashDebounce(this.updateExtent, 250);+ }++ componentDidUpdate(prevProps) {+ const { selectedDate } = this.props;+ const { currentExtent } = this.state;++ const didDateChange = selectedDate !== prevProps.selectedDate;+ if (didDateChange) this.updateGranuleCount(currentExtent);}updateExtent() {@@ -116,6 +125,9 @@ class SmartHandoff extends Component {async updateGranuleCount(currentExtent) {const { selectedDate } = this.props;const { selectedLayer, showBoundingBox } = this.state;++ this.setState({ isSearchingForGranules: true });+const startDate = `${moment.utc(selectedDate).format('YYYY-MM-DD')}T00:00:00.000Z`;const endDate = `${moment.utc(selectedDate).format('YYYY-MM-DD')}T23:59:59.999Z`;const dateRange = `${startDate},${endDate}`;@@ -150,6 +162,7 @@ class SmartHandoff extends Component {}this.setState({ selectedGranules, totalGranules });+ this.setState({ isSearchingForGranules: false });}/**@@ -165,7 +178,7 @@ class SmartHandoff extends Component {selectedDate,} = this.props;- const { selectedLayer } = this.state;+ const { selectedLayer, isSearchingForGranules } = this.state;const {selectedGranules, totalGranules, coordinates, currentExtent, showBoundingBox,} = this.state;@@ -206,10 +219,10 @@ class SmartHandoff extends Component {<hr /><div id="smart-handoff-layer-list">- {activeLayers.map((layer, i) => {+ {activeLayers.map((layer, index) => {if (layer.conceptId && layer.visible) {return (- <div className="layer-item" key={layer.conceptId}>+ <div className="layer-item"><inputid={layer.id}type="radio"@@ -232,7 +245,7 @@ class SmartHandoff extends Component {<div id="crop-toggle"><Checkboxid="chk-crop-toggle"- label="Bounding Box"+ label="Toggle Bounding Box"text="Toggle boundary selection."checked={showBoundingBox}onCheck={() => {@@ -245,33 +258,21 @@ class SmartHandoff extends Component {<hr />- { showBoundingBox && (- <div id="granule-count">- <h1>- {' '}- Granules available:- {' '}- <span>{`${selectedGranules} of ${totalGranules}`}</span>- </h1>- </div>- )}-- { !showBoundingBox && (<div id="granule-count"><h1>- {' '}Granules available:{' '}- <span>{totalGranules}</span>+ { 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>- )}{ /** Download button that transfers user to NASA's Earthdata Search */ }<ButtononClick={() => {- if (showModal) showWarningModal(selectedDate, selectedLayer, currentExtent);- else openEarthDataSearch(selectedDate, selectedLayer, currentExtent)();+ if (showModal) showWarningModal(selectedDate, selectedLayer, currentExtent, showBoundingBox);+ else openEarthDataSearch(selectedDate, selectedLayer, currentExtent, showBoundingBox)();}}id="download-btn"text="GO TO EARTHDATA SEARCH"@@ -333,7 +334,7 @@ class SmartHandoff extends Component {}}-const openEarthDataSearch = (selectedDate, selectedLayer, extentCoords) => () => {+const openEarthDataSearch = (selectedDate, selectedLayer, extentCoords, showBoundingBox) => () => {const { conceptId, daynight } = selectedLayer;const { southWest, northEast } = extentCoords;@@ -342,11 +343,10 @@ const openEarthDataSearch = (selectedDate, selectedLayer, extentCoords) => () =>const dateRange = `${startDate},${endDate}`;- let earthDataSearchURL = `https://search.earthdata.nasa.gov/search/granules?p=${conceptId}&[qt]=${dateRange}&sb=${southWest},${northEast}&m=0.0!-180.0!0!1!0!0,2`;+ let earthDataSearchURL = `https://search.earthdata.nasa.gov/search/granules?p=${conceptId}&[qt]=${dateRange}&m=0.0!-180.0!0!1!0!0,2`;- if (daynight) {- earthDataSearchURL += `&pg[0][dnf]=${daynight}`;- }+ if (daynight) earthDataSearchURL += `&pg[0][dnf]=${daynight}`;+ if (showBoundingBox) earthDataSearchURL += `&sb=${southWest},${northEast}`;window.open(earthDataSearchURL, '_blank');};@@ -399,7 +399,7 @@ const mapStateToProps = (state, ownProps) => {* @param {*} dispatch | A function of the Redux store that is triggered upon a change of state.*/const mapDispatchToProps = (dispatch) => ({- showWarningModal: (selectedDate, selectedLayer, extentCoords) => {+ showWarningModal: (selectedDate, selectedLayer, extentCoords, showBoundingBox) => {dispatch(openCustomContent('transferring-to-earthdata-search', {headerText: 'Leaving Worldview',@@ -408,7 +408,8 @@ const mapDispatchToProps = (dispatch) => ({selectedDate,selectedLayer,extentCoords,- goToEarthDataSearch: openEarthDataSearch(selectedDate, selectedLayer, extentCoords),+ showBoundingBox,+ goToEarthDataSearch: openEarthDataSearch(selectedDate, selectedLayer, extentCoords, showBoundingBox),},size: 'lg',}),