Interactive interface for browsing global, full-resolution satellite imagery
connect new timeline date change to date select for layer change
Edward Platoe5566256888d
diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsindex d92eebfb6..e13971215 100644--- a/web/js/components/date-selector/date-selector.js+++ b/web/js/components/date-selector/date-selector.js@@ -32,6 +32,13 @@ class DateSelector extends React.Component {maxZoom: props.maxZoom});}+ // shouldComponentUpdate(prevProps, prevState) {+ // console.log(prevProps.date, prevState.date, this.props.date, this.state.date)+ // if (prevProps.date === this.props.date) {+ // return false;+ // }+ // return true;+ // }blur() {this.setState({ tab: null });}@@ -62,6 +69,7 @@ class DateSelector extends React.Component {});}updateDate(date, type, amt) {+ console.log(date);this.setState({date: date});diff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.jsindex 18a717600..336b5a2b5 100644--- a/web/js/components/date-selector/input.js+++ b/web/js/components/date-selector/input.js@@ -120,7 +120,8 @@ class DateInputColumn extends React.Component {}onClickUp() {if (this.props.type === 'minute') {- this.rollDate(10);+ // this.rollDate(10);+ this.rollDate(1);} else {this.rollDate(1);}@@ -130,7 +131,8 @@ class DateInputColumn extends React.Component {}onClickDown() {if (this.props.type === 'minute') {- this.rollDate(-10);+ // this.rollDate(-10);+ this.rollDate(-1);} else {this.rollDate(-1);}diff --git a/web/js/components/timeline/timeline-axis/timeline-axis-container.js b/web/js/components/timeline/timeline-axis/timeline-axis-container.jsindex 477f587c7..fdfa9f5d8 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis-container.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis-container.js@@ -10,7 +10,7 @@ class TimelineAxisContainer extends React.Component {}render() {- console.log(this.props)+ // console.log(this.props)return (<React.Fragment><TimelineAxis {...this.props} />diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex b29f553df..45efd7d4c 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -76,8 +76,6 @@ class TimelineAxis extends React.Component {showHoverLine: false,draggerTimeState: null,leftOffset: 0,- redLineOffset: -254,- redLineClick: -254,selectedDate: this.props.selectedDate, // center of viewport unless restricted by being start/end of available timetimeScale: 'day',endDate: null,@@ -562,13 +560,13 @@ class TimelineAxis extends React.Component {// }// set temp place holder for where hover line was when clicked to check for drag vs click- setLineClick = () => {- // console.log('hit', this.state.hoverTime)- this.setState({- // draggerTimeState: this.state.hoverTime,- redLineClick: this.state.leftOffset,- })- }+ // setLineClick = () => {+ // // console.log('hit', this.state.hoverTime)+ // this.setState({+ // // draggerTimeState: this.state.hoverTime,+ // redLineClick: this.state.leftOffset,+ // })+ // }// move red line to new positionsetLineTime = (e) => {@@ -596,12 +594,10 @@ class TimelineAxis extends React.Component {draggerVisible: true,draggerPositionB: draggerPositionB,// draggerVisible: true,- // redLineOffset: this.state.leftOffsetRelativeToInnerParent,- redLineOffset: this.state.leftOffset,draggerTimeState: this.state.hoverTime,selectedDate: this.state.hoverTime,moved: false- })+ }, this.props.updateDate(this.state.hoverTime))}}@@ -705,7 +701,6 @@ class TimelineAxis extends React.Component {draggerVisible: draggerVisible,draggerPositionB: draggerPositionB + midPoint - 49,draggerVisibleB: draggerVisibleB,- redLineOffset: draggerPosition + pixelsToAdd + 49,numberOfVisibleTiles: numberOfVisibleTiles,dragSentinelChangeNumber: dragSentinelChangeNumber,axisWidth: axisWidth,@@ -730,18 +725,20 @@ class TimelineAxis extends React.Component {});}- shouldComponentUpdate(nextProps, nextState) {+ // shouldComponentUpdate(nextProps, nextState) {// console.log(nextProps.timeScale, nextState.timeScale, this.state.timeScale)// if (this.state.timeScale !== nextState.timeScale) {// console.log('update')// return true;// }// return false;- return true;- }+ // return true;+ // }//# BEST WAY TO HANDLE THIS?componentDidUpdate(prevProps, prevState) {++ // console.log(this.props.selectedDate, prevProps.selectedDate)// console.log(moment.utc(prevProps.selectedDate).format(), moment.utc(prevState.selectedDate).format())// let propsSelectedDate = moment.utc(prevProps.selectedDate).format();// let stateSelectedDate = moment.utc(prevState.selectedDate).format();@@ -757,8 +754,10 @@ class TimelineAxis extends React.Component {if (this.props.selectedDate !== prevProps.selectedDate) {- console.log('ok', this.props)- let manualTimeScaleChangeUnit = this.props.timeScaleChangeUnit;++ // console.log(this.props.selectedDate, prevProps.selectedDate)+ // console.log('ok', this.props)+ let manualTimeScaleChangeUnit = this.props.timeScaleChangeUnit || this.state.timeScale;let options = timeScaleOptions[manualTimeScaleChangeUnit].timeAxis;let gridWidth = options.gridWidth;@@ -766,15 +765,18 @@ class TimelineAxis extends React.Component {let frontDate = moment.utc(this.state.deque.peekFront().rawDate);let newSelectedDate = moment.utc(this.props.selectedDate);- console.log(newSelectedDate.format(), frontDate.format(), manualTimeScaleChangeUnit, gridWidth)+ // console.log(newSelectedDate.format(), frontDate.format(), manualTimeScaleChangeUnit, gridWidth)+ // console.log(moment.utc(this.props.selectedDate).format(), moment.utc(prevProps.selectedDate).format())let newDraggerPosition = this.getDraggerPosition(newSelectedDate, frontDate, manualTimeScaleChangeUnit, gridWidth)- console.log(this.state.draggerPosition, newDraggerPosition)+ // console.log(this.state.draggerPosition, newDraggerPosition)if (this.props.changeAmt !== null) {if (this.props.changeAmt > 0) {this.addTimeUnit(manualTimeScaleChangeUnit, this.props.changeAmt)+ this.props.incrementDate(manualTimeScaleChangeUnit, this.props.changeAmt);} else {this.minusTimeUnit(manualTimeScaleChangeUnit, -this.props.changeAmt)+ this.props.incrementDate(manualTimeScaleChangeUnit, this.props.changeAmt);}}@@ -809,7 +811,6 @@ class TimelineAxis extends React.Component {let pixelsToAddToDragger = Math.abs(frontDate.diff(draggerTimeState, timeScale, true) * gridWidth);let pixelsToAddToDraggerNew = Math.abs(frontDate.diff(draggerTimeStateAdded, timeScale, true) * gridWidth);let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;- // let newDraggerPosition;let isVisible = this.state.draggerVisible;if (isVisible) {@@ -822,15 +823,8 @@ class TimelineAxis extends React.Component {draggerPosition: newDraggerPosition,draggerVisible: draggerVisible,draggerTimeState: draggerTimeStateAdded.format(),- // redLineOffset: this.state.redLineOffset + pixelsToAddBasedOnFrontDate- },- this.props.incrementDate(timeScaleSelected, increment));- // } else {- // this.setState({- // draggerVisible: false,- // draggerTimeState: draggerTimeStateAdded.format()- // });- // }+ },)+ // this.props.incrementDate(timeScaleSelected, increment));}// move red line backward one timeScale unit and update time@@ -854,7 +848,6 @@ class TimelineAxis extends React.Component {let pixelsToAddToDragger = Math.abs(frontDate.diff(draggerTimeState, timeScale, true) * gridWidth);let pixelsToAddToDraggerNew = Math.abs(frontDate.diff(draggerTimeStateSubtracted, timeScale, true) * gridWidth);let pixelsToAddBasedOnFrontDate = pixelsToAddToDraggerNew - pixelsToAddToDragger;- // let newDraggerPosition;let isVisible = this.state.draggerVisible;if (isVisible) {@@ -866,30 +859,18 @@ class TimelineAxis extends React.Component {draggerPosition: newDraggerPosition,draggerVisible: draggerVisible,draggerTimeState: draggerTimeStateSubtracted.format(),- // redLineOffset: this.state.redLineOffset + pixelsToAddBasedOnFrontDate- },- this.props.incrementDate(timeScaleSelected, increment));- // } else {- // this.setState({- // draggerVisible: false,- // draggerTimeState: draggerTimeStateSubtracted.format()- // });- // }+ },)+ // this.props.incrementDate(timeScaleSelected, increment));}handleStopDrag = (e, d) => {let midPoint = this.state.midPoint;let position = this.state.position - midPoint;- // let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;- // let timeScale = this.state.timeScale;let moved = false;// necesarry for timescale change, d.x and midPoint are off// after timeScale change- // console.log(d.x, midPoint, position, this.state.currentTransformX)- // let panelUpdate = this.state;if (d.x > midPoint) { // drag rightmoved = true;-} else if(d.x < midPoint) { // drag leftmoved = true;}@@ -972,7 +953,7 @@ class TimelineAxis extends React.Component {moved: true,draggerSelected: true,draggerSelectedB: false,- });+ }, this.props.updateDate(newDraggerTime));} else {this.setState({draggerPositionB: draggerPosition,@@ -986,15 +967,8 @@ class TimelineAxis extends React.Component {})}- // get mid tile date in currentDateRange from deque- // getMidTileDate = () => {- // let midTile = this.state.deque.get(Math.floor(this.state.deque.length / 2));- // return midTile.rawDate;- // }-// select draggerselectDragger = (draggerName) => {- console.log(draggerName)this.setState((prev) => ({draggerSelected: draggerName === 'A' ? true : false,draggerSelectedB: draggerName === 'B' ? true : false@@ -1089,7 +1063,7 @@ class TimelineAxis extends React.Component {// ref={this.timelineRef} //# REFstyle={{width: `${this.state.axisWidth}px`}}// onMouseMove={(e) => this.getLeftOffset(e, e.clientX)}- onMouseDown={() => this.setLineClick()}+ // onMouseDown={() => this.setLineClick()}onMouseUp={(e) => this.setLineTime(e)}onWheel={(e) => this.wheelZoom(e)}// onMouseOver={() => this.setState({showHoverLine: true})}@@ -1151,7 +1125,6 @@ class TimelineAxis extends React.Component {parentPosition={this.state.position} /></svg>: null }- {/* <div className="linered" style={{transform: `translate(${Math.floor(this.state.redLineOffset)}px, 0px)`}}></div> */}<div className="line" style={{transform: `translate(${this.state.leftOffset}px, 0px)`, display: this.state.showHoverLine ? 'block' : 'none'}}></div><div className="dateToolTip" style={{transform: `translate(${this.state.draggerPosition - 5}px, -100px)`}}>{this.state.draggerTimeState ? this.state.draggerTimeState : null}</div><div className="dateToolTip" style={{transform: `translate(${this.state.leftOffset - 52}px, -125px)`, display: this.state.showHoverLine ? 'block' : 'none'}}>{this.state.hoverTime ? this.state.hoverTime : null}</div>diff --git a/web/js/components/timeline/timeline-controls/date-change-controls.js b/web/js/components/timeline/timeline-controls/date-change-controls.jsindex 329a6be78..875bf8c53 100644--- a/web/js/components/timeline/timeline-controls/date-change-controls.js+++ b/web/js/components/timeline/timeline-controls/date-change-controls.js@@ -12,23 +12,43 @@ class DateChangeControls extends React.Component {};}+ // shouldComponentUpdate(nextProps, nextState) {+ // // console.log(nextProps.timeScale, nextState.timeScale, this.state.timeScale)+ // // if (this.state.timeScale !== nextState.timeScale) {+ // // console.log('update')+ // // return true;+ // // }+ // // return false;+ // return true;+ // }++ componentDidUpdate() {+ // console.log('update')+ }+render() {// ZOOM LEVELS:// 1-YEAR, 2-MONTH, 3-DAY, 4-MINUTE, 5-DAY??// console.log(this.props, new Date())- let selectedDate = this.props.selectedDate;+ // let selectedDate = this.props.selectedDate;let mockDateSelectorProps = {- date: new Date(selectedDate),+ date: new Date(this.props.selectedDate),fontSize: null,height: '30',- id: 'main',+ id: 'main-TEST',idSuffix: 'animation-widget-main',- maxDate: new Date('2019-04-01'),+ maxDate: new Date('2020-01-01T00:00:00.000'),maxZoom: 5, // 3 === DAY, 5 TRIGGERS CONDITIONAL TO SHOW SUBDAILY- minDate: new Date('1947-02-01'),+ minDate: new Date('1940-01-01T00:00:00.000'),onDateChange: this.props.dateChange,width: '120'}+++// const pastDateLimit = moment.utc('1940-01-01T00:00:00.000');+// const futureDateLimit = moment.utc('2020-01-01T00:00:00.000');++ // console.log(this.props.selectedDate)return (<div><DateSelectordiff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.jsindex f54a345fb..5392f4b5a 100644--- a/web/js/components/timeline/timeline.js+++ b/web/js/components/timeline/timeline.js@@ -10,26 +10,68 @@ class Timeline extends React.Component {constructor(props) {super(props);this.state = {- width: this.props.width,- selectedDate: this.props.selectedDate,- changeDate: this.props.changeDate,- timeScale: this.props.timeScale,- incrementDate: this.props.incrementDate,- timeScaleChangeUnit: this.props.timeScaleChangeUnit,- changeAmt: 1,+ dateFormatted: '',+ width: '',+ selectedDate: '',+ changeDate: '',+ timeScale: '',+ incrementDate: '',+ timeScaleChangeUnit: '',+ changeAmt: '',};}dateChange = (date, id, type, amt) => {+ // console.log(date, id, type, amt)+ let dateFormatted = date.toISOString();+ console.log(dateFormatted)this.setState({- selectedDate: date,+ selectedDate: date.toISOString(),timeScaleChangeUnit: type,- changeAmt: amt+ changeAmt: amt,+ dateFormatted: dateFormatted+ })+ }++ updateDate = (date) => {+ console.log(date)+ this.props.updateDate(date);+ let dateFormatted = new Date(date).toISOString();+ // this.setState({+ // selectedDate: dateFormatted,+ // dateFormatted: dateFormatted+ // })+ }++ componentDidUpdate() {+ // console.log('CDU')+ }++ componentDidMount() {+ this.init();+ }++ init = () => {+ this.setState({+ dateFormatted: this.props.selectedDate.toISOString(),+ width: this.props.width,+ selectedDate: this.props.selectedDate.toISOString(),+ changeDate: this.props.changeDate,+ timeScale: this.props.timeScale,+ incrementDate: this.props.incrementDate,+ timeScaleChangeUnit: this.props.timeScaleChangeUnit,+ changeAmt: 1})}+ shouldComponentUpdate(nextProps, nextState) {+ // console.log(this.props, nextProps, this.state, nextState)+ return true;+ }+render() {- let dateFormatted = this.state.selectedDate.toISOString();+ // console.log(this.state)+ // let dateFormatted = this.state.selectedDate.toISOString();// let tempStyle = {// position: 'absolute',// border: '1px solid #333',@@ -43,14 +85,18 @@ class Timeline extends React.Component {// bottom: '10px'// }- console.log(this.props)+ // console.log(this.props)+ // console.log('DATE', dateFormatted)++return (+ this.state.dateFormatted ?<React.Fragment>- <DateChangeControls selectedDate={dateFormatted} dateChange={this.dateChange} />+ <DateChangeControls selectedDate={this.state.dateFormatted} dateChange={this.dateChange} />{/* <TimelineAxis {...this.state} selectedDate={dateFormatted}/> */}{/* new modular version - currently a shell */}- <TimelineAxisContainer {...this.state} selectedDate={dateFormatted}/>+ <TimelineAxisContainer {...this.state} selectedDate={this.state.dateFormatted} updateDate={this.updateDate} />{/* hammmmmmmmmmmburger 🍔 */}{/* <div id="timeline-hide">@@ -59,6 +105,8 @@ class Timeline extends React.Component {</svg></div> */}</React.Fragment>+ :+ null);}}diff --git a/web/js/date/model.js b/web/js/date/model.jsindex a219cd5c4..44c4585a0 100644--- a/web/js/date/model.js+++ b/web/js/date/model.js@@ -42,6 +42,7 @@ export function dateModel(models, config, spec) {};self.select = function(date, selectionStr) {+ // console.log(date, selectionStr)if (!date) return null;selectionStr = selectionStr || self.activeDate;date = self.clamp(date);diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.jsindex f9bb61e40..6040c997d 100644--- a/web/js/date/timeline-input.js+++ b/web/js/date/timeline-input.js@@ -73,6 +73,7 @@ export function timelineInput(models, config, ui) {$(document).mouseout(stopper).keydown(function(event) {+ console.log('asdasd')if (event.target.nodeName === 'INPUT' || keyDown === event.keyCode) {return;}@@ -182,12 +183,14 @@ export function timelineInput(models, config, ui) {* @return {void}*/self.animateByIncrement = function(delta, increment) {+ console.log(delta, increment)var endTime = models.layers.lastDateTime();var endDate = models.layers.lastDate();self.delta = Math.abs(delta);function animate() {var nextTime = getNextTimeSelection(delta, increment);+ console.log(tl.data.start(), nextTime, endTime)if (ui.timeline.config.currentZoom >= 4) {if (tl.data.start() <= nextTime && nextTime <= endTime) {models.date.add(increment, delta);@@ -207,6 +210,9 @@ export function timelineInput(models, config, ui) {* @return {void}*/var stopper = function() {+ // invokes when mouse over < > and date selector arrows/boxes+ // sticks on new timeline date selector+ console.log('STOPPPPPPPP')clearInterval(animator);animator = 0;};diff --git a/web/js/date/timeline.js b/web/js/date/timeline.jsindex 88b2c1797..c1480b2f7 100644--- a/web/js/date/timeline.js+++ b/web/js/date/timeline.js@@ -149,14 +149,26 @@ export function timeline(models, config, ui) {self.input.animateByIncrement(increment, timeScale);};+ var updateDate = (date) => {+ let updatedDate = new Date(date);+ // console.log(models)+ // self.input.update(updatedDate);+ // models.date.setActiveDate(updatedDate);++ //# ALLOWS UPDATE OF MODELS DATE WHICH LAYERS IS CONNECTED TO+ models.date.select(updatedDate);+ };+var getInitialProps = () => {+ console.log(self)return {width: self.width,height: self.height,selectedDate: models.date[models.date.activeDate],changeDate: changeDate,timeScale: 'day',- incrementDate: incrementDate+ incrementDate: incrementDate,+ updateDate: updateDate};};