Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Reduxify GIF #1623 #1622 #1576

Benjamin King6468f2b80840
diff --git a/package-lock.json b/package-lock.json
index 08bc2ba2c..ba114a3cd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16502,6 +16502,16 @@
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
+ "react-loader": {
+ "version": "2.4.5",
+ "resolved": "https://registry.npmjs.org/react-loader/-/react-loader-2.4.5.tgz",
+ "integrity": "sha1-zT5VHGzQc4wcDxPwc2VPk4KL5ak=",
+ "requires": {
+ "create-react-class": "15.6.3",
+ "prop-types": "15.7.2",
+ "spin.js": "2.3.2"
+ }
+ },
"react-masonry-component": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/react-masonry-component/-/react-masonry-component-6.2.1.tgz",
@@ -18952,6 +18962,11 @@
"integrity": "sha512-Nc/QN/A425Qog7j9aHmwOrlwX2e7pNI47ciwxwy4jOlvbbMHkNNJchit+FX+UjF3IAdiaaV5BKeWuDUnws6G1A==",
"dev": true
},
+ "spin.js": {
+ "version": "2.3.2",
+ "resolved": "https://registry.npmjs.org/spin.js/-/spin.js-2.3.2.tgz",
+ "integrity": "sha1-bKpW1SBnNFD9XPvGlx5tB3LDeho="
+ },
"split": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz",
diff --git a/package.json b/package.json
index 32f1a5673..bbf5a121b 100644
--- a/package.json
+++ b/package.json
@@ -183,6 +183,7 @@
"react-dom": "^16.3.0",
"react-draggable": "^3.0.5",
"react-image-crop": "^6.0.11",
+ "react-loader": "^2.4.5",
"react-masonry-component": "^6.2.1",
"react-portal": "^4.2.0",
"react-redux": "^6.0.0",
diff --git a/web/js/components/animation-widget/gif-post-creation.js b/web/js/components/animation-widget/gif-post-creation.js
index f33833f76..8bb9e70ce 100644
--- a/web/js/components/animation-widget/gif-post-creation.js
+++ b/web/js/components/animation-widget/gif-post-creation.js
@@ -32,11 +32,11 @@ export class GifResults extends Component {
gifObject,
boundaries,
screenWidth,
- screenHeight
+ screenHeight,
+ onClose
} = this.props;
const blob = gifObject.blob;
const size = gifObject.size;
- const height = gifObject.height;
const blobURL = URL.createObjectURL(blob);
var dlURL = util.format(
'nasa-worldview-{1}-to-{2}.gif',
@@ -56,9 +56,10 @@ export class GifResults extends Component {
isOpen={true}
style={this.getStyle(imgElWidth, imgElHeight)}
className={'dynamic-modal'}
+ toggle={onClose}
>
{/* <DetectOuterClick onClick={onClose} disabled={true}> */}
- <ModalHeader>GIF Results</ModalHeader>
+ <ModalHeader toggle={onClose}>GIF Results</ModalHeader>
<ModalBody>
<div className="gif-results-dialog-case clearfix">
<img src={blobURL} width={imgElWidth} height={imgElHeight} />
@@ -93,24 +94,26 @@ export class GifResults extends Component {
<div> {lodashCapitalize(increment)} </div>
</div>
</div>
- <Button
- text="Download"
- id="download-gif-button"
- className="download wv-button"
- onClick={e => {
- e.stopPropagation();
- e.preventDefault();
- FileSaver.saveAs(blob, dlURL);
- googleTagManager.pushEvent({
- event: 'GIF_download',
- GIF: {
- downloadSize: size,
- increments: increment,
- frameSpeed: speed
- }
- });
- }}
- />
+ <div style={{ paddingTop: 10 }}>
+ <Button
+ text="Download"
+ id="download-gif-button"
+ className="download wv-button"
+ onClick={e => {
+ e.stopPropagation();
+ e.preventDefault();
+ FileSaver.saveAs(blob, dlURL);
+ googleTagManager.pushEvent({
+ event: 'GIF_download',
+ GIF: {
+ downloadSize: size,
+ increments: increment,
+ frameSpeed: speed
+ }
+ });
+ }}
+ />
+ </div>
</div>
</ModalBody>
</Modal>
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index 5bab06981..b859fc77f 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -19,7 +19,6 @@ import {
changeStartDate,
changeEndDate
} from '../modules/animation/actions';
-import { openCustomContent } from '../modules/modal/actions';
import GifContainer from './gif';
import { timeScaleFromNumberKey } from '../modules/date/constants';
@@ -116,95 +115,107 @@ class AnimationWidget extends React.Component {
startDate,
endDate,
onPushPlay,
- onPushPause
+ onPushPause,
+ isActive
} = this.props;
- if (this.state.isGifActive) return <GifContainer />;
- return (
- <ErrorBoundary>
- <div
- id="wv-animation-widget"
- className={
- 'wv-animation-widget' + (hasSubdailyLayers ? ' subdaily' : '')
- }
- >
- <AnimWidgetHeader
- text={increment}
- toolTipTextArray={incrementArray}
- onClick={onZoomSelect}
- />
-
- <PlayButton
- playing={isPlaying}
- play={onPushPlay}
- pause={onPushPause}
- />
- <LoopButton looping={looping} onLoop={this.onLoop.bind(this)} />
- <div className="wv-slider-case">
- <Slider
- className="input-range"
- step={0.5}
- max={10}
- min={0.5}
- value={this.state.speed}
- onChange={num => this.setState({ speed: num })}
- handle={RangeHandle}
- onBeforeChange={() => this.setState({ isSliding: true })}
- onAfterChange={() => {
- this.setState({ isSliding: false });
- this.props.onSlide(this.state.speed);
- }}
- />
- <span className="wv-slider-label">{sliderLabel}</span>
- </div>
-
- <a
- href="javascript:void(null)"
- title="Create Animated GIF"
- className="wv-icon-case"
- onClick={() => {
- this.toggleGIF();
- }}
+ if (!isActive) {
+ return '';
+ } else if (this.state.isGifActive) {
+ return (
+ <GifContainer
+ onClose={() => {
+ this.setState({ isGifActive: false });
+ }}
+ />
+ );
+ } else {
+ return (
+ <ErrorBoundary>
+ <div
+ id="wv-animation-widget"
+ className={
+ 'wv-animation-widget' + (hasSubdailyLayers ? ' subdaily' : '')
+ }
>
- <i
- id="wv-animation-widget-file-video-icon"
- className="fas fa-file-video wv-animation-widget-icon"
+ <AnimWidgetHeader
+ text={increment}
+ toolTipTextArray={incrementArray}
+ onClick={onZoomSelect}
/>
- </a>
- <div className="wv-anim-dates-case">
- <TimeSelector
- width="120"
- height="30"
- date={startDate}
- id="start"
- idSuffix="animation-widget-start"
- onDateChange={this.onDateChange}
- maxDate={endDate}
- minDate={minDate}
- hasSubdailyLayers={hasSubdailyLayers}
- />
- <div className="thru-label">To</div>
- <TimeSelector
- width="120"
- height="30"
- date={endDate}
- id="end"
- idSuffix="animation-widget-end"
- onDateChange={this.onDateChange}
- maxDate={maxDate}
- minDate={startDate}
- hasSubdailyLayers={hasSubdailyLayers}
+ <PlayButton
+ playing={isPlaying}
+ play={onPushPlay}
+ pause={onPushPause}
/>
+ <LoopButton looping={looping} onLoop={this.onLoop.bind(this)} />
+ <div className="wv-slider-case">
+ <Slider
+ className="input-range"
+ step={0.5}
+ max={10}
+ min={0.5}
+ value={this.state.speed}
+ onChange={num => this.setState({ speed: num })}
+ handle={RangeHandle}
+ onBeforeChange={() => this.setState({ isSliding: true })}
+ onAfterChange={() => {
+ this.setState({ isSliding: false });
+ this.props.onSlide(this.state.speed);
+ }}
+ />
+ <span className="wv-slider-label">{sliderLabel}</span>
+ </div>
+
+ <a
+ href="javascript:void(null)"
+ title="Create Animated GIF"
+ className="wv-icon-case"
+ onClick={() => {
+ this.toggleGIF();
+ }}
+ >
+ <i
+ id="wv-animation-widget-file-video-icon"
+ className="fas fa-file-video wv-animation-widget-icon"
+ />
+ </a>
+ <div className="wv-anim-dates-case">
+ <TimeSelector
+ width="120"
+ height="30"
+ date={startDate}
+ id="start"
+ idSuffix="animation-widget-start"
+ onDateChange={this.onDateChange}
+ maxDate={endDate}
+ minDate={minDate}
+ hasSubdailyLayers={hasSubdailyLayers}
+ />
+ <div className="thru-label">To</div>
+
+ <TimeSelector
+ width="120"
+ height="30"
+ date={endDate}
+ id="end"
+ idSuffix="animation-widget-end"
+ onDateChange={this.onDateChange}
+ maxDate={maxDate}
+ minDate={startDate}
+ hasSubdailyLayers={hasSubdailyLayers}
+ />
+ </div>
+ <i className="fa fa-times wv-close" onClick={this.props.onClose} />
</div>
- <i className="fa fa-times wv-close" onClick={this.props.onClose} />
- </div>
- </ErrorBoundary>
- );
+ </ErrorBoundary>
+ );
+ }
}
}
function mapStateToProps(state) {
- const { layers, compare, animation, date } = state;
- const { startDate, endDate, speed, loop, isPlaying } = animation;
+ const { layers, compare, animation, date, sidebar, modal } = state;
+ const { startDate, endDate, speed, loop, isPlaying, isActive } = animation;
const { minDate, maxDate } = date;
const activeStr = compare.activeString;
const hasSubdailyLayers = hasSubDailySelector(layers[activeStr]);
@@ -215,6 +226,10 @@ function mapStateToProps(state) {
endDate,
// minDate,
// maxDate,
+ isActive:
+ isActive &&
+ sidebar.activeTab !== 'download' && // No Animation when data download is active
+ !(modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT'), // No Animation when Image download is open
hasSubdailyLayers,
incrementArray: zoomObj.array,
increment: zoomObj.increment,
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index d764d014c..b98add56a 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -1,5 +1,6 @@
-import React, { Component, Fragment } from 'react';
+import React, { Component } from 'react';
import PropTypes from 'prop-types';
+import Spinner from 'react-loader';
import { connect } from 'react-redux';
import GifPanel from '../components/animation-widget/gif-panel';
import GifStream from '@entryline/gifstream'; // '../map/animation/gif-stream';
@@ -42,9 +43,13 @@ class GIF extends Component {
isDownloadError: false,
showDates: true,
isValidSelection: true,
+ progress: 0,
downloadedObject: {},
+ offsetLeft: boundaries.x2 + 20,
+ offsetTop: boundaries.y - 20,
boundaries
};
+ // set initial position of GIF panel
this.onBoundaryChange = this.onBoundaryChange.bind(this);
this.onGifProgress = this.onGifProgress.bind(this);
}
@@ -92,9 +97,9 @@ class GIF extends Component {
wrapClassName={'clickable-behind-modal toolbar_modal_outer'}
className={'gif-modal dynamic-modal'}
style={this.getStyle(this.state)}
+ toggle={onClose}
>
- {/* <DetectOuterClick onClick={onClose} disabled={true}> */}
- <ModalHeader>Create An Animated GIF</ModalHeader>
+ <ModalHeader toggle={onClose}>Create An Animated GIF</ModalHeader>
<ModalBody>
<GifPanel
speed={speed}
@@ -125,7 +130,6 @@ class GIF extends Component {
showCoordinates={false}
/>
</ModalBody>
- {/* </DetectOuterClick> */}
</Modal>
);
}
@@ -148,7 +152,6 @@ class GIF extends Component {
// won't be true if there are too mant frames
return;
}
- console.log(imageArra);
gifStream.createGIF(
{
gifWidth: width,
@@ -259,7 +262,8 @@ class GIF extends Component {
endDate,
startDate,
screenHeight,
- screenWidth
+ screenWidth,
+ onClose
} = this.props;
const {
isDownloaded,
@@ -270,11 +274,16 @@ class GIF extends Component {
} = this.state;
if (isDownloading) {
+ let headerText = progress ? 'Creating GIF' : 'Requesting Imagery';
return (
- <Modal isOpen={true}>
- <ModalHeader>Creating GIF</ModalHeader>
+ <Modal isOpen={true} toggle={onClose}>
+ <ModalHeader toggle={onClose}>{headerText}</ModalHeader>
<ModalBody>
- <Progress value={progress} />
+ <div style={{ minHeight: 50 }}>
+ <Spinner color={'#fff'} loaded={progress}>
+ <Progress value={progress} />
+ </Spinner>
+ </div>
</ModalBody>
</Modal>
);
@@ -285,6 +294,7 @@ class GIF extends Component {
speed={speed}
gifObject={downloadedObject}
startDate={startDate}
+ onClose={onClose}
endDate={endDate}
increment={increment}
boundaries={boundaries}
@@ -329,7 +339,7 @@ function mapStateToProps(state, ownProps) {
state
);
},
- onClose: () => {}
+ onClose: ownProps.onClose
};
}
const mapDispatchToProps = dispatch => ({});
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 299a09f7e..534179994 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -121,7 +121,6 @@ class Timeline extends React.Component {
// handle SET of custom time scale panel
changeCustomInterval = (delta, timeScale) => {
- console.log(delta, timeScale);
this.props.changeCustomInterval(
delta,
Number(timeScaleToNumberKey[timeScale])
@@ -142,7 +141,6 @@ class Timeline extends React.Component {
intervalSelected = Number(timeScaleToNumberKey[intervalSelected]);
delta = 1;
}
- console.log(delta, intervalSelected, customSelected);
this.props.selectInterval(delta, intervalSelected, customSelected);
if (customIntervalModalOpen) {
this.setState({
diff --git a/web/js/modules/animation/selectors.js b/web/js/modules/animation/selectors.js
index 4625af093..aa9987985 100644
--- a/web/js/modules/animation/selectors.js
+++ b/web/js/modules/animation/selectors.js
@@ -4,8 +4,7 @@ import {
imageUtilGetCoordsFromPixelValues,
imageUtilGetLayerOpacities,
bboxWMS13,
- imageUtilGetLayers,
- getDimensions
+ imageUtilGetLayers
} from '../image-download/util';
import { getLayers } from '../layers/selectors';
import { timeScaleFromNumberKey } from '../date/constants';
@@ -72,8 +71,8 @@ export function getImageArray(
`CRS=${crs}`,
`LAYERS=${layersArray.join(',')}`,
`FORMAT=${imgFormat}`,
- `WIDTH=${height}`,
- `HEIGHT=${width}`
+ `WIDTH=${width}`,
+ `HEIGHT=${height}`
];
if (opacities.length > 0) {
params.push(`OPACITIES=${opacities.join(',')}`);