Interactive interface for browsing global, full-resolution satellite imagery
add ae and as location permalinks, modify t to prevent init location serialize, modify defaults for custom interval value and delta, add animation widget change increment by header
Edward Platoc5dd07e637e1
diff --git a/web/js/app.js b/web/js/app.jsindex ce4218aa9..34c9966fb 100644--- a/web/js/app.js+++ b/web/js/app.js@@ -85,7 +85,6 @@ class App extends React.Component {this.onload();}render() {- // const { config } = this.props;return (<div className="wv-content" id="wv-content" data-role="content"><Toolbar />@@ -101,9 +100,6 @@ class App extends React.Component {<div id="timewheels" style={{ display: 'none' }} /><Timeline /><OlCoordinates mouseEvents={this.props.mapMouseEvents} />- {/* <div id="wv-animation-widet-case"> */}- {/* {config.features.animation ? <AnimationWidget /> : ''} */}- {/* </div> */}<Modal /><ErrorBoundary><Debug parameters={this.props.parameters} />diff --git a/web/js/components/timeline/timeline-controls/interval-timescale-change.js b/web/js/components/timeline/timeline-controls/interval-timescale-change.jsindex 8308ce63a..8ab328f5d 100644--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js@@ -31,6 +31,7 @@ class TimeScaleIntervalChange extends Component {toolTipHovered: false}, this.props.setTimeScaleIntervalChangeUnit(timescale, openDialog));}+// individual linking timescale handlershandleClickZoomYear = () => {this.handleClickZoom('year');@@ -62,12 +63,12 @@ class TimeScaleIntervalChange extends Component {}componentDidMount () {- if (this.props.customDelta !== 1) {+ if (this.props.customDelta !== 1 && this.props.customIntervalZoomLevel) {this.setCustomIntervalText();}}- componentDidUpdate (prevProps, prevState) {+ componentDidUpdate (prevProps) {let {customDelta,timeScaleChangeUnit,diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.jsindex 8cd46399c..71b4051c7 100644--- a/web/js/containers/animation-widget.js+++ b/web/js/containers/animation-widget.js@@ -20,8 +20,9 @@ import {changeEndDate} from '../modules/animation/actions';import GifContainer from './gif';+import { selectInterval } from '../modules/date/actions';-import { timeScaleFromNumberKey } from '../modules/date/constants';+import { timeScaleFromNumberKey, timeScaleToNumberKey } from '../modules/date/constants';const RangeHandle = props => {const { value, offset, dragging, ...restProps } = props;@@ -61,6 +62,7 @@ class AnimationWidget extends React.Component {isGifActive: false};this.onDateChange = this.onDateChange.bind(this);+ this.onZoomSelect = this.onZoomSelect.bind(this);}static getDerivedStateFromProps(props, state) {if (props.speed !== state.speed && !state.isSliding) {@@ -101,11 +103,31 @@ class AnimationWidget extends React.Component {onUpdateEndDate(date);}}+ /*+ * Changes selected default or custom interval in header and+ * changes left/right date arrow increments+ *+ * @method onZoomSelect+ *+ * @param {string} zoom - clicked header string (ex: 'day', 'year', '12 day')+ * component+ *+ * @return {void}+ */+ onZoomSelect(zoom) {+ let { customDelta, customInterval, onZoomSelect } = this.props;+ let zoomToNumber = timeScaleToNumberKey[zoom]; // undefined if custom+ if (zoomToNumber) {+ onZoomSelect(1, zoomToNumber, false);+ } else {+ onZoomSelect(customDelta, customInterval, true);+ }+ }+render() {const {hasSubdailyLayers,increment,- onZoomSelect,incrementArray,looping,isPlaying,@@ -140,7 +162,7 @@ class AnimationWidget extends React.Component {<AnimWidgetHeadertext={increment}toolTipTextArray={incrementArray}- onClick={onZoomSelect}+ onClick={this.onZoomSelect}/><PlayButton@@ -241,6 +263,8 @@ function mapStateToProps(state) {hasSubdailyLayers,incrementArray: zoomObj.array,increment: zoomObj.increment,+ customDelta: zoomObj.customDelta,+ customInterval: zoomObj.customInterval,sliderLabel: 'Frames Per Second',speed,isPlaying,@@ -260,12 +284,11 @@ const mapDispatchToProps = dispatch => ({onPushLoop: () => {dispatch(toggleLooping());},-onSlide: num => {dispatch(changeFrameRate(num));},- onZoomSelect: num => {- // dispatch(onZoomSelect(num));+ onZoomSelect: (delta, zoom, customSelected) => {+ dispatch(selectInterval(delta, zoom, customSelected));},onUpdateStartDate(date) {dispatch(changeStartDate(date));@@ -312,9 +335,9 @@ const getZoomObject = function(dateModel, hasSubDaily) {}`: 'custom';if (hasSubDaily) {- zooms = [customText, 'yearly', 'monthly', 'daily', 'hourly', 'minutely'];+ zooms = [customText, 'year', 'month', 'day', 'hour', 'minute'];} else {- zooms = [customText, 'yearly', 'monthly', 'daily'];+ zooms = [customText, 'year', 'month', 'day'];}if (dateModel.customSelected) {headerText = zooms[0];@@ -322,11 +345,13 @@ const getZoomObject = function(dateModel, hasSubDaily) {let interval = dateModel.interval? dateModel.interval: dateModel.selectedZoom - 1;- headerText = zooms[interval];+ headerText = '1 ' + zooms[interval];}return {increment: headerText,- array: lodashWithout(zooms, headerText)+ array: lodashWithout(zooms, headerText),+ customDelta: dateModel.customDelta,+ customInterval: dateModel.customInterval};};diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 9b760eb80..12a5552d9 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -127,15 +127,16 @@ class Timeline extends React.Component {customIntervalModalOpen) => {let delta;+ let { customIntervalZoomLevel, customIntervalValue, selectInterval } = this.props;let customSelected = intervalSelected === 'custom';- if (customSelected) {- intervalSelected = this.props.customIntervalZoomLevel;- delta = this.props.customIntervalValue;+ if (customSelected && customIntervalZoomLevel && customIntervalValue) {+ intervalSelected = customIntervalZoomLevel;+ delta = customIntervalValue;} else {intervalSelected = Number(timeScaleToNumberKey[intervalSelected]);delta = 1;}- this.props.selectInterval(delta, intervalSelected, customSelected);+ selectInterval(delta, intervalSelected, customSelected);this.setState({customIntervalModalOpen: !!customIntervalModalOpen});@@ -254,9 +255,7 @@ class Timeline extends React.Component {</div><div id="zoom-buttons-group"><TimeScaleIntervalChange- setTimeScaleIntervalChangeUnit={- this.setTimeScaleIntervalChangeUnit- }+ setTimeScaleIntervalChangeUnit={this.setTimeScaleIntervalChangeUnit}customIntervalZoomLevel={timeScaleFromNumberKey[customIntervalZoomLevel]}customSelected={customSelected}customDelta={customIntervalValue}@@ -421,8 +420,8 @@ function mapStateToProps(state) {selectedDate: selectedDate,timeScale: timeScaleFromNumberKey[selectedZoom.toString()],timeScaleChangeUnit: timeScaleChangeUnit,- customIntervalValue: customDelta,- customIntervalZoomLevel: customInterval,+ customIntervalValue: customDelta || 1,+ customIntervalZoomLevel: customInterval || 3,intervalChangeAmt: deltaChangeAmt,parentOffset: dimensionsAndOffsetValues.parentOffset,timelineEndDateLimit,@@ -436,7 +435,7 @@ const mapDispatchToProps = dispatch => ({changeDate: val => {dispatch(selectDate(val));},- // changes/sets custom delta and timescale interval, sets customSelected to TRUE+ // changes/sets custom delta and timescale intervalchangeCustomInterval: (delta, timeScale) => {dispatch(changeCustomInterval(delta, timeScale));},@@ -444,7 +443,7 @@ const mapDispatchToProps = dispatch => ({changeTimeScale: val => {dispatch(changeTimeScale(val));},- // changes to non-custom timescale interval, sets customSelected to FALSE+ // changes to non-custom timescale interval, sets customSelected to TRUE/FALSEselectInterval: (delta, timeScale, customSelected) => {dispatch(selectInterval(delta, timeScale, customSelected));},@@ -457,10 +456,10 @@ const mapDispatchToProps = dispatch => ({toggleActiveCompareState: () => {dispatch(toggleActiveCompareState());},- changeStartDate: (date) => {+ changeStartDate: date => {dispatch(changeStartDate(date));},- changeEndDate: (date) => {+ changeEndDate: date => {dispatch(changeEndDate(date));}});diff --git a/web/js/location.js b/web/js/location.jsindex 994ecb1b3..c9059e853 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -78,7 +78,8 @@ export function mapLocationToState(state, location) {}const getParameters = function(config, parameters) {- const now = util.now();+ const now = config.now;+ const nowMinusSevenDays = util.dateAdd(config.now, 'day', -7);return {p: {stateKey: 'proj.id',@@ -86,7 +87,7 @@ const getParameters = function(config, parameters) {},t: {stateKey: 'date.selected',- initialState: now, // ! now is not the same as default util.now() in the date.state due to invoking at different times+ initialState: now,type: 'date',options: {serializeNeedsGlobalState: true,@@ -95,11 +96,17 @@ const getParameters = function(config, parameters) {const compareIsActive = get(state, 'compare.active');const isCompareA = get(state, 'compare.isCompareA');const dateB = get(state, 'date.selectedB');+ const nowString = util.toISOStringSeconds(now);+return !compareIsActive && !isCompareA- ? serializeDate(dateB)- : !currentItemState+ ? util.toISOStringSeconds(dateB) === nowString+ ? undefined+ : serializeDate(dateB)+ : util.toISOStringSeconds(currentItemState) === nowString? undefined- : serializeDate(currentItemState);+ : !currentItemState+ ? undefined+ : serializeDate(currentItemState);},parse: str => {return tryCatchDate(str, now);@@ -108,18 +115,18 @@ const getParameters = function(config, parameters) {},t1: {stateKey: 'legacy.date.selectedB',- initialState: util.dateAdd(now, 'day', -7),+ initialState: nowMinusSevenDays,options: {serializeNeedsGlobalState: true,serialize: (currentItemState, state) => {const isActive = get(state, 'compare.active');if (!isActive) return undefined;return serializeDate(- currentItemState || util.dateAdd(now, 'day', -7)+ currentItemState || nowMinusSevenDays);},parse: str => {- return tryCatchDate(str, util.dateAdd(now, 'day', -7));+ return tryCatchDate(str, nowMinusSevenDays);}}},@@ -155,11 +162,10 @@ const getParameters = function(config, parameters) {},ici: {stateKey: 'date.customInterval',- initialState: 3,+ initialState: undefined,options: {serializeNeedsGlobalState: true,serialize: (currentItemState, state) => {- console.log(currentItemState, state)const isCustomSelected = get(state, 'date.customSelected');if (!isCustomSelected) return undefined;return currentItemState.toString();@@ -171,7 +177,7 @@ const getParameters = function(config, parameters) {},icd: {stateKey: 'date.customDelta',- initialState: 1,+ initialState: undefined,options: {serializeNeedsGlobalState: true,serialize: (currentItemState, state) => {@@ -184,19 +190,31 @@ const getParameters = function(config, parameters) {}}},+ as: {+ stateKey: 'animation.startDate',+ initialState: nowMinusSevenDays,+ type: 'date',+ options: {+ serializeNeedsGlobalState: true,+ serialize: (currentItemState) => {+ return serializeDate(+ currentItemState || nowMinusSevenDays+ );+ },+ parse: str => {+ return tryCatchDate(str, nowMinusSevenDays);+ }+ }+ },ae: {stateKey: 'animation.endDate',initialState: now,+ type: 'date',options: {serializeNeedsGlobalState: true,- serialize: (currentItemState, state) => {- console.log(currentItemState, state)-- // startDate: util.dateAdd(new Date(), 'day', -7),- // endDate: new Date()-+ serialize: (currentItemState) => {return serializeDate(- currentItemState+ currentItemState || now);},parse: str => {@@ -204,21 +222,6 @@ const getParameters = function(config, parameters) {}}},- // ae: {- // stateKey: 'animation.endDate',- // initialState: undefined,- // options: {- // serializeNeedsGlobalState: true,- // serialize: (currentItemState, state) => {- // return serializeDate(- // currentItemState- // );- // },- // parse: str => {- // return tryCatchDate(str, undefined);- // }- // }- // },e: {stateKey: 'events',type: 'object',diff --git a/web/js/main.js b/web/js/main.jsindex 5bc8b54bc..178faf39a 100644--- a/web/js/main.js+++ b/web/js/main.js@@ -54,6 +54,7 @@ window.onload = () => {loadingIndicator.delayed(promise, 1000);promise.done(config => {+ config.now = new Date();elapsed('Config loaded', startTime, parameters);let legacyState = parse(parameters, config, errors);layerValidate(errors, config);diff --git a/web/js/modules/animation/reducers.js b/web/js/modules/animation/reducers.jsindex c149f6b52..22ac5e031 100644--- a/web/js/modules/animation/reducers.js+++ b/web/js/modules/animation/reducers.js@@ -15,18 +15,13 @@ const defaultState = {isActive: false,isPlaying: false,loop: false,- speed: 3,- startDate: util.dateAdd(new Date(), 'day', -7),- endDate: new Date()+ speed: 3};-// export function getInitialState(config) {-// return lodashAssign({}, defaultState, {-// startDate: util.dateAdd(new Date(), 'day', -7),-// endDate: new Date()-// });-// }export function getInitialState(config) {- return lodashAssign({}, defaultState);+ return lodashAssign({}, defaultState, {+ startDate: util.dateAdd(config.now, 'day', -7),+ endDate: config.now+ });}export function animationReducer(state = defaultState, action) {diff --git a/web/js/modules/combine-reducers.js b/web/js/modules/combine-reducers.jsindex ad6a061b9..42a8258f9 100644--- a/web/js/modules/combine-reducers.js+++ b/web/js/modules/combine-reducers.js@@ -25,7 +25,10 @@ import {layerReducer,getInitialState as getLayersInitialState} from './layers/reducers';-import { dateReducer } from './date/reducers';+import {+ dateReducer,+ getInitialState as getDateInitialState+} from './date/reducers';import {animationReducer,getInitialState as getAnimationInitialState@@ -62,6 +65,7 @@ export function getInitialState(models, config, parameters) {config,models,legacy: models,+ date: getDateInitialState(config),animation: getAnimationInitialState(config),proj: getProjInitialState(config),layers: getLayersInitialState(config),diff --git a/web/js/modules/date/reducers.js b/web/js/modules/date/reducers.jsindex 03a54daf7..8588c01ba 100644--- a/web/js/modules/date/reducers.js+++ b/web/js/modules/date/reducers.js@@ -12,13 +12,18 @@ const defaultState = {selectedZoom: 3,interval: 3,delta: 1,- selected: util.now(),- selectedB: util.dateAdd(util.now(), 'day', -7),customSelected: false,- customDelta: 1,- customInterval: 3+ customDelta: undefined,+ customInterval: undefined};+export function getInitialState(config) {+ return lodashAssign({}, defaultState, {+ selected: config.now,+ selectedB: util.dateAdd(config.now, 'day', -7)+ });+}+export function dateReducer(state = defaultState, action) {switch (action.type) {case CHANGE_TIME_SCALE: