Interactive interface for browsing global, full-resolution satellite imagery
add max limit, add exceed limit alert, revise alerts to allow compare and events in mobile
Ed Plato560c22f451f5
diff --git a/web/js/containers/alerts.js b/web/js/containers/alerts.jsindex ce35c3373..484c2b281 100644--- a/web/js/containers/alerts.js+++ b/web/js/containers/alerts.js@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';import AlertUtil from '../components/util/alert';import { openCustomContent } from '../modules/modal/actions';import { hasVectorLayers } from '../modules/layers/util';-import { DISABLE_VECTOR_ALERT, MODAL_PROPERTIES } from '../modules/alerts/constants';+import { DISABLE_VECTOR_ZOOM_ALERT, DISABLE_VECTOR_EXCEEDED_ALERT, MODAL_PROPERTIES } from '../modules/alerts/constants';import safeLocalStorage from '../util/local-storage';import { getActiveLayers } from '../modules/layers/selectors';@@ -61,13 +61,15 @@ class DismissableAlerts extends React.Component {render() {const {- dismissVectorAlert,+ dismissVectorZoomAlert,+ dismissVectorExceededAlert,isCompareActive,isDistractionFreeModeActive,isEmbedModeActive,isEventsActive,isSmall,- isVectorAlertPresent,+ isVectorZoomAlertPresent,+ isVectorExceededAlertPresent,openAlertModal,} = this.props;const {@@ -77,12 +79,14 @@ class DismissableAlerts extends React.Component {distractionFreeModeInitLoad,} = this.state;const { eventModalProps, compareModalProps, vectorModalProps } = MODAL_PROPERTIES;- const hasFailCondition = isSmall- || !HAS_LOCAL_STORAGE+ const hasFailCondition = !HAS_LOCAL_STORAGE|| isEmbedModeActive|| distractionFreeModeInitLoad;if (hasFailCondition) return null;+ const showEventsAlert = !isSmall && !hasDismissedEvents && isEventsActive;+ const showCompareAlert = !isSmall && !hasDismissedCompare && isCompareActive;+return isDistractionFreeModeActive? !hasDismissedDistractionFree && (<AlertUtil@@ -94,7 +98,7 @@ class DismissableAlerts extends React.Component {/>) : (<>- {!hasDismissedEvents && isEventsActive && (+ {showEventsAlert && (<AlertUtilid="event-alert"isOpen@@ -104,7 +108,7 @@ class DismissableAlerts extends React.Component {message="Events may not be visible at all times."/>)}- {!hasDismissedCompare && isCompareActive && (+ {showCompareAlert && (<AlertUtilisOpennoPortal@@ -113,15 +117,23 @@ class DismissableAlerts extends React.Component {message="You are now in comparison mode."/>)}- {isVectorAlertPresent && (+ {isVectorZoomAlertPresent && (<AlertUtilisOpennoPortalonClick={() => openAlertModal(vectorModalProps)}- onDismiss={dismissVectorAlert}+ onDismiss={dismissVectorZoomAlert}message="Vector features may not be clickable at all zoom levels."/>)}+ {isVectorExceededAlertPresent && (+ <AlertUtil+ isOpen+ noPortal+ onDismiss={dismissVectorExceededAlert}+ message="Too many results at selected point. Zoom in map to see more individual points."+ />+ )}</>);}@@ -130,14 +142,16 @@ const mapDispatchToProps = (dispatch) => ({openAlertModal: ({ id, props }) => {dispatch(openCustomContent(id, props));},- dismissVectorAlert: () => dispatch({ type: DISABLE_VECTOR_ALERT }),+ dismissVectorZoomAlert: () => dispatch({ type: DISABLE_VECTOR_ZOOM_ALERT }),+ dismissVectorExceededAlert: () => dispatch({ type: DISABLE_VECTOR_EXCEEDED_ALERT }),});const mapStateToProps = (state) => {const {browser, embed, events, sidebar, compare, alerts, ui,} = state;- const { isVectorAlertActive } = alerts;+ const { isVectorZoomAlertPresent, isVectorExceededAlertPresent } = alerts;const activeLayers = getActiveLayers(state);+ const hasActiveVectorLayers = hasVectorLayers(activeLayers);return {isCompareActive: compare.active,@@ -145,7 +159,8 @@ const mapStateToProps = (state) => {isEmbedModeActive: embed.isEmbedModeActive,isEventsActive: !!(events.selected.id && sidebar.activeTab === 'events'),isSmall: browser.lessThan.small,- isVectorAlertPresent: hasVectorLayers(activeLayers) && isVectorAlertActive,+ isVectorZoomAlertPresent: hasActiveVectorLayers && isVectorZoomAlertPresent,+ isVectorExceededAlertPresent: hasActiveVectorLayers && isVectorExceededAlertPresent,};};export default connect(@@ -154,12 +169,14 @@ export default connect()(DismissableAlerts);DismissableAlerts.propTypes = {- dismissVectorAlert: PropTypes.func,+ dismissVectorZoomAlert: PropTypes.func,+ dismissVectorExceededAlert: PropTypes.func,isCompareActive: PropTypes.bool,isDistractionFreeModeActive: PropTypes.bool,isEmbedModeActive: PropTypes.bool,isEventsActive: PropTypes.bool,isSmall: PropTypes.bool,- isVectorAlertPresent: PropTypes.bool,+ isVectorZoomAlertPresent: PropTypes.bool,+ isVectorExceededAlertPresent: PropTypes.bool,openAlertModal: PropTypes.func,};diff --git a/web/js/containers/map-interactions/ol-vector-interactions.js b/web/js/containers/map-interactions/ol-vector-interactions.jsindex 496ccdbc7..77f0df795 100644--- a/web/js/containers/map-interactions/ol-vector-interactions.js+++ b/web/js/containers/map-interactions/ol-vector-interactions.js@@ -16,7 +16,7 @@ import { onMapClickGetVectorFeatures } from '../../modules/vector-styles/util';import { openCustomContent, onClose } from '../../modules/modal/actions';import { selectVectorFeatures as selectVectorFeaturesActionCreator } from '../../modules/vector-styles/actions';import { changeCursor as changeCursorActionCreator } from '../../modules/map/actions';-import { ACTIVATE_VECTOR_ALERT } from '../../modules/alerts/constants';+import { ACTIVATE_VECTOR_ZOOM_ALERT, ACTIVATE_VECTOR_EXCEEDED_ALERT } from '../../modules/alerts/constants';import util from '../../util/util';const { events } = util;@@ -71,7 +71,7 @@ export class VectorInteractions extends React.Component {const {browser, lastSelected, openVectorDialog, onCloseModal, selectVectorFeatures,modalState, getDialogObject, measureIsActive, activeLayers,- activateVectorAlert, proj, isEmbedModeActive,+ activateVectorZoomAlert, activateVectorExceededResultsAlert, proj, isEmbedModeActive, isMobile,} = this.props;if (measureIsActive) return;@@ -83,23 +83,29 @@ export class VectorInteractions extends React.Component {const offsetLeft = clickObj.offsetLeft || 10;const offsetTop = clickObj.offsetTop || 100;const isCoordinatesMarker = clickObj.isCoordinatesMarker || false;+ const exceededLengthLimit = clickObj.exceededLengthLimit || false;const dialogId = isVectorModalOpen ? modalState.id : `vector_dialog${pixels[0]}${pixels[1]}`;if (isCoordinatesMarker) {return;}+ const mapRes = map.getView().getResolution();+ const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes, proj.id, isMobile);if (metaArray.length) {- openVectorDialog(dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive);- } else {- const mapRes = map.getView().getResolution();- const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes, proj.id);-if (hasNonClickableVectorLayerType) {- activateVectorAlert();+ activateVectorZoomAlert();+ } else {+ openVectorDialog(dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive);+ if (exceededLengthLimit) {+ activateVectorExceededResultsAlert();+ }}+ } else if (hasNonClickableVectorLayerType) {+ activateVectorZoomAlert();}if (Object.entries(selected).length || (Object.entries(lastSelected).length && !isVectorModalOpen)) {+ if (isMobile && hasNonClickableVectorLayerType) return;selectVectorFeatures(selected);} else if (isVectorModalOpen && !Object.entries(selected).length) {onCloseModal();@@ -122,10 +128,11 @@ function mapStateToProps(state) {const percentOffset = state.compare.value || 50;swipeOffset = browser.screenWidth * (percentOffset / 100);}-+ const isMobile = browser.lessThan.medium;return {activeLayers,browser,+ isMobile,compareState: compare,getDialogObject: (pixels, olMap) => onMapClickGetVectorFeatures(pixels, olMap, state, swipeOffset),isDistractionFreeModeActive: ui.isDistractionFreeModeActive,@@ -154,12 +161,14 @@ const mapDispatchToProps = (dispatch) => ({onCloseModal: () => {dispatch(onClose());},- activateVectorAlert: () => dispatch({ type: ACTIVATE_VECTOR_ALERT }),+ activateVectorZoomAlert: () => dispatch({ type: ACTIVATE_VECTOR_ZOOM_ALERT }),+ activateVectorExceededResultsAlert: () => dispatch({ type: ACTIVATE_VECTOR_EXCEEDED_ALERT }),openVectorDialog: (dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive) => {const { screenHeight, screenWidth } = browser;const isMobile = browser.lessThan.medium;const dialogKey = new Date().getUTCMilliseconds();const modalClassName = isEmbedModeActive && !isMobile ? 'vector-modal light modal-embed' : 'vector-modal light';+ const mobileTopOffset = 106;dispatch(openCustomContent(dialogId,{backdrop: false,@@ -170,12 +179,13 @@ const mapDispatchToProps = (dispatch) => ({modalClassName,CompletelyCustomModal: vectorDialog,isResizable: !isMobile,+ mobileFullScreen: true,dragHandle: '.modal-header',dialogKey,key: dialogKey,vectorMetaObject: lodashGroupBy(metaArray, 'id'),width: isMobile ? screenWidth : 445,- height: isMobile ? screenHeight : 300,+ height: isMobile ? screenHeight - mobileTopOffset : 300,offsetLeft: isMobile ? 0 : offsetLeft,offsetTop: isMobile ? 40 : offsetTop,timeout: 0,@@ -197,11 +207,13 @@ VectorInteractions.propTypes = {onCloseModal: PropTypes.func.isRequired,openVectorDialog: PropTypes.func.isRequired,selectVectorFeatures: PropTypes.func.isRequired,- activateVectorAlert: PropTypes.func,+ activateVectorZoomAlert: PropTypes.func,+ activateVectorExceededResultsAlert: PropTypes.func,activeLayers: PropTypes.array,browser: PropTypes.object,compareState: PropTypes.object,isEmbedModeActive: PropTypes.bool,+ isMobile: PropTypes.bool,lastSelected: PropTypes.object,proj: PropTypes.object,swipeOffset: PropTypes.number,diff --git a/web/js/containers/modal.js b/web/js/containers/modal.jsindex 03592a6f0..653b06694 100644--- a/web/js/containers/modal.js+++ b/web/js/containers/modal.js@@ -62,13 +62,14 @@ class ModalContainer extends Component {getStyle() {const {- isMobile,+ isMobile, customProps,} = this.props;const {offsetLeft, offsetRight, offsetTop, width, height,} = this.state;-- const top = isMobile ? 0 : offsetTop;+ const { mobileFullScreen } = customProps;+ const mobileTopOffset = 106;+ const top = isMobile && mobileFullScreen ? mobileTopOffset : offsetTop;const margin = isMobile ? 0 : '0.5rem';return {left: offsetLeft,diff --git a/web/js/containers/sidebar/layer-row.js b/web/js/containers/sidebar/layer-row.jsindex 68f4ad305..b58f7ec14 100644--- a/web/js/containers/sidebar/layer-row.js+++ b/web/js/containers/sidebar/layer-row.js@@ -343,8 +343,9 @@ const makeMapStateToProps = () => {compareState,} = ownProps;const {- palettes, config, embed, map, compare, proj, ui,+ browser, palettes, config, embed, map, compare, proj, ui,} = state;+ const isMobile = browser.lessThan.medium;const { isDistractionFreeModeActive } = ui;const hasPalette = !lodashIsEmpty(layer.palette);const renderedPalettes = palettes.rendered;@@ -370,10 +371,10 @@ const makeMapStateToProps = () => {isDistractionFreeModeActive,isEmbedModeActive,isLoading: palettes.isLoading[paletteName],- isMobile: state.browser.lessThan.medium,+ isMobile,isVisible,isVectorLayer: isVector,- hasClickableFeature: isVector && isVisible && isVectorLayerClickable(layer, mapRes, proj.id),+ hasClickableFeature: isVector && isVisible && isVectorLayerClickable(layer, mapRes, proj.id, isMobile),hasPalette,getPalette: (layerId, i) => getPalette(layer.id, i, compareState, state),paletteLegends,diff --git a/web/js/containers/timeline/timeline.js b/web/js/containers/timeline/timeline.jsindex 191c43e22..c6deda88f 100644--- a/web/js/containers/timeline/timeline.js+++ b/web/js/containers/timeline/timeline.js@@ -1644,7 +1644,6 @@ const getTimelineEndDateLimit = (state) => {}let timelineEndDateLimit;- console.log(layerDateRange && layerDateRange.end > appNow);if (layerDateRange && layerDateRange.end > appNow) {const layerDateRangeEndRoundedQuarterHour = util.roundTimeQuarterHour(layerDateRange.end);const appNowRoundedQuarterHour = util.roundTimeQuarterHour(appNow);diff --git a/web/js/modules/alerts/constants.js b/web/js/modules/alerts/constants.jsindex 2cd3ea5c5..25a66b2d8 100644--- a/web/js/modules/alerts/constants.js+++ b/web/js/modules/alerts/constants.js@@ -1,10 +1,11 @@import EventsAlertModalBody from '../../components/events/alert-body';import CompareAlertModalBody from '../../components/compare/alert';-import VectorAlertModalBody from '../../components/feature-alert/vector-alert-modal';+import VectorZoomAlertModalBody from '../../components/feature-alert/vector-alert-modal';-export const TOGGLE_VECTOR_ALERT = 'ALERTS/TOGGLE_VECTOR_ALERT';-export const DISABLE_VECTOR_ALERT = 'ALERTS/DISABLE_VECTOR_ALERT';-export const ACTIVATE_VECTOR_ALERT = 'ALERTS/ACTIVATE_VECTOR_ALERT';+export const DISABLE_VECTOR_ZOOM_ALERT = 'ALERTS/DISABLE_VECTOR_ZOOM_ALERT';+export const ACTIVATE_VECTOR_ZOOM_ALERT = 'ALERTS/ACTIVATE_VECTOR_ZOOM_ALERT';+export const DISABLE_VECTOR_EXCEEDED_ALERT = 'ALERTS/DISABLE_VECTOR_EXCEEDED_ALERT';+export const ACTIVATE_VECTOR_EXCEEDED_ALERT = 'ALERTS/ACTIVATE_VECTOR_EXCEEDED_ALERT';export const MODAL_PROPERTIES = {eventModalProps: {@@ -36,7 +37,7 @@ export const MODAL_PROPERTIES = {backdrop: false,size: 'lg',clickableBehindModal: true,- bodyComponent: VectorAlertModalBody,+ bodyComponent: VectorZoomAlertModalBody,desktopOnly: true,},},diff --git a/web/js/modules/alerts/reducer.js b/web/js/modules/alerts/reducer.jsindex 41b006385..9048a6856 100644--- a/web/js/modules/alerts/reducer.js+++ b/web/js/modules/alerts/reducer.js@@ -1,33 +1,47 @@import { assign as lodashAssign } from 'lodash';-import { TOGGLE_VECTOR_ALERT, DISABLE_VECTOR_ALERT, ACTIVATE_VECTOR_ALERT } from './constants';+import {+ DISABLE_VECTOR_ZOOM_ALERT,+ ACTIVATE_VECTOR_ZOOM_ALERT,+ DISABLE_VECTOR_EXCEEDED_ALERT,+ ACTIVATE_VECTOR_EXCEEDED_ALERT,+} from './constants';import { hasVectorLayers } from '../layers/util';import { REMOVE_LAYER, REMOVE_GROUP } from '../layers/constants';+import { UPDATE_MAP_EXTENT } from '../map/constants';export const defaultAlertState = {- isVectorAlertActive: false,+ isVectorZoomAlertPresent: false,+ isVectorExceededAlertPresent: false,};export function alertReducer(state = defaultAlertState, action) {switch (action.type) {- case TOGGLE_VECTOR_ALERT:+ case DISABLE_VECTOR_ZOOM_ALERT:return lodashAssign({}, state, {- isVectorAlertActive: !state.isVectorAlertActive,+ isVectorZoomAlertPresent: false,});- case DISABLE_VECTOR_ALERT:+ case ACTIVATE_VECTOR_ZOOM_ALERT:return lodashAssign({}, state, {- isVectorAlertActive: false,+ isVectorZoomAlertPresent: true,});- case ACTIVATE_VECTOR_ALERT:+ case DISABLE_VECTOR_EXCEEDED_ALERT:+ case UPDATE_MAP_EXTENT:return lodashAssign({}, state, {- isVectorAlertActive: true,+ isVectorExceededAlertPresent: false,+ });+ case ACTIVATE_VECTOR_EXCEEDED_ALERT:+ return lodashAssign({}, state, {+ isVectorExceededAlertPresent: true,+ isVectorZoomAlertPresent: false,});case REMOVE_LAYER:case REMOVE_GROUP:- if (!state.isVectorAlertActive) {+ if (!state.isVectorZoomAlertPresent && !state.isVectorExceededAlertPresent) {return state;} if (!hasVectorLayers(action.layers)) {return lodashAssign({}, state, {- isVectorAlertActive: false,+ isVectorZoomAlertPresent: false,+ isVectorExceededAlertPresent: false,});}return state;diff --git a/web/js/modules/alerts/reducer.test.js b/web/js/modules/alerts/reducer.test.jsindex b5370d708..2d9785226 100644--- a/web/js/modules/alerts/reducer.test.js+++ b/web/js/modules/alerts/reducer.test.js@@ -1,5 +1,5 @@import { alertReducer, defaultAlertState } from './reducer';-import { ACTIVATE_VECTOR_ALERT, DISABLE_VECTOR_ALERT, TOGGLE_VECTOR_ALERT } from './constants';+import { ACTIVATE_VECTOR_ZOOM_ALERT, DISABLE_VECTOR_ZOOM_ALERT } from './constants';describe('alertReducer', () => {test('should return the initial state', () => {@@ -7,28 +7,17 @@ describe('alertReducer', () => {defaultAlertState,);});- test('DISABLE_VECTOR_ALERT should disable vector alert state', () => {+ test('DISABLE_VECTOR_ZOOM_ALERT should disable vector alert state', () => {expect(alertReducer(- { ...defaultAlertState, isVectorAlertActive: true },- { type: DISABLE_VECTOR_ALERT },+ { ...defaultAlertState, isVectorZoomAlertPresent: true },+ { type: DISABLE_VECTOR_ZOOM_ALERT },)).toEqual(defaultAlertState,);});- test('ACTIVATE_VECTOR_ALERT should enable vector alert state', () => {- const vectorEnabledState = { ...defaultAlertState, isVectorAlertActive: true };+ test('ACTIVATE_VECTOR_ZOOM_ALERT should enable vector alert state', () => {+ const vectorEnabledState = { ...defaultAlertState, isVectorZoomAlertPresent: true };expect(alertReducer(undefined,- { type: ACTIVATE_VECTOR_ALERT })).toEqual(vectorEnabledState);- });- test('TOGGLE_VECTOR_ALERT should toggle vector alert state', () => {- const vectorEnabledState = { ...defaultAlertState, isVectorAlertActive: true };- expect(alertReducer(undefined,- { type: TOGGLE_VECTOR_ALERT })).toEqual(vectorEnabledState);- expect(alertReducer(- { ...defaultAlertState, isVectorAlertActive: true },- { type: TOGGLE_VECTOR_ALERT },- )).toEqual(- defaultAlertState,- );+ { type: ACTIVATE_VECTOR_ZOOM_ALERT })).toEqual(vectorEnabledState);});});diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.jsindex 7d1757546..f5e96f688 100644--- a/web/js/modules/layers/util.js+++ b/web/js/modules/layers/util.js@@ -1278,11 +1278,11 @@ export const hasVectorLayers = (activeLayers) => {** @return {Boolean}*/-export const isVectorLayerClickable = (layer, mapRes, projId) => {+export const isVectorLayerClickable = (layer, mapRes, projId, isMobile) => {if (!mapRes) return false;- const resolutionBreakPoint = lodashGet(layer, `breakPointLayer.projections.${projId}.resolutionBreakPoint`);-+ let resolutionBreakPoint = lodashGet(layer, `breakPointLayer.projections.${projId}.resolutionBreakPoint`);if (resolutionBreakPoint) {+ if (isMobile) resolutionBreakPoint /= 2;return mapRes < resolutionBreakPoint;}return true;@@ -1297,14 +1297,14 @@ export const isVectorLayerClickable = (layer, mapRes, projId) => {** @return {Boolean}*/-export const hasNonClickableVectorLayer = (activeLayers, mapRes, projId) => {+export const hasNonClickableVectorLayer = (activeLayers, mapRes, projId, isMobile) => {if (!mapRes) return false;let isNonClickableVectorLayer = false;const len = activeLayers.length;for (let i = 0; i < len; i += 1) {const def = activeLayers[i];if (def.type === 'vector' && def.visible) {- isNonClickableVectorLayer = !isVectorLayerClickable(def, mapRes, projId);+ isNonClickableVectorLayer = !isVectorLayerClickable(def, mapRes, projId, isMobile);if (isNonClickableVectorLayer) break;}}diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.jsindex b6539ba05..b0cec6291 100644--- a/web/js/modules/vector-styles/util.js+++ b/web/js/modules/vector-styles/util.js@@ -213,12 +213,19 @@ function getModalOffset(dimensionProps) {* @param Object*} config* @param {Object} compareState*/-function getModalContentsAtPixel(mapProps, config, compareState) {+function getModalContentsAtPixel(mapProps, config, compareState, isMobile) {const metaArray = [];const selected = {};+ let exceededLengthLimit = false;let isCoordinatesMarker = false;const { pixels, map, swipeOffset } = mapProps;+ const featureOptions = isMobile ? { hitTolerance: 5 } : {};map.forEachFeatureAtPixel(pixels, (feature, layer) => {+ const lengthCheck = (arr) => arr.length >= (isMobile ? 5 : 12);+ if (lengthCheck(metaArray)) {+ exceededLengthLimit = true;+ return;+ }const featureId = feature.getId();if (featureId === 'coordinates-map-marker') {isCoordinatesMarker = true;@@ -262,8 +269,10 @@ function getModalContentsAtPixel(mapProps, config, compareState) {metaArray.push(obj);selected[layerId].push(uniqueIdentifier);}- });- return { selected, metaArray, isCoordinatesMarker };+ }, featureOptions);+ return {+ selected, metaArray, isCoordinatesMarker, exceededLengthLimit,+ };}/*** Get organized vector modal contents for clicked@@ -287,13 +296,16 @@ export function onMapClickGetVectorFeatures(pixels, map, state, swipeOffset) {};const mapProps = { pixels, map, swipeOffset };const { offsetLeft, offsetTop } = getModalOffset(modalOffsetProps);- const { selected, metaArray, isCoordinatesMarker } = getModalContentsAtPixel(mapProps, config, compare);+ const {+ selected, metaArray, isCoordinatesMarker, exceededLengthLimit,+ } = getModalContentsAtPixel(mapProps, config, compare, isMobile);return {selected, // Object containing unique identifiers of selected featuresmetaArray, // Organized metadata for modaloffsetLeft, // Modal default offsetLeftoffsetTop, // Modal default offsetTopisCoordinatesMarker,+ exceededLengthLimit,};}export function updateVectorSelection(selectionObj, lastSelection, layers, type, state) {