Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

gid redux wip

Benjamin Kingfa752e48c513
diff --git a/web/js/components/animation-widget/gif-panel.js b/web/js/components/animation-widget/gif-panel.js
index e06768b4f..883786330 100644
--- a/web/js/components/animation-widget/gif-panel.js
+++ b/web/js/components/animation-widget/gif-panel.js
@@ -50,6 +50,7 @@ export default class GifPanel extends React.Component {
const width = dimensions.width;
const requestSize = ((width * height * 24) / 8388608).toFixed(2);
const valid = isFileSizeValid(requestSize, height, width);
+ console.log(width, height);
return (
<div className="gif-dialog">
<div className="animation-gif-dialog-wrapper">
diff --git a/web/js/components/animation-widget/gif-post-creation.js b/web/js/components/animation-widget/gif-post-creation.js
index b9ee2b705..f33833f76 100644
--- a/web/js/components/animation-widget/gif-post-creation.js
+++ b/web/js/components/animation-widget/gif-post-creation.js
@@ -5,16 +5,35 @@ import Button from '../util/button';
import FileSaver from 'file-saver';
import googleTagManager from 'googleTagManager';
import util from '../../util/util';
-/*
- * A table that updates with image
- * data
- *
- * @class ResolutionTable
- * @extends React.Component
- */
+import { Modal, ModalBody, ModalHeader } from 'reactstrap';
+
export class GifResults extends Component {
+ getStyle(imgElWidth, imgElHeight) {
+ const { screenHeight, screenWidth } = this.props;
+ const width = imgElWidth + 204;
+ const height = imgElHeight + 100;
+ const top = (screenHeight - height) / 2 - 20;
+ const left = (screenWidth - width) / 2;
+ return {
+ left: left,
+ maxWidth: screenWidth,
+ maxHeight: screenHeight,
+ top: top > 0 ? top : 0,
+ height: height,
+ width: width < screenWidth ? width : screenWidth
+ };
+ }
render() {
- const { speed, startDate, endDate, increment, gifObject } = this.props;
+ const {
+ speed,
+ startDate,
+ endDate,
+ increment,
+ gifObject,
+ boundaries,
+ screenWidth,
+ screenHeight
+ } = this.props;
const blob = gifObject.blob;
const size = gifObject.size;
const height = gifObject.height;
@@ -24,69 +43,82 @@ export class GifResults extends Component {
startDate,
endDate
);
+ const pixelWidth = boundaries.x2 - boundaries.x;
+ const pixelHeight = boundaries.y2 - boundaries.y;
+ const imgElWidth =
+ pixelWidth > screenWidth - 198 ? screenWidth - 198 : pixelWidth;
+ const imgElHeight =
+ pixelHeight > screenHeight - 120 ? screenHeight - 120 : pixelHeight;
return (
- <div className="gif-results-dialog-case clearfix">
- <div
- className="gif-results-dialog"
- style={{ height: height, minHeight: 210 }}
- >
- <img src={blobURL} />
- <div>
- <div>
- <b> Size: </b>
- </div>
- <div>{size} MB</div>
- </div>
- <div>
- <div>
- <b>Speed:</b>
+ <Modal
+ backdrop={true}
+ isOpen={true}
+ style={this.getStyle(imgElWidth, imgElHeight)}
+ className={'dynamic-modal'}
+ >
+ {/* <DetectOuterClick onClick={onClose} disabled={true}> */}
+ <ModalHeader>GIF Results</ModalHeader>
+ <ModalBody>
+ <div className="gif-results-dialog-case clearfix">
+ <img src={blobURL} width={imgElWidth} height={imgElHeight} />
+ <div
+ className="gif-results-dialog"
+ style={{ height: imgElHeight, minHeight: 210 }}
+ >
+ <div>
+ <div>
+ <b> Size: </b>
+ </div>
+ <div>{size} MB</div>
+ </div>
+ <div>
+ <div>
+ <b>Speed:</b>
+ </div>
+ <div>{speed} fps</div>
+ </div>
+ <div>
+ <div>
+ <b>Date Range:</b>
+ </div>
+ <div>{startDate}</div>
+ <div> - </div>
+ <div>{endDate} </div>
+ </div>
+ <div>
+ <div>
+ <b>Increments:</b>
+ </div>
+ <div> {lodashCapitalize(increment)} </div>
+ </div>
</div>
- <div>{speed} fps</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>
- <div>
- <div>
- <b>Date Range:</b>
- </div>
- <div>{startDate}</div>
- <div> - </div>
- <div>{endDate} </div>
- </div>
- <div>
- <div>
- <b>Increments:</b>
- </div>
- <div> {lodashCapitalize(increment)} </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>
- </div>
+ </ModalBody>
+ </Modal>
);
}
}
+
GifResults.propTypes = {
- width: PropTypes.number,
- height: PropTypes.number,
- maxGifSize: PropTypes.number,
- maxImageDimensionSize: PropTypes.number,
- startDate: PropTypes.string,
endDate: PropTypes.string,
speed: PropTypes.number,
valid: PropTypes.bool,
diff --git a/web/js/components/image-download/panel.js b/web/js/components/image-download/panel.js
index 98cceea4b..537773125 100644
--- a/web/js/components/image-download/panel.js
+++ b/web/js/components/image-download/panel.js
@@ -36,12 +36,12 @@ export default class ImageResSelection extends React.Component {
};
}
onDownload(imgWidth, imgHeight) {
- const { getLayers, url, lonlats, crs, proj, date } = this.props;
+ const { getLayers, url, lonlats, crs, projection, date } = this.props;
const { fileType, isWorldfile, resolution } = this.state;
let time = new Date(date.getTime());
time.setUTCHours(0, 0, 0, 0);
let layerList = getLayers();
- let layers = imageUtilGetLayers(layerList, proj.id);
+ let layers = imageUtilGetLayers(layerList, projection.id);
let opacities = imageUtilGetLayerOpacities(layerList);
let params = [
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.js
index 3962fd761..5bab06981 100644
--- a/web/js/containers/animation-widget.js
+++ b/web/js/containers/animation-widget.js
@@ -118,7 +118,7 @@ class AnimationWidget extends React.Component {
onPushPlay,
onPushPause
} = this.props;
- if (this.state.isGifActive) return '';
+ if (this.state.isGifActive) return <GifContainer />;
return (
<ErrorBoundary>
<div
@@ -163,7 +163,6 @@ class AnimationWidget extends React.Component {
className="wv-icon-case"
onClick={() => {
this.toggleGIF();
- this.props.onPushGIF(this.toggleGIF);
}}
>
<i
@@ -238,20 +237,7 @@ const mapDispatchToProps = dispatch => ({
onPushLoop: () => {
dispatch(toggleLooping());
},
- onPushGIF: onToggle => {
- const customProps = {
- headerText: 'Create An Animated GIF',
- backdrop: false,
- wrapClassName: 'clickable-behind-modal toolbar_modal_outer',
- width: 342,
- type: 'selection',
- dynamicOffsets: true,
- modalClassName: 'gif-modal dynamic-modal',
- bodyComponent: GifContainer,
- toggle: onToggle
- };
- dispatch(openCustomContent('GIF_MODAL', customProps));
- },
+
onSlide: num => {
dispatch(changeFrameRate(num));
},
diff --git a/web/js/containers/gif.js b/web/js/containers/gif.js
index 200771045..d764d014c 100644
--- a/web/js/containers/gif.js
+++ b/web/js/containers/gif.js
@@ -2,10 +2,11 @@ import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import GifPanel from '../components/animation-widget/gif-panel';
-import GifStream from '@entryline/gifstream';
+import GifStream from '@entryline/gifstream'; // '../map/animation/gif-stream';
import util from '../util/util';
import * as olProj from 'ol/proj';
import { debounce as lodashDebounce, round as lodashRound } from 'lodash';
+
import Crop from '../components/util/image-crop';
import {
resolutionsGeo,
@@ -17,7 +18,7 @@ import {
getPercentageFromPixel,
getPixelFromPercentage
} from '../modules/image-download/util';
-import { Progress } from 'reactstrap';
+import { Progress, Modal, ModalBody, ModalHeader } from 'reactstrap';
import { timeScaleFromNumberKey } from '../modules/date/constants';
import { GifResults } from '../components/animation-widget/gif-post-creation';
import { getImageArray } from '../modules/animation/selectors';
@@ -44,10 +45,17 @@ class GIF extends Component {
downloadedObject: {},
boundaries
};
- props.onChangeLocation(boundaries);
this.onBoundaryChange = this.onBoundaryChange.bind(this);
this.onGifProgress = this.onGifProgress.bind(this);
}
+ getStyle(props) {
+ return {
+ left: props.offsetLeft,
+ right: props.offsetRight,
+ top: props.offsetTop,
+ maxWidth: 342
+ };
+ }
renderSelectableBox() {
const {
increment,
@@ -78,36 +86,47 @@ class GIF extends Component {
proj.resolutions
);
return (
- <Fragment>
- <GifPanel
- speed={speed}
- resolutions={resolutions}
- resolution={resolution}
- showDates={showDates}
- increment={increment}
- projId={proj.id}
- lonlats={lonlats}
- startDate={startDate}
- endDate={endDate}
- onClick={this.createGIF.bind(this)}
- />
+ <Modal
+ backdrop={false}
+ isOpen={true}
+ wrapClassName={'clickable-behind-modal toolbar_modal_outer'}
+ className={'gif-modal dynamic-modal'}
+ style={this.getStyle(this.state)}
+ >
+ {/* <DetectOuterClick onClick={onClose} disabled={true}> */}
+ <ModalHeader>Create An Animated GIF</ModalHeader>
+ <ModalBody>
+ <GifPanel
+ speed={speed}
+ resolutions={resolutions}
+ resolution={resolution}
+ showDates={showDates}
+ increment={increment}
+ projId={proj.id}
+ lonlats={lonlats}
+ startDate={startDate}
+ endDate={endDate}
+ onClick={this.createGIF.bind(this)}
+ />
- <Crop
- x={getPercentageFromPixel(screenWidth, x)}
- y={getPercentageFromPixel(screenHeight, y)}
- maxHeight={screenHeight}
- maxWidth={screenWidth}
- width={getPercentageFromPixel(screenWidth, x2 - x)}
- height={getPercentageFromPixel(screenHeight, y2 - y)}
- onChange={lodashDebounce(this.onBoundaryChange, 5)}
- onClose={onClose}
- coordinates={{
- bottomLeft: util.formatCoordinate([geolonlat1[0], geolonlat1[1]]),
- topRight: util.formatCoordinate([geolonlat2[0], geolonlat2[1]])
- }}
- showCoordinates={false}
- />
- </Fragment>
+ <Crop
+ x={getPercentageFromPixel(screenWidth, x)}
+ y={getPercentageFromPixel(screenHeight, y)}
+ maxHeight={screenHeight}
+ maxWidth={screenWidth}
+ width={getPercentageFromPixel(screenWidth, x2 - x)}
+ height={getPercentageFromPixel(screenHeight, y2 - y)}
+ onChange={lodashDebounce(this.onBoundaryChange, 5)}
+ onClose={onClose}
+ coordinates={{
+ bottomLeft: util.formatCoordinate([geolonlat1[0], geolonlat1[1]]),
+ topRight: util.formatCoordinate([geolonlat2[0], geolonlat2[1]])
+ }}
+ showCoordinates={false}
+ />
+ </ModalBody>
+ {/* </DetectOuterClick> */}
+ </Modal>
);
}
createGIF(width, height) {
@@ -129,6 +148,7 @@ class GIF extends Component {
// won't be true if there are too mant frames
return;
}
+ console.log(imageArra);
gifStream.createGIF(
{
gifWidth: width,
@@ -206,13 +226,24 @@ class GIF extends Component {
});
}
onBoundaryChange(boundaries) {
- const { screenWidth, screenHeight, onChangeLocation } = this.props;
+ const { screenWidth, screenHeight } = this.props;
const x = getPixelFromPercentage(screenWidth, boundaries.x);
const y = getPixelFromPercentage(screenHeight, boundaries.y);
const x2 = x + getPixelFromPercentage(screenWidth, boundaries.width);
const y2 = y + getPixelFromPercentage(screenHeight, boundaries.height);
- onChangeLocation({ x, y, x2, y2 });
+ const width = 342;
+ const height = 280;
+ let left = x2 + 20;
+ let top = y - 20;
+ if (left + width > screenWidth && x - 20 - width > 0) {
+ left = x - 20 - width;
+ }
+ if (top + height > screenHeight) {
+ top = screenHeight - 20 - height;
+ }
this.setState({
+ offsetLeft: left,
+ offsetTop: top,
boundaries: {
x: x,
y: y,
@@ -222,16 +253,32 @@ class GIF extends Component {
});
}
render() {
- const { isActive, increment, speed, endDate, startDate } = this.props;
+ const {
+ increment,
+ speed,
+ endDate,
+ startDate,
+ screenHeight,
+ screenWidth
+ } = this.props;
const {
isDownloaded,
isDownloading,
progress,
- downloadedObject
+ downloadedObject,
+ boundaries
} = this.state;
- if (!isActive) return '';
- if (isDownloading) return <Progress value={progress} />;
+ if (isDownloading) {
+ return (
+ <Modal isOpen={true}>
+ <ModalHeader>Creating GIF</ModalHeader>
+ <ModalBody>
+ <Progress value={progress} />
+ </ModalBody>
+ </Modal>
+ );
+ }
if (isDownloaded) {
return (
<GifResults
@@ -240,6 +287,9 @@ class GIF extends Component {
startDate={startDate}
endDate={endDate}
increment={increment}
+ boundaries={boundaries}
+ screenWidth={screenWidth}
+ screenHeight={screenHeight}
/>
);
}
diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.js
index 51440232b..c93185e6f 100644
--- a/web/js/containers/image-download.js
+++ b/web/js/containers/image-download.js
@@ -60,10 +60,10 @@ class ImageDownloadContainer extends Component {
map,
url,
onClose,
- models,
screenWidth,
screenHeight,
- date
+ date,
+ getLayers
} = this.props;
const { boundaries } = this.state;
const { x, y, x2, y2 } = boundaries;
@@ -94,6 +94,7 @@ class ImageDownloadContainer extends Component {
date={date}
url={url}
crs={crs}
+ getLayers={getLayers}
/>
<Crop
x={getPercentageFromPixel(screenWidth, x)}
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index a18b39388..97563500c 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -16,7 +16,6 @@ class ModalContainer extends Component {
offsetLeft: props.customProps.offsetLeft,
width: props.customProps.width
};
- this.setOffsets = this.setOffsets.bind(this);
}
// static getDerivedStateFromProps(newProps, state) {
// const customProps = newProps.customProps;
@@ -40,25 +39,6 @@ class ModalContainer extends Component {
maxWidth: props.width
};
}
- setOffsets(boundaries) {
- const { screenHeight, screenWidth, customProps } = this.props;
- const { x, y, x2 } = boundaries;
- const width = customProps.width;
- const height = 280;
- let left = x2 + 20;
- let top = y - 20;
- if (left + width > screenWidth && x - 20 - width > 0) {
- left = x - 20 - width;
- }
- if (top + height > screenHeight) {
- top = screenHeight - 20 - height;
- }
- this.setState({
- offsetLeft: left,
- offsetTop: top,
- width
- });
- }
getTemplateBody() {
const { bodyTemplate } = this.props;
return bodyTemplate.isLoading ? (
@@ -91,12 +71,9 @@ class ModalContainer extends Component {
onClose,
CompletelyCustomModal,
bodyComponentProps,
- timeout,
- dynamicOffsets
+ timeout
} = newProps;
- const style = dynamicOffsets
- ? this.getStyle(this.state)
- : this.getStyle(newProps);
+ const style = this.getStyle(newProps);
const lowerCaseId = lodashToLower(id);
const BodyComponent = bodyComponent || '';
const toggleWithClose = () => {
@@ -123,7 +100,7 @@ class ModalContainer extends Component {
modalTransition={{ timeout: timeout || 100 }}
>
{CompletelyCustomModal ? (
- <CompletelyCustomModal />
+ <CompletelyCustomModal {...customProps} />
) : (
<DetectOuterClick
onClick={toggleWithClose}
@@ -139,10 +116,7 @@ class ModalContainer extends Component {
<ModalBody>
{bodyHeader ? <h3>{bodyHeader}</h3> : ''}
{BodyComponent ? (
- <BodyComponent
- {...bodyComponentProps}
- onChangeLocation={this.setOffsets}
- />
+ <BodyComponent {...bodyComponentProps} />
) : isTemplateModal ? (
this.getTemplateBody()
) : (