Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

change date format to YYYY MMM DD axis tooltip, compare sidebar tabs, compare swiper, layer coverage, update styling and tests

Ed Plato41827192db8a
diff --git a/e2e/features/compare/compare-mobile-test.js b/e2e/features/compare/compare-mobile-test.js
index 10e0b8844..47d6627d1 100644
--- a/e2e/features/compare/compare-mobile-test.js
+++ b/e2e/features/compare/compare-mobile-test.js
@@ -41,12 +41,12 @@ module.exports = {
'Toggling to B compare side changes mobile date picker date': (c) => {
// confirm initial A mobile date picker date
c.waitForElementVisible(mobileDatePickerSelectButton, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectButton, '2018-08-17');
+ c.assert.containsText(mobileDatePickerSelectButton, '2018 AUG 17');
});
// click B compare toggle button and confirm B mobile date picker date
c.click(bMobileCompareButton);
c.waitForElementVisible(mobileDatePickerSelectButton, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectButton, '2018-08-16');
+ c.assert.containsText(mobileDatePickerSelectButton, '2018 AUG 16');
});
},
diff --git a/e2e/features/compare/permalinks-test.js b/e2e/features/compare/permalinks-test.js
index f5bbd9fb4..820254608 100644
--- a/e2e/features/compare/permalinks-test.js
+++ b/e2e/features/compare/permalinks-test.js
@@ -23,7 +23,7 @@ module.exports = {
client.assert.cssClassPresent(localSelectors.aTab, 'active');
client
.useCss()
- .assert.containsText(localSelectors.aTab, 'A: 2018-08-17');
+ .assert.containsText(localSelectors.aTab, 'A: 2018 AUG 17');
},
);
},
@@ -34,7 +34,7 @@ module.exports = {
client.waitForElementVisible('#ab-slider-case', TIME_LIMIT, () => {
client.expect.element(localSelectors.opacityButton).to.not.be.enabled;
client.assert.cssClassPresent(localSelectors.bTab, 'active');
- client.useCss().assert.containsText(localSelectors.bTab, 'B: 2018-08-16');
+ client.useCss().assert.containsText(localSelectors.bTab, 'B: 2018 AUG 16');
});
},
'Spy mode is active in B state': function(client) {
@@ -42,7 +42,7 @@ module.exports = {
client.waitForElementPresent('.ab-spy-span', TIME_LIMIT, () => {
client.expect.element(localSelectors.spyButton).to.not.be.enabled;
client.assert.cssClassPresent(localSelectors.bTab, 'active');
- client.useCss().assert.containsText(localSelectors.bTab, 'B: 2018-08-16');
+ client.useCss().assert.containsText(localSelectors.bTab, 'B: 2018 AUG 16');
});
},
/**
diff --git a/e2e/features/compare/timeline-test.js b/e2e/features/compare/timeline-test.js
index 87e41dc1c..411cef7bd 100644
--- a/e2e/features/compare/timeline-test.js
+++ b/e2e/features/compare/timeline-test.js
@@ -56,7 +56,7 @@ module.exports = {
);
},
'Dragging B dragger updates date in label': function(client) {
- client.useCss().assert.containsText(localSelectors.bTab, '2018-08-16');
+ client.useCss().assert.containsText(localSelectors.bTab, '2018 AUG 16');
client
.useCss()
.moveToElement(draggerB, 20, 20)
@@ -65,7 +65,7 @@ module.exports = {
.mouseButtonUp(0)
.pause(2000);
client.getText(localSelectors.bTab, function(result) {
- this.assert.notEqual('B: 2018-08-16', result.value);
+ this.assert.notEqual('B: 2018 AUG 16', result.value);
});
},
'Deactivate A|B is no longer active': function(client) {
diff --git a/e2e/features/social/share-test.js b/e2e/features/social/share-test.js
index a29a4d7f1..e44991597 100644
--- a/e2e/features/social/share-test.js
+++ b/e2e/features/social/share-test.js
@@ -4,33 +4,33 @@ const localSelectors = require('../../reuseables/selectors.js');
const TIME_LIMIT = 10000;
const {
- socialToolbar,
- socialCopyLinkButton,
- socialLinkInput,
+ shareToolbar,
+ shareToolbarButton,
+ shareLinkInput,
} = localSelectors;
module.exports = {
before(client) {
reuseables.loadAndSkipTour(client, TIME_LIMIT);
},
- 'Clicking the social link button opens the social share dialog': (client) => {
- client.waitForElementVisible(socialCopyLinkButton, TIME_LIMIT);
- client.click(socialCopyLinkButton);
- client.waitForElementVisible(socialToolbar, TIME_LIMIT);
- client.expect.element(socialToolbar).to.be.present;
+ 'Clicking the share link button opens the share dialog': (client) => {
+ client.waitForElementVisible(shareToolbarButton, TIME_LIMIT);
+ client.click(shareToolbarButton);
+ client.waitForElementVisible(shareToolbar, TIME_LIMIT);
+ client.expect.element(shareToolbar).to.be.present;
},
'Share link clipboard with existing time query string param in the page url will have the same serialized time': (client) => {
const queryString = '?t=2018-12-31';
client.url(client.globals.url + queryString);
- client.waitForElementVisible(socialCopyLinkButton, TIME_LIMIT);
- client.click(socialCopyLinkButton);
+ client.waitForElementVisible(shareToolbarButton, TIME_LIMIT);
+ client.click(shareToolbarButton);
client.assert.urlContains('t=');
- client.assert.attributeContains(socialLinkInput, 'value', `${client.globals.url}?t=2018-12-31-T00%3A00%3A00Z`);
+ client.assert.attributeContains(shareLinkInput, 'value', `${client.globals.url}?t=2018-12-31-T00%3A00%3A00Z`);
},
'Share link clipboard with no time query string param in the page url will have the same serialized time (partial YYYY-MM-DD)': (client) => {
reuseables.loadAndSkipTour(client, TIME_LIMIT);
- client.waitForElementVisible(socialCopyLinkButton, TIME_LIMIT);
- client.click(socialCopyLinkButton);
+ client.waitForElementVisible(shareToolbarButton, TIME_LIMIT);
+ client.click(shareToolbarButton);
let date = new Date();
if (date.getUTCHours() < 3) {
date = new Date(date.getTime() - 86400000);
@@ -41,7 +41,7 @@ module.exports = {
const monthText = month < 10 ? `0${month}` : month;
const dayText = day < 10 ? `0${day}` : day;
client.assert.not.urlContains('t=');
- client.assert.attributeContains(socialLinkInput, 'value', `t=${year}-${monthText}-${dayText}`);
+ client.assert.attributeContains(shareLinkInput, 'value', `t=${year}-${monthText}-${dayText}`);
},
after(client) {
client.end();
diff --git a/e2e/features/timeline/timeline-mobile-test.js b/e2e/features/timeline/timeline-mobile-test.js
index 426826a1e..8f0f51214 100644
--- a/e2e/features/timeline/timeline-mobile-test.js
+++ b/e2e/features/timeline/timeline-mobile-test.js
@@ -13,7 +13,7 @@ module.exports = {
},
'date.mob.init.2a: Before 3:00 UTC: load yesterdays date': (c) => {
c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-14');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013 MAR 14');
});
},
'date.mob.init.2b: Before 3:00 UTC: right button is not disabled': (c) => {
@@ -25,7 +25,7 @@ module.exports = {
'date.mob.init.3a: After 3:00 UTC: load todays date': (c) => {
c.url(`${c.globals.url}?now=2013-03-15T4`);
c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-15');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013 MAR 15');
});
},
'date.mob.init.3b:After 3:00 UTC: right button is disabled': (c) => {
@@ -35,16 +35,16 @@ module.exports = {
'date.mob.range.1: Date label should show 2013-07-20': (c) => {
c.url(`${c.globals.url}?now=2013-03-15T12`);
c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectBtn, '2013-03-15');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013 MAR 15');
});
},
- 'date.mob.range.2: mobile selector header should show 2013-03-15': (c) => {
+ 'date.mob.range.2: mobile selector header should show 2013 MAR 15': (c) => {
c.click(mobileDatePickerSelectBtn);
c.waitForElementVisible(datepickerHeader, TIME_LIMIT, (e) => {
- c.assert.containsText(datepickerHeader, '2013-03-15');
+ c.assert.containsText(datepickerHeader, '2013 MAR 15');
});
},
- 'date.mob.range.3: Date label should show 2012-03-15 after year drag': (c) => {
+ 'date.mob.range.3: Date label should show 2012 MAR 15 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='2013']", 15, 15)
.pause(300)
.mouseButtonDown(0)
@@ -53,26 +53,26 @@ module.exports = {
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2012-03-15');
+ c.assert.containsText(datepickerHeader, '2012 MAR 15');
},
- 'date.mob.range.4: Date in header should be 2012-01-15 after month drag': (c) => {
- c.moveToElement('xpath', "//li[text()='03']", 10, 10)
+ 'date.mob.range.4: Date in header should be 2012 JAN 15 after month drag': (c) => {
+ c.moveToElement('xpath', "//li[text()='Mar']", 10, 10)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='04']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Apr']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='02']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Feb']", 10, 10)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='03']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Mar']", 10, 10)
.pause(300)
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2012-01-15');
+ c.assert.containsText(datepickerHeader, '2012 JAN 15');
},
- 'date.mob.range.5: Date in header should be 2012-01-19 after day drag': (c) => {
+ 'date.mob.range.5: Date in header should be 2012 JAN 19 after day drag': (c) => {
c.moveToElement('xpath', "//li[text()='15']", 10, 10)
.pause(300)
.mouseButtonDown(0)
@@ -99,24 +99,24 @@ module.exports = {
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2012-01-19');
+ c.assert.containsText(datepickerHeader, '2012 JAN 19');
},
'date.mob.range.6: Click okay button verify date has updated': (c) => {
c.useXpath().click("//a[text()='OK']");
c.pause(300);
c.useCss();
- c.assert.containsText(mobileDatePickerSelectBtn, '2012-01-19');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2012 JAN 19');
},
- 'date.mob.nav.1: Date label should show 2013-07-20': (c) => {
+ 'date.mob.nav.1: Date label should show 2013 JUL 20': (c) => {
c.url(`${c.globals.url}?now=2014-03-15&t=2013-07-20T12`);
c.waitForElementVisible(mobileDatePickerSelectBtn, TIME_LIMIT, (e) => {
- c.assert.containsText(mobileDatePickerSelectBtn, '2013-07-20');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013 JUL 20');
});
},
- 'date.mob.nav.2a: mobile selector header should show 2013-07-20': (c) => {
+ 'date.mob.nav.2a: mobile selector header should show 2013 JUL 20': (c) => {
c.click(mobileDatePickerSelectBtn);
c.waitForElementVisible(datepickerHeader, TIME_LIMIT, (e) => {
- c.assert.containsText(datepickerHeader, '2013-07-20');
+ c.assert.containsText(datepickerHeader, '2013 JUL 20');
});
},
'date.mob.nav.2b: Year 2014 should be disabled and 2013 is not': (c) => {
@@ -127,42 +127,42 @@ module.exports = {
c.expect.element("//li[text()='2013']").to.be.present;
});
},
- 'date.mob.nav.3: Date in header should be 2013-02-20 after year drag': (c) => {
- c.moveToElement('xpath', "//li[text()='07']", 15, 15)
+ 'date.mob.nav.3: Date in header should be 2013 FEB 20 after year drag': (c) => {
+ c.moveToElement('xpath', "//li[text()='Jul']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='08']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Aug']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='06']", 15, 15)
+ .moveToElement('xpath', "//li[text()='Jun']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='07']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Jul']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='05']", 15, 15)
+ .moveToElement('xpath', "//li[text()='May']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='06']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Jun']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='04']", 15, 15)
+ .moveToElement('xpath', "//li[text()='Apr']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='05']", 10, 10)
+ .moveToElement('xpath', "//li[text()='May']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='03']", 15, 15)
+ .moveToElement('xpath', "//li[text()='Mar']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='04']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Apr']", 10, 10)
.pause(300)
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2013-02-20');
+ c.assert.containsText(datepickerHeader, '2013 FEB 20');
},
- 'date.mob.nav.4: Date label should show 2014-02-20 after year drag': (c) => {
+ 'date.mob.nav.4: Date label should show 2014 FEB 20 after year drag': (c) => {
c.moveToElement('xpath', "//li[text()='2013']", 15, 15)
.pause(300)
.mouseButtonDown(0)
@@ -171,30 +171,30 @@ module.exports = {
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2014-02-20');
+ c.assert.containsText(datepickerHeader, '2014 FEB 20');
},
- 'date.mob.nav.5: Date in header should be 2013-12-20 after year drag': (c) => {
- c.moveToElement('xpath', "//li[text()='02']", 15, 15)
+ 'date.mob.nav.5: Date in header should be 2013 DEC 20 after year drag': (c) => {
+ c.moveToElement('xpath', "//li[text()='Feb']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='03']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Mar']", 10, 10)
.pause(300)
.mouseButtonUp(0)
- .moveToElement('xpath', "//li[text()='01']", 15, 15)
+ .moveToElement('xpath', "//li[text()='Jan']", 15, 15)
.pause(300)
.mouseButtonDown(0)
- .moveToElement('xpath', "//li[text()='02']", 10, 10)
+ .moveToElement('xpath', "//li[text()='Feb']", 10, 10)
.pause(300)
.mouseButtonUp(0);
c.pause(300);
c.useCss();
- c.assert.containsText(datepickerHeader, '2013-12-20');
+ c.assert.containsText(datepickerHeader, '2013 DEC 20');
},
- 'date.mob.nav.6: Click okay button verify date has updated to 2013-12-20': (c) => {
+ 'date.mob.nav.6: Click okay button verify date has updated to 2013 DEC 20': (c) => {
c.useXpath().click("//a[text()='OK']");
c.pause(300);
c.useCss();
- c.assert.containsText(mobileDatePickerSelectBtn, '2013-12-20');
+ c.assert.containsText(mobileDatePickerSelectBtn, '2013 DEC 20');
},
after: (c) => {
c.end();
diff --git a/e2e/features/timeline/timeline-test.js b/e2e/features/timeline/timeline-test.js
index e2c9b6a7f..f20939f19 100644
--- a/e2e/features/timeline/timeline-test.js
+++ b/e2e/features/timeline/timeline-test.js
@@ -132,14 +132,14 @@ module.exports = {
'Date tooltip date present load': (c) => {
c.url(`${c.globals.url}?t=2019-02-22`);
c.waitForElementVisible('.date-tooltip', TIME_LIMIT)
- .assert.containsText('.date-tooltip', '2019-02-22 (DOY 053)');
+ .assert.containsText('.date-tooltip', '2019 FEB 22 (DOY 053)');
},
// date subdaily tooltip date present on load
'Date subdaily tooltip date present load': (c) => {
c.url(c.globals.url + localQueryStrings.subdailyLayerIntervalTimescale);
c.waitForElementVisible('.date-tooltip', TIME_LIMIT)
- .assert.containsText('.date-tooltip', '2019-10-04 09:46Z (DOY 277)');
+ .assert.containsText('.date-tooltip', '2019 OCT 04 09:46Z (DOY 277)');
},
after: (c) => {
diff --git a/e2e/reuseables/selectors.js b/e2e/reuseables/selectors.js
index ddd589f68..9698926f3 100644
--- a/e2e/reuseables/selectors.js
+++ b/e2e/reuseables/selectors.js
@@ -155,15 +155,14 @@ module.exports = {
// ui toolbar
locationSearchToolbarButton: '#wv-location-search-button',
- shareToolbarButton: '#wv-link-button',
+ shareToolbarButton: '#wv-share-button',
projToolbarButton: '#wv-proj-button',
snapshotToolbarButton: '#wv-image-button',
infoToolbarButton: '#wv-info-button',
- // social
- socialToolbar: '#toolbar_share_link',
- socialCopyLinkButton: '#wv-share-button',
- socialLinkInput: '#permalink-content-link',
+ // share
+ shareToolbar: '#toolbar_share_link',
+ shareLinkInput: '#permalink-content-link',
// Location Search
locationSearchComponent: '.location-search-component',
diff --git a/web/css/compare.css b/web/css/compare.css
index c11d14423..4437d418e 100644
--- a/web/css/compare.css
+++ b/web/css/compare.css
@@ -9,12 +9,12 @@
cursor: grab;
user-select: none;
& .show-date-label {
- width: 98px;
+ width: 109px;
}
& .left-label {
left: -23px;
&.show-date-label {
- left: -107px;
+ left: -118px;
}
}
& .right-label {
diff --git a/web/css/sidebar.css b/web/css/sidebar.css
index 03ecaf054..28f2b1847 100644
--- a/web/css/sidebar.css
+++ b/web/css/sidebar.css
@@ -112,8 +112,13 @@
}
/* override bootstrap styles */
-.tab-content .ab-tabs-case .nav-item .active {
- color: #495057;
+.tab-content .ab-tabs-case .nav-item {
+ .active {
+ color: #495057;
+ }
+ .ab-tab {
+ padding-left: 5px;
+ }
}
.nav-item .sidebar-tab.active {
background: #00457b;
diff --git a/web/js/components/timeline/date-util.js b/web/js/components/timeline/date-util.js
index 3534e7a0f..ae4b65d4c 100644
--- a/web/js/components/timeline/date-util.js
+++ b/web/js/components/timeline/date-util.js
@@ -1,3 +1,5 @@
+import util from '../../util/util';
+
// return boolean based on is dateChecking is between front and back dates
export const getIsBetween = (date, frontDate, backDate) => {
const dateValue = new Date(date).getTime();
@@ -17,6 +19,17 @@ export const getDaysInYear = (date) => {
// return string in ISO format "2018-03-16T06:17:30Z"
export const getISODateFormatted = (date) => `${new Date(date).toISOString().split('.')[0]}Z`;
+
+// display date as '2000 OCT 28' for default or '2000 OCT 28 20:28Z' for subdaily
+export const getDisplayDate = (date, isSubdaily) => {
+ let displayDate = util.toISOStringDateMonthAbbrev(new Date(date));
+ if (isSubdaily) {
+ const subdailyHHSSZ = `${getISODateFormatted(date).split('T')[1].split(':', 2).join(':')}Z`;
+ displayDate += ` ${subdailyHHSSZ}`;
+ }
+ return displayDate;
+};
+
// timeRange extension to pop NUM times
export const removeBackMultipleInPlace = (timeRange, num) => {
for (let i = 0; i < num; i += 1) {
diff --git a/web/js/components/timeline/mobile-date-picker.js b/web/js/components/timeline/mobile-date-picker.js
index d1ba31edd..4aed69952 100644
--- a/web/js/components/timeline/mobile-date-picker.js
+++ b/web/js/components/timeline/mobile-date-picker.js
@@ -1,11 +1,25 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import DatePicker from 'react-mobile-datepicker';
-
-import { getISODateFormatted } from './date-util';
+import { getDisplayDate, getISODateFormatted } from './date-util';
// https://www.npmjs.com/package/react-mobile-datepicker
// configs for date order, caption, and date step
+const monthMap = {
+ 1: 'Jan',
+ 2: 'Feb',
+ 3: 'Mar',
+ 4: 'Apr',
+ 5: 'May',
+ 6: 'Jun',
+ 7: 'Jul',
+ 8: 'Aug',
+ 9: 'Sep',
+ 10: 'Oct',
+ 11: 'Nov',
+ 12: 'Dec',
+};
+
const defaultDateConfig = {
year: {
format: 'YYYY',
@@ -13,8 +27,8 @@ const defaultDateConfig = {
step: 1,
},
month: {
- format: 'MM',
- caption: 'Month',
+ format: (value) => monthMap[value.getMonth() + 1],
+ caption: 'Mon',
step: 1,
},
date: {
@@ -31,7 +45,7 @@ const subDailyDateConfig = {
step: 1,
},
month: {
- format: 'MM',
+ format: (value) => monthMap[value.getMonth() + 1],
caption: 'Mon',
step: 1,
},
@@ -82,16 +96,26 @@ class MobileDatePicker extends Component {
}
handleCancel = () => {
+ const {
+ date,
+ } = this.props;
this.setState({
isOpen: false,
+ time: this.convertToUTCDateObject(date),
+ });
+ }
+
+ handleChange = (date) => {
+ this.setState({
+ time: date,
});
}
handleSelect = (time) => {
const { onDateChange } = this.props;
this.setState({
- time,
isOpen: false,
+ time,
});
// convert date back to local time
const date = this.convertToLocalDateObject(time);
@@ -125,6 +149,12 @@ class MobileDatePicker extends Component {
return dateLocal;
}
+ getHeaderTime = (time, isSubdaily) => (
+ <div className="datepicker-header">
+ {getDisplayDate(new Date(this.convertToLocalDateObject(time)), isSubdaily)}
+ </div>
+ )
+
render() {
const {
time,
@@ -136,35 +166,34 @@ class MobileDatePicker extends Component {
date,
hasSubdailyLayers,
} = this.props;
- // display date as '2000-10-28' for default or '2000-10-28 20:28Z' for subdaily
- const displayDate = hasSubdailyLayers ? `${date.split('T').join(' ').split(':', 2).join(':')}Z` : date.split('T')[0];
+ const displayDate = getDisplayDate(date, hasSubdailyLayers);
+
return (
- time
- ? (
- <>
- <div
- className="mobile-date-picker-select-btn"
- onClick={this.handleClickDateButton}
- >
- {displayDate}
- </div>
- <DatePicker
- dateConfig={hasSubdailyLayers ? subDailyDateConfig : defaultDateConfig}
- showCaption
- theme="android-dark"
- headerFormat={hasSubdailyLayers ? 'YYYY-MM-DD hh:mmZ' : 'YYYY-MM-DD'}
- confirmText="OK"
- cancelText="CANCEL"
- min={minDate}
- max={maxDate}
- value={time}
- isOpen={isOpen}
- onSelect={this.handleSelect}
- onCancel={this.handleCancel}
- />
- </>
- )
- : null
+ time && (
+ <>
+ <div
+ className="mobile-date-picker-select-btn"
+ onClick={this.handleClickDateButton}
+ >
+ {displayDate}
+ </div>
+ <DatePicker
+ dateConfig={hasSubdailyLayers ? subDailyDateConfig : defaultDateConfig}
+ showCaption
+ theme="android-dark"
+ customHeader={this.getHeaderTime(time, hasSubdailyLayers)}
+ confirmText="OK"
+ cancelText="CANCEL"
+ min={minDate}
+ max={maxDate}
+ value={time}
+ isOpen={isOpen}
+ onCancel={this.handleCancel}
+ onChange={this.handleChange}
+ onSelect={this.handleSelect}
+ />
+ </>
+ )
);
}
}
diff --git a/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js b/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
index 4b5ecb816..15198d987 100644
--- a/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
+++ b/web/js/components/timeline/timeline-axis/date-tooltip/date-tooltip.js
@@ -1,7 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
-import { getDaysInYear } from '../../date-util';
-import util from '../../../../util/util';
+import { getDaysInYear, getDisplayDate } from '../../date-util';
/*
* Date tooltip for hover and draggers
@@ -62,18 +61,11 @@ class DateTooltip extends Component {
/**
* @param {String} time
- * @returns {String} formatted YYYY-MM-DD -OR- YYYY-MM-DD hh:mmZ (subdaily)
+ * @returns {String} formatted YYYY MMM DD OR YYYY MMM DD hh:mmZ (subdaily)
*/
getTooltipTime = (time) => {
const { hasSubdailyLayers } = this.props;
- const date = new Date(time);
-
- // if subdaily, return YYYY-MM-DD hh:mmZ / 2020-02-15 18:00Z
- if (hasSubdailyLayers) {
- return util.toISOStringMinutes(date).replace('T', ' ');
- }
- // if no subdaily, return YYYY-MM-DD / 2020-02-15
- return util.toISOStringDate(date);
+ return getDisplayDate(new Date(time), hasSubdailyLayers);
};
/**
@@ -97,14 +89,14 @@ class DateTooltip extends Component {
let tooltipHeightOffset;
if (showTooltip || showDraggerTooltip) {
- tooltipLeftOffset = selectedDraggerPosition - (hasSubdailyLayers ? 85 : 52);
+ tooltipLeftOffset = selectedDraggerPosition - (hasSubdailyLayers ? 97 : 60);
display = selectedDraggerPosition > -49 && selectedDraggerPosition < axisWidth - 49
? 'block'
: 'none';
} else if (showHoverTooltip) {
tooltipLeftOffset = hasSubdailyLayers
- ? leftOffset - 134
- : leftOffset - 101;
+ ? leftOffset - 146
+ : leftOffset - 109;
display = 'block';
}
@@ -122,8 +114,8 @@ class DateTooltip extends Component {
}
const width = hasSubdailyLayers
- ? 274
- : 200;
+ ? 286
+ : 212;
return {
transform: `translate(${tooltipLeftOffset}px, ${tooltipHeightOffset}px)`,
@@ -135,7 +127,6 @@ class DateTooltip extends Component {
render() {
const { showTooltip } = this.state;
const {
- hasSubdailyLayers,
hoverTime,
selectedDate,
showDraggerTime,
@@ -150,11 +141,11 @@ class DateTooltip extends Component {
if (showTooltip || showDraggerTooltip) {
// handle dragger tooltip
- tooltipDate = this.getTooltipTime(selectedDate, hasSubdailyLayers);
+ tooltipDate = this.getTooltipTime(selectedDate);
dayOfYear = getDaysInYear(selectedDate);
} else if (showHoverTooltip) {
// handle hover tooltip
- tooltipDate = this.getTooltipTime(hoverTime, hasSubdailyLayers);
+ tooltipDate = this.getTooltipTime(hoverTime);
dayOfYear = getDaysInYear(hoverTime);
}
diff --git a/web/js/components/timeline/timeline-coverage/coverage-item-list.js b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
index cda42c81b..b56c64f1d 100644
--- a/web/js/components/timeline/timeline-coverage/coverage-item-list.js
+++ b/web/js/components/timeline/timeline-coverage/coverage-item-list.js
@@ -172,14 +172,7 @@ class CoverageItemList extends Component {
} = layer;
let dateRangeStart;
if (startDate) {
- const yearMonthDaySplit = startDate.split('T')[0].split('-');
- const year = yearMonthDaySplit[0];
- const month = yearMonthDaySplit[1];
- const day = yearMonthDaySplit[2];
-
- const monthAbbrev = util.monthStringArray[Number(month) - 1];
-
- dateRangeStart = `${year} ${monthAbbrev} ${day}`;
+ dateRangeStart = util.toISOStringDateMonthAbbrev(new Date(startDate));
} else {
dateRangeStart = 'Start';
}
@@ -187,14 +180,7 @@ class CoverageItemList extends Component {
// get end date -or- 'present'
let dateRangeEnd;
if (endDate) {
- const yearMonthDaySplit = endDate.split('T')[0].split('-');
- const year = yearMonthDaySplit[0];
- const month = yearMonthDaySplit[1];
- const day = yearMonthDaySplit[2];
-
- const monthAbbrev = util.monthStringArray[Number(month) - 1];
-
- dateRangeEnd = `${year} ${monthAbbrev} ${day}`;
+ dateRangeEnd = util.toISOStringDateMonthAbbrev(new Date(endDate));
} else {
dateRangeEnd = 'Present';
}
diff --git a/web/js/components/timeline/timeline-coverage/coverage-line.js b/web/js/components/timeline/timeline-coverage/coverage-line.js
index ef688f780..328aa449b 100644
--- a/web/js/components/timeline/timeline-coverage/coverage-line.js
+++ b/web/js/components/timeline/timeline-coverage/coverage-line.js
@@ -1,5 +1,6 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
+import util from '../../../util/util';
/*
* Coverage Line for DOM Element layer coverage.
@@ -27,8 +28,8 @@ class CoverageLine extends PureComponent {
// eslint-disable-next-line default-case
switch (lineType) {
case 'SINGLE':
- dateRangeStart = (startDate && startDate.split('T')[0]) || 'start';
- dateRangeEnd = (endDate && endDate.split('T')[0]) || 'present';
+ dateRangeStart = (startDate && util.toISOStringDateMonthAbbrev(new Date(startDate))) || 'Start';
+ dateRangeEnd = (endDate && util.toISOStringDateMonthAbbrev(new Date(endDate))) || 'Present';
toolTipText = `${dateRangeStart} to ${dateRangeEnd}`;
break;
case 'MULTI':
@@ -42,9 +43,9 @@ class CoverageLine extends PureComponent {
dateRangeStart = dateRangeStart.replace(/[.:]/g, '_');
dateRangeEnd = dateRangeEnd.replace(/[.:]/g, '_');
} else {
- dateRangeStart = startDate.replace(/[.:]/g, '_');
- dateRangeEnd = endDate.replace(/[.:]/g, '_');
- toolTipText = `${dateRangeStart.split('T')[0]} to ${dateRangeEnd.split('T')[0]}`;
+ dateRangeStart = util.toISOStringDateMonthAbbrev(new Date(startDate));
+ dateRangeEnd = util.toISOStringDateMonthAbbrev(new Date(endDate));
+ toolTipText = `${dateRangeStart} to ${dateRangeEnd}`;
}
break;
}
diff --git a/web/js/containers/sidebar/compare.js b/web/js/containers/sidebar/compare.js
index 860bec531..6769ad3ef 100644
--- a/web/js/containers/sidebar/compare.js
+++ b/web/js/containers/sidebar/compare.js
@@ -84,11 +84,13 @@ const mapDispatchToProps = (dispatch) => ({
const mapStateToProps = (state) => {
const { compare, date } = state;
+ const dateStringA = util.toISOStringDateMonthAbbrev(date.selected);
+ const dateStringB = util.toISOStringDateMonthAbbrev(date.selectedB);
return {
isCompareA: compare.isCompareA,
- dateStringA: util.toISOStringDate(date.selected),
- dateStringB: util.toISOStringDate(date.selectedB),
+ dateStringA,
+ dateStringB,
isActive: compare.active,
};
};
diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.js
index 7557b7fee..51b94cd27 100644
--- a/web/js/containers/timeline/timeline.js
+++ b/web/js/containers/timeline/timeline.js
@@ -979,7 +979,7 @@ class Timeline extends React.Component {
const isScreenWidthLessThan450 = screenWidth < 450;
// default positioning
- let mobileLeft = '180px';
+ let mobileLeft = '190px';
let mobileBottom = '10px';
// positioning will change depending on a combination of:
@@ -991,7 +991,7 @@ class Timeline extends React.Component {
mobileLeft = isCompareModeActive ? '112px' : '10px';
mobileBottom = '65px';
} else {
- mobileLeft = '277px';
+ mobileLeft = '287px';
}
} else if (isScreenWidthLessThan350) {
mobileLeft = isCompareModeActive ? '112px' : '10px';
diff --git a/web/js/map/compare/swipe.js b/web/js/map/compare/swipe.js
index 0c4f72d26..d9c8f7b3b 100644
--- a/web/js/map/compare/swipe.js
+++ b/web/js/map/compare/swipe.js
@@ -39,8 +39,8 @@ export default class Swipe {
create(state) {
const { date } = state;
const { selected, selectedB } = date;
- this.dateA = util.toISOStringDate(selected);
- this.dateB = util.toISOStringDate(selectedB);
+ this.dateA = util.toISOStringDateMonthAbbrev(selected);
+ this.dateB = util.toISOStringDateMonthAbbrev(selectedB);
line = addLineOverlay(this.map, this.dateA, this.dateB);
this.update(state);
}
@@ -66,8 +66,8 @@ export default class Swipe {
update(state, groupName) {
const { date } = state;
const { selected, selectedB } = date;
- const dateA = util.toISOStringDate(selected);
- const dateB = util.toISOStringDate(selectedB);
+ const dateA = util.toISOStringDateMonthAbbrev(selected);
+ const dateB = util.toISOStringDateMonthAbbrev(selectedB);
if (dateA !== this.dateA || dateB !== this.dateB) {
this.destroy();
this.create(state);
diff --git a/web/js/util/util.js b/web/js/util/util.js
index af891fae6..31be0b4cf 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -303,6 +303,25 @@ export default (function(self) {
.split('T')[0];
};
+ /**
+ * Converts a date into an ISO string with only the date portion and month abbreviation.
+ *
+ * @method toISOStringDateMonthAbbrev
+ * @static
+ * @param date {Date} the date to convert
+ * @return {string} ISO string in the form of ``YYYY-MMM-DD``.
+ */
+ self.toISOStringDateMonthAbbrev = function(date) {
+ const stringDate = self.toISOStringDate(date).split('-');
+ const year = stringDate[0];
+ const month = stringDate[1];
+ const day = stringDate[2];
+
+ const monthAbbrev = self.monthStringArray[Number(month) - 1];
+
+ return `${year} ${monthAbbrev} ${day}`;
+ };
+
/**
* Converts a time into an ISO string without milliseconds.
*