Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add timescale zoom, add 1 unit to interval, add hour interval, change to pure components and remove state where available, clean up commented out dead code

Edward Platocd704a321aa4
diff --git a/web/css/timeline.css b/web/css/timeline.css
index d1013a184..0ef0500de 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -151,11 +151,13 @@ g.plot rect.data-bar-invisible {
#timeline-header .input-time-divider,
#timeline-header .input-wrapper-minute,
#timeline-header .input-time-zmark,
-#timeline-header .zoom-minutes {
+#timeline-header .zoom-minutes,
+#timeline-header .zoom-hours {
display: none;
}
-#timeline-header.subdaily .zoom-minutes {
+#timeline-header.subdaily .zoom-minutes,
+#timeline-header.subdaily .zoom-hours {
display: block;
}
@@ -430,9 +432,10 @@ g.plot rect.data-bar-invisible {
stroke: #4682b4;
}
-#timeline-header .timeline-zoom {
+#timeline-header .timeline-zoom,
+#zoom-btn-container-axis .wv-zoom-tooltip {
display: block;
- width: 80px;
+ /* width: 80px; */
margin-left: auto;
margin-right: auto;
padding: 4px;
@@ -440,7 +443,8 @@ g.plot rect.data-bar-invisible {
border-radius: 3px;
}
-#timeline-header #zoom-btn-container {
+#timeline-header #zoom-btn-container,
+#zoom-btn-container-axis {
display: block;
}
@@ -453,6 +457,14 @@ g.plot rect.data-bar-invisible {
z-index: 10;
}
+#zoom-btn-container-axis .wv-zoom-tooltip {
+ /* display: none; */
+ position: absolute;
+ bottom: 100%;
+ border-bottom: 8px solid transparent;
+ z-index: 10;
+}
+
#zoom-btn-container .wv-tooltip::after {
position: absolute;
top: 100%;
@@ -506,16 +518,16 @@ g.plot rect.data-bar-invisible {
top: 0;
right: 0;
height: 64px;
- width: 0;
- /* cursor: pointer; */
+ width: 20px;
+ cursor: pointer;
border-left: 1px solid #1a1a1a;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
-/* #timeline-hide:hover {
+#timeline-hide:hover {
background-color: #fff;
-} */
+}
#guitarpick {
cursor: pointer;
diff --git a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
index 525d691e6..cc3db5a47 100644
--- a/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
+++ b/web/js/components/timeline/timeline-axis/grid-range/tile-rect.js
@@ -36,8 +36,8 @@ const axisScaleGridElement = {
return (
<React.Fragment>
{/* <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill={item.withinRange ? 'rgba(0,0,0,0)' : 'black'} shapeRendering="optimizeSpeed"></rect> */}
- {/* <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill={midTile ? 'yellow' : 'rgba(0,0,0,0)'} shapeRendering="optimizeSpeed"></rect> */}
- <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill='rgba(0,0,0,0)' shapeRendering="optimizeSpeed"></rect>
+ <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill={midTile ? 'yellow' : 'rgba(0,0,0,0)'} shapeRendering="optimizeSpeed"></rect>
+ {/* <rect className="grid" width={gridWidth} height={100} transform={`translate(${index * gridWidth}, 0)`} fill='rgba(0,0,0,0)' shapeRendering="optimizeSpeed"></rect> */}
<line stroke="black" strokeLinecap="round" strokeWidth="0.2" x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 2.2}, 0)`} />
<line stroke="white" strokeLinecap="round" strokeWidth="2" x1="0" x2="0" y1="0" y2={lineLengthY} transform={`translate(${index * gridWidth + 1}, 0)`} />
</React.Fragment>
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 3dc5bf665..44302281f 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -94,11 +94,11 @@ class TimelineAxis extends React.Component {
// this.showHoverOff = this.showHoverOff.bind(this);
}
//? how do position and transforms change between scale changes? lock into one line would be ideal
- updateScale = (inputDate, timeScale, axisWidthInput) => {
+ updateScale = (inputDate, timeScale, axisWidthInput, leftOffsetFixedCoeff) => {
let options = timeScaleOptions[timeScale].timeAxis;
let gridWidth = options.gridWidth;
let axisWidth = axisWidthInput ? axisWidthInput : this.state.axisWidth;
- let leftOffset = this.state.leftOffset;
+ let leftOffset = leftOffsetFixedCoeff ? axisWidth * leftOffsetFixedCoeff : this.state.leftOffset;
if (leftOffset === 0) {
leftOffset = axisWidth / 2;
@@ -250,25 +250,17 @@ class TimelineAxis extends React.Component {
// changes timeScale state
wheelZoom = (e) => {
- // e.preventDefault();
+ // e.preventDefault(); //TODO: investigate treated as passive event error/warning when on
let arrayIndex = timeScales.indexOf(this.state.timeScale);
if (e.deltaY > 0) { // wheel zoom out
if (arrayIndex < 4) {
let nextGreaterTimeScale = timeScales[arrayIndex + 1];
-
- //# componentDidUpdate catches this change - BEST WAY TO HANDLE THIS?
- this.setState({
- timeScale: nextGreaterTimeScale
- });
+ this.props.changeTimescale(nextGreaterTimeScale);
}
} else {
if (arrayIndex > 0) { // wheel zoom in
let nextSmallerTimeScale = timeScales[arrayIndex - 1];
-
- //# componentDidUpdate catches this change - BEST WAY TO HANDLE THIS?
- this.setState({
- timeScale: nextSmallerTimeScale
- });
+ this.props.changeTimescale(nextSmallerTimeScale);
}
}
}
@@ -690,6 +682,8 @@ class TimelineAxis extends React.Component {
// console.log(draggerPosition, pixelsToAdd, midPoint)
// console.log(this.getDraggerPosition(draggerTimeStateBDraggerBTest, current.dates[0].rawDate, 'day', gridWidth))
+ console.log(current.dates[Math.floor(gridNumber/2)].rawDate)
+
this.setState({
compareMode: false,
timeScaleSelectValue: timeScale,
@@ -733,37 +727,62 @@ class TimelineAxis extends React.Component {
// return true;
// }
- //# BEST WAY TO HANDLE THIS?
- componentDidUpdate(prevProps, prevState) {
- // console.log(this.props)
-// console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)
+/**
+ * check if newDraggerDate will be within acceptable visible axis width
+ *
+ * @param {String} selectedDate
+ * @return {Boolean} withinRange
+ * @return {Boolean} newDateInThePast
+ * @return {Number} newDraggerDiff
+ */
+ checkDraggerMoveOrUpdateScale = (selectedDate) => {
+ let draggerTimeState = this.state.draggerTimeState;
+ let draggerPosition = this.state.draggerPosition;
+
+ let timeScale = this.state.timeScale;
+ let gridWidth = this.state.gridWidth;
+
+ let selectedDateMoment = moment.utc(selectedDate);
+ let draggerDateMoment = moment.utc(draggerTimeState);
+
+ 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;
+
+ return {
+ withinRange: newDraggerWithinRangeCheck,
+ newDateInThePast: newDateInThePast,
+ newDraggerDiff: Math.abs(newDraggerDiff)
+ };
+ }
+ componentDidUpdate(prevProps, prevState) {
+ // console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)
+console.log(this.props.timeScale)
if (this.props.inputChange === true) {
- console.log(this.props.selectedDate)
- this.updateScale(this.props.selectedDate, this.state.timeScale);
this.props.resetInput();
+ // check if newDraggerDate will be within acceptable visible axis width
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(this.props.selectedDate);
+ if (newDraggerDate.withinRange) {
+ 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);
+ }
}
- // 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();
-
- // console.log(propsSelectedDate, stateSelectedDate)
- // console.log(prevProps.timeScaleChangeUnit, this.props.timeScaleChangeUnit, this.state.timeScaleChangeUnit, prevState.timeScaleChangeUnit)
if (this.state.timeScale !== prevState.timeScale) {
this.updateScale(null, this.state.timeScale);
}
- // if (prevProps.timeScaleChangeUnit !== this.props.timeScaleChangeUnit) {
- // this.updateScale(null, this.props.timeScaleChangeUnit);
- // }
+ if (this.props.timeScale !== this.state.timeScale) {
+ this.updateScale(null, this.props.timeScale);
+ }
if (this.props.timelineWidth !== prevProps.timelineWidth) {
this.handleResize();
}
-// console.log(prevProps.selectedDate, this.props.selectedDate, this.state.selectedDate, prevState.selectedDate)
-// console.log(prevProps.draggerTimeState, this.props.draggerTimeState, this.state.draggerTimeState, prevState.draggerTimeState)
// # CHANGED CONDITIONAL FROM "&&" TO "||" TO DEBUG LEFT/RIGHT ARROW UPDATE ISSUE
if (this.props.selectedDate !== prevProps.selectedDate ||
this.state.draggerTimeState !== prevState.draggerTimeState ||
@@ -776,52 +795,26 @@ class TimelineAxis extends React.Component {
// && moment.utc(this.state.draggerTimeState).format() !== moment.utc(this.props.selectedDate).format()) {
// console.log(this.props.selectedDate, prevProps.selectedDate, this.state.hoverTime, this.state.draggerTimeState)
- // console.log(moment.utc(this.state.hoverTime).format(), moment.utc(this.props.selectedDate).format())
-
- // let manualTimeScaleChangeUnit = this.props.timeScaleChangeUnit || this.state.timeScale;
-
- // let options = timeScaleOptions[manualTimeScaleChangeUnit].timeAxis;
- // let gridWidth = options.gridWidth;
-
- // 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(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.props, newSelectedDate, moment.utc(this.props.selectedDate).format())
- // this.setDraggerToTime(this.props.selectedDate)
- // this.updateScale(this.props.selectedDate, this.state.timeScale);
- // if (this.props.changeAmt !== null) {
- // console.log('hit')
- // 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);
- // }
-
- // }
+
+
+ if (!this.props.inputChange && (moment.utc(this.state.draggerTimeState).format() !== moment.utc(this.props.selectedDate).format())) {
+ // check if newDraggerDate will be within acceptable visible axis width
+ let newDraggerDate = this.checkDraggerMoveOrUpdateScale(this.props.selectedDate);
+ if (newDraggerDate.withinRange) {
+ 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);
+ }
+ }
+
}
- // else if (propsSelectedDate !== stateSelectedDate) {
- // this.setState({
- // selectedDate: propsSelectedDate,
- // hoverTime: propsSelectedDate,
- // draggerTimeState: propsSelectedDate
- // }, this.updateScale(this.state.timeScale))
- // }
}
- // move red line forward one timeScale unit and update time
+ // move draggerTimeState to inputTime
setDraggerToTime = (inputTime) => {
- // console.log(inputTime)
- // let timeScaleSelected = manualTimeScaleChangeUnit ? manualTimeScaleChangeUnit : this.state.timeScaleSelectValue;
let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- // let increment = manualIncrementAmount ? manualIncrementAmount : this.state.increment;
let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
let draggerTimeStateAdded = moment.utc(inputTime);
@@ -853,83 +846,6 @@ class TimelineAxis extends React.Component {
// this.props.incrementDate(timeScaleSelected, increment));
}
- // TODO: may need to restrict based on zoom levels, year zoom adding 7 minutes does nothing for example
- // move red line forward one timeScale unit and update time
- addTimeUnit = (manualTimeScaleChangeUnit, manualIncrementAmount) => {
- // let timeScaleSelected = manualTimeScaleChangeUnit ? manualTimeScaleChangeUnit : this.state.timeScaleSelectValue;
- let timeScaleSelected = this.props.customIntervalZoomLevel;
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- // let increment = manualIncrementAmount ? manualIncrementAmount : this.state.increment;
- let increment = this.props.customIntervalValue;
- let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
- let draggerTimeStateAdded = draggerTimeState.clone().add(increment, timeScaleSelected);
-
- let isBetween = draggerTimeStateAdded.isBetween(frontDate, backDate, null, '[]');
- let draggerVisible = false;
- let newDraggerPosition;
- if (isBetween) {
- draggerVisible = true;
- }
- let gridWidth = this.state.gridWidth;
- let timeScale = this.state.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;
- if (isVisible) {
- newDraggerPosition = this.state.draggerPosition + pixelsToAddBasedOnFrontDate;
- } else {
- newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - 49 + this.state.currentTransformX;
- }
-
- this.setState({
- draggerPosition: newDraggerPosition,
- draggerVisible: draggerVisible,
- draggerTimeState: draggerTimeStateAdded.format(),
- }, this.props.updateDate(draggerTimeStateAdded.format()))
- // this.props.incrementDate(timeScaleSelected, increment));
- }
-
- // move red line backward one timeScale unit and update time
- minusTimeUnit = (manualTimeScaleChangeUnit, manualIncrementAmount) => {
- // let timeScaleSelected = manualTimeScaleChangeUnit ? manualTimeScaleChangeUnit : this.state.timeScaleSelectValue;
- let timeScaleSelected = this.props.customIntervalZoomLevel;
- let frontDate = moment.utc(this.state.deque.peekFront().rawDate);
- let backDate = moment.utc(this.state.deque.peekBack().rawDate);
- // let increment = manualIncrementAmount ? manualIncrementAmount : this.state.increment;
- let increment = this.props.customIntervalValue;
- let draggerTimeState = moment.utc(this.state.draggerTimeState, 'YYYY-MM-DDTHH:mm:ss.SSSZ');
- let draggerTimeStateSubtracted = draggerTimeState.clone().subtract(increment, timeScaleSelected);
-
- let isBetween = draggerTimeStateSubtracted.isBetween(frontDate, backDate, null, '[]');
- let draggerVisible = false;
- let newDraggerPosition;
- if (isBetween) {
- draggerVisible = true;
- }
-
- let gridWidth = this.state.gridWidth;
- let timeScale = this.state.timeScale;
- 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 isVisible = this.state.draggerVisible;
- if (isVisible) {
- newDraggerPosition = this.state.draggerPosition + pixelsToAddBasedOnFrontDate;
- } else {
- newDraggerPosition = pixelsToAddToDraggerNew + this.state.position - 49 + this.state.currentTransformX;
- }
- this.setState({
- draggerPosition: newDraggerPosition,
- draggerVisible: draggerVisible,
- draggerTimeState: draggerTimeStateSubtracted.format(),
- }, this.props.updateDate(draggerTimeStateSubtracted.format()))
- // this.props.incrementDate(timeScaleSelected, increment));
- }
-
handleStopDrag = (e, d) => {
let midPoint = this.state.midPoint;
let position = this.state.position - midPoint;
@@ -1115,31 +1031,6 @@ handleDragDragger = (draggerName, e, d) => {
)
}
- //# HANDLE INCREMENT FORM TESTING
- handleChangeZoomLevel(event) {
- event.preventDefault();
- this.setState({
- timeScale: event.target.value,
- leftOffset: this.state.axisWidth/2
- });
- }
-
- handleChange(event) {
- this.setState({ increment: Number(event.target.value) });
- }
-
- handleSubmit(event) {
- event.preventDefault();
- }
-
- handleReset(event) {
- this.setState({ increment: 1 });
- }
-
- handleTimeScaleSelectChange(event) {
- this.setState({ timeScaleSelectValue: event.target.value })
- }
-
showHoverOn = () => {
if (!this.state.showDraggerTime) {
this.setState({ showHoverLine: true });
@@ -1176,37 +1067,6 @@ handleDragDragger = (draggerName, e, d) => {
window.moment = moment;
return (
<React.Fragment>
- {/* <div style={{display: 'flex', position: 'relative', left: (window.innerWidth * 0.05)}}>
- <div style={{display: 'flex', background: '#999', border: '1px solid black', width: '155px', height: '100px'}}>
- <form onSubmit={this.handleSubmit.bind(this)}>
- <label>
- <input type="text" value={this.state.increment} onChange={(e) => this.handleChange(e)} />
- </label>
- <select value={this.state.timeScaleSelectValue} onChange={(e) => this.handleTimeScaleSelectChange(e)}>
- <option value="minute">minute</option>
- <option value="hour">hour</option>
- <option value="day">day</option>
- <option value="month">month</option>
- <option value="year">year</option>
- </select>
- <button >Set</button>
- <button onClick={() => this.handleReset()}>Reset</button>
-
- </form>
- <button className="incrementButton" onClick={() => this.minusTimeUnit()}>{"<"}</button>
- <button className="incrementButton" onClick={() => this.addTimeUnit()}>{">"}</button>
- </div>
- <div className="changeZoomLevelButtons" style={{display: 'flex', border: '1px solid black'}}>
- <button value="minute" onClick={(e) => this.handleChangeZoomLevel(e)}>minute</button>
- <button value="hour" onClick={(e) => this.handleChangeZoomLevel(e)}>hour</button>
- <button value="day" onClick={(e) => this.handleChangeZoomLevel(e)}>day</button>
- <button value="month" onClick={(e) => this.handleChangeZoomLevel(e)}>month</button>
- <button value="year" onClick={(e) => this.handleChangeZoomLevel(e)}>year</button>
- </div>
- <div>
- <button onClick={(e) => this.toggleCompareMode(e)}>Compare Mode</button>
- </div>
- </div> */}
<div id="wv-timeline-axis"
// ref={this.timelineRef} //# REF
style={{width: `${this.state.axisWidth}px`}}
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.js
new file mode 100644
index 000000000..1e777eb2a
--- /dev/null
+++ b/web/js/components/timeline/timeline-controls/axis-zoom-change-controls.js
@@ -0,0 +1,71 @@
+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-tooltip.js b/web/js/components/timeline/timeline-controls/axis-zoom-change-tooltip.js
new file mode 100644
index 000000000..d8c4fa91b
--- /dev/null
+++ b/web/js/components/timeline/timeline-controls/axis-zoom-change-tooltip.js
@@ -0,0 +1,81 @@
+import React, { PureComponent } from 'react';
+
+const timeUnitAbbreviations = {
+ year: 'year',
+ month: 'mon',
+ day: 'day',
+ hour: 'hour',
+ minute: 'min'
+};
+
+class AxisZoomChangeTooltip extends PureComponent {
+
+ handleClickZoom = (zoomSelected) => {
+ this.props.changeZoomLevel(zoomSelected);
+ }
+
+ render() {
+ return (
+ <React.Fragment>
+ <div id="zoom-btn-container-axis"
+ >
+ {/* timeScale display */}
+ <span
+ id="current-zoom"
+ className={'zoom-btn zoom-level-display-text'}
+ >
+ {timeUnitAbbreviations[this.props.zoomLevel]}
+ </span>
+
+ {/* hover timeScale unit dialog / entry point to Custom selector */}
+ <div className="wv-zoom-tooltip"
+ style={{ display: this.props.toolTipHovered ? 'block' : 'none' }}
+ >
+ <div id="timeline-zoom" className="timeline-zoom">
+ <label style={{ textDecoration: 'underline', paddingBottom: '4px', color: '#fff' }}>TIMESCALE</label>
+ <span
+ id="zoom-years"
+ className="zoom-btn zoom-btn-inactive zoom-years"
+ onClick={() => this.handleClickZoom('year')}
+ >
+ YEAR
+ </span>
+ <span
+ id="zoom-months"
+ className="zoom-btn zoom-btn-inactive zoom-months"
+ onClick={() => this.handleClickZoom('month')}
+ >
+ MONTH
+ </span>
+ <span
+ id="zoom-days"
+ className="zoom-btn zoom-btn-inactive zoom-days"
+ onClick={() => this.handleClickZoom('day')}
+ >
+ DAY
+ </span>
+ <span
+ id="zoom-hours"
+ className="zoom-btn zoom-btn-inactive zoom-hours"
+ style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}
+ onClick={() => this.handleClickZoom('hour')}
+ >
+ HOUR
+ </span>
+ <span
+ id="zoom-minutes"
+ className="zoom-btn zoom-btn-inactive zoom-minutes"
+ style={{ display: this.props.hasSubdailyLayers ? 'block' : 'none' }}
+ onClick={() => this.handleClickZoom('minute')}
+ >
+ MINUTE
+ </span>
+ </div>
+ </div>
+ </div>
+ </React.Fragment>
+ );
+ }
+}
+
+export default AxisZoomChangeTooltip;
diff --git a/web/js/components/timeline/timeline-controls/axis-zoom-change.js b/web/js/components/timeline/timeline-controls/axis-zoom-change.js
new file mode 100644
index 000000000..77a85b46c
--- /dev/null
+++ b/web/js/components/timeline/timeline-controls/axis-zoom-change.js
@@ -0,0 +1,139 @@
+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) => {
+ console.log(isHovered)
+ 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() {
+ console.log(this.props)
+ 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-zoom-change.js b/web/js/components/timeline/timeline-controls/date-zoom-change.js
index a3a2ffae8..60b3b534a 100644
--- a/web/js/components/timeline/timeline-controls/date-zoom-change.js
+++ b/web/js/components/timeline/timeline-controls/date-zoom-change.js
@@ -58,7 +58,7 @@ class DateZoomChange extends Component {
id="current-zoom"
className={`zoom-btn zoom-btn-active${this.state.customSelected ? ' custom-interval-text' : ''}`}
>
- {this.state.intervalText}
+ {this.state.customSelected ? this.state.intervalText : '1 ' + this.state.intervalText}
</span>
{/* hover timeScale unit dialog / entry point to Custom selector */}
@@ -87,6 +87,13 @@ class DateZoomChange extends Component {
>
Day
</span>
+ <span
+ id="zoom-hours"
+ className="zoom-btn zoom-btn-inactive zoom-hours"
+ onClick={() => this.handleClickZoom('hour')}
+ >
+ Hour
+ </span>
<span
id="zoom-minutes"
className="zoom-btn zoom-btn-inactive zoom-minutes"
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 1c6f507d0..5f1aed5cc 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -138,6 +138,32 @@ form select {
background: #999;
}
+.zoom-level-display-text {
+ color: white;
+ font-family: 'Roboto Mono', monospace;
+ text-align: center;
+ font-size: 20px;
+ line-height: 1.2em;
+ vertical-align: baseline;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ text-transform: uppercase;
+ margin: 4px 0 4px 0;
+ display: block;
+}
+
+.zoom-level-change-arrows {
+ user-select: none;
+ background: transparent;
+ border: 1px solid transparent;
+ vertical-align: middle;
+ box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ width: 55px;
+ padding-top: 7px;
+}
+
.interval-input {
width: 80px;
height: 40px;
@@ -204,19 +230,21 @@ form select {
.wv-timeline-hide-arrow {
vertical-align: middle;
display: block;
- margin: 26px 0 0 10px;
- font-size: 40px;
+ margin: 26px 0 0 7px;
+ /* font-size: 40px; */
color: white;
cursor: pointer;
- background: rgba(40, 40, 40, 0.9);
- width: 40px;
+ /* background: rgba(40, 40, 40, 0.9); */
+ /* width: 40px; */
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
- padding-left: 2px;
- transform: scale(1.5,1);
+ /* padding-left: 2px; */
+ /* transform: scale(1.75,1); */
+ user-select: none;
}
-.wv-timeline-hide-arrow:hover {
+
+#timeline-hide:hover .wv-timeline-hide-arrow {
color: #1a1a1a;
background: white;
}
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index 8622840c1..2499970f8 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -12,6 +12,8 @@ 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';
+
class Timeline extends React.Component {
constructor(props) {
super(props);
@@ -77,6 +79,15 @@ class Timeline extends React.Component {
}));
}
+ // Change the timescale parent state
+ changeTimescale = (timeScale) => {
+ if (this.state.timeScale !== timeScale) {
+ this.setState({
+ timeScale: timeScale
+ });
+ }
+ }
+
componentDidUpdate(prevProps, prevState) {
// console.log('CDU', this.state, this.props)
}
@@ -238,17 +249,27 @@ class Timeline extends React.Component {
subdaily={this.props.subdaily}
parentOffset={this.props.parentOffset}
resetInput={this.resetInput}
+ changeTimescale={this.changeTimescale}
/>
{/* </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}
+ changeTimescale={this.changeTimescale}
+ hasSubdailyLayers={this.state.hasSubdailyLayers}
+ />
+ </div>
+
+
<div id="timeline-hide" onClick={this.toggleHideTimeline}>
{this.state.timelineHidden ?
- <i className="far fa-caret-square-right wv-timeline-hide-arrow"></i>
+ <i className="fas fa-chevron-right wv-timeline-hide-arrow"></i>
:
- <i className="far fa-caret-square-left 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" />
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index a0db3a7b6..bc6ddab21 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -297,7 +297,6 @@ export function timeline(models, config, ui) {
* @return {void}
*/
var stopper = function() {
- console.log('stoppppp')
if (animationInProcess) {
animationInProcess = false;
// # invokes when mouse over < > and date selector arrows/boxes
@@ -334,6 +333,7 @@ export function timeline(models, config, ui) {
// $('#timeline-hide').outerWidth(true) -
self.parentOffset -
20 -
+ 20 -
self.margin.left -
self.margin.right +
28;