Interactive interface for browsing global, full-resolution satellite imagery
get ui visible, wip scale and interval select
Edward Platob6a5b2e283fd
diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.jsindex 8467bfb94..3748e318f 100644--- a/web/js/components/timeline/interval-selector/interval-selector.js+++ b/web/js/components/timeline/interval-selector/interval-selector.js@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';import IntervalInput from './interval-input';import TimeScaleSelect from './timescale-select';+import { timeScaleFromNumberKey, timeScaleToNumberKey } from '../../../modules/date/constants';+/** CustomIntervalSelectorWidget for Custom Interval Selector* group. It is a parent component of this group.@@ -23,20 +25,20 @@ class CustomIntervalSelectorWidget extends PureComponent {intervalValue: value}, () => {if (value > 0 && value <= 1000) {- this.props.setIntervalChangeUnit(value, this.state.zoomLevel);+ this.props.changeCustomInterval(value, this.state.zoomLevel);}});}changeZoomLevel = (zoomLevel) => {this.setState({- zoomLevel: zoomLevel- }, this.props.setIntervalChangeUnit(this.state.intervalValue, zoomLevel));+ zoomLevel: timeScaleFromNumberKey[zoomLevel]+ }, this.props.changeCustomInterval(this.state.intervalValue, zoomLevel));}- setIntervalChangeUnit = () => {+ changeCustomInterval = () => {if (this.state.intervalValue > 0) {- this.props.setIntervalChangeUnit(this.state.intervalValue, this.state.zoomLevel);+ this.props.changeCustomInterval(this.state.intervalValue, this.state.zoomLevel);}}@@ -44,7 +46,7 @@ class CustomIntervalSelectorWidget extends PureComponent {const value = this.state.intervalValue;if (e.key === 'Enter') {if (value > 0) {- this.setIntervalChangeUnit();+ this.changeCustomInterval();}} else if (e.key === 'Escape') {this.props.toggleCustomIntervalModal();@@ -53,23 +55,24 @@ class CustomIntervalSelectorWidget extends PureComponent {componentDidMount() {this.setState({- intervalValue: this.props.customIntervalValue,- zoomLevel: this.props.customIntervalZoomLevel+ intervalValue: this.props.customDelta,+ zoomLevel: timeScaleFromNumberKey[this.props.customIntervalZoomLevel]})}componentDidUpdate(prevProps) {- let { customIntervalModalOpen, customIntervalValue, zoomLevel, customIntervalZoomLevel } = this.props;+ let { customIntervalModalOpen, customDelta, zoomLevel, customIntervalZoomLevel } = this.props;// handle focus widget on openingif (customIntervalModalOpen && !prevProps.customIntervalModalOpen) {this.customIntervalWidget.focus();}+ console.log(this.props)// update if higher state changed- if (customIntervalValue !== prevProps.customIntervalValue+ if (customDelta !== prevProps.customDelta|| zoomLevel !== prevProps.zoomLevel) {this.setState({- intervalValue: customIntervalValue,- zoomLevel: customIntervalZoomLevel+ intervalValue: customDelta,+ zoomLevel: timeScaleFromNumberKey[customIntervalZoomLevel]})}}@@ -77,6 +80,7 @@ class CustomIntervalSelectorWidget extends PureComponent {render() {let { customIntervalModalOpen, hasSubdailyLayers, toggleCustomIntervalModal } = this.props;let { intervalValue, zoomLevel } = this.state;+ console.log(this.props, this.state)return (<divid="wv-animation-widget-custom-interval"@@ -109,10 +113,10 @@ class CustomIntervalSelectorWidget extends PureComponent {}CustomIntervalSelectorWidget.propTypes = {- setIntervalChangeUnit: PropTypes.func,+ changeCustomInterval: PropTypes.func,toggleCustomIntervalModal: PropTypes.func,- customIntervalValue: PropTypes.number,- customIntervalZoomLevel: PropTypes.string,+ customDelta: PropTypes.number,+ customIntervalZoomLevel: PropTypes.number,customIntervalModalOpen: PropTypes.bool,hasSubdailyLayers: PropTypes.bool};diff --git a/web/js/components/timeline/interval-selector/timescale-select.js b/web/js/components/timeline/interval-selector/timescale-select.jsindex 3500a6597..cc966a143 100644--- a/web/js/components/timeline/interval-selector/timescale-select.js+++ b/web/js/components/timeline/interval-selector/timescale-select.js@@ -19,6 +19,7 @@ class TimeScaleSelect extends PureComponent {render() {let { zoomLevel, hasSubdailyLayers } = this.props;+ console.log(this.props)return (<form className="interval-timescale-select" onSubmit={this.handleSubmit}><label>diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js b/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.jsindex 837a94f5d..43b60f8e0 100644--- a/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js@@ -10,11 +10,11 @@ import AxisTimeScaleChangeTooltip from './axis-timescale-change-tooltip';*/class AxisTimeScaleChangeControls extends PureComponent {onClickUp = () => {- this.props.incrementTimeScale();+ this.props.decrementTimeScale();}onClickDown = () => {- this.props.decrementTimeScale();+ this.props.incrementTimeScale();}render() {let { timeScale, toolTipHovered, changeTimeScale, hasSubdailyLayers } = this.props;diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change.js b/web/js/components/timeline/timeline-controls/axis-timescale-change.jsindex 9b6371d13..5c1b0f2a1 100644--- a/web/js/components/timeline/timeline-controls/axis-timescale-change.js+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js@@ -1,4 +1,4 @@-import React from 'react';+import React, { PureComponent } from 'react';import PropTypes from 'prop-types';import AxisTimeScaleChangeControls from './axis-timescale-change-controls';@@ -18,7 +18,7 @@ const timeScaleToNumberKey = {* @class AxisTimeScaleChange* @extends React.Component*/-class AxisTimeScaleChange extends React.Component {+class AxisTimeScaleChange extends PureComponent {constructor(props) {super(props);this.state = {@@ -51,6 +51,7 @@ class AxisTimeScaleChange extends React.Component {})}+ // ex: month(2) to day(3)incrementTimeScale = () => {let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];let maxTimeScaleNumber = this.props.hasSubdailyLayers ? 5 : 3;@@ -59,6 +60,7 @@ class AxisTimeScaleChange extends React.Component {}}+ // ex: day(3) to month(2)decrementTimeScale = () => {let timeScaleNumber = timeScaleToNumberKey[this.props.timeScale];if (timeScaleNumber > 1) {@@ -67,7 +69,6 @@ class AxisTimeScaleChange extends React.Component {}render() {- console.log(this.props)let { timeScale, hasSubdailyLayers, changeTimeScale } = this.props;return (timeScale ?diff --git a/web/js/components/timeline/timeline-controls/interval-timescale-change.js b/web/js/components/timeline/timeline-controls/interval-timescale-change.jsindex 834499194..97be1e189 100644--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js@@ -18,6 +18,7 @@ class TimeScaleIntervalChange extends Component {}handleClickZoom = (intervalSelected, openDialog) => {+ console.log(intervalSelected)// close tooltip// send props function to change timescale zoom level throughout appthis.setState({@@ -28,22 +29,22 @@ class TimeScaleIntervalChange extends Component {// set custom text for custom intervalsetCustomIntervalText = () => {this.setState({- customIntervalText: this.props.customIntervalValue + ' ' + this.props.customIntervalZoomLevel+ customIntervalText: this.props.customDelta + ' ' + this.props.customIntervalZoomLevel})}componentDidMount () {- if (this.props.customIntervalValue !== 1) {+ if (this.props.customDelta !== 1) {this.setCustomIntervalText();}}componentDidUpdate (prevProps, prevState) {- let { customIntervalValue, timeScaleChangeUnit, customSelected } = this.props;- if (customIntervalValue && timeScaleChangeUnit) {- if (customSelected && customIntervalValue !== 1 && this.state.customIntervalText === 'Custom') {+ let { customDelta, timeScaleChangeUnit, customSelected } = this.props;+ if (customDelta && timeScaleChangeUnit) {+ if (customSelected && customDelta !== 1 && this.state.customIntervalText === 'Custom') {this.setCustomIntervalText();- } else if (customSelected && (customIntervalValue !== prevProps.customIntervalValue || timeScaleChangeUnit !== prevProps.timeScaleChangeUnit)) {+ } else if (customSelected && (customDelta !== prevProps.customDelta || timeScaleChangeUnit !== prevProps.timeScaleChangeUnit)) {this.setCustomIntervalText();}}@@ -131,7 +132,7 @@ class TimeScaleIntervalChange extends Component {}TimeScaleIntervalChange.propTypes = {- customIntervalValue: PropTypes.number,+ customDelta: PropTypes.number,customIntervalText: PropTypes.string,customSelected: PropTypes.bool,setTimeScaleIntervalChangeUnit: PropTypes.func,diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 1ecde6096..967061a43 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -33,9 +33,8 @@ class Timeline extends React.Component {constructor(props) {super(props);this.state = {- leftArrowDisabled: this.checkLeftArrowDisabled(),- rightArrowDisabled: this.checkRightArrowDisabled(),- timelineHidden: false+ timelineHidden: false,+ customIntervalModalOpen: false};this.animator = 0;}@@ -75,8 +74,6 @@ class Timeline extends React.Component {let animate = () => {var nextTime = getNextTimeSelection(delta, increment, selectedDate);- console.log(startDate, nextTime, endTime)- console.log(new Date(startDate) <= nextTime, nextTime <= endTime)if (hasSubdailyLayers) {// can we remove this logic?if (new Date(startDate) <= nextTime && nextTime <= endTime) {@@ -87,24 +84,16 @@ class Timeline extends React.Component {changeDate(util.dateAdd(selectedDate, increment, delta));}}- let leftArrowDisabled = this.checkLeftArrowDisabled();- let rightArrowDisabled = this.checkRightArrowDisabled();this.animator = setTimeout(animate, ANIMATION_DELAY);this.setState({- animationInProcess: true,- leftArrowDisabled,- rightArrowDisabled+ animationInProcess: true});};animate();}- changeDate = (date) => {- this.props.changeDate(date);- }-// show/hide custom interval modal- toggleCustomIntervalModal() {+ toggleCustomIntervalModal = () => {this.setState(prevState => ({customIntervalModalOpen: !prevState.customIntervalModalOpen}));@@ -117,25 +106,33 @@ class Timeline extends React.Component {// handle SET of custom time scale panelchangeCustomInterval = (delta, timeScale) => {- changeCustomInterval(delta, timeScale);+ console.log(delta,timeScale)+ this.props.changeCustomInterval(delta, Number(timeScaleToNumberKey[timeScale]));}// handle SELECT of LEFT/RIGHT interval selection- setTimeScaleIntervalChangeUnit = (intervalSelected) => {+ setTimeScaleIntervalChangeUnit = (intervalSelected, customIntervalModalOpen) => {console.log(intervalSelected)let delta;- if (intervalSelected === 'custom') {+ let customSelected = intervalSelected === 'custom';+ if (customSelected) {intervalSelected = this.props.customIntervalZoomLevel;delta = this.props.customIntervalValue;} else {- intervalSelected = timeScaleToNumberKey[intervalSelected];+ intervalSelected = Number(timeScaleToNumberKey[intervalSelected]);delta = 1;}- this.props.selectInterval(delta, intervalSelected);+ this.props.selectInterval(delta, intervalSelected, customSelected);+ if (customIntervalModalOpen) {+ this.setState({+ customIntervalModalOpen: customIntervalModalOpen+ });+ }}// left/right arrows increment dateincrementDate = (multiplier) => {+ console.log(this.props.customSelected)let delta = this.props.customSelected ? this.props.intervalChangeAmt : 1;this.animateByIncrement(Number(delta * multiplier),@@ -143,60 +140,6 @@ class Timeline extends React.Component {);}- // checkLeftArrowDisabled- checkLeftArrowDisabled() {- let {- draggerSelected,- dateFormatted,- dateFormattedB,- intervalChangeAmt,- timeScaleChangeUnit,- timelineStartDateLimit- } = this.props;- let previousIncrementDate;- if (intervalChangeAmt && timeScaleChangeUnit) {- if (draggerSelected === 'selected') {- previousIncrementDate = moment- .utc(dateFormatted)- .subtract(intervalChangeAmt, timeScaleChangeUnit);- } else {- previousIncrementDate = moment- .utc(dateFormattedB)- .subtract(intervalChangeAmt, timeScaleChangeUnit);- }- return previousIncrementDate.isSameOrBefore(- timelineStartDateLimit- );- }- }-- // checkRightArrowDisabled- checkRightArrowDisabled() {- let {- draggerSelected,- dateFormatted,- dateFormattedB,- intervalChangeAmt,- timeScaleChangeUnit,- timelineEndDateLimit- } = this.props;- let nextIncrementDate;- if (intervalChangeAmt && timeScaleChangeUnit) {- if (draggerSelected === 'selected') {- nextIncrementDate = moment- .utc(dateFormatted)- .add(intervalChangeAmt, timeScaleChangeUnit);- } else {- nextIncrementDate = moment- .utc(dateFormattedB)- .add(intervalChangeAmt, timeScaleChangeUnit);- }- return nextIncrementDate.isSameOrAfter(- timelineEndDateLimit- );- }- }-// open animation dialogclickAnimationButton() {// Will be a setState({})@@ -217,6 +160,8 @@ class Timeline extends React.Component {dateFormattedB,hasSubdailyLayers,draggerSelected,+ leftArrowDisabled,+ rightArrowDisabled,customSelected,customIntervalValue,customIntervalZoomLevel,@@ -236,7 +181,7 @@ class Timeline extends React.Component {<div id="date-selector-main"><DateSelector{...this.props}- onDateChange={this.changeDate}+ onDateChange={this.props.changeDate}date={new Date(dateFormatted)}dateB={new Date(dateFormattedB)}hasSubdailyLayers={hasSubdailyLayers}@@ -248,19 +193,19 @@ class Timeline extends React.Component {setTimeScaleIntervalChangeUnit={this.setTimeScaleIntervalChangeUnit}- customIntervalZoomLevel={customIntervalZoomLevel}+ customIntervalZoomLevel={timeScaleFromNumberKey[customIntervalZoomLevel]}customSelected={customSelected}- customIntervalValue={customIntervalValue}+ customDelta={customIntervalValue}timeScaleChangeUnit={timeScaleChangeUnit}/><DateChangeArrowsleftArrowDown={() => this.incrementDate(-1)}leftArrowUp={this.stopper.bind(this)}- leftArrowDisabled={this.state.leftArrowDisabled}+ leftArrowDisabled={leftArrowDisabled}rightArrowDown={() => this.incrementDate(1)}rightArrowUp={this.stopper.bind(this)}- rightArrowDisabled={this.state.rightArrowDisabled}+ rightArrowDisabled={rightArrowDisabled}/></div>@@ -276,7 +221,7 @@ class Timeline extends React.Component {axisWidth={axisWidth}selectedDate={dateFormatted}selectedDateB={dateFormattedB}- changeDate={this.changeDate}+ changeDate={this.props.changeDate}hasSubdailyLayers={hasSubdailyLayers}parentOffset={parentOffset}changeTimeScale={this.changeTimeScale}@@ -286,7 +231,6 @@ class Timeline extends React.Component {}}timelineStartDateLimit={timelineStartDateLimit}timelineEndDateLimit={timelineEndDateLimit}- customIntervalModalOpen={this.state.customIntervalModalOpen}updateAnimationRange={() => {}}// animStartLocationDate={this.state.animStartLocationDate}@@ -298,11 +242,11 @@ class Timeline extends React.Component {{/* custom interval selector */}<CustomIntervalSelectorWidget- customIntervalValue={customIntervalValue}+ customDelta={customIntervalValue}customIntervalZoomLevel={customIntervalZoomLevel}toggleCustomIntervalModal={this.toggleCustomIntervalModal}customIntervalModalOpen={this.state.customIntervalModalOpen}- setIntervalChangeUnit={this.changeCustomInterval}+ changeCustomInterval={this.changeCustomInterval}hasSubdailyLayers={hasSubdailyLayers}/></div>@@ -342,6 +286,7 @@ function mapStateToProps(state) {selectedB,selectedZoom,interval,+ delta,customInterval,customDelta} = date;@@ -361,6 +306,28 @@ function mapStateToProps(state) {const dimensionsAndOffsetValues = getOffsetValues(screenWidth, hasSubdailyLayers);const timelineEndDateLimit = endTime.toISOString();// console.log(date, compare);++ let selectedDate = isCompareA ? selected : selectedB;+ let deltaChangeAmt = customSelected+ ? customDelta+ : delta;+ let timeScaleChangeUnit = customSelected+ ? timeScaleFromNumberKey[customInterval]+ : timeScaleFromNumberKey[interval];+ let timelineStartDateLimit = config.startDate;+ let leftArrowDisabled = checkLeftArrowDisabled(+ selectedDate,+ deltaChangeAmt,+ timeScaleChangeUnit,+ timelineStartDateLimit+ );+ let rightArrowDisabled = checkRightArrowDisabled(+ selectedDate,+ deltaChangeAmt,+ timeScaleChangeUnit,+ timelineEndDateLimit+ );+return {draggerSelected: isCompareA ? 'selected' : 'selectedB', // ! will work for dragger?hasSubdailyLayers,@@ -373,16 +340,16 @@ function mapStateToProps(state) {endTime,isAnimationWidgetOpen: animation.active,axisWidth: dimensionsAndOffsetValues.width,- selectedDate: isCompareA ? selected : selectedB,+ selectedDate: selectedDate,timeScale: timeScaleFromNumberKey[selectedZoom.toString()],- timeScaleChangeUnit: customSelected- ? timeScaleFromNumberKey[customInterval]- : timeScaleFromNumberKey[interval],+ timeScaleChangeUnit: timeScaleChangeUnit,customIntervalValue: customDelta,customIntervalZoomLevel: customInterval,intervalChangeAmt: interval,parentOffset: dimensionsAndOffsetValues.parentOffset,- timelineEndDateLimit+ timelineEndDateLimit,+ leftArrowDisabled,+ rightArrowDisabled};}@@ -400,8 +367,8 @@ const mapDispatchToProps = dispatch => ({dispatch(changeTimeScale(val));},// changes to non-custom timescale interval, sets customSelected to FALSE- selectInterval: (delta, timeScale) => {- dispatch(selectInterval(delta, timeScale));+ selectInterval: (delta, timeScale, customSelected) => {+ dispatch(selectInterval(delta, timeScale, customSelected));}// set currently selected delta - will always be 1 if !customSelected// selectDelta: val => {@@ -424,15 +391,15 @@ Timeline.propTypes = {screenHeight: PropTypes.number};-function getOffsetValues(innerWidth, hasSubDaily) {+// get axisWidth and parentOffset for axis, footer, and leftoffset calculations+const getOffsetValues = (innerWidth, hasSubDaily) => {const parentOffset = (hasSubDaily ? 414 : 310) + 10;-const width =innerWidth - parentOffset - 20 - 20 - MARGIN.left - MARGIN.right + 28;return { width, parentOffset };}-function getEndTime(layers, config) {+const getEndTime = (layers, config) => {const endDateA = layersLastDateTime(layers['active'], config);const endDateB = layersLastDateTime(layers['activeB'], config);return endDateA > endDateB ? endDateA : endDateB;@@ -443,7 +410,7 @@ function getEndTime(layers, config) {* e.g. months,minutes, years, days* @return {Object} JS Date Object*/-var getNextTimeSelection = function(delta, increment, prevDate) {+const getNextTimeSelection = (delta, increment, prevDate) => {switch (increment) {case 'year':return new Date(@@ -467,3 +434,23 @@ var getNextTimeSelection = function(delta, increment, prevDate) {);}};++// check if left arrow should be disabled on predicted decrement+const checkLeftArrowDisabled = (date, delta, timeScaleChangeUnit, timelineStartDateLimit) => {+ let nextDecrementDate = moment+ .utc(date)+ .subtract(delta, timeScaleChangeUnit);+ return nextDecrementDate.isSameOrBefore(+ timelineStartDateLimit+ );+}++// check if right arrow should be disabled on predicted increment+const checkRightArrowDisabled = (date, delta, timeScaleChangeUnit, timelineEndDateLimit) => {+ let nextIncrementDate = moment+ .utc(date)+ .add(delta, timeScaleChangeUnit);+ return nextIncrementDate.isSameOrAfter(+ timelineEndDateLimit+ );+}diff --git a/web/js/modules/date/actions.js b/web/js/modules/date/actions.jsindex 8b2ad3990..644207f61 100644--- a/web/js/modules/date/actions.js+++ b/web/js/modules/date/actions.js@@ -25,17 +25,20 @@ export function selectDate(value) {};}export function changeCustomInterval(delta, customInterval) {+ console.log(delta, customInterval)return {type: CHANGE_CUSTOM_INTERVAL,- customInterval,- value: delta+ value: customInterval,+ delta: delta};}-export function selectInterval(delta, interval) {+export function selectInterval(delta, interval, customSelected) {+ console.log(delta, interval)return {type: CHANGE_INTERVAL,value: interval,- delta: delta+ delta: delta,+ customSelected};}// export function selectDelta(delta) {diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.jsindex c9aa7f980..cea8257ff 100644--- a/web/js/modules/date/reducers.js+++ b/web/js/modules/date/reducers.js@@ -35,13 +35,14 @@ export function dateReducer(state = defaultState, action) {return lodashAssign({}, state, {interval: action.value,delta: action.delta,- customSelected: false+ customSelected: action.customSelected});// case CHANGE_DELTA:// return lodashAssign({}, state, {// delta: action.value// });case SELECT_DATE:+ console.log(action.value)return lodashAssign({}, state, {[action.activeString]: action.value});