Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add alert ui & tour-alert component; check localStorage and show alert on dismissing tour modal

ZachTRicea9927a47aa15
diff --git a/web/css/events.css b/web/css/events.css
index 64282db09..3f0fd836d 100644
--- a/web/css/events.css
+++ b/web/css/events.css
@@ -307,15 +307,30 @@
.event-icon-wildfires {
background: url("../images/natural-events/icon-wildfires.svg");
}
+
.events-loading-text {
color: #fff;
padding: 10px;
}
+
+.wv-alert,
.notify-alert {
position: absolute;
top: 60px !important;
right: 10px !important;
left: auto !important;
+ color: #fff;
+ background: #282828;
+ border: #282828;
+ border-radius: 0;
+}
+
+/* combine with notify-alert after dialog boxes have been converted to reacstrap */
+.wv-alert {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-height: 40px;
}
.notify-alert .ui-dialog-content div::after {
diff --git a/web/index.html b/web/index.html
index 0eef62a75..a635d2565 100644
--- a/web/index.html
+++ b/web/index.html
@@ -59,4 +59,4 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<div class="backdrop"></div>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/web/js/alert/ui.js b/web/js/alert/ui.js
new file mode 100644
index 000000000..2ddfd8c96
--- /dev/null
+++ b/web/js/alert/ui.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+import TourAlert from '../components/alert/alert-tour';
+import util from '../util/util';
+
+export function alertUi(ui) {
+ var self = {};
+
+ var init = function() {
+ self.reactComponent = ReactDOM.render(
+ React.createElement(TourAlert, getInitialAlertProps()),
+ document.getElementById('wv-alerts')
+ );
+ };
+
+ var getInitialAlertProps = function() {
+ return {
+ visible: false,
+ showTourAlert: self.showTourAlert
+ };
+ };
+
+ self.showTourAlert = function(e) {
+ var tourAlert = localStorage.getItem('tourAlert');
+
+ if (!util.browser.localStorage) return;
+ if (tourAlert) return;
+
+ localStorage.setItem('tourAlert', !tourAlert);
+
+ self.reactComponent.setState({
+ visible: true
+ });
+ };
+
+ init();
+ return self;
+}
diff --git a/web/js/app.js b/web/js/app.js
index 3a6435f38..21971f127 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -99,6 +99,9 @@ import { parse as tourParser } from './tour/tour';
import { tourModel } from './tour/model';
import { tourUi } from './tour/ui';
+// Alert
+import { alertUi } from './alert/ui';
+
// Other
import { debugConfig, debugLayers } from './debug';
import Brand from './brand';
@@ -436,6 +439,7 @@ class App extends React.Component {
elapsed('ui');
// Create widgets
+ ui.alert = alertUi(ui);
ui.proj = projectionUi(models, config);
ui.tour = tourUi(models, ui, config);
ui.sidebar = sidebarUi(models, config, ui);
diff --git a/web/js/components/alert/alert-tour.js b/web/js/components/alert/alert-tour.js
new file mode 100644
index 000000000..4846a9410
--- /dev/null
+++ b/web/js/components/alert/alert-tour.js
@@ -0,0 +1,35 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Alert } from 'reactstrap';
+
+class TourAlert extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ visible: props.visible
+ };
+
+ this.onDismiss = this.onDismiss.bind(this);
+ }
+
+ onDismiss() {
+ this.setState({ visible: false });
+ }
+
+ render() {
+ return (
+ <div>
+ <Alert className="wv-alert" isOpen={this.state.visible} toggle={this.onDismiss}>
+ <p>To view these tours again. Click the 'Start Tour' link in the "i" button menu above.</p>
+ </Alert>
+ </div>
+ );
+ };
+}
+
+TourAlert.propTypes = {
+ visible: PropTypes.bool.isRequired
+};
+
+export default TourAlert;
diff --git a/web/js/components/tour/modal-complete.js b/web/js/components/tour/modal-tour-complete.js
similarity index 100%
rename from web/js/components/tour/modal-complete.js
rename to web/js/components/tour/modal-tour-complete.js
diff --git a/web/js/components/tour/modal-in-progress.js b/web/js/components/tour/modal-tour-in-progress.js
similarity index 96%
rename from web/js/components/tour/modal-in-progress.js
rename to web/js/components/tour/modal-tour-in-progress.js
index 49b0125b0..05ba53d84 100644
--- a/web/js/components/tour/modal-in-progress.js
+++ b/web/js/components/tour/modal-tour-in-progress.js
@@ -149,7 +149,7 @@ class ModalInProgress extends React.Component {
return (
<div>
- <Modal isOpen={this.props.modalInProgress} toggle={this.props.toggleModalInProgress} wrapClassName='tour tour-in-progress' className={this.props.className + ' ' + this.props.currentStory['type']} backdrop={false}>
+ <Modal isOpen={this.props.modalInProgress} toggle={this.props.toggleModalInProgress} onClosed={this.props.showTourAlert} wrapClassName='tour tour-in-progress' className={this.props.className + ' ' + this.props.currentStory['type']} backdrop={false}>
<ModalHeader toggle={this.props.toggleModalInProgress} charCode="">{this.props.currentStory['title']}<i className="modal-icon" aria-hidden="true"></i></ModalHeader>
<ModalBody>
{/* eslint-disable */}
@@ -176,6 +176,7 @@ ModalInProgress.propTypes = {
currentStoryId: PropTypes.string.isRequired,
decreaseStep: PropTypes.func.isRequired,
incrementStep: PropTypes.func.isRequired,
+ showTourAlert: PropTypes.func.isRequired,
className: PropTypes.string
};
diff --git a/web/js/components/tour/modal-start.js b/web/js/components/tour/modal-tour-start.js
similarity index 85%
rename from web/js/components/tour/modal-start.js
rename to web/js/components/tour/modal-tour-start.js
index ab94d3e96..3313526dc 100644
--- a/web/js/components/tour/modal-start.js
+++ b/web/js/components/tour/modal-tour-start.js
@@ -8,7 +8,7 @@ class ModalStart extends React.Component {
render() {
return (
<div>
- <Modal isOpen={this.props.modalStart} toggle={this.props.toggleModalStart} wrapClassName='tour tour-start' className={this.props.className} backdrop={true}>
+ <Modal isOpen={this.props.modalStart} toggle={this.props.toggleModalStart} onClosed={this.props.showTourAlert} wrapClassName='tour tour-start' className={this.props.className} backdrop={true}>
<ModalHeader toggle={this.props.toggleModalStart} charCode="">Welcome to Worldview!</ModalHeader>
<ModalBody>
<TourIntro toggleModalStart={this.props.toggleModalStart}></TourIntro>
@@ -26,6 +26,7 @@ ModalStart.propTypes = {
modalStart: PropTypes.bool.isRequired,
toggleModalStart: PropTypes.func.isRequired,
selectTour: PropTypes.func.isRequired,
+ showTourAlert: PropTypes.func.isRequired,
className: PropTypes.string
};
diff --git a/web/js/components/tour/tour.js b/web/js/components/tour/tour.js
index 4334944da..7ae000e11 100644
--- a/web/js/components/tour/tour.js
+++ b/web/js/components/tour/tour.js
@@ -1,8 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
-import TourStart from './modal-start';
-import TourInProgress from './modal-in-progress';
-import TourComplete from './modal-complete';
+import TourStart from './modal-tour-start';
+import TourInProgress from './modal-tour-in-progress';
+import TourComplete from './modal-tour-complete';
class Tour extends React.Component {
constructor(props) {
@@ -19,7 +19,8 @@ class Tour extends React.Component {
tourParameter: props.tourParameter,
currentStoryIndex: props.currentStoryIndex,
currentStory: props.currentStory,
- currentStoryId: props.currentStoryId
+ currentStoryId: props.currentStoryId,
+ showTourAlert: props.showTourAlert
};
this.toggleModalStart = this.toggleModalStart.bind(this);
@@ -74,6 +75,7 @@ class Tour extends React.Component {
toggleModalInProgress={this.toggleModalInProgress}
toggleModalComplete={this.toggleModalComplete}
selectTour={this.props.selectTour}
+ showTourAlert={this.props.showTourAlert}
></TourStart>
<TourInProgress
@@ -122,7 +124,8 @@ Tour.propTypes = {
currentStory: PropTypes.object,
currentStoryId: PropTypes.string,
startTour: PropTypes.func.isRequired,
- selectTour: PropTypes.func.isRequired
+ selectTour: PropTypes.func.isRequired,
+ showTourAlert: PropTypes.func.isRequired
};
export default Tour;
diff --git a/web/js/tour/ui.js b/web/js/tour/ui.js
index 7ff330938..eb2a3ef98 100644
--- a/web/js/tour/ui.js
+++ b/web/js/tour/ui.js
@@ -9,6 +9,7 @@ export function tourUi(models, ui, config) {
if (!config.features.tour || !config.stories || !config.storyOrder) {
return;
}
+
self.reactComponent = ReactDOM.render(
React.createElement(Tour, getInitialProps()),
document.getElementById('wv-tour')
@@ -30,7 +31,9 @@ export function tourUi(models, ui, config) {
currentStory: {},
currentStoryId: '',
startTour: self.startTour,
- selectTour: self.selectTour
+ selectTour: self.selectTour,
+ notifyUserOfTour: self.notifyUserOfTour,
+ showTourAlert: ui.alert.showTourAlert
};
};
@@ -45,6 +48,7 @@ export function tourUi(models, ui, config) {
};
self.selectTour = function(e, currentStory, currentStoryIndex, currentStoryId) {
+ console.log('test');
if (e) e.preventDefault();
self.reactComponent.setState({
currentStep: 1,