Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

updating with changes from wv-2497-granule-count branch (#4036)

Ryan Weiler0b15feccef1b
diff --git a/web/js/components/layer/settings/granule-count-slider.js b/web/js/components/layer/settings/granule-count-slider.js
index d58e348cc..48a074243 100644
--- a/web/js/components/layer/settings/granule-count-slider.js
+++ b/web/js/components/layer/settings/granule-count-slider.js
@@ -1,50 +1,59 @@
-import React from 'react';
+import React, { useState } from 'react';
import PropTypes from 'prop-types';
+import { connect } from 'react-redux';
import Slider from 'rc-slider';
import lodashDebounce from 'lodash/debounce';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { UncontrolledTooltip } from 'reactstrap';
import { DEFAULT_NUM_GRANULES, MIN_GRANULES, MAX_GRANULES } from '../../../modules/layers/constants';
-class GranuleCountSlider extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- value: props.count,
- };
- this.onChange = this.onChange.bind(this);
- this.debounceOnchange = lodashDebounce(this.onChange, 300);
- }
-
- onChange(val) {
- const {
- def,
- updateGranuleLayerOptions,
- granuleDates,
- } = this.props;
- updateGranuleLayerOptions(granuleDates, def.id, val);
- }
-
- render() {
- const { count } = this.props;
- const { value } = this.state;
- return (
- <div className="layer-granule-count-select settings-component">
+const GranuleCountSlider = (props) => {
+ const {
+ count,
+ def,
+ granuleDates,
+ granulePlatform,
+ updateGranuleLayerOptions,
+ } = props;
+
+ const [granuleCount, setGranuleCount] = useState(count);
+
+ const onChange = (val) => {
+ updateGranuleLayerOptions(granuleDates, def, val);
+ };
+ const debounceOnchange = lodashDebounce(onChange, 300);
+
+ const satelliteInfo = `Updating granule count for all granules layers associated with the ${granulePlatform} satellite.`;
+
+ return (
+ <div className="layer-granule-count-select settings-component">
+ <div className="d-flex">
<h2 className="wv-header">Granule Count</h2>
- <Slider
- min={MIN_GRANULES}
- max={MAX_GRANULES}
- defaultValue={count}
- onChange={(val) => {
- this.setState({ value: val });
- this.debounceOnchange(val);
- }}
- />
- <div className="wv-label wv-label-granule-count">
- {value}
- </div>
+ <FontAwesomeIcon id="bbox-limit-info" icon="info-circle" className="ml-2" />
+ <UncontrolledTooltip
+ placement="right"
+ target="bbox-limit-info"
+ >
+ {satelliteInfo}
+ </UncontrolledTooltip>
+ </div>
+
+ <Slider
+ min={MIN_GRANULES}
+ max={MAX_GRANULES}
+ defaultValue={count}
+ onChange={(val) => {
+ setGranuleCount(val);
+ debounceOnchange(val);
+ }}
+ />
+ <div className="wv-label wv-label-granule-count">
+ {granuleCount}
</div>
- );
- }
-}
+ </div>
+ );
+};
+
GranuleCountSlider.defaultProps = {
count: DEFAULT_NUM_GRANULES,
};
@@ -52,7 +61,19 @@ GranuleCountSlider.propTypes = {
granuleDates: PropTypes.array,
def: PropTypes.object,
count: PropTypes.number,
+ granulePlatform: PropTypes.string,
updateGranuleLayerOptions: PropTypes.func,
};
-export default GranuleCountSlider;
+const mapStateToProps = (state) => {
+ const { layers } = state;
+ const { granulePlatform } = layers.active;
+
+ return {
+ granulePlatform,
+ };
+};
+
+export default connect(
+ mapStateToProps,
+)(GranuleCountSlider);
diff --git a/web/js/components/layer/settings/granule-date-list.js b/web/js/components/layer/settings/granule-date-list.js
index 8fe8204a2..ba93e9241 100644
--- a/web/js/components/layer/settings/granule-date-list.js
+++ b/web/js/components/layer/settings/granule-date-list.js
@@ -82,7 +82,7 @@ class GranuleDateList extends PureComponent {
result.source.index,
result.destination.index,
);
- updateGranuleLayerOptions(reorderedItems, def.id, granuleCount);
+ updateGranuleLayerOptions(reorderedItems, def, granuleCount);
this.setState({
lastMovedItem: result.draggableId, // granule date
});
@@ -90,13 +90,14 @@ class GranuleDateList extends PureComponent {
// move granule item to top of list
moveUp = (e, sourceIndex, granuleDate) => {
+ console.log('uhh');
e.preventDefault();
const { updateGranuleLayerOptions, granuleCount, def } = this.props;
const reorderedItems = this.reorderItems(
sourceIndex,
sourceIndex - 1,
);
- updateGranuleLayerOptions(reorderedItems, def.id, granuleCount);
+ updateGranuleLayerOptions(reorderedItems, def, granuleCount);
this.setState({
lastMovedItem: granuleDate,
});
@@ -110,7 +111,7 @@ class GranuleDateList extends PureComponent {
sourceIndex,
sourceIndex + 1,
);
- updateGranuleLayerOptions(reorderedItems, def.id, granuleCount);
+ updateGranuleLayerOptions(reorderedItems, def, granuleCount);
this.setState({
lastMovedItem: granuleDate,
});
diff --git a/web/js/components/layer/settings/layer-settings.js b/web/js/components/layer/settings/layer-settings.js
index 98e2584bf..317edc51e 100644
--- a/web/js/components/layer/settings/layer-settings.js
+++ b/web/js/components/layer/settings/layer-settings.js
@@ -438,8 +438,8 @@ const mapDispatchToProps = (dispatch) => ({
setOpacity: (id, opacity) => {
dispatch(setOpacity(id, opacity));
},
- updateGranuleLayerOptions: (dates, id, count) => {
- dispatch(updateGranuleLayerOptions(dates, id, count));
+ updateGranuleLayerOptions: (dates, def, count) => {
+ dispatch(updateGranuleLayerOptions(dates, def, count));
},
resetGranuleLayerDates: (id) => {
dispatch(resetGranuleLayerDates(id));
diff --git a/web/js/modules/layers/actions.js b/web/js/modules/layers/actions.js
index 97f0e8c1f..82743003d 100644
--- a/web/js/modules/layers/actions.js
+++ b/web/js/modules/layers/actions.js
@@ -10,6 +10,7 @@ import {
activateLayersForEventCategory as activateLayersForEventCategorySelector,
findEventLayers,
getGranuleLayer,
+ getGranuleLayersOfActivePlatform,
getActiveGranuleLayers,
} from './selectors';
import {
@@ -343,16 +344,23 @@ function addGranuleLayerDates(layer, granuleFootprints, granulePlatform) {
};
}
-export function updateGranuleLayerOptions(dates, id, count) {
+export function updateGranuleLayerOptions(dates, def, count) {
return (dispatch, getState) => {
- const { compare: { activeString } } = getState();
+ const state = getState();
+ const { activeString } = state.compare;
- dispatch({
- type: UPDATE_GRANULE_LAYER_OPTIONS,
- id,
- activeKey: activeString,
- dates,
- count,
+ const granulePlatform = def.subtitle;
+ const activeGranuleLayers = getActiveGranuleLayers(state);
+ const platformLayers = getGranuleLayersOfActivePlatform(granulePlatform, activeGranuleLayers);
+
+ platformLayers.forEach((layer) => {
+ dispatch({
+ type: UPDATE_GRANULE_LAYER_OPTIONS,
+ id: layer,
+ activeKey: activeString,
+ dates,
+ count,
+ });
});
};
}
diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.js
index c8946c95d..2dd03ea5a 100644
--- a/web/js/modules/layers/reducers.js
+++ b/web/js/modules/layers/reducers.js
@@ -274,6 +274,7 @@ export function layerReducer(state = initialState, action) {
dates,
count,
granuleFootprints,
+ granulePlatform,
},
},
},
diff --git a/web/js/modules/layers/selectors.js b/web/js/modules/layers/selectors.js
index 21fe789fb..ea526739a 100644
--- a/web/js/modules/layers/selectors.js
+++ b/web/js/modules/layers/selectors.js
@@ -90,6 +90,17 @@ export const getGranulePlatform = (state, activeString) => {
return granulePlatform;
};
+export const getGranuleLayersOfActivePlatform = (platform, activeLayers) => {
+ const activeLayersArray = Object.entries(activeLayers);
+ const platformLayers = [];
+ activeLayersArray.forEach(([key, value]) => {
+ if (value.granulePlatform === platform) {
+ platformLayers.push(key);
+ }
+ });
+ return platformLayers;
+};
+
/**
* Return an array of overlay groups for the currently active compare state
* that are available for the currently active projection