Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

sync animation panel with draggers, remove custom interval set and reset buttons and functionality, if turn off subdaily reset custom if subdaily zoom level, larger tooltips, styling fixes

Edward Plato660bc6710a70
diff --git a/web/js/animation/range-select.js b/web/js/animation/range-select.js
index 332816afe..72c9e1883 100644
--- a/web/js/animation/range-select.js
+++ b/web/js/animation/range-select.js
@@ -258,11 +258,16 @@ export function animationRangeSelect(models, config, ui) {
* @returns {object} props
*
*/
- self.updateRange = function(startLocation, EndLocation) {
+ self.updateRange = function(startLocation, EndLocation, TEST) {
// var startDate = util.roundTimeTenMinute(timeline.x.invert(startLocation));
// var endDate = util.roundTimeTenMinute(timeline.x.invert(EndLocation));
var startDate = new Date();
var endDate = new Date();
+ if (TEST) {
+ startDate = new Date(startLocation);
+ endDate = new Date(EndLocation);
+ }
+
var state = model.rangeState;
state.startDate = util.toISOStringSeconds(startDate) || 0;
// prevent endDate overdrag from occuring in monthly/yearly by setting to max date limit
diff --git a/web/js/animation/ui.js b/web/js/animation/ui.js
index f0ef5ce9b..6a25d3970 100644
--- a/web/js/animation/ui.js
+++ b/web/js/animation/ui.js
@@ -209,6 +209,7 @@ export function animationUi(models, ui) {
// # need to change subdaily argument for custom intervals - rework for all zoom levels presumably
self.nextDate = function (date) {
+ // console.log(date)
let customSelected = models.date.customSelected;
let interval;
let delta;
@@ -337,6 +338,7 @@ export function animationUi(models, ui) {
var day = new Date(self.state.playIndex);
var startDate = new Date(animModel.rangeState.startDate);
var endDate = new Date(animModel.rangeState.endDate);
+ console.log(startDate, endDate);
var jsTestDate = new Date(testDate);
while (i < queueLength) {
if (self.nextDate(day) > endDate) {
@@ -386,6 +388,7 @@ export function animationUi(models, ui) {
var currentDate;
var startDate = util.parseDateUTC(animModel.rangeState.startDate);
var endDate = util.parseDateUTC(animModel.rangeState.endDate);
+
var lastToQueue;
if (!animModel.rangeState.playing) {
return self.refreshState();
diff --git a/web/js/components/timeline/interval-selector/interval-input.js b/web/js/components/timeline/interval-selector/interval-input.js
index 80ca31723..0ae845c2e 100644
--- a/web/js/components/timeline/interval-selector/interval-input.js
+++ b/web/js/components/timeline/interval-selector/interval-input.js
@@ -1,6 +1,5 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
-// import util from '../../util/util';
/*
* A react component, is a draggable svg
@@ -19,7 +18,9 @@ class IntervalInput extends PureComponent {
}
onClickUp = () => {
let value = this.props.intervalValue;
- this.props.changeInterval(value + 1);
+ if (value < 1000) {
+ this.props.changeInterval(value + 1);
+ }
}
onClickDown = () => {
@@ -56,23 +57,9 @@ class IntervalInput extends PureComponent {
}
}
-// IntervalInput.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
-// };
+IntervalInput.propTypes = {
+ intervalValue: PropTypes.number,
+ changeInterval: PropTypes.func
+};
export default IntervalInput;
diff --git a/web/js/components/timeline/interval-selector/interval-selector.js b/web/js/components/timeline/interval-selector/interval-selector.js
index 6b65728c9..c878d2b78 100644
--- a/web/js/components/timeline/interval-selector/interval-selector.js
+++ b/web/js/components/timeline/interval-selector/interval-selector.js
@@ -1,8 +1,7 @@
-import React from 'react';
+import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import IntervalInput from './interval-input';
import TimeScaleSelect from './timescale-select';
-import Button from '../../util/button';
/*
* A react component, Builds a rather specific
@@ -11,7 +10,7 @@ import Button from '../../util/button';
* @class AnimationWidget
* @extends React.Component
*/
-class CustomIntervalSelectorWidget extends React.Component {
+class CustomIntervalSelectorWidget extends PureComponent {
constructor(props) {
super(props);
this.state = {
@@ -23,20 +22,17 @@ class CustomIntervalSelectorWidget extends React.Component {
changeInterval = (value) => {
this.setState({
intervalValue: value
- })
- }
-
- changeZoomLevel = (value) => {
- this.setState({
- zoomLevel: value
- })
+ }, () => {
+ if (value > 0 && value <= 1000) {
+ this.props.setIntervalChangeUnit(value, this.state.zoomLevel);
+ }
+ });
}
- reset = () => {
+ changeZoomLevel = (zoomLevel) => {
this.setState({
- intervalValue: 1,
- zoomLevel: this.props.customIntervalZoomLevel
- })
+ zoomLevel: zoomLevel
+ }, this.props.setIntervalChangeUnit(this.state.intervalValue, zoomLevel));
}
setIntervalChangeUnit = () => {
@@ -61,23 +57,31 @@ class CustomIntervalSelectorWidget extends React.Component {
})
}
+ componentDidUpdate(prevProps) {
+ if (prevProps.customIntervalValue !== this.props.customIntervalValue
+ || prevProps.zoomLevel !== this.props.zoomLevel) {
+ this.setState({
+ intervalValue: this.props.customIntervalValue,
+ zoomLevel: this.props.customIntervalZoomLevel
+ })
+ }
+ }
+
render() {
return (
<div
id="wv-animation-widget-custom-interval"
- // className={
- // 'wv-animation-widget' + (this.state.maxZoom >= 4 ? ' subdaily' : '')
- // }
onKeyDown={this.handleKeyPress}
className='wv-animation-widget-custom-interval'
- style={{display: this.props.customIntervalModalOpen ? 'block' : 'none'}}
+ style={{display: this.props.customIntervalModalOpen ? 'block' : 'none',
+ left: this.props.hasSubdailyLayers ? '-258px' : '-153px'}}
>
<div>Custom Interval Selector</div>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', marginTop: '10px' }}>
<div style={{display: 'flex', flexDirection: 'row' }}>
<IntervalInput
- intervalValue={this.state.intervalValue}
+ intervalValue={Number(this.state.intervalValue)}
changeInterval={this.changeInterval}
/>
<TimeScaleSelect
@@ -86,21 +90,6 @@ class CustomIntervalSelectorWidget extends React.Component {
changeZoomLevel={this.changeZoomLevel}
/>
</div>
-
- <div style={{display: 'flex', flexDirection: 'column' }} className="custom-interval-buttons">
- <Button
- onClick={this.setIntervalChangeUnit}
- id='set-interval-button'
- text='Set'
- className='red'
- style={{marginBottom: '10px'}}
- />
- <Button
- onClick={() => this.reset()}
- id='reset-interval-button'
- text='Reset'
- />
- </div>
</div>
<i className="fa fa-times wv-close" onClick={this.props.toggleCustomIntervalModal}/>
@@ -110,10 +99,12 @@ class CustomIntervalSelectorWidget extends React.Component {
}
CustomIntervalSelectorWidget.propTypes = {
- hasSubdailyLayers: PropTypes.bool,
+ setIntervalChangeUnit: PropTypes.func,
toggleCustomIntervalModal: PropTypes.func,
customIntervalValue: PropTypes.number,
- customIntervalZoomLevel: PropTypes.string
+ customIntervalZoomLevel: PropTypes.string,
+ customIntervalModalOpen: PropTypes.bool,
+ hasSubdailyLayers: PropTypes.bool
};
export default CustomIntervalSelectorWidget;
diff --git a/web/js/components/timeline/timeline-axis/date-calc.js b/web/js/components/timeline/timeline-axis/date-calc.js
index 8a0484c51..fca4e1ef3 100644
--- a/web/js/components/timeline/timeline-axis/date-calc.js
+++ b/web/js/components/timeline/timeline-axis/date-calc.js
@@ -1,11 +1,6 @@
import moment from 'moment';
-// const pastDateLimit = '1940-01-01T00:00:00.000';
-// const futureDateLimit = '2020-01-01T00:00:00.000';
-const pastDateLimit = moment.utc('1940-01-01T00:00:00.000');
-const futureDateLimit = moment.utc('2020-01-01T00:00:00.000');
-
const timeScaleOptions = {
'minute': {
timeAxis: {
@@ -50,10 +45,6 @@ export default (function (self) {
let startDateLimit = moment.utc(timelineStartDateLimit);
let endDateLimit = moment.utc(timelineEndDateLimit);
- console.log(timelineStartDateLimit, timelineEndDateLimit)
-
-// endDate = endDate.isAfter(currentDate) ? currentDate : endDate;
-// console.log(endDate.format(), currentDate.format)
while (startDate <= endDate) {
let date = startDate.format(format);
let rawDate = startDate.format();
diff --git a/web/js/components/timeline/timeline-axis/timeline-axis.js b/web/js/components/timeline/timeline-axis/timeline-axis.js
index 9c1d49e0e..2f5b3ab72 100644
--- a/web/js/components/timeline/timeline-axis/timeline-axis.js
+++ b/web/js/components/timeline/timeline-axis/timeline-axis.js
@@ -567,8 +567,8 @@ console.log(leftOffset,axisWidth)
// let isBackDateSameOrAfterCurrentDate = time.isSameOrAfter(currentDate);
// if (isBackDateSameOrAfterCurrentDate) {
- let diff = time.diff(currentDate, timeScale);
- console.log(diff)
+ // let diff = time.diff(currentDate, timeScale);
+ // console.log(diff)
// }
// format to strings
@@ -1091,10 +1091,16 @@ console.log(leftOffset,axisWidth)
animationEndLocation: endLocation,
animationStartLocationDate: animationStartLocationDate,
animationEndLocationDate: animationEndLocationDate
+ }, function() {
+ this.props.updateAnimationRange(animationStartLocationDate, animationEndLocationDate)
})
}
render() {
+ let draggerTimeLeftOffest = this.props.draggerSelected === 'selected'
+ ? this.state.draggerPosition - (this.props.hasSubdailyLayers ? 33 : 3)
+ : this.state.draggerPositionB - (this.props.hasSubdailyLayers ? 33 : 3);
+ let hoverTimeLeftOffset = this.props.hasSubdailyLayers ? this.state.leftOffset - 82 : this.state.leftOffset - 52;
return (
<React.Fragment>
<div id="wv-timeline-axis"
@@ -1152,7 +1158,7 @@ console.log(leftOffset,axisWidth)
endLocationDate={this.state.animationEndLocationDate}
timelineStartDateLimit={this.props.timelineStartDateLimit}
timelineEndDateLimit={this.props.timelineEndDateLimit}
- max={{end: false, start: false, startOffset: -50, width: 1000}}
+ max={{end: false, start: false, startOffset: -50, width: this.props.axisWidth}}
pinWidth={5}
height={45}
// onDrag={(sx, ex) => console.log('onDrag', sx, ex)}
@@ -1223,21 +1229,33 @@ console.log(leftOffset,axisWidth)
<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}
+ transform: `translate(${draggerTimeLeftOffest}px, -100px)`,
+ display: this.state.showDraggerTime && this.state.draggerTimeState ? 'block' : 'none',
+ width: this.props.hasSubdailyLayers ? '170px' : '110px'
+ }}
+ >
+ { this.state.showDraggerTime && this.state.draggerTimeState
+ ? this.props.draggerSelected === 'selected'
+ ? this.props.hasSubdailyLayers ? this.state.draggerTimeState : this.state.draggerTimeState.split('T')[0]
+ : this.props.hasSubdailyLayers ? this.state.draggerTimeStateB : this.state.draggerTimeStateB.split('T')[0]
+ : 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>
+ transform: `translate(${hoverTimeLeftOffset}px, -100px)`,
+ display: !this.state.showDraggerTime && this.state.showHoverLine ? 'block' : 'none',
+ width: this.props.hasSubdailyLayers ? '170px' : '110px'
+ }}
+ >
+ { !this.state.showDraggerTime && this.state.hoverTime
+ ? this.props.hasSubdailyLayers ? this.state.hoverTime : this.state.hoverTime.split('T')[0]
+ : null
+ }
+ </div>
</div>
</React.Fragment>
);
diff --git a/web/js/components/timeline/timeline.css b/web/js/components/timeline/timeline.css
index 575f16879..dcf8bad73 100644
--- a/web/js/components/timeline/timeline.css
+++ b/web/js/components/timeline/timeline.css
@@ -30,7 +30,7 @@ html, body {
.dateToolTip {
background: rgb(233, 233, 233);
border: thin solid #555;
- font-size: 9px;
+ font-size: 16px;
text-align: center;
border-radius: 5px;
width: 110px;
@@ -43,9 +43,6 @@ html, body {
display: flex;
flex-direction: row;
align-items: center;
- /* -webkit-clip-path: url('#timelineBoundary');
- clip-path: url('#timelineBoundary'); */
- /* position: 100px; */
}
.grid {
@@ -57,8 +54,6 @@ html, body {
.gridText {
font-size: 24px;
font-weight: 500;
- /* font-size: 10px; */
- /* font-family: Arial, Helvetica, sans-serif; */
font-family: 'Roboto Mono', monospace;
color: white;
pointer-events: none;
@@ -202,34 +197,18 @@ form select {
margin-top: 1px;
}
-.custom-interval-buttons {
- margin-right: 8px;
-}
-
.custom-interval-text {
color: #7890cd !important;
}
-#set-interval-button {
-}
-
-#reset-interval-button {
-
-}
-
.wv-timeline-hide-arrow {
vertical-align: middle;
display: block;
margin: 26px 0 0 7px;
- /* font-size: 40px; */
color: white;
cursor: pointer;
- /* 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.75,1); */
user-select: none;
}
@@ -257,7 +236,7 @@ form select {
.wv-animation-widget-custom-interval {
height: 110px;
- width: 286px;
+ width: 225px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background: #212121;
@@ -286,36 +265,6 @@ form select {
}
/* DEMO DOM CLEANUP */
-
-/* #timeline-footer-svg {
- opacity: 0;
- display: none;
-}
-
-#timeline-header {
- background: rgba(0, 0, 0, 0.8) !important;
-}
-
-.timeline-inner {
- background: rgba(0, 0, 0, 0.5) !important;
-}
-
-#wv-animation-widget-custom-interval {
- left: -180px;
-}
-
-#timeline-hide {
- opacity: 0;
-}
-
-#timeline-footer {
- margin-right: 0px !important;
-}
-
-#wv-animation-widget {
- margin-left: 500px;
-} */
-
/* #timeline-footer svg {
overflow: visible !important;
} */
\ No newline at end of file
diff --git a/web/js/components/timeline/timeline.js b/web/js/components/timeline/timeline.js
index 965b39e28..f16492467 100644
--- a/web/js/components/timeline/timeline.js
+++ b/web/js/components/timeline/timeline.js
@@ -204,6 +204,7 @@ class Timeline extends React.Component {
timelineStartDateLimit={this.state.timelineStartDateLimit}
timelineEndDateLimit={this.state.timelineEndDateLimit}
customIntervalModalOpen={this.state.customIntervalModalOpen}
+ updateAnimationRange={this.props.updateAnimationRange}
/>
</div>
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index 3b5303445..e810e0cee 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -175,11 +175,6 @@ export function timeline(models, config, ui) {
};
};
- // var onDateSelect = function(date) {
- // console.log(date)
- // models.date.select(date);
- // };
-
// ? INPUT ABOVE
self.margin = {
top: 0,
@@ -367,6 +362,11 @@ export function timeline(models, config, ui) {
});
};
+ // TEST updateRange
+ var updateAnimationRange = (startDate, endDate) => {
+ ui.anim.rangeselect.updateRange(startDate, endDate, true);
+ };
+
// update date in model
var updateDate = (date, selectionStr) => {
let updatedDate = new Date(date);
@@ -375,6 +375,7 @@ export function timeline(models, config, ui) {
// set custom interval
var setIntervalInput = (intervalValue, zoomLevel) => {
+ console.log(intervalValue, zoomLevel)
models.date.setCustomInterval(intervalValue, timeScaleToNumberKey[zoomLevel]);
let zoomCustomText = document.querySelector('#zoom-custom');
zoomCustomText.textContent = `${intervalValue} ${zoomLevel.toUpperCase().substr(0, 3)}`;
@@ -384,12 +385,13 @@ export function timeline(models, config, ui) {
customIntervalValue: intervalValue,
customIntervalZoomLevel: zoomLevel,
intervalChangeAmt: intervalValue,
- customIntervalModalOpen: false
+ // customIntervalModalOpen: false
});
};
// set selected interval either custom or standard delta of 1
var setSelectedInterval = (interval, intervalChangeAmt, customSelected) => {
+ console.log(interval, intervalChangeAmt, customSelected)
models.date.setSelectedInterval(timeScaleToNumberKey[interval], customSelected);
self.reactComponent.setState({
timeScaleChangeUnit: interval,
@@ -510,7 +512,8 @@ export function timeline(models, config, ui) {
intervalTimeScale: intervalSelected,
intervalDelta: intervalDelta,
setSelectedInterval: setSelectedInterval,
- customSelected: customSelected
+ customSelected: customSelected,
+ updateAnimationRange: updateAnimationRange
};
};
@@ -614,9 +617,12 @@ export function timeline(models, config, ui) {
} else {
subdaily = models.layers.hasSubDaily();
}
+console.log(models.date.selectedZoom)
+console.log(models.date.customInterval, timeScaleFromNumberKey[models.date.customInterval], models.date.interval, timeScaleFromNumberKey[models.date.interval])
// let subdaily = models.layers.hasSubDaily();
- if (!subdaily && models.date.selectedZoom > 3) {
+ if (!subdaily && (models.date.customInterval > 3 || models.date.interval > 3)) {
+ setIntervalInput(1, 'day')
self.reactComponent.setState({
hasSubdailyLayers: subdaily
}, changeTimeScale('day'));
diff --git a/web/js/map/layerbuilder.js b/web/js/map/layerbuilder.js
index 71de365a2..e9e998227 100644
--- a/web/js/map/layerbuilder.js
+++ b/web/js/map/layerbuilder.js
@@ -125,6 +125,7 @@ export function mapLayerBuilder(models, config, cache, mapUi) {
var dateArray = def.availableDates || [];
if (options.date) {
if (def.period !== 'subdaily') {
+ console.log(options.date)
date = util.clearTimeUTC(new Date(options.date.getTime()));
} else {
date = options.date;