Interactive interface for browsing global, full-resolution satellite imagery
ab refactor and state sync
Edward Platoc4fc051d636f
diff --git a/web/css/timeline.css b/web/css/timeline.cssindex 0ef0500de..e9dff002e 100644--- a/web/css/timeline.css+++ b/web/css/timeline.css@@ -10,8 +10,9 @@ button:focus {.timeline-inner {position: absolute;border: 1px solid #333;- background: rgb(40, 40, 40);- background: rgba(40, 40, 40, 0.9);+ /* background: rgb(40, 40, 40);+ background: rgba(40, 40, 40, 0.9); */+ background: rgba(0, 0, 0, 0.8);border-radius: 5px;display: flex;flex-flow: row nowrap;@@ -22,7 +23,7 @@ button:focus {}#timeline-footer text {- font: 400 12px/125% 'Roboto Mono', monospace;+ /* font: 400 12px/125% 'Roboto Mono', monospace;text-align: start;letter-spacing: 0;word-spacing: 0;@@ -31,7 +32,7 @@ button:focus {writing-mode: lr-tb;text-anchor: start;fill-opacity: 1;- stroke: none;+ stroke: none; */}.x.axis .tick {diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsindex 3d8d909d2..161488b36 100644--- a/web/js/components/date-selector/date-selector.js+++ b/web/js/components/date-selector/date-selector.js@@ -17,7 +17,7 @@ class DateSelector extends React.Component {constructor(props) {super(props);this.state = {- date: props.date,+ date: props.draggerSelected === 'selectedB' ? props.dateB : props.date,maxDate: props.maxDate,minDate: props.minDate,tab: null,@@ -27,7 +27,8 @@ class DateSelector extends React.Component {}componentWillReceiveProps(props) {this.setState({- date: props.date,+ // date: props.draggerSelectedB ? props.dateB : props.date,+ date: props.draggerSelected === 'selectedB' ? props.dateB : props.date,maxDate: props.maxDate,minDate: props.minDate,// maxZoom: props.maxZoom,@@ -64,13 +65,15 @@ class DateSelector extends React.Component {});}updateDate(date, type, amt) {- console.log(date);+ console.log(this.state.date)this.setState({date: date});// this.props.onDateChange(date, this.props.id, type, amt);// # send argument to indicate input change for time axis updateScale call- this.props.onDateChange(date, true);+ // let selectionStr = this.props.draggerSelectedB ? 'selectedB' : 'selected';+ // let selectionStr = this.props.draggerSelectedB ? 'selectedB' : 'selected';+ this.props.onDateChange(date, this.props.draggerSelected);}renderSubdaily() {if (this.props.hasSubdailyLayers) {@@ -123,6 +126,8 @@ class DateSelector extends React.Component {}}render() {+ console.log(this.props.date)+ console.log(this.props.draggerSelected === 'selected')return (<div className="wv-date-selector-widget"><DateInputColumndiff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.jsindex 10339566e..392bbc5d4 100644--- a/web/js/components/date-selector/input.js+++ b/web/js/components/date-selector/input.js@@ -189,14 +189,14 @@ class DateInputColumn extends React.Component {minuteValidation(input) {var newDate;// var coeff = 1000 * 60 * 10;- console.log(input);+ // console.log(input);if (input >= 0 && input <= 59) {// newDate = new Date(// Math.round(new Date(this.props.date).setUTCMinutes(input) / coeff) *// coeff// );newDate = new Date(new Date(this.props.date).setUTCMinutes(input));- console.log(newDate)+ // console.log(newDate)return this.validateDate(newDate);}}diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.jsindex ca2fd52f9..e5d36e663 100644--- a/web/js/components/timeline/interval-selector/interval-selector.js+++ b/web/js/components/timeline/interval-selector/interval-selector.js@@ -15,8 +15,8 @@ class CustomIntervalSelectorWidget extends React.Component {constructor(props) {super(props);this.state = {- intervalValue: 1,- zoomLevel: 'day'+ intervalValue: '',+ zoomLevel: ''};}@@ -69,6 +69,7 @@ class CustomIntervalSelectorWidget extends React.Component {changeInterval={this.changeInterval}/><TimeScaleSelect+ hasSubdailyLayers={this.props.hasSubdailyLayers}zoomLevel={this.state.zoomLevel}changeZoomLevel={this.changeZoomLevel}/>@@ -98,6 +99,7 @@ class CustomIntervalSelectorWidget extends React.Component {}CustomIntervalSelectorWidget.propTypes = {+ hasSubdailyLayers: PropTypes.bool,setInterval: PropTypes.func,toggleCustomIntervalModal: PropTypes.func,customIntervalValue: PropTypes.number,diff --git a/web/js/components/timeline/interval-selector/timescale-select.js b/web/js/components/timeline/interval-selector/timescale-select.jsindex befca7fc1..dc1e2d294 100644--- a/web/js/components/timeline/interval-selector/timescale-select.js+++ b/web/js/components/timeline/interval-selector/timescale-select.js@@ -11,6 +11,7 @@ class TimeScaleSelect extends PureComponent {}render() {+ console.log(this.props.hasSubdailyLayers)return (<form className="interval-timescale-select" onSubmit={this.handleSubmit}><label>@@ -18,8 +19,14 @@ class TimeScaleSelect extends PureComponent {<option value="year">year</option><option value="month">month</option><option value="day">day</option>- <option value="hour">hour</option>- <option value="minute">minute</option>+ {this.props.hasSubdailyLayers ?+ <React.Fragment>+ <option value="hour">hour</option>+ <option value="minute">minute</option>+ </React.Fragment>+ :+ null+ }</select></label></form>diff --git a/web/js/components/timeline/timeline-axis/grid-range/grid-range.js b/web/js/components/timeline/timeline-axis/grid-range/grid-range.jsindex 2ad2aae8e..c69d3d727 100644--- a/web/js/components/timeline/timeline-axis/grid-range/grid-range.js+++ b/web/js/components/timeline/timeline-axis/grid-range/grid-range.js@@ -56,8 +56,15 @@ constructor(props) {let gridWidth = this.props.gridWidth;return (<g className="gridShell" transform={`translate(${this.props.transformX}, 0)`}>- <TileHolder dateArray={this.props.dateArray} gridWidth={gridWidth} showHover={this.showHover} timeScale={this.props.timeScale} />- <line className="svgLine" style={{display: this.props.showHoverLine ? 'block' : 'none'}} stroke="blue" strokeWidth="2" strokeOpacity="0.48" x1="0" x2="0" y1="0" y2="90" transform={`translate(${this.state.hoverLinePosition + 2}, 0)`} shapeRendering="optimizeSpeed"/>+ <TileHolder+ timeScale={this.props.timeScale}+ dateArray={this.props.dateArray}+ gridWidth={gridWidth}+ showHover={this.showHover}+ />+ <line className="svgLine" style={{display: this.props.showHoverLine ? 'block' : 'none'}}+ stroke="blue" strokeWidth="2" strokeOpacity="0.48" x1="0" x2="0" y1="0" y2="90"+ transform={`translate(${this.state.hoverLinePosition + 2}, 0)`} shapeRendering="optimizeSpeed"/></g>)}@@ -95,7 +102,6 @@ const tileTextConditionOptions = {class TileHolder extends PureComponent {render() {let timeScale = this.props.timeScale;- console.log(timeScale)let tileTextCondition = tileTextConditionOptions[timeScale];let midTile = Math.floor(this.props.dateArray.length / 2);return (diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.jsindex 01f3188a7..72b01aae1 100644--- a/web/js/components/timeline/timeline-axis/timeline-axis.js+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js@@ -39,7 +39,7 @@ const timeScaleOptions = {timeAxis: {scale: 'month',gridWidth: 12,- scaleMs: null //# null set to require a+ scaleMs: null// scaleMs: 2678400000}},@@ -57,30 +57,20 @@ class TimelineAxis extends React.Component {constructor(props) {super(props);this.state = {- // midTileDate: '',showDraggerTime: false,- compareMode: true,dragSentinelCount: 0,draggerPosition: 0,draggerVisible: true,- draggerSelected: true,draggerPositionB: 0,draggerVisibleB: true,- draggerSelectedB: false,moved: false,- timeScaleChange: false,deque: null,- timeScaleSelectValue: 'day',- increment: 1,- axisWidth: 800,hoverTime: null,showHoverLine: false,draggerTimeState: null,+ draggerTimeStateB: null,leftOffset: 0,selectedDate: this.props.selectedDate, // center of viewport unless restricted by being start/end of available time- timeScale: 'day',- endDate: null,- startDate: null,position: -2500,currentDateRange: null,currentTransformX: 0,@@ -90,20 +80,20 @@ class TimelineAxis extends React.Component {}// this.timelineRef = React.createRef(); //# REF- // this.showHoverOn = this.showHoverOn.bind(this);- // this.showHoverOff = this.showHoverOff.bind(this);}//? how do position and transforms change between scale changes? lock into one line would be idealupdateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff) => {let options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth;- let axisWidth = axisWidthInput ? axisWidthInput : this.state.axisWidth;+ let axisWidth = axisWidthInput ? axisWidthInput : this.props.axisWidth;let leftOffset = leftOffsetFixedCoeff ? axisWidth * leftOffsetFixedCoeff : this.state.leftOffset;if (leftOffset === 0) {leftOffset = axisWidth / 2;}+ console.log(leftOffset, this.state.draggerPosition)+let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));let gridNumber = Math.floor(numberOfVisibleTiles * 1.5); // should get from state?let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);@@ -191,7 +181,7 @@ class TimelineAxis extends React.Component {let draggerPositionB = 0;let draggerVisibleB = false;// let pixelsToAddToDraggerB = 0;- if (this.state.compareMode) {+ if (this.props.compareModeActive) {let isBetweenB = draggerDateActualB.isBetween(frontDate, backDate, null, '[]');if (isBetweenB) {draggerPositionB = Math.abs(frontDate.diff(draggerDateActualB, timeScale, true) * gridWidth);@@ -223,7 +213,6 @@ class TimelineAxis extends React.Component {// console.log(draggerPositionB - pixelsToAdd + position - 49)this.setState({draggerTimeState: draggerDateActual.format(),- // redLineTime: draggerDateActual.format(),draggerPosition: draggerPosition - pixelsToAdd + position - 49,draggerVisible: draggerVisible,draggerPositionB: draggerPositionB - pixelsToAdd + position - 49,@@ -235,8 +224,6 @@ class TimelineAxis extends React.Component {gridWidth: gridWidth,numberOfVisibleTiles: numberOfVisibleTiles,moved: false,- timeScaleChange: true,- timeScale: timeScale,dragSentinelChangeNumber: dragSentinelChangeNumber,position: position - pixelsToAdd,midPoint: position,@@ -251,7 +238,7 @@ class TimelineAxis extends React.Component {// changes timeScale statewheelZoom = (e) => {// e.preventDefault(); //TODO: investigate treated as passive event error/warning when on- let arrayIndex = timeScales.indexOf(this.state.timeScale);+ let arrayIndex = timeScales.indexOf(this.props.timeScale);if (e.deltaY > 0) { // wheel zoom outif (arrayIndex < 4) {let nextGreaterTimeScale = timeScales[arrayIndex + 1];@@ -301,7 +288,7 @@ class TimelineAxis extends React.Component {// deltaX = Math.max(-this.state.gridWidth * 3, deltaX);// }let position = this.state.position + deltaX;- let timeScale = this.state.timeScale;+ let timeScale = this.props.timeScale;let gridWidth = this.state.gridWidth;let draggerPosition = this.state.draggerPosition + deltaX;let draggerPositionB = this.state.draggerPositionB + deltaX;@@ -464,8 +451,8 @@ class TimelineAxis extends React.Component {draggerVisible = false;}- let compareModeOn = this.state.compareMode;- if (compareModeOn) {+ // let compareModeOn = this.props.compareModeActive;+ if (this.props.compareModeActive) {let isBetweenB = moment.utc(this.state.draggerTimeStateB).isBetween(frontDate, backDate, null, '[]');if (isBetweenB) {draggerVisibleB = true;@@ -502,6 +489,7 @@ class TimelineAxis extends React.Component {// subtract - integer (negative numbers selects start date in the future)// add - integer (negative numbers selects end date in the past)getDateArray = (subtract, add, timeScale, inputDate) => {+ console.log(subtract, add, timeScale, inputDate)let dayZeroed;let startDate;let endDate;@@ -557,7 +545,6 @@ class TimelineAxis extends React.Component {// move red line to new positionsetLineTime = (e) => {-e.preventDefault();e.stopPropagation();//TODO: handle stop bubbling up to parent wv-timeline-axis to prevent invoking on clicking draggers@@ -574,15 +561,13 @@ class TimelineAxis extends React.Component {// this.handleDragDragger(null, {'deltaX': this.state.leftOffset})// console.log(this.state.leftOffset)// TODO: FIX PARENT OFFSET- let draggerPosition = this.state.draggerSelected ? this.state.leftOffset - 49 : this.state.draggerPosition;- let draggerPositionB = this.state.draggerSelectedB ? this.state.leftOffset - 49 : this.state.draggerPositionB;+ let draggerPosition = this.props.draggerSelected === 'selected' ? this.state.leftOffset - 49 : this.state.draggerPosition;+ let draggerPositionB = this.props.draggerSelected === 'selectedB' ? this.state.leftOffset - 49 : this.state.draggerPositionB;- // console.log(this.state.draggerSelected, this.state.draggerSelectedB)this.setState({draggerPosition: draggerPosition,draggerVisible: true,draggerPositionB: draggerPositionB,- // draggerVisible: true,draggerTimeState: this.state.hoverTime,selectedDate: this.state.hoverTime,moved: false@@ -590,68 +575,45 @@ class TimelineAxis extends React.Component {}}- handleResize = (e) => {- // let axisWidth = Math.floor(window.innerWidth * 0.9);- let axisWidth = this.props.timelineWidth;- let timeScale = this.state.timeScale;- this.updateScale(null, timeScale, axisWidth);- // console.log('resize')- this.setState({- axisWidth: axisWidth- }, function() {- let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();- this.setState({- parentBoundingClientRectLeft: this.props.parentOffset- });- })- };+ // handleResize = (e) => {+ // let axisWidth = this.props.axisWidth;+ // let timeScale = this.props.timeScale;+ // this.updateScale(null, timeScale, axisWidth);+ // };componentDidMount() {console.log(this.props)- //# resize- window.addEventListener("resize", this.handleResize);- // let axisWidth = Number((window.innerWidth * 0.9).toFixed(2));- let axisWidth = this.props.timelineWidth;- let timeScale = this.props.timeScale; // 'day'- let time = moment.utc(this.props.selectedDate).format() //'1941-01-01T12:00:00Z';-- // time = moment.utc(time.toISOString());- // console.log(time)- // let draggerTimeStateBDraggerBTest = '1941-01-03T12:00:00Z';- let draggerTimeStateBDraggerBTest = moment.utc(time).add(7, timeScale).format();+ // window.addEventListener("resize", this.handleResize);+ let axisWidth = this.props.axisWidth;+ let timeScale = this.props.timeScale;+ let time = moment.utc(this.props.selectedDate).format();++ let draggerTimeStateB;+ if (this.props.selectedDateB) {+ draggerTimeStateB = moment.utc(this.props.selectedDateB).format();+ }//# get timeScale specifics based on propslet options = timeScaleOptions[timeScale].timeAxis;let gridWidth = options.gridWidth; // 12//# calculate number of grids viewable based on axisWidth and gridWidth of timeScale- // console.log(axisWidth, Math.floor(axisWidth / gridWidth))- // this.handleResize();let numberOfVisibleTiles = Number((axisWidth / gridWidth).toFixed(8));- // let tilesTillSelectedDAte = Math.floor(numberOfVisibleTiles / 2);- // let draggerPosition = Number(((axisWidth / 2) - 50).toFixed(8));// let draggerPosition = tilesTillSelectedDAte * gridWidth - 49; //# CENTER DRAGGER Alet draggerVisible = true;//# DRAGGER B TESTING POSITION- // let draggerPositionB = draggerPosition + (gridWidth * 2.5);let draggerVisibleB = false;- let compareModeOn = false;- if (compareModeOn) {+ if (this.props.compareModeActive) {draggerVisibleB = true;}- // console.log(numberOfVisibleTiles)//# times 1.5 is cutting it close (down to 1 grid at leading edge - will continue to test)let gridNumber = Math.floor(numberOfVisibleTiles * 1.5);let dragSentinelChangeNumber = gridWidth * (Math.floor(numberOfVisibleTiles * 0.25) + 1);- // console.log(dragSentinelChangeNumber)- //# get midPoint for position based on # of tiles and gridWidth- //# 120 test case - this.getDateArray(60, 60, timeScale, selectedDate);- // let midPointOLD = -((gridWidth * (numberOfVisibleTiles * 1.5)) / 2) + (numberOfVisibleTiles / 2 * gridWidth);- // let midPoint = +(-(+((gridWidth * +(numberOfVisibleTiles * 1.5).toFixed(10)) / 2).toFixed(10)) + +(+(numberOfVisibleTiles / 2).toFixed(10) * gridWidth).toFixed(10)).toFixed(10); //# CAN'T FLOOR numberOfVisibleTiles / 2+ //# get midPoint for position based on # of tiles and gridWidthlet midPoint = -((gridWidth * gridNumber) / 2) + (numberOfVisibleTiles / 2 * gridWidth);let draggerTime = moment.utc(time);@@ -675,18 +637,11 @@ class TimelineAxis extends React.Component {let frontDate = moment.utc(current.dates[0].rawDate);let draggerPosition = Math.abs(frontDate.diff(draggerTime, timeScale, true) * gridWidth);- let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateBDraggerBTest), timeScale, true) * gridWidth);- // this.addLine(initDateStart);- // console.log(numberOfVisibleTiles, dragSentinelChangeNumber)-- // console.log(draggerPosition, pixelsToAdd, midPoint)- // console.log(this.getDraggerPosition(draggerTimeStateBDraggerBTest, current.dates[0].rawDate, 'day', gridWidth))+ // let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateBDraggerBTest), timeScale, true) * gridWidth);+ let draggerPositionB = Math.abs(frontDate.diff(moment.utc(draggerTimeStateB), timeScale, true) * gridWidth);- console.log(current.dates[Math.floor(gridNumber/2)].rawDate)this.setState({- compareMode: false,- timeScaleSelectValue: timeScale,deque: new Deque(current.dates),// draggerPosition: draggerPosition + pixelsToAdd,draggerPosition: draggerPosition + midPoint - 49,@@ -695,37 +650,22 @@ class TimelineAxis extends React.Component {draggerVisibleB: draggerVisibleB,numberOfVisibleTiles: numberOfVisibleTiles,dragSentinelChangeNumber: dragSentinelChangeNumber,- axisWidth: axisWidth,- timeScale: timeScale,selectedDate: time,- // midTileDate: selectedDate.format(),currentDateRange: current.dates,gridWidth: gridWidth,draggerTimeState: time,- draggerTimeStateB: draggerTimeStateBDraggerBTest,+ // draggerTimeStateB: draggerTimeStateBDraggerBTest,+ draggerTimeStateB: draggerTimeStateB,hoverTime: time,currentTransformX: 0,midPoint: midPoint,position: midPoint,- }, function() {- // let setPosition = this.getPositionFromDate(selectedDate);- // console.log(setPosition)- let parentBoundingClientRect = document.querySelector('#wv-timeline-axis').getBoundingClientRect();- this.setState({- parentBoundingClientRectLeft: this.props.parentOffset- });- });+ })}- // 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;- // }+ shouldComponentUpdate(nextProps, nextState) {+ return true;+ }/*** check if newDraggerDate will be within acceptable visible axis width@@ -739,7 +679,7 @@ class TimelineAxis extends React.Component {let draggerTimeState = this.state.draggerTimeState;let draggerPosition = this.state.draggerPosition;- let timeScale = this.state.timeScale;+ let timeScale = this.props.timeScale;let gridWidth = this.state.gridWidth;let selectedDateMoment = moment.utc(selectedDate);@@ -748,7 +688,7 @@ class TimelineAxis extends React.Component {let newDraggerDiff = selectedDateMoment.diff(draggerDateMoment, timeScale, true);let newDraggerPosition = draggerPosition + (newDraggerDiff * gridWidth);let newDateInThePast = selectedDateMoment < draggerDateMoment;- let newDraggerWithinRangeCheck = newDraggerPosition <= (this.state.axisWidth - 80) && newDraggerPosition >= -26;+ let newDraggerWithinRangeCheck = newDraggerPosition <= (this.props.axisWidth - 80) && newDraggerPosition >= -26;return {withinRange: newDraggerWithinRangeCheck,@@ -759,8 +699,7 @@ class TimelineAxis extends React.Component {componentDidUpdate(prevProps, prevState) {// console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)- // console.log(prevProps.dateFormatted, this.props.dateFormatted)-// console.log(this.props.timeScale)+if (this.props.inputChange === true) {this.props.resetInput();// check if newDraggerDate will be within acceptable visible axis width@@ -769,19 +708,20 @@ class TimelineAxis extends React.Component {this.setDraggerToTime(this.props.selectedDate);} else {let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;- this.updateScale(this.props.selectedDate, this.state.timeScale, null, leftOffsetFixedCoeff);+ this.updateScale(this.props.selectedDate, this.props.timeScale, null, leftOffsetFixedCoeff);}}- if (this.state.timeScale !== prevState.timeScale) {- this.updateScale(null, this.state.timeScale);- }- if (this.props.timeScale !== this.state.timeScale) {+ if (this.props.timeScale !== prevProps.timeScale) {this.updateScale(null, this.props.timeScale);}- if (this.props.timelineWidth !== prevProps.timelineWidth) {- this.handleResize();+ if (this.props.axisWidth !== prevProps.axisWidth) {+ this.updateScale(null, this.props.timeScale, this.props.axisWidth);+ }++ if (this.props.compareModeActive !== prevProps.compareModeActive) {+ this.setDraggerToTime(this.props.selectedDateB, true)}// # CHANGED CONDITIONAL FROM "&&" TO "||" TO DEBUG LEFT/RIGHT ARROW UPDATE ISSUE@@ -805,7 +745,7 @@ class TimelineAxis extends React.Component {this.setDraggerToTime(this.props.selectedDate);} else {let leftOffsetFixedCoeff = newDraggerDate.newDraggerDiff > 5 ? 0.5 : newDraggerDate.newDateInThePast ? 0.25 : 0.75;- this.updateScale(this.props.selectedDate, this.state.timeScale, null, leftOffsetFixedCoeff);+ this.updateScale(this.props.selectedDate, this.props.timeScale, null, leftOffsetFixedCoeff);}}@@ -813,10 +753,11 @@ class TimelineAxis extends React.Component {}// move draggerTimeState to inputTime- setDraggerToTime = (inputTime) => {+ setDraggerToTime = (inputTime, draggerB) => {let frontDate = moment.utc(this.state.deque.peekFront().rawDate);let backDate = moment.utc(this.state.deque.peekBack().rawDate);- let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');+ let draggerTime = draggerB ? this.state.draggerTimeStateB : this.state.draggerTimeState;+ let draggerTimeState = moment.utc(draggerTime, 'YYYY-MM-DDTHH:mm:ss.SSSZ');let draggerTimeStateAdded = moment.utc(inputTime);let isBetween = draggerTimeStateAdded.isBetween(frontDate, backDate, null, '[]');@@ -826,24 +767,43 @@ class TimelineAxis extends React.Component {draggerVisible = true;}let gridWidth = this.state.gridWidth;- let timeScale = this.state.timeScale;+ let timeScale = this.props.timeScale;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 isVisible = this.state.draggerVisible;+ let isVisible = draggerB ? this.state.draggerVisibleB : this.state.draggerVisible;if (isVisible) {- newDraggerPosition = this.state.draggerPosition + pixelsToAddBasedOnFrontDate;+ let draggerPosition = draggerB ? this.state.draggerPositionB : this.state.draggerPosition;+ newDraggerPosition = draggerPosition + pixelsToAddBasedOnFrontDate;} else {newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - 49 + this.state.currentTransformX;}- this.setState({- draggerPosition: newDraggerPosition,- draggerVisible: draggerVisible,- draggerTimeState: draggerTimeStateAdded.format(),- selectedDate: draggerTimeStateAdded.format(),- })+ console.log(this.state.draggerTimeStateB, this.state.draggerPositionB, pixelsToAddBasedOnFrontDate)+ console.log(newDraggerPosition, draggerVisible, draggerTimeStateAdded.format())++ if (draggerB) {+ this.setState({+ draggerPositionB: newDraggerPosition,+ draggerVisibleB: draggerVisible,+ draggerTimeStateB: draggerTimeStateAdded.format(),+ selectedDate: draggerTimeStateAdded.format(),+ })+ } else {+ this.setState({+ draggerPosition: newDraggerPosition,+ draggerVisible: draggerVisible,+ draggerTimeState: draggerTimeStateAdded.format(),+ selectedDate: draggerTimeStateAdded.format(),+ })+ }+ // this.setState({+ // draggerPosition: newDraggerPosition,+ // draggerVisible: draggerVisible,+ // draggerTimeState: draggerTimeStateAdded.format(),+ // selectedDate: draggerTimeStateAdded.format(),+ // })// this.props.incrementDate(timeScaleSelected, increment));}@@ -871,7 +831,7 @@ class TimelineAxis extends React.Component {//! IE11 undefined parentElement issue fixthis.setState({hoverTime: date,- leftOffset: leftOffset - this.state.parentBoundingClientRectLeft // relative location from parent bounding box for BLUE LINE+ leftOffset: leftOffset - this.props.parentOffset // relative location from parent bounding box for BLUE LINE});})}@@ -888,8 +848,8 @@ handleDragDragger = (draggerName, e, d) => {// var deltaX = d.deltaX || e.movementX; //# NOT THE SAMEvar deltaX = d.deltaX;let gridWidth = this.state.gridWidth;- let timeScale = this.state.timeScale;- let axisWidth = this.state.axisWidth;+ let timeScale = this.props.timeScale;+ let axisWidth = this.props.axisWidth;let dragSentinelChangeNumber = this.state.dragSentinelChangeNumber;let dragSentinelCount = this.state.dragSentinelCount;@@ -900,21 +860,25 @@ handleDragDragger = (draggerName, e, d) => {time = this.state.draggerTimeState;} else { // draggerName === 'B'draggerPosition = this.state.draggerPositionB + deltaX;- time = this.state.redLineTimeB;+ time = this.state.draggerTimeStateB;}// console.log(draggerPosition, time)// update redLineTime based on deltaX from state redLineTime// TODO: test consistency throught timescales, currently seems off 0.5 on ocassionlet draggerTime = moment.utc(time);- let draggerTimeZero = draggerTime.clone().startOf(timeScale);- let draggerTimeNextZero = draggerTimeZero.clone().add(1, timeScale);-let draggerTimeValue = draggerTime.valueOf();- let draggerTimeZeroValue = draggerTimeZero.valueOf();- let draggerTimeNextZeroValue = draggerTimeNextZero.valueOf();+ // only need to calculate difference in time unit for varying timescales - month and year+ let diffZeroValues = timeScaleOptions[timeScale].timeAxis.scaleMs;+ if (!diffZeroValues) {+ let draggerTimeZero = draggerTime.clone().startOf(timeScale);+ let draggerTimeNextZero = draggerTimeZero.clone().add(1, timeScale);- let diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;+ let draggerTimeZeroValue = draggerTimeZero.valueOf();+ let draggerTimeNextZeroValue = draggerTimeNextZero.valueOf();++ diffZeroValues = draggerTimeNextZeroValue - draggerTimeZeroValue;+ }let diffFactor = diffZeroValues / gridWidth;let newDraggerTime = moment.utc(draggerTimeValue + (diffFactor * deltaX)).format();@@ -1001,23 +965,17 @@ handleDragDragger = (draggerName, e, d) => {}} else { // handle drag within axis viewif (draggerName === 'A') {- console.log(newDraggerTime)this.setState({draggerPosition: draggerPosition,- // redLineTime: newDraggerTime,draggerTimeState: newDraggerTime,moved: true,- draggerSelected: true,- draggerSelectedB: false,}, this.props.updateDate(newDraggerTime));} else {this.setState({draggerPositionB: draggerPosition,- redLineTimeB: newDraggerTime,+ draggerTimeStateB: newDraggerTime,moved: true,- draggerSelected: false,- draggerSelectedB: true,- });+ }, this.props.updateDate(newDraggerTime, 'selectedB'));}}})@@ -1025,11 +983,10 @@ handleDragDragger = (draggerName, e, d) => {// select draggerselectDragger = (draggerName) => {- this.setState((prev) => ({- draggerSelected: draggerName === 'A' ? true : false,- draggerSelectedB: draggerName === 'B' ? true : false- })- )+ let selectionStr = draggerName === 'A' ? 'selected' : 'selectedB'+ if (selectionStr !== this.props.draggerSelected) {+ this.props.onChangeSelectedDragger(selectionStr)+ }}showHoverOn = () => {@@ -1042,19 +999,6 @@ handleDragDragger = (draggerName, e, d) => {this.setState({ showHoverLine: false });}- toggleCompareMode = () => {- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);- let backDate = moment.utc(this.state.deque.peekBack().rawDate);- let draggerTimeStateB = moment.utc(this.state.draggerTimeStateB, 'YYYY-MM-DDTHH:mm:ss.SSSZ');- let isBetween = draggerTimeStateB.isBetween(frontDate, backDate, null, '[]');-- let draggerVisibleB = isBetween ? true : false;- this.setState({- compareMode: !this.state.compareMode,- draggerVisibleB: draggerVisibleB- });- }-toggleShowDraggerTime = (toggleBoolean) => {this.setState({showDraggerTime: toggleBoolean,@@ -1072,26 +1016,19 @@ handleDragDragger = (draggerName, e, d) => {<React.Fragment><div id="wv-timeline-axis"// ref={this.timelineRef} //# REF- style={{width: `${this.state.axisWidth}px`}}- // onMouseMove={(e) => this.getLeftOffset(e, e.clientX)}- // onMouseDown={() => this.setLineClick()}+ style={{width: `${this.props.axisWidth}px`}}onMouseUp={(e) => this.setLineTime(e)}onWheel={(e) => this.wheelZoom(e)}- // onMouseOver={() => this.setState({showHoverLine: true})}- // onMouseLeave={() => this.setState({showHoverLine: false})}onMouseOver={this.showHoverOn}onMouseLeave={this.showHoverOff}>{this.state.currentDateRange ?<svg className="inner"id="timeline-footer-svg"- width={this.state.axisWidth}+ width={this.props.axisWidth}height={70}- viewBox={`0 0 ${this.state.axisWidth} 75`}+ viewBox={`0 0 ${this.props.axisWidth} 75`}preserveAspectRatio="none">- {/* <clipPath id="myClip">- <rect width="884" height="90" x={-this.state.position}/>- </clipPath> */}<defs><clipPath id="textDisplay"><rect width="200" height="70" />@@ -1102,15 +1039,12 @@ handleDragDragger = (draggerName, e, d) => {axis="x"onDrag={this.handleDrag.bind(this)}position={{ x: this.state.position, y: 0 }}- // onStart={this.handleStartDrag.bind(this)}onStop={this.handleStopDrag.bind(this)}->- {/* <g clipPath="url(#myClip)"> */}<g><GridRangeshowHoverLine={this.state.showHoverLine}- timeScale={this.state.timeScale}+ timeScale={this.props.timeScale}displayDate={this.displayDate}gridWidth={this.state.gridWidth}dateArray={this.state.currentDateRange}@@ -1121,51 +1055,47 @@ handleDragDragger = (draggerName, e, d) => {toggleShowDraggerTime={this.toggleShowDraggerTime}handleDragDragger={this.handleDragDragger}selectDragger={this.selectDragger}- compareOn={this.state.compareMode}+ compareModeActive={this.props.compareModeActive}draggerName='A'draggerPosition={this.state.draggerPosition}draggerVisible={this.state.draggerVisible}transformX={this.state.currentTransformX}- draggerSelected={this.state.draggerSelected}+ draggerSelected={this.props.draggerSelected === 'selected'}parentPosition={this.state.position} /><DraggertoggleShowDraggerTime={this.toggleShowDraggerTime}handleDragDragger={this.handleDragDragger}selectDragger={this.selectDragger}- compareOn={this.state.compareMode}+ compareModeActive={this.props.compareModeActive}draggerName='B'draggerPosition={this.state.draggerPositionB}- draggerVisible={this.state.compareMode ? this.state.draggerVisibleB : false}+ draggerVisible={this.props.compareModeActive ? this.state.draggerVisibleB : false}transformX={this.state.currentTransformX}- draggerSelected={this.state.draggerSelectedB}+ draggerSelected={this.props.draggerSelected === 'selectedB'}parentPosition={this.state.position} /></svg>: null }- {/* <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)`, display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none'}}>{this.state.showDraggerTime && this.state.draggerTimeState ? this.state.draggerTimeState : null}</div>-- {/* 404 is #timeline-header width and 10 is margin - parent offset issue most likely */}- <div className="dateToolTip" style={{transform: `translate(${this.state.leftOffset - 52}px, -100px)`, display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none'}}>{!this.state.showDraggerTime && this.state.hoverTime ? this.state.hoverTime : null}</div>- </div>- {/* <div style={{ display: 'flex', marginTop: 10 }}>- <div className="dateTempHolderTextBlock" style={{borderColor: 'blue'}}>- <h4 style={{marginTop: 5, marginBottom: 5}}>HOVER TIME</h4>- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.hoverTime ? this.state.hoverTime : null}</p>- </div>- <div className="dateTempHolderTextBlock" style={{borderColor: 'red'}}>- <h4 style={{marginTop: 5, marginBottom: 5}}>DRAGGER A TIME</h4>- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.draggerTimeState ? this.state.draggerTimeState : null}</p>- </div>- <div className="dateTempHolderTextBlock" style={{borderColor: 'orange'}}>- <h4 style={{marginTop: 5, marginBottom: 5}}>DRAGGER B TIME</h4>- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.draggerTimeStateB ? this.state.draggerTimeStateB : null}</p>+ {/* DRAGGER TIME */}+ <div+ className="dateToolTip"+ style={{+ transform: `translate(${this.props.draggerSelected === 'selected' ? this.state.draggerPosition - 5 : this.state.draggerPositionB - 5 }px, -100px)`,+ display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none'+ }}>+ {this.state.showDraggerTime && this.state.draggerTimeState ? this.props.draggerSelected === 'selected' ? this.state.draggerTimeState : this.state.draggerTimeStateB : null}+ </div>++ {/* HOVER TIME */}+ <div+ className="dateToolTip"+ style={{+ transform: `translate(${this.state.leftOffset - 52}px, -100px)`,+ display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none'+ }}>+ {!this.state.showDraggerTime && this.state.hoverTime ? this.state.hoverTime : null}</div>- <div className="dateTempHolderTextBlock" style={{borderColor: 'black'}}>- <h4 style={{marginTop: 5, marginBottom: 5}}>TIMESCALE ZOOM</h4>- <p style={{marginTop: 5, marginBottom: 0, fontSize: 20}}>{this.state.timeScale ? this.state.timeScale.toUpperCase() : null}</p>- </div>- </div> */}+ </div></React.Fragment>);}diff --git a/web/js/components/timeline/timeline-axis/timeline-dragger.js b/web/js/components/timeline/timeline-axis/timeline-dragger.jsindex 9008a13e0..8aa912ffc 100644--- a/web/js/components/timeline/timeline-axis/timeline-dragger.js+++ b/web/js/components/timeline/timeline-axis/timeline-dragger.js@@ -4,7 +4,7 @@ import Draggable from 'react-draggable';class Dragger extends PureComponent {render() {// console.log(this.props)- let { transformX, draggerPosition, draggerName, handleDragDragger, toggleShowDraggerTime, selectDragger, compareOn } = this.props;+ let { transformX, draggerPosition, draggerName, handleDragDragger, toggleShowDraggerTime, selectDragger, compareModeActive } = this.props;return (<Draggableaxis='x'@@ -17,13 +17,25 @@ class Dragger extends PureComponent {// this.props.onStop(this.props.id, this.state.position);// }}>- <g style={{cursor: 'pointer', display: this.props.draggerVisible ? 'flex' : 'none'}} className='gridShell dragger' transform={`translate(${transformX}, 0)`}>- {/* <polygon fill='#ccc' stroke={this.props.draggerSelected ? 'yellow' : '#515151'} strokeWidth='2px' points='50,25, 90,90, 10,90'></polygon> */}- <polygon fill='#ccc' stroke='#515151' strokeWidth='2px' points='50,25, 90,90, 10,90'></polygon>- {compareOn ?- <text fontSize='30px' fontWeight='700' x='0' y='65' fill='#515151' transform='translate(39, 10)' textRendering='optimizeLegibility' clipPath='url(#textDisplay)'>{draggerName}</text>- :- <React.Fragment>+ <g+ style={{ cursor: 'pointer', display: this.props.draggerVisible ? 'flex' : 'none' }}+ className='gridShell dragger' transform={`translate(${transformX}, 0)`}+ >+ <polygon fill='#ccc' stroke={this.props.draggerSelected ? 'yellow' : '#515151'} strokeWidth='2px' points='50,25, 90,90, 10,90'></polygon>+ {/* <polygon fill='#ccc' stroke='#515151' strokeWidth='2px' points='50,25, 90,90, 10,90'></polygon> */}+ {compareModeActive+ ? <text+ fontSize='30px'+ fontWeight='700'+ x='0'+ y='65'+ fill='#515151'+ transform='translate(39, 10)'+ textRendering='optimizeLegibility'+ clipPath='url(#textDisplay)'>+ {draggerName}+ </text>+ : <React.Fragment><rect pointerEvents="none" fill='#515151' width='4' height='20' x='41' y='55'></rect><rect pointerEvents="none" fill='#515151' width='4' height='20' x='48' y='55'></rect><rect pointerEvents="none" fill='#515151' width='4' height='20' x='55' y='55'></rect>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.jsnew file mode 100644index 000000000..174db0506--- /dev/null+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change-controls.js@@ -0,0 +1,59 @@+import React, { PureComponent } from 'react';+import PropTypes from 'prop-types';+import AxisTimeScaleChangeTooltip from './axis-timescale-change-tooltip';++/*+ * Up/down arrows for changing timeScale, also wrapper for tooltip+ *+ * @class AxisTimeScaleChangeControls+ * @extends React.Component+ */+class AxisTimeScaleChangeControls extends PureComponent {+ onClickUp = () => {+ this.props.incrementTimeScale();+ }++ onClickDown = () => {+ this.props.decrementTimeScale();+ }+ render() {+ return (+ <div className="zoom-level-change-arrows">+ <div+ onClick={this.onClickUp}+ className="date-arrows date-arrow-up"+ >+ <svg width="25" height="8">+ <path d="M 12.5,0 25,8 0,8 z" className="uparrow" />+ </svg>+ </div>+ <AxisTimeScaleChangeTooltip+ timeScale={this.props.timeScale}+ toolTipHovered={this.props.toolTipHovered}+ changeTimeScale={this.props.changeTimeScale}+ hasSubdailyLayers={this.props.hasSubdailyLayers}+ />+ <div+ onClick={this.onClickDown}+ className="date-arrows date-arrow-down"+ >+ <svg width="25" height="8">+ <path d="M 12.5,0 25,8 0,8 z" className="downarrow" />+ </svg>+ </div>+ </div>++ );+ }+}++AxisTimeScaleChangeControls.propTypes = {+ timeScale: PropTypes.string,+ changeTimeScale: PropTypes.func,+ incrementTimeScale: PropTypes.func,+ decrementTimeScale: PropTypes.func,+ toolTipHovered: PropTypes.bool,+ hasSubdailyLayers: PropTypes.bool+};++export default AxisTimeScaleChangeControls;diff --git a/web/js/components/timeline/timeline-controls/axis-zoom-change-tooltip.js b/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.jssimilarity index 64%rename from web/js/components/timeline/timeline-controls/axis-zoom-change-tooltip.jsrename to web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.jsindex d8c4fa91b..0d7ee59ec 100644--- a/web/js/components/timeline/timeline-controls/axis-zoom-change-tooltip.js+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change-tooltip.js@@ -1,4 +1,5 @@import React, { PureComponent } from 'react';+import PropTypes from 'prop-types';const timeUnitAbbreviations = {year: 'year',@@ -8,49 +9,46 @@ const timeUnitAbbreviations = {minute: 'min'};-class AxisZoomChangeTooltip extends PureComponent {-- handleClickZoom = (zoomSelected) => {- this.props.changeZoomLevel(zoomSelected);- }-+/*+ * Tooltip appears on hover with clickable timeScales based on subdaily availabilty+ *+ * @class AxisTimeScaleChangeTooltip+ * @extends React.Component+ */+class AxisTimeScaleChangeTooltip extends PureComponent {render() {return (<React.Fragment>- <div id="zoom-btn-container-axis"- >- {/* timeScale display */}+ <div id="zoom-btn-container-axis"><spanid="current-zoom"className={'zoom-btn zoom-level-display-text'}>- {timeUnitAbbreviations[this.props.zoomLevel]}+ {timeUnitAbbreviations[this.props.timeScale]}</span>-- {/* hover timeScale unit dialog / entry point to Custom selector */}<div className="wv-zoom-tooltip"- style={{ display: this.props.toolTipHovered ? 'block' : 'none' }}+ style={{ display: this.props.toolTipHovered ? 'block' : 'none' }}><div id="timeline-zoom" className="timeline-zoom"><label style={{ textDecoration: 'underline', paddingBottom: '4px', color: '#fff' }}>TIMESCALE</label><spanid="zoom-years"className="zoom-btn zoom-btn-inactive zoom-years"- onClick={() => this.handleClickZoom('year')}+ onClick={() => this.props.changeTimeScale('year')}>YEAR</span><spanid="zoom-months"className="zoom-btn zoom-btn-inactive zoom-months"- onClick={() => this.handleClickZoom('month')}+ onClick={() => this.props.changeTimeScale('month')}>MONTH</span><spanid="zoom-days"className="zoom-btn zoom-btn-inactive zoom-days"- onClick={() => this.handleClickZoom('day')}+ onClick={() => this.props.changeTimeScale('day')}>DAY</span>@@ -58,7 +56,7 @@ class AxisZoomChangeTooltip extends PureComponent {id="zoom-hours"className="zoom-btn zoom-btn-inactive zoom-hours"style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}- onClick={() => this.handleClickZoom('hour')}+ onClick={() => this.props.changeTimeScale('hour')}>HOUR</span>@@ -66,7 +64,7 @@ class AxisZoomChangeTooltip extends PureComponent {id="zoom-minutes"className="zoom-btn zoom-btn-inactive zoom-minutes"style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}- onClick={() => this.handleClickZoom('minute')}+ onClick={() => this.props.changeTimeScale('minute')}>MINUTE</span>@@ -78,4 +76,10 @@ class AxisZoomChangeTooltip extends PureComponent {}}-export default AxisZoomChangeTooltip;+AxisTimeScaleChangeTooltip.propTypes = {+ timeScale: PropTypes.string,+ changeTimeScale: PropTypes.func,+ hasSubdailyLayers: PropTypes.bool+};++export default AxisTimeScaleChangeTooltip;diff --git a/web/js/components/timeline/timeline-controls/axis-timescale-change.js b/web/js/components/timeline/timeline-controls/axis-timescale-change.jsnew file mode 100644index 000000000..3690546ac--- /dev/null+++ b/web/js/components/timeline/timeline-controls/axis-timescale-change.js@@ -0,0 +1,114 @@+import React from 'react';+import PropTypes from 'prop-types';+import AxisTimeScaleChangeControls from './axis-timescale-change-controls';++/*+ * Parent element for timeScale change controls and tooltip+ * on the right side of the timeline+ *+ * @class AxisTimeScaleChange+ * @extends React.Component+ */+class AxisTimeScaleChange extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ toolTipHovered: false,+ timeScales: [ 'day', 'month', 'year' ]+ };+ }++ // Toggle timeScale select tooltip+ toggleTooltipHover = (isHovered) => {+ // toggle visibility of map scales+ let imperialMapScale = document.querySelectorAll('.wv-map-scale-imperial');+ let metricMapScale = document.querySelectorAll('.wv-map-scale-metric');+ if (isHovered) {+ for (let el of imperialMapScale) {+ el.style.display = 'none';+ }+ for (let el of metricMapScale) {+ el.style.display = 'none';+ }+ } else {+ for (let el of imperialMapScale) {+ el.style.display = 'block';+ }+ for (let el of metricMapScale) {+ el.style.display = 'block';+ }+ }+ this.setState({+ toolTipHovered: isHovered+ })+ }++ // get available time scales based on if subdaily or not+ getTimeScales = (hasSubdailyLayers) => {+ if (hasSubdailyLayers) {+ return [ 'minute', 'hour', 'day', 'month', 'year' ];+ } else {+ return [ 'day', 'month', 'year' ];+ }+ }++ incrementTimeScale = () => {+ let timeScales = this.state.timeScales;+ let arrayIndex = timeScales.indexOf(this.props.timeScale);+ if (arrayIndex < timeScales.length - 1) {+ let nextGreaterTimeScale = timeScales[arrayIndex + 1];+ this.props.changeTimescale(nextGreaterTimeScale);+ }+ }++ decrementTimeScale = () => {+ let timeScales = this.state.timeScales;+ let arrayIndex = timeScales.indexOf(this.props.timeScale);+ if (arrayIndex > 0) {+ let nextSmallerTimeScale = timeScales[arrayIndex - 1];+ this.props.changeTimescale(nextSmallerTimeScale);+ }+ }++ componentDidMount() {+ this.setState({+ timeScales: this.getTimeScales(this.props.hasSubdailyLayers)+ })+ }++ componentDidUpdate(prevProps) {+ if(this.props.hasSubdailyLayers !== prevProps.hasSubdailyLayers) {+ this.setState({+ timeScales: this.getTimeScales(this.props.hasSubdailyLayers)+ })+ }+ }++ render() {+ return (+ this.props.timeScale ?+ <div+ onMouseEnter={() => this.toggleTooltipHover(true)}+ onMouseLeave={() => this.toggleTooltipHover(false)}>+ <AxisTimeScaleChangeControls+ timeScale={this.props.timeScale}+ hasSubdailyLayers={this.props.hasSubdailyLayers}+ toolTipHovered={this.state.toolTipHovered}+ changeTimeScale={this.props.changeTimescale}+ incrementTimeScale={this.incrementTimeScale}+ decrementTimeScale={this.decrementTimeScale}+ />+ </div>+ :+ <div></div>+ );+ }+}++AxisTimeScaleChange.propTypes = {+ timeScale: PropTypes.string,+ changeTimescale: PropTypes.func,+ hasSubdailyLayers: PropTypes.bool+};++export default AxisTimeScaleChange;diff --git a/web/js/components/timeline/timeline-controls/axis-zoom-change-controls.js b/web/js/components/timeline/timeline-controls/axis-zoom-change-controls.jsdeleted file mode 100644index 1e777eb2a..000000000--- a/web/js/components/timeline/timeline-controls/axis-zoom-change-controls.js+++ /dev/null@@ -1,71 +0,0 @@-import React, { PureComponent } from 'react';-import PropTypes from 'prop-types';-// import util from '../../util/util';-import AxisZoomChangeTooltip from './axis-zoom-change-tooltip';--/*- * A react component, is a draggable svg- * group. It is a parent component that- * rerenders when child elements are dragged- *- * @class TimelineRangeSelector- */-class AxisZoomChangeControls extends PureComponent {- onClickUp = () => {- this.props.incrementZoomLevel();- }-- onClickDown = () => {- this.props.decrementZoomLevel();- }- render() {- return (- <div className="zoom-level-change-arrows">- <div- onClick={this.onClickUp}- className="date-arrows date-arrow-up"- >- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" className="uparrow" />- </svg>- </div>- <AxisZoomChangeTooltip- zoomLevel={this.props.zoomLevel}- toolTipHovered={this.props.toolTipHovered}- changeZoomLevel={this.props.changeZoomLevel}- hasSubdailyLayers={this.props.hasSubdailyLayers}- />- <div- onClick={this.onClickDown}- className="date-arrows date-arrow-down"- >- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" className="downarrow" />- </svg>- </div>- </div>-- );- }-}--// AxisZoomChangeControls.propTypes = {-// value: PropTypes.node,-// focused: PropTypes.bool,-// tabIndex: PropTypes.number,-// step: PropTypes.number,-// type: PropTypes.string,-// updateDate: PropTypes.func,-// date: PropTypes.object,-// minDate: PropTypes.object,-// maxDate: PropTypes.object,-// maxZoom: PropTypes.number,-// blur: PropTypes.func,-// setFocusedTab: PropTypes.func,-// changeTab: PropTypes.func,-// height: PropTypes.string,-// inputId: PropTypes.string,-// fontSize: PropTypes.number-// };--export default AxisZoomChangeControls;diff --git a/web/js/components/timeline/timeline-controls/axis-zoom-change.js b/web/js/components/timeline/timeline-controls/axis-zoom-change.jsdeleted file mode 100644index 3e8fb7ea8..000000000--- a/web/js/components/timeline/timeline-controls/axis-zoom-change.js+++ /dev/null@@ -1,155 +0,0 @@-import React from 'react';-import PropTypes from 'prop-types';-import AxisZoomChangeControls from './axis-zoom-change-controls';-import AxisZoomChangeTooltip from './axis-zoom-change-tooltip';--/*- * A react component, Builds a rather specific- * interactive widget- *- * @class AnimationWidget- * @extends React.Component- */-class AxisZoomChange extends React.Component {- constructor(props) {- super(props);- this.state = {- zoomLevel: '',- toolTipHovered: false,- hasSubdailyLayers: '',- timeScales: ''- };- }-- // Toggle zoom select tooltip- toggleTooltipHover = (isHovered) => {- // toggle visibility of map scales- let imperialMapScale = document.querySelectorAll('.wv-map-scale-imperial');- let metricMapScale = document.querySelectorAll('.wv-map-scale-metric');- if (isHovered) {- for (let el of imperialMapScale) {- el.style.display = 'none';- }- for (let el of metricMapScale) {- el.style.display = 'none';- }- } else {- for (let el of imperialMapScale) {- el.style.display = 'block';- }- for (let el of metricMapScale) {- el.style.display = 'block';- }- }- this.setState({- toolTipHovered: isHovered- })- }-- // get available time scales based on if subdaily or not- getTimeScales = (hasSubdailyLayers) => {- if (hasSubdailyLayers) {- return [ 'minute', 'hour', 'day', 'month', 'year' ];- } else {- return [ 'day', 'month', 'year' ];- }- }-- // changeInterval = (value) => {- // this.setState({- // intervalValue: value- // })- // }-- changeZoomLevel = (timeScale) => {- // this.setState({- // zoomLevel: value- // })- // if (timeScale !== this.state.zoomLevel) {- this.props.changeTimescale(timeScale);- // }- }-- incrementZoomLevel = () => {- let timeScales = this.state.timeScales;- let arrayIndex = timeScales.indexOf(this.state.zoomLevel);- console.log(timeScales, arrayIndex)- if (arrayIndex < timeScales.length - 1) {- let nextGreaterTimeScale = timeScales[arrayIndex + 1];- this.changeZoomLevel(nextGreaterTimeScale);- }- }-- decrementZoomLevel = () => {- let timeScales = this.state.timeScales;- let arrayIndex = timeScales.indexOf(this.state.zoomLevel);- console.log(timeScales, arrayIndex)- if (arrayIndex > 0) {- let nextSmallerTimeScale = timeScales[arrayIndex - 1];- this.changeZoomLevel(nextSmallerTimeScale);- }- }-- // reset = () => {- // this.setState({- // intervalValue: 1,- // zoomLevel: this.props.customIntervalZoomLevel- // })- // }-- // setIntervalChangeUnit = () => {- // this.props.setIntervalChangeUnit(this.state.intervalValue, this.state.zoomLevel);- // }-- componentDidMount() {- this.setState({- zoomLevel: this.props.zoomLevel,- hasSubdailyLayers: this.props.hasSubdailyLayers,- timeScales: this.getTimeScales(this.props.hasSubdailyLayers)- })- }-- componentDidUpdate(prevProps) {- if(this.props.zoomLevel !== prevProps.zoomLevel) {- this.setState({- zoomLevel: this.props.zoomLevel- })- }- if(this.props.hasSubdailyLayers !== prevProps.hasSubdailyLayers) {- this.setState({- hasSubdailyLayers: this.props.hasSubdailyLayers,- timeScales: this.getTimeScales(this.props.hasSubdailyLayers)- })- }- }-- render() {- return (- this.state.zoomLevel ?- <div- onMouseEnter={() => this.toggleTooltipHover(true)}- onMouseLeave={() => this.toggleTooltipHover(false)}>- <AxisZoomChangeControls- zoomLevel={this.state.zoomLevel}- toolTipHovered={this.state.toolTipHovered}- changeZoomLevel={this.changeZoomLevel}- hasSubdailyLayers={this.state.hasSubdailyLayers}- incrementZoomLevel={this.incrementZoomLevel}- decrementZoomLevel={this.decrementZoomLevel}- />-- </div>- :- <div></div>- );- }-}--// AxisZoomChange.propTypes = {-// setInterval: PropTypes.func,-// toggleCustomIntervalModal: PropTypes.func,-// customIntervalValue: PropTypes.number,-// customIntervalZoomLevel: PropTypes.string-// };--export default AxisZoomChange;diff --git a/web/js/components/timeline/timeline-controls/date-change-controls.js b/web/js/components/timeline/timeline-controls/date-change-controls.jsdeleted file mode 100644index eb0477be5..000000000--- a/web/js/components/timeline/timeline-controls/date-change-controls.js+++ /dev/null@@ -1,81 +0,0 @@-import React from 'react';-import PropTypes from 'prop-types';--import DateSelector from '../../date-selector/date-selector';-import DateZoomChange from './date-zoom-change';-import DateChangeArrows from './date-change-arrows';--class DateChangeControls extends React.Component {- constructor(props) {- super(props);- this.state = {- };- }-- // 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', this.props.selectedDate)- }-- 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 mockDateSelectorProps = {- date: new Date(this.props.selectedDate),- fontSize: null,- height: '30',- id: 'main-TEST',- idSuffix: 'date-selector-main',- maxDate: new Date('2020-01-01T00:00:00.000'),- maxZoom: 5, // 3 === DAY, 5 TRIGGERS CONDITIONAL TO SHOW SUBDAILY- 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>- {/* <DateSelector- {...mockDateSelectorProps}- /> */}- {/* <DateZoomChange />- <DateChangeArrows /> */}-- {/* animation button */}- {/* <div- className="button-action-group animate-button"- id="animate-button"- title="Set up animation"- >- <i id="wv-animate" className="fas fa-video wv-animate" />- </div> */}- </div>- );- }-}-// Timeline.defaultProps = {-// };-// Timeline.propTypes = {-// width: PropTypes.number,-// drawContainers: PropTypes.func,-// changeDate: PropTypes.func,-// selectedDate: PropTypes.instanceOf(Date)-// };--export default DateChangeControls;diff --git a/web/js/components/timeline/timeline-controls/date-zoom-change.js b/web/js/components/timeline/timeline-controls/interval-timescale-change.jssimilarity index 65%rename from web/js/components/timeline/timeline-controls/date-zoom-change.jsrename to web/js/components/timeline/timeline-controls/interval-timescale-change.jsindex 60b3b534a..b4ca5635d 100644--- a/web/js/components/timeline/timeline-controls/date-zoom-change.js+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js@@ -1,11 +1,11 @@import React, { Component } from 'react';+import PropTypes from 'prop-types';-class DateZoomChange extends Component {+class TimeScaleIntervalChange extends Component {constructor(props) {super(props);this.state = {toolTipHovered: false,- intervalText: this.props.intervalText,customSelected: false}}@@ -18,34 +18,41 @@ class DateZoomChange extends Component {}handleClickZoom = (zoomSelected) => {- console.log(zoomSelected)// close tooltip// send props function to change timescale zoom level throughout app- if (zoomSelected === 'custom') {- let text = this.props.customIntervalText ? this.props.customIntervalText : 'Custom';- this.setState({- customSelected: true,- toolTipHovered: false,- intervalText: text- }, this.props.setIntervalChangeUnitFromZoom(zoomSelected));- } else {- this.setState({- customSelected: false,- toolTipHovered: false,- intervalText: zoomSelected- }, this.props.setIntervalChangeUnitFromZoom(zoomSelected));- }- }+ let customSelected = zoomSelected === 'custom';+ this.setState({+ customSelected: customSelected,+ toolTipHovered: false,+ // intervalText: text+ }, this.props.setTimeScaleIntervalChangeUnit(zoomSelected));- componentDidUpdate(prevProps, prevState) {- if (prevProps.intervalText !== this.props.intervalText) {- this.setState({- intervalText: this.props.intervalText- })- }+ // if (zoomSelected === 'custom') {+ // // let text = this.props.customIntervalText ? this.props.customIntervalText : 'Custom';+ // this.setState({+ // customSelected: true,+ // toolTipHovered: false,+ // // intervalText: text+ // }, this.props.setTimeScaleIntervalChangeUnit(zoomSelected));+ // } else {+ // this.setState({+ // customSelected: false,+ // toolTipHovered: false,+ // // intervalText: zoomSelected+ // }, this.props.setTimeScaleIntervalChangeUnit(zoomSelected));+ // }}+ // componentDidUpdate(prevProps, prevState) {+ // if (prevProps.intervalText !== this.props.intervalText) {+ // this.setState({+ // intervalText: this.props.intervalText+ // })+ // }++ // }+render() {return (<React.Fragment>@@ -58,7 +65,7 @@ class DateZoomChange extends Component {id="current-zoom"className={`zoom-btn zoom-btn-active${this.state.customSelected ? ' custom-interval-text' : ''}`}>- {this.state.customSelected ? this.state.intervalText : '1 ' + this.state.intervalText}+ {this.state.customSelected ? this.props.customIntervalText ? this.props.customIntervalText : 'custom' : '1 ' + this.props.intervalText}</span>{/* hover timeScale unit dialog / entry point to Custom selector */}@@ -117,4 +124,10 @@ class DateZoomChange extends Component {}}-export default DateZoomChange;+TimeScaleIntervalChange.propTypes = {+ intervalText: PropTypes.string,+ customIntervalText: PropTypes.string,+ setTimeScaleIntervalChangeUnit: PropTypes.func+};++export default TimeScaleIntervalChange;diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.cssindex 5f1aed5cc..e35f7ccd0 100644--- a/web/js/components/timeline/timeline.css+++ b/web/js/components/timeline/timeline.css@@ -32,7 +32,7 @@ html, body {}.inner {- background: rgba(0, 0, 0, 0.5);+ /* background: rgba(0, 0, 0, 0.5); */height: 66px;display: flex;flex-direction: row;@@ -42,6 +42,7 @@ html, body {.dateToolTip {background: rgb(233, 233, 233);+ border: thin solid #555;font-size: 9px;text-align: center;border-radius: 5px;@@ -156,7 +157,7 @@ form select {.zoom-level-change-arrows {user-select: none;background: transparent;- border: 1px solid transparent;+ border: thin solid transparent;vertical-align: middle;box-sizing: border-box;-webkit-box-sizing: border-box;@@ -180,7 +181,7 @@ form select {-webkit-box-sizing: border-box;padding: 0;text-align: center;- border: 1px solid #fff;+ border: thin solid #fff;margin: 5px 0 5px 0;}@@ -208,7 +209,7 @@ form select {color: #7890cd;height: 40px;width: 130px;- border: 1px solid #fff;+ border: thin solid #fff;margin-top: 1px;}diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.jsindex 83d4c5959..5d3525963 100644--- a/web/js/components/timeline/timeline.js+++ b/web/js/components/timeline/timeline.js@@ -3,10 +3,8 @@ import PropTypes from 'prop-types';import moment from 'moment';-import DateChangeControls from './timeline-controls/date-change-controls';-import DateZoomChange from './timeline-controls/date-zoom-change';+import TimeScaleIntervalChange from './timeline-controls/interval-timescale-change';import './timeline.css';-// import TimelineAxis from './timeline-axis';import TimelineAxisContainer from './timeline-axis/timeline-axis-container';import IntervalSelectorWidget from './interval-selector/interval-selector';@@ -14,14 +12,24 @@ import DateSelector from '../date-selector/date-selector';import DateChangeArrows from './timeline-controls/date-change-arrows';import AnimationButton from './timeline-controls/animation-button';-import AxisZoomChange from './timeline-controls/axis-zoom-change';+import AxisTimeScaleChange from './timeline-controls/axis-timescale-change';++const timeUnitAbbreviations = {+ year: 'year',+ month: 'mon',+ day: 'day',+ hour: 'hour',+ minute: 'min'+};class Timeline extends React.Component {constructor(props) {super(props);this.state = {+ compareModeActive: '',dateFormatted: '',- timelineWidth: '',+ dateFormattedB: '',+ axisWidth: '',selectedDate: '',changeDate: '',timeScale: '',@@ -39,34 +47,17 @@ class Timeline extends React.Component {};}- //# may not be necessary if incrementing doesn't matter for performance- // dateChange = (date, id, type, amt) => {- // // console.log(date, id, type, amt)- // let dateFormatted = date.toISOString();- // console.log(dateFormatted)- // this.setState({- // selectedDate: date.toISOString(),- // timeScaleChangeUnit: type,- // changeAmt: amt,- // dateFormatted: dateFormatted- // })- // }-- updateDate = (date, inputChange) => {- console.log(date, inputChange)+ // updateDate = (date, inputChange) => {+ updateDate = (date, selectionStr) => {+ console.log(date, selectionStr)// if (inputChange) {// this.setState({// inputChange: true// }, this.props.updateDate(date));// } else {- this.props.updateDate(date);+ this.props.updateDate(date, selectionStr);// }- // let dateFormatted = new Date(date).toISOString();- // this.setState({- // selectedDate: dateFormatted,- // dateFormatted: dateFormatted- // })}resetInput = () => {@@ -85,9 +76,10 @@ class Timeline extends React.Component {// Change the timescale parent statechangeTimescale = (timeScale) => {if (this.state.timeScale !== timeScale) {- this.setState({- timeScale: timeScale- });+ // this.setState({+ // timeScale: timeScale+ // });+ this.props.changeTimeScale(timeScale);}}@@ -98,7 +90,6 @@ class Timeline extends React.Component {// dateFormatted: this.props.dateFormatted// })// }- // console.log('CDU', this.state, this.props)}componentDidMount() {@@ -106,37 +97,36 @@ class Timeline extends React.Component {}init = () => {+ let timeScaleChangeUnitString = `${this.props.intervalDelta} ${timeUnitAbbreviations[this.props.intervalTimeScale]}`;this.setState({dateFormatted: this.props.selectedDate.toISOString(),- timelineWidth: this.props.timelineWidth,+ dateFormattedB: this.props.selectedDateB ? this.props.selectedDateB.toISOString() : null,+ draggerSelected: this.props.draggerSelected,+ // draggerSelectedB: this.props.draggerSelectedB,+ axisWidth: this.props.axisWidth,selectedDate: this.props.selectedDate.toISOString(),changeDate: this.props.changeDate,timeScale: this.props.timeScale,incrementDate: this.props.incrementDate,- timeScaleChangeUnit: this.props.timeScale,- changeAmt: 1,- customIntervalValue: 1,- customIntervalZoomLevel: this.props.timeScale,+ timeScaleChangeUnit: this.props.intervalTimeScale,+ changeAmt: this.props.intervalDelta,+ customIntervalValue: this.props.intervalDelta,+ customIntervalZoomLevel: this.props.intervalTimeScale,hasSubdailyLayers: this.props.hasSubdailyLayers,- intervalText: this.props.timeScale+ intervalText: this.props.timeScale,+ compareModeActive: this.props.compareModeActive});}setInterval = (intervalValue, zoomLevel) => {- this.setState({- customIntervalValue: intervalValue,- customIntervalZoomLevel: zoomLevel- }, this.props.setIntervalInput(intervalValue, zoomLevel));+ // this.setState({+ // customIntervalValue: intervalValue,+ // customIntervalZoomLevel: zoomLevel+ // }, this.props.setIntervalInput(intervalValue, zoomLevel));+ this.props.setIntervalInput(intervalValue, zoomLevel);}setIntervalChangeUnit = (intervalValue, zoomLevel) => {- const timeUnitAbbreviations = {- year: 'year',- month: 'mon',- day: 'day',- hour: 'hour',- minute: 'min'- };let timeScaleChangeUnitString = `${intervalValue} ${timeUnitAbbreviations[zoomLevel]}`;@@ -147,10 +137,10 @@ class Timeline extends React.Component {customIntervalZoomLevel: zoomLevel,changeAmt: intervalValue,timeScaleChangeUnit: zoomLevel- })+ }, this.props.setIntervalInput(intervalValue, zoomLevel))}- setIntervalChangeUnitFromZoom = (customIntervalChangeUnit) => {+ setTimeScaleIntervalChangeUnit = (customIntervalChangeUnit) => {if (customIntervalChangeUnit === 'custom') {this.setState({intervalText: this.state.customIntervalText ? this.state.customIntervalText : 'Custom',@@ -167,11 +157,9 @@ class Timeline extends React.Component {}// left/right arrows increment dateincrementDate = (multiplier) => {- console.log(moment(this.state.dateFormatted).format(), moment.utc(this.state.dateFormatted).format())let newDate = moment.utc(this.state.dateFormatted).add((multiplier * this.state.changeAmt), this.state.timeScaleChangeUnit)// this.props.incrementDate((multiplier * this.state.changeAmt), this.state.timeScaleChangeUnit);- console.log(this.state.dateFormatted, newDate.format())this.updateDate(new Date(newDate.format()));}@@ -203,6 +191,7 @@ class Timeline extends React.Component {console.log(this.state)console.log(this.props.hasSubdailyLayers, this.state.hasSubdailyLayers)console.log(this.props)+ console.log(this.props.draggerSelected)return (this.state.dateFormatted ?<React.Fragment>@@ -212,31 +201,28 @@ class Timeline extends React.Component {{...this.props}onDateChange={this.updateDate}date={new Date(this.state.dateFormatted)}+ dateB={new Date(this.state.dateFormattedB)}hasSubdailyLayers={this.state.hasSubdailyLayers}+ draggerSelected={this.state.draggerSelected}+ // draggerSelectedB={this.state.draggerSelectedB}/></div><div id="zoom-buttons-group">- <DateZoomChange- // timeScaleChangeUnit={this.state.timeScaleChangeUnit}- setIntervalChangeUnitFromZoom={this.setIntervalChangeUnitFromZoom}+ <TimeScaleIntervalChange+ setTimeScaleIntervalChangeUnit={this.setTimeScaleIntervalChangeUnit}intervalText={this.state.intervalText}customIntervalText={this.state.customIntervalText}/>- {/* </div> */}- {/* <DateChangeControls- toggleCustomIntervalModal={this.toggleCustomIntervalModal}- selectedDate={this.state.dateFormatted}- dateChange={this.updateDate} /> */}-{/* custom interval selector */}<IntervalSelectorWidgetsetInterval={this.setInterval}- customIntervalValue={1}- customIntervalZoomLevel={this.props.timeScale}+ customIntervalValue={this.state.customIntervalValue}+ customIntervalZoomLevel={this.state.customIntervalZoomLevel}toggleCustomIntervalModal={this.toggleCustomIntervalModal}customIntervalModalOpen={this.state.customIntervalModalOpen}setIntervalChangeUnit={this.setIntervalChangeUnit}+ hasSubdailyLayers={this.state.hasSubdailyLayers}/><DateChangeArrows@@ -257,36 +243,37 @@ class Timeline extends React.Component {{/* new modular version - currently a shell */}<TimelineAxisContainer{...this.state}+ axisWidth={this.state.axisWidth}selectedDate={this.state.dateFormatted}+ selectedDateB={this.state.dateFormattedB}updateDate={this.updateDate}subdaily={this.props.subdaily}parentOffset={this.props.parentOffset}resetInput={this.resetInput}changeTimescale={this.changeTimescale}+ compareModeActive={this.state.compareModeActive}+ draggerSelected={this.state.draggerSelected}+ // draggerSelectedB={this.state.draggerSelectedB}+ onChangeSelectedDragger={this.props.onChangeSelectedDragger}/>{/* </svg> */}</div>{/* hammmmmmmmmmmburger 🍔 */}- {/* <div className="timeline-hamburger-date">DAY</div> */}<div className="zoom-level-change" style={{ width: '75px', display: this.state.timelineHidden ? 'none' : 'block'}}>- <AxisZoomChange- zoomLevel={this.state.timeScale}+ <AxisTimeScaleChange+ timeScale={this.state.timeScale}changeTimescale={this.changeTimescale}hasSubdailyLayers={this.state.hasSubdailyLayers}/></div>-<div id="timeline-hide" onClick={this.toggleHideTimeline}>- {this.state.timelineHidden ?- <i className="fas fa-chevron-right wv-timeline-hide-arrow"></i>- :- <i className="fas fa-chevron-left wv-timeline-hide-arrow"></i>- }- {/* <svg className="hamburger" width="10" height="9">- <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z" />- </svg> */}+ {this.state.timelineHidden ?+ <i className="fas fa-chevron-right wv-timeline-hide-arrow"></i>+ :+ <i className="fas fa-chevron-left wv-timeline-hide-arrow"></i>+ }</div></React.Fragment>:diff --git a/web/js/date/compare-picks.js b/web/js/date/compare-picks.jsindex 0ceeefc09..311508207 100644--- a/web/js/date/compare-picks.js+++ b/web/js/date/compare-picks.js@@ -18,6 +18,7 @@ export function timelineCompare(models, config, ui) {var parentSvg;var max;self.events = util.events();+ // # this class puts a 0 OPACITY on the regular draggerif (models.compare.active) {$timeline.addClass('ab-active');}diff --git a/web/js/date/model.js b/web/js/date/model.jsindex b82b25728..27fce7c49 100644--- a/web/js/date/model.js+++ b/web/js/date/model.js@@ -9,6 +9,9 @@ export function dateModel(models, config, spec) {self.selectedB = null;self.activeDate = 'selected';+ self.delta = null;+ self.interval = null;+self.monthAbbr = ['JAN','FEB',@@ -37,11 +40,17 @@ export function dateModel(models, config, spec) {self.activeDate = dateString;self.events.trigger('state-update');};+ self.setCustomInterval = (delta, interval) => {+ self.delta = delta;+ self.interval = interval;+ self.events.trigger('state-update');+ };self.string = function() {return util.toISOStringDate(self.selected);};self.select = function(date, selectionStr) {+ console.log(self.selected, self.selectedB, self.activeDate)if (!date) return null;selectionStr = selectionStr || self.activeDate;date = self.clamp(date);@@ -147,21 +156,40 @@ export function dateModel(models, config, spec) {state.t1 = dateToStringForUrl(self.selectedB);}}+ // custom interval delta and interval+ console.log(state, self.delta, self.interval, models)+ if (self.delta) {+ state.intd = self.delta.toString();+ }+ if (self.interval) {+ state.inti = self.interval.toString();+ }};self.load = function(state) {+ // COMPARE ACTIVE? - A dragger/tab selected : state.ca === 'true', B is state.ca === 'falseif (state.ca === 'false') {self.setActiveDate('selectedB');}+ // TIMEif (state.t) {self.select(state.t, 'selected');}+ // TIMESCALE (ZOOM) - can't change in order to support older, established permalinksif (state.z) {self.selectedZoom = Number(state.z);}+ // TIME FOR DRAGGER Bif (state.t1) {self.select(state.t1, 'selectedB');}+ // # INTERVALS+ if (state.intd) {+ self.delta = Number(state.intd);+ }+ if (state.inti) {+ self.interval = state.inti;+ }};init();return self;diff --git a/web/js/date/timeline.js b/web/js/date/timeline.jsindex 8f6d87450..3d4ac5ff4 100644--- a/web/js/date/timeline.js+++ b/web/js/date/timeline.js@@ -5,8 +5,6 @@ import ReactDOM from 'react-dom';import googleTagManager from 'googleTagManager';import Timeline from '../components/timeline/timeline';-import DateZoomChange from '../components/timeline/timeline-controls/date-zoom-change';-export function timeline(models, config, ui) {var self = {};var model = models.date;@@ -16,7 +14,9 @@ export function timeline(models, config, ui) {self.parentOffset = (subdaily ? 404 : 310) + 10;// ? INPUT REFACTOR- self.interval = 'day';+ // self.interval = null;+ // self.delta = 3;+self.delta = 1;self.active = false;self.delay = 500;@@ -424,7 +424,9 @@ export function timeline(models, config, ui) {// self.axis.select('line:first-child').attr('x2', self.width);}- self.reactComponent.setState({ timelineWidth: self.getWidth() });+ self.reactComponent.setState({+ axisWidth: self.getWidth()+ });};self.setClip = function() {@@ -443,16 +445,11 @@ export function timeline(models, config, ui) {// }, 50);};- // var changeDate = (date) => {- // self.reactComponent.setState({ selectedDate: date });- // };-var incrementDate = (increment, timeScale) => {// self.expand(true);// console.log(increment, timeScale)self.animateByIncrement(increment, timeScale);// let newDate = models.date[models.date.activeDate];- // console.log('XXXXX', newDate);// models.date.add(timeScale, increment);// self.input.animateByIncrement(increment, timeScale);// models.date.select(date);@@ -462,53 +459,149 @@ export function timeline(models, config, ui) {// });};- var updateDate = (date) => {- console.log(date)+ // invoked when compare mode is toggled++ // # rework in order to allow A and B dates to persist on reopening dialog+ var onCompareModeToggle = () => {+ let isCompareModeActive = models.compare.active;+ if (!isCompareModeActive) {+ let activeDate = models.date.activeDate;+ let date = models.date[activeDate];+ let dateFormatted = new Date(date).toISOString();+ self.reactComponent.setState({+ compareModeActive: isCompareModeActive,+ selectedDate: date,+ dateFormatted: dateFormatted,+ draggerSelected: 'selected'+ });+ } else {+ self.reactComponent.setState({+ compareModeActive: isCompareModeActive+ });+ }+ };++ var onChangeSelectedDragger = (selectionStr) => {+ let isCompareModeActive = models.compare.active;+ if (isCompareModeActive) {+ models.compare.toggleState();+ }+ self.reactComponent.setState({+ draggerSelected: selectionStr+ });+ };++ var updateDate = (date, selectionStr) => {+ console.log(date, selectionStr)let updatedDate = new Date(date);- console.log(date, updatedDate)// console.log(models)// self.input.update(updatedDate);// models.date.setActiveDate(updatedDate);// console.log('updateDate', date, updatedDate)//# ALLOWS UPDATE OF MODELS DATE WHICH LAYERS IS CONNECTED TO- models.date.select(updatedDate);+ models.date.select(updatedDate, selectionStr);};var setIntervalInput = (intervalValue, zoomLevel) => {- // console.log(self.input.delta)- self.delta = intervalValue;- self.interval = zoomLevel;-+ models.date.setCustomInterval(intervalValue, timeScaleToNumberKey[zoomLevel]);let zoomCustomText = document.querySelector('#zoom-custom');zoomCustomText.textContent = `${intervalValue} ${zoomLevel.toUpperCase().substr(0, 3)}`;- // console.log(self)+ // model.events.trigger('zoom-change');+ self.reactComponent.setState({+ customIntervalValue: intervalValue,+ customIntervalZoomLevel: zoomLevel+ });};var clickAnimationButton = () => {console.log(ui);};+ var changeTimeScale = (timeScale) => {+ console.log(timeScale)+ models.date.selectedZoom = timeScaleToNumberKey[timeScale];+ model.events.trigger('zoom-change');+ self.reactComponent.setState({+ timeScale: timeScale+ });+ };++ const timeScaleFromNumberKey = {+ '1': 'year',+ '2': 'month',+ '3': 'day',+ '4': 'hour',+ '5': 'minute'+ };++ const timeScaleToNumberKey = {+ 'year': '1',+ 'month': '2',+ 'day': '3',+ 'hour': '4',+ 'minute': '5'+ };+var getInitialProps = () => {- // console.log(self)- let selectedDate = models.date[models.date.activeDate];+ let isCompareModeActive = models.compare.active;let subdaily = models.layers.hasSubDaily();+ // timeScale zoom and reset if subdaily zoom in permalink+ let selectedTimeScaleState = models.date.selectedZoom;+ if (!subdaily && selectedTimeScaleState > 3) {+ selectedTimeScaleState = 3;+ }+ let selectedTimeScale = selectedTimeScaleState ? timeScaleFromNumberKey[selectedTimeScaleState] : 'day';++ let selectedDate = models.date.selected;+ let selectedDateB = models.date.selectedB ? models.date.selectedB : util.dateAdd(selectedDate, selectedTimeScale, -7);++ console.log(selectedDate, selectedDateB);++ // custom interval+ let intervalTimeScale = models.date.interval ? models.date.interval : selectedTimeScale;+ let intervalDelta = models.date.delta ? models.date.delta : 1;++ console.log(intervalTimeScale, intervalDelta)+ // console.log(selectedDate, selectedDateB, models.date[models.date.activeDate])+ // let selectedDate = models.date.selected;+ // get selected A+ // get selected B+ // determine which one is selected+ // let activeDate = models.date.activeDate;++ // let draggerSelected = activeDate === 'selected';+ // let draggerSelectedB = activeDate === 'selectedB';+ let draggerSelected = models.date.activeDate;let inputProps = getInputProps();++ let dateFormatted = selectedDate ? new Date(selectedDate).toISOString() : '';+ let dateFormattedB = selectedDateB ? new Date(selectedDateB).toISOString() : '';+ console.log(self)return Object.assign(inputProps, {- timelineWidth: self.width,+ compareModeActive: isCompareModeActive,+ onChangeSelectedDragger: onChangeSelectedDragger,+ draggerSelected: draggerSelected,+ // draggerSelectedB: draggerSelectedB,+ axisWidth: self.width,parentOffset: self.parentOffset,hasSubdailyLayers: subdaily,timelineHeight: self.height,selectedDate: selectedDate,- // changeDate: changeDate,- timeScale: 'day',+ selectedDateB: selectedDateB,+ // timeScale: 'day',+ timeScale: selectedTimeScale,incrementDate: incrementDate,updateDate: updateDate,setIntervalInput: setIntervalInput,- dateFormatted: new Date(selectedDate).toISOString(),+ dateFormatted: dateFormatted,+ dateFormattedB: dateFormattedB,stopper: stopper,clickAnimationButton: clickAnimationButton,- toggleHideTimeline: self.toggle+ toggleHideTimeline: self.toggle,+ changeTimeScale: changeTimeScale,+ intervalTimeScale: intervalTimeScale,+ intervalDelta: intervalDelta});};@@ -520,16 +613,6 @@ export function timeline(models, config, ui) {document.getElementById('timeline'));- // self.reactComponent = ReactDOM.render(- // React.createElement(Timeline, initialProps),- // document.getElementById('timelineContainer')- // );-- // self.reactComponent2 = ReactDOM.render(- // React.createElement(DateZoomChange),- // document.getElementById('zoom-btn-container')- // );-// self.svg = d3// .select('#timeline-footer')// .append('svg:svg')@@ -592,21 +675,45 @@ export function timeline(models, config, ui) {// self.animboundary.append('g').attr('id', 'wv-rangeselector-case');};- var updateReactTimelineDate = function() {+ var updateReactTimelineDate = function(date, selectionStr) {// debugger;- let selectedDate = models.date[models.date.activeDate];- // console.log(selectedDate, new Date(selectedDate).toISOString())- console.log(selectedDate);+ // let selectedDate = models.date[models.date.activeDate];+ let selectedDate = models.date.selected;+ let selectedDateB = models.date.selectedB;++ // let activeDate = models.date.activeDate;++ // let draggerSelected = activeDate === 'selected';+ // let draggerSelectedB = activeDate === 'selectedB';+ let draggerSelected = models.date.activeDate;++ let dateFormatted = selectedDate ? new Date(selectedDate).toISOString() : '';+ let dateFormattedB = selectedDateB ? new Date(selectedDateB).toISOString() : '';++ // // console.log(selectedDate, new Date(selectedDate).toISOString())+ // console.log(selectedDate);self.reactComponent.setState({selectedDate: selectedDate,- dateFormatted: new Date(selectedDate).toISOString()+ dateFormatted: dateFormatted,+ draggerSelected: draggerSelected,+ selectedDateB: selectedDateB,+ dateFormattedB: dateFormattedB+ // draggerSelectedB: draggerSelectedB});++ // console.log(selectedDate, date);+ // self.reactComponent.setState({+ // selectedDate: date,+ // dateFormatted: date.toISOString()+ // });};- var updateTimeUi = function() {+ // arguments passed as date (date object) and selectionStr ('selected' or 'selectedB')+ var updateTimeUi = function(date, selectionStr) {+ console.log(date, selectionStr);// console.log('%c updateTimeUi ', 'background: #555; color: cornflowerblue');- updateReactTimelineDate();+ updateReactTimelineDate(date, selectionStr);// updateInput();// self.input.update();// self.pick.shiftView();@@ -615,7 +722,15 @@ export function timeline(models, config, ui) {// Update status of subdaily layers being in sidebarvar updateSubdailyState = function() {let subdaily = models.layers.hasSubDaily();- self.reactComponent.setState({ hasSubdailyLayers: subdaily });+ if (!subdaily && models.date.selectedZoom > 3) {+ self.reactComponent.setState({+ hasSubdailyLayers: subdaily+ }, changeTimeScale('day'));+ } else {+ self.reactComponent.setState({+ hasSubdailyLayers: subdaily+ });+ }};var onLayerUpdate = function() {@@ -704,6 +819,7 @@ export function timeline(models, config, ui) {model.events.on('state-update', updateTimeUi);if (models.compare) {models.compare.events.on('toggle-state', onLayerUpdate);+ models.compare.events.on('toggle', onCompareModeToggle);}models.layers.events.on('change', onLayerUpdate);