Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Replace natural-events alert with react alert #1755

Benjamin King3fe123febd5c
diff --git a/web/css/events.css b/web/css/events.css
index c9f693ce7..bec9b3e1d 100644
--- a/web/css/events.css
+++ b/web/css/events.css
@@ -393,12 +393,12 @@
line-height: 40px;
}
-.wv-dialog ul {
+.event-alert-modal-body ul {
padding-left: 20px;
margin: 10px 0;
}
-.wv-dialog ul li {
+.event-alert-modal-body ul li {
list-style-type: disc;
display: list-item;
margin: 2px 0 2px 20px;
diff --git a/web/js/components/compare/alert.js b/web/js/components/compare/alert.js
index 8e3d0fa17..6b5c77f2b 100644
--- a/web/js/components/compare/alert.js
+++ b/web/js/components/compare/alert.js
@@ -1,6 +1,6 @@
import React from 'react';
-export class compareAlertModalBody extends React.Component {
+export class CompareAlertModalBody extends React.Component {
render() {
return (
<div className="compare-dialog">
diff --git a/web/js/components/events/alert-body.js b/web/js/components/events/alert-body.js
new file mode 100644
index 000000000..4925efa6a
--- /dev/null
+++ b/web/js/components/events/alert-body.js
@@ -0,0 +1,50 @@
+import React from 'react';
+
+export class EventsAlertModalBody extends React.Component {
+ render() {
+ return (
+ <div className="event-alert-modal-body">
+ <h3 className="wv-data-unavailable-header">
+ Why can’t I see an event?
+ </h3>
+ <p>
+ There are a variety of factors as to why you may not be seeing an
+ event in Worldview at the moment.
+ </p>
+ <ul>
+ <li>
+ Satellite overpass may have occurred before the event. Check out
+ subsequent days or try a different satellite/sensor which has a
+ different overpass time.
+ </li>
+ <li>Cloud cover may obscure the event.</li>
+ <li>
+ Some events don’t appear on the day that they are reported, you may
+ have to wait a day or two for an event to become visible. Try and
+ scroll through the days to see an event’s progression and/or change
+ the satellite/sensor. NOTE: Wildfire events are currently set to
+ automatically display the next day, as fire events often do not
+ appear in the satellite imagery on the day they are reported.
+ </li>
+ <li>
+ The resolution of the imagery may be too coarse to see an event.
+ </li>
+ <li>
+ There are normal swath data gaps in some of the imagery layers due
+ to way the satellite orbits the Earth, and an event may have
+ occurred in the data gap.
+ </li>
+ </ul>
+ <p>
+ This is currently an experimental feature and we are working closely
+ with the provider of these events, the{' '}
+ <a href="https://eonet.sci.gsfc.nasa.gov/" target="_blank">
+ Earth Observatory Natural Event Tracker
+ </a>
+ , to refine this listing to only show events that are visible with our
+ satellite imagery.
+ </p>
+ </div>
+ );
+ }
+}
diff --git a/web/js/components/sidebar/event.js b/web/js/components/sidebar/event.js
index 77db7b82e..372791f64 100644
--- a/web/js/components/sidebar/event.js
+++ b/web/js/components/sidebar/event.js
@@ -76,6 +76,7 @@ class Event extends React.Component {
getReferenceList() {
const { sources, event, selectedDate } = this.props;
if (!selectedDate) return;
+
const references = Array.isArray(event.sources)
? event.sources
: [event.sources];
@@ -156,7 +157,8 @@ Event.propTypes = {
isVisible: PropTypes.bool,
deselectEvent: PropTypes.func,
selectEvent: PropTypes.func,
- sources: PropTypes.array
+ sources: PropTypes.array,
+ isSelected: PropTypes.bool
};
export default Event;
diff --git a/web/js/components/util/alert.js b/web/js/components/util/alert.js
index 6751375f7..6381733b8 100644
--- a/web/js/components/util/alert.js
+++ b/web/js/components/util/alert.js
@@ -26,6 +26,7 @@ export default class AlertComponent extends React.Component {
''
)}
{this.props.message}
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Read More...
</span>
</div>
<div className="close-alert" onClick={this.props.onDismiss}>
diff --git a/web/js/containers/sidebar/compare.js b/web/js/containers/sidebar/compare.js
index 55c736eaf..c4df46309 100644
--- a/web/js/containers/sidebar/compare.js
+++ b/web/js/containers/sidebar/compare.js
@@ -6,10 +6,10 @@ import { toggleActiveCompareState } from '../../modules/compare/actions';
import util from '../../util/util';
import { connect } from 'react-redux';
import AlertUtil from '../../components/util/alert';
-import { compareAlertModalBody } from '../../components/compare/alert';
+import { CompareAlertModalBody } from '../../components/compare/alert';
import { openCustomContent } from '../../modules/modal/actions';
-
import { Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';
+
const tabHeight = 32;
class CompareCase extends React.Component {
constructor(props) {
@@ -116,7 +116,7 @@ const mapDispatchToProps = dispatch => ({
backdrop: false,
size: 'lg',
wrapClassName: 'clickable-behind-modal',
- bodyComponent: compareAlertModalBody,
+ bodyComponent: CompareAlertModalBody,
desktopOnly: true
})
);
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.js
index 474bc308b..1ee4af86b 100644
--- a/web/js/containers/sidebar/events.js
+++ b/web/js/containers/sidebar/events.js
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
import Event from '../../components/sidebar/event';
import Scrollbars from '../../components/util/scrollbar';
import { connect } from 'react-redux';
+import AlertUtil from '../../components/util/alert';
+import { openCustomContent } from '../../modules/modal/actions';
import {
requestEvents,
requestCategories,
@@ -10,6 +12,8 @@ import {
selectEvent,
deselectEvent
} from '../../modules/natural-events/actions';
+import util from '../../util/util';
+import { EventsAlertModalBody } from '../../components/events/alert-body';
import { getEventsWithinExtent } from '../../modules/natural-events/selectors';
import { get as lodashGet } from 'lodash';
import { collapseSidebar } from '../../modules/sidebar/actions';
@@ -18,6 +22,10 @@ class Events extends React.Component {
constructor(props) {
super(props);
this.initRequests();
+ this.state = {
+ showAlert: !localStorage.getItem('dismissedEventVisibilityAlert')
+ };
+ this.dismissAlert = this.dismissAlert.bind(this);
}
initRequests() {
const {
@@ -55,6 +63,10 @@ class Events extends React.Component {
requestCategories(categoryRequestURL);
requestSources(sourceRequestURL);
}
+ dismissAlert() {
+ localStorage.setItem('dismissedEventVisibilityAlert', true);
+ this.setState({ showAlert: false });
+ }
render() {
const {
events,
@@ -66,7 +78,9 @@ class Events extends React.Component {
height,
deselectEvent,
hasRequestError,
- isMobile
+ isMobile,
+ openAlertModal,
+ showAlert
} = this.props;
const errorOrLoadingText = isLoading
? 'Loading...'
@@ -74,49 +88,63 @@ class Events extends React.Component {
? 'There has been an ERROR retrieving events from the EONET events API'
: '';
return (
- <Scrollbars style={{ maxHeight: height + 'px' }}>
- <div id="wv-events">
- <span
- className="events-loading-text"
- style={
- isLoading || hasRequestError
- ? { display: 'block' }
- : { display: 'none' }
- }
- >
- {errorOrLoadingText}
- </span>
- <div
- className="wv-eventslist sidebar-panel"
- style={events ? { display: 'block' } : { display: 'none' }}
- >
- <ul id="wv-eventscontent" className="content map-item-list">
- {events && sources
- ? events.map(event => (
- <Event
- key={event.id}
- event={event}
- selectEvent={() =>
- selectEvent(event.id, event.date, isMobile)
- }
- deselectEvent={deselectEvent}
- isSelected={
- selected.id === event.id && visibleEvents[event.id]
- }
- selectedDate={
- selected.id === event.id && visibleEvents[event.id]
- ? selected.date
- : null
- }
- isVisible={visibleEvents[event.id]}
- sources={sources}
- />
- ))
- : ''}
- </ul>
+ <React.Fragment>
+ {showAlert && this.state.showAlert ? (
+ <AlertUtil
+ isOpen={true}
+ onClick={openAlertModal}
+ onDismiss={this.dismissAlert}
+ message="Events may not be visible at all times."
+ />
+ ) : (
+ ''
+ )}
+ <Scrollbars style={{ maxHeight: height + 'px' }}>
+ <div id="wv-events">
+ <span
+ className="events-loading-text"
+ style={
+ isLoading || hasRequestError
+ ? { display: 'block' }
+ : { display: 'none' }
+ }
+ >
+ {errorOrLoadingText}
+ </span>
+
+ <div
+ className="wv-eventslist sidebar-panel"
+ style={events ? { display: 'block' } : { display: 'none' }}
+ >
+ <ul id="wv-eventscontent" className="content map-item-list">
+ {events && sources
+ ? events.map(event => (
+ <Event
+ showAlert={showAlert}
+ key={event.id}
+ event={event}
+ selectEvent={() =>
+ selectEvent(event.id, event.date, isMobile)
+ }
+ deselectEvent={deselectEvent}
+ isSelected={
+ selected.id === event.id && visibleEvents[event.id]
+ }
+ selectedDate={
+ selected.id === event.id && visibleEvents[event.id]
+ ? selected.date
+ : null
+ }
+ isVisible={visibleEvents[event.id]}
+ sources={sources}
+ />
+ ))
+ : ''}
+ </ul>
+ </div>
</div>
- </div>
- </Scrollbars>
+ </Scrollbars>
+ </React.Fragment>
);
}
}
@@ -127,6 +155,18 @@ const mapDispatchToProps = dispatch => ({
dispatch(collapseSidebar());
}
},
+ openAlertModal: () => {
+ dispatch(
+ openCustomContent('event_visibility_info', {
+ headerText: 'Events may not be visible at all times.',
+ backdrop: false,
+ size: 'lg',
+ wrapClassName: 'clickable-behind-modal',
+ bodyComponent: EventsAlertModalBody,
+ desktopOnly: true
+ })
+ );
+ },
deselectEvent: (id, date) => {
dispatch(deselectEvent());
},
@@ -147,7 +187,8 @@ function mapStateToProps(state) {
requestedEventCategories,
config,
proj,
- browser
+ browser,
+ sidebar
} = state;
const { selected, showAll } = state.events;
@@ -175,6 +216,13 @@ function mapStateToProps(state) {
);
}
+ const showAlert =
+ util.browser.localStorage &&
+ selected.id &&
+ sidebar.activeTab === 'events' &&
+ browser.greaterThan.small &&
+ !localStorage.getItem('dismissedEventVisibilityAlert');
+
return {
events,
showAll,
@@ -185,7 +233,8 @@ function mapStateToProps(state) {
visibleEvents,
apiURL,
config,
- isMobile: browser.lessThan.medium
+ isMobile: browser.lessThan.medium,
+ showAlert
};
}
export default connect(
@@ -213,5 +262,7 @@ Events.propTypes = {
isLoading: PropTypes.bool,
selectEvent: PropTypes.func,
hasRequestError: PropTypes.bool,
- isMobile: PropTypes.bool
+ isMobile: PropTypes.bool,
+ showAlert: PropTypes.bool,
+ openAlertModal: PropTypes.func
};
diff --git a/web/js/map/natural-events/ui.js b/web/js/map/natural-events/ui.js
index b7f8a5bae..6fe886d36 100644
--- a/web/js/map/natural-events/ui.js
+++ b/web/js/map/natural-events/ui.js
@@ -21,7 +21,6 @@ const zoomLevelReference = {
export default function naturalEventsUI(ui, config, store, models) {
var self = {};
- var eventVisibilityAlert;
var map;
var view;
var isLoading = true;
@@ -116,10 +115,6 @@ export default function naturalEventsUI(ui, config, store, models) {
}
} else {
naturalEventMarkers.remove(self.markers);
- if (eventVisibilityAlert) {
- eventVisibilityAlert.dialog('close');
- eventVisibilityAlert = null;
- }
}
};
// get events for projection change
@@ -288,30 +283,6 @@ export default function naturalEventsUI(ui, config, store, models) {
activateLayersForCategory(event.categories[0].title);
}
} else if (!isInitialLoad) store.dispatch(selectDate(util.parseDateUTC(date)));
-
- // Show event visiblity alert
- if (!eventVisibilityAlert) {
- eventVisibilityAlert = wvui.alert(
- eventVisibilityAlertBody,
- 'Events may not be visible at all times.',
- 800,
- 'exclamation-triangle',
- 'fas',
- function() {
- if (util.browser.localStorage) {
- localStorage.setItem('dismissedEventVisibilityAlert', true);
- }
- eventVisibilityAlert.dialog('close');
- }
- );
- }
- if (
- util.browser.localStorage &&
- !localStorage.getItem('dismissedEventVisibilityAlert') &&
- !util.browser.mobileAndTabletDevice
- ) {
- eventVisibilityAlert.dialog('open');
- }
naturalEventsTrack.update(event, ui.map.selected, date, self.selectEvent);
self.selecting = false;
models.map.events.trigger('update-layers'); // hack to update layers
@@ -466,14 +437,3 @@ export default function naturalEventsUI(ui, config, store, models) {
init();
return self;
}
-
-var eventVisibilityAlertBody =
- '<h3 class="wv-data-unavailable-header">Why can’t I see an event?</h3><p>There are a variety of factors as to why you may not be seeing an event in Worldview at the moment.</p>' +
- '<ul>' +
- '<li>Satellite overpass may have occurred before the event. Check out subsequent days or try a different satellite/sensor which has a different overpass time.</li>' +
- '<li>Cloud cover may obscure the event.</li>' +
- '<li>Some events don’t appear on the day that they are reported, you may have to wait a day or two for an event to become visible. Try and scroll through the days to see an event’s progression and/or change the satellite/sensor. NOTE: Wildfire events are currently set to automatically display the next day, as fire events often do not appear in the satellite imagery on the day they are reported.</li>' +
- '<li>The resolution of the imagery may be too coarse to see an event.</li>' +
- '<li>There are normal swath data gaps in some of the imagery layers due to way the satellite orbits the Earth, and an event may have occurred in the data gap.</li>' +
- '</ul>' +
- '<p>This is currently an experimental feature and we are working closely with the provider of these events, the <a href="https://eonet.sci.gsfc.nasa.gov/" target="_blank">Earth Observatory Natural Event Tracker</a>, to refine this listing to only show events that are visible with our satellite imagery.</p>';