Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add alert util function #1755

Benjamin Kinga8dcba3f4551
diff --git a/web/css/alert.css b/web/css/alert.css
new file mode 100644
index 000000000..e20643d3f
--- /dev/null
+++ b/web/css/alert.css
@@ -0,0 +1,32 @@
+.wv-alert {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-height: 40px;
+ cursor: pointer;
+ padding: 0;
+ border: none
+}
+.wv-alert div {
+ display: inline-block;
+ padding: 11px;
+}
+.wv-alert div:hover {
+ display: inline-block;
+ background: #dddddd;
+ color: #333333;
+}
+.wv-alert i {
+ color: #d54e21;
+ margin-right: 10px;
+ font-size: 1.4em;
+
+}
+.wv-alert i.exit {
+ color: #fff;
+ margin-left: 10px;
+ font-size: 1.4em;
+}
+.wv-alert div:hover .exit {
+ color: #333333;
+}
\ No newline at end of file
diff --git a/web/css/events.css b/web/css/events.css
index 64bd1f5d4..c9f693ce7 100644
--- a/web/css/events.css
+++ b/web/css/events.css
@@ -325,13 +325,6 @@
border-radius: 0;
}
-.wv-alert {
- display: flex;
- align-items: center;
- justify-content: center;
- min-height: 40px;
-}
-
.notify-alert .ui-dialog-content div::after {
pointer-events: none;
transform: translateY(50%);
diff --git a/web/js/app.js b/web/js/app.js
index 5f8eefcf6..dbd7b6e5e 100644
--- a/web/js/app.js
+++ b/web/js/app.js
@@ -41,6 +41,7 @@ import '../../node_modules/@fortawesome/fontawesome-free/css/all.css';
import 'react-image-crop/dist/ReactCrop.css';
// App CSS
import '../css/fonts.css';
+import '../css/alert.css';
import '../css/reset.css';
import '../css/compare.css';
import '../css/jquery-ui-override.css';
@@ -107,7 +108,7 @@ class App extends React.Component {
<div id="dlMap" />
<Timeline />
<div id="wv-animation-widet-case">
- { isAnimationWidgetActive ? <AnimationWidget /> : null }
+ {isAnimationWidgetActive ? <AnimationWidget /> : null}
</div>
<OlCoordinates mouseEvents={this.props.mapMouseEvents} />
<Modal />
diff --git a/web/js/components/compare/alert.js b/web/js/components/compare/alert.js
new file mode 100644
index 000000000..8e3d0fa17
--- /dev/null
+++ b/web/js/components/compare/alert.js
@@ -0,0 +1,35 @@
+import React from 'react';
+
+export class compareAlertModalBody extends React.Component {
+ render() {
+ return (
+ <div className="compare-dialog">
+ <p>How to get started?</p>
+ <ul>
+ <li className="compare-dialog-list-item">
+ <p>
+ Select the respective tab (A or B) in order to update the layers
+ and date of that state.
+ </p>
+ <img src="images/ab-tabs.png" />
+ </li>
+ <li className="compare-dialog-list-item">
+ <p>
+ There are now two time sliders on the timeline. You can click on
+ the deactivated time slider to activate that state and change the
+ date.
+ </p>
+ <img src="images/ab-picks.png" />
+ </li>
+ <li className="compare-dialog-list-item">
+ <p>
+ There are three compare modes. You can choose different modes
+ using the selection at the bottom of the layer list.
+ </p>
+ <img src="images/ab-modes.png" />
+ </li>
+ </ul>
+ </div>
+ );
+ }
+}
diff --git a/web/js/components/util/alert.js b/web/js/components/util/alert.js
new file mode 100644
index 000000000..6751375f7
--- /dev/null
+++ b/web/js/components/util/alert.js
@@ -0,0 +1,50 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Alert } from 'reactstrap';
+import { Portal } from 'react-portal';
+/*
+ * A react component, Builds a rather specific
+ * interactive widget
+ *
+ * @class OpacitySlider
+ * @extends React.Component
+ */
+export default class AlertComponent extends React.Component {
+ render() {
+ return (
+ <Portal node={document && document.getElementById('wv-content')}>
+ <Alert className="wv-alert" isOpen={this.props.isOpen}>
+ <div
+ className="alert-content"
+ title={this.props.title}
+ onClick={this.props.onClick}
+ >
+ <span>
+ {this.props.iconClassName ? (
+ <i className={this.props.iconClassName} />
+ ) : (
+ ''
+ )}
+ {this.props.message}
+ </span>
+ </div>
+ <div className="close-alert" onClick={this.props.onDismiss}>
+ <i className="fa fa-times exit fa-1x" />
+ </div>
+ </Alert>
+ </Portal>
+ );
+ }
+}
+AlertComponent.defaultProps = {
+ iconClassName: 'fas fa-exclamation-triangle fa-1x',
+ title: ''
+};
+AlertComponent.propTypes = {
+ isOpen: PropTypes.bool,
+ onDismiss: PropTypes.func,
+ onClick: PropTypes.func,
+ message: PropTypes.string,
+ title: PropTypes.string,
+ iconClassName: PropTypes.string
+};
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index b55d785a7..50539d357 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -79,7 +79,8 @@ class ModalContainer extends Component {
CompletelyCustomModal,
bodyComponentProps,
timeout,
- desktopOnly
+ desktopOnly,
+ size
} = newProps;
const style = this.getStyle(newProps);
@@ -101,6 +102,7 @@ class ModalContainer extends Component {
toggle={toggleWithClose}
backdrop={backdrop && type !== 'selection'}
id={lowerCaseId}
+ size={size}
className={
isTemplateModal
? 'template-modal'
diff --git a/web/js/containers/sidebar/compare.js b/web/js/containers/sidebar/compare.js
index 46b7100b7..55c736eaf 100644
--- a/web/js/containers/sidebar/compare.js
+++ b/web/js/containers/sidebar/compare.js
@@ -5,10 +5,24 @@ import { getLayers } from '../../modules/layers/selectors';
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 { openCustomContent } from '../../modules/modal/actions';
import { Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';
const tabHeight = 32;
class CompareCase extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ showAlert: props.showAlert
+ };
+ this.dismissAlert = this.dismissAlert.bind(this);
+ }
+ dismissAlert() {
+ localStorage.setItem('dismissedCompareAlert', true);
+ this.setState({ showAlert: false });
+ }
render() {
const {
isActive,
@@ -18,12 +32,25 @@ class CompareCase extends React.Component {
isCompareA,
height,
layersA,
- layersB
+ layersB,
+ openAlertModal
} = this.props;
+
const outerClass = 'layer-container sidebar-panel';
const tabClasses = 'ab-tab';
return (
<div className={isActive ? '' : 'hidden '}>
+ {this.state.showAlert ? (
+ <AlertUtil
+ isOpen={true}
+ onClick={openAlertModal}
+ onDismiss={this.dismissAlert}
+ message="You are now in comparison mode"
+ />
+ ) : (
+ ''
+ )}
+ }
<div className={outerClass}>
<div className="ab-tabs-case">
<Nav tabs>
@@ -81,10 +108,27 @@ class CompareCase extends React.Component {
const mapDispatchToProps = dispatch => ({
toggleActiveCompareState: () => {
dispatch(toggleActiveCompareState());
+ },
+ openAlertModal: () => {
+ dispatch(
+ openCustomContent('compare_mode_info', {
+ headerText: 'You are now in comparison mode',
+ backdrop: false,
+ size: 'lg',
+ wrapClassName: 'clickable-behind-modal',
+ bodyComponent: compareAlertModalBody,
+ desktopOnly: true
+ })
+ );
}
});
function mapStateToProps(state, ownProps) {
- const { layers, compare, date } = state;
+ const { layers, compare, date, browser } = state;
+ const showAlert =
+ util.browser.localStorage &&
+ browser.greaterThan.small &&
+ !localStorage.getItem('dismissedCompareAlert');
+
return {
isCompareA: compare.isCompareA,
layersA: getLayers(layers.active, { group: 'all', proj: 'all' }, state),
@@ -92,7 +136,8 @@ function mapStateToProps(state, ownProps) {
dateStringA: util.toISOStringDate(date.selected),
dateStringB: util.toISOStringDate(date.selectedB),
isActive: compare.active,
- height: ownProps.height
+ height: ownProps.height,
+ showAlert
};
}
CompareCase.propTypes = {
@@ -103,7 +148,9 @@ CompareCase.propTypes = {
isCompareA: PropTypes.bool,
height: PropTypes.number,
layersA: PropTypes.object,
- layersB: PropTypes.object
+ layersB: PropTypes.object,
+ showAlert: PropTypes.bool,
+ openAlertModal: PropTypes.func
};
export default connect(
mapStateToProps,