Interactive interface for browsing global, full-resolution satellite imagery
Make image download reverts temp #2571
Benjamin King1042164567aa
diff --git a/web/js/containers/animation-widget.js b/web/js/containers/animation-widget.jsindex a2186538a..4239b9db5 100644--- a/web/js/containers/animation-widget.js+++ b/web/js/containers/animation-widget.js@@ -51,9 +51,9 @@ import {} from '../modules/animation/actions';import { notificationWarnings } from '../modules/image-download/constants';import { onToggle, openCustomContent } from '../modules/modal/actions';-import { clearCustoms } from '../modules/palettes/actions';-import { clearRotate } from '../modules/map/actions';-import { clearGraticule } from '../modules/layers/actions';+import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';+import { clearRotate, refreshRotation } from '../modules/map/actions';+import { clearGraticule, refreshGraticule } from '../modules/layers/actions';import { hasCustomPaletteInActiveProjection } from '../modules/palettes/util';import { Tooltip } from 'reactstrap';import Draggable from 'react-draggable';@@ -198,7 +198,10 @@ class AnimationWidget extends React.Component {hasCustomPalettes,isRotated,hasGraticule,- numberOfFrames+ rotation,+ activePalettes,+ numberOfFrames,+ refreshStateAfterGif} = this.props;const {startDate,@@ -228,6 +231,10 @@ class AnimationWidget extends React.Component {googleTagManager.pushEvent({event: 'GIF_create_animated_button'});+ this.onCloseGif = () => {+ refreshStateAfterGif(hasCustomPalettes ? activePalettes : undefined, rotation, hasGraticule);+ toggleGif();+ };toggleGif();});});@@ -384,8 +391,8 @@ class AnimationWidget extends React.Component {placement="right"isOpen={showTooltip}target="create-gif-button">- Too many frames were selected. <br/>- Please request less than 40 frames if you would like to generate a GIF.+ Too many frames were selected. <br />+ Please request less than 40 frames if you would like to generate a GIF.</Tooltip>);}@@ -561,7 +568,6 @@ class AnimationWidget extends React.Component {map,selectDate,currentDate,- toggleGif,isGifActive,delta,interval@@ -588,7 +594,7 @@ class AnimationWidget extends React.Component {return null;}if (isGifActive) {- return <GifContainer onClose={toggleGif} />;+ return <GifContainer onClose={this.onCloseGif} />;}return (<ErrorBoundary>@@ -653,9 +659,10 @@ function mapStateToProps(state) {{ proj: proj.id },state);+ const activePalettes = palettes[activeStr];const hasCustomPalettes = hasCustomPaletteInActiveProjection(activeLayersForProj,- palettes[activeStr]+ activePalettes);const minDate = new Date(config.startDate);const maxDate = appNow;@@ -680,13 +687,14 @@ function mapStateToProps(state) {customSelected && customDelta ? customDelta : delta,maxFrames);-+ const rotation = map.rotation;return {screenWidth: browser.screenWidth,animationCustomModalOpen,customSelected,startDate,endDate,+ activePalettes,currentDate: date[activeDateStr],minDate,maxDate,@@ -710,7 +718,8 @@ function mapStateToProps(state) {},isGifActive: gifActive,isCompareActive: compare.active,- isRotated: Boolean(map.rotation !== 0),+ isRotated: Boolean(rotation !== 0),+ rotation,hasGraticule: Boolean(lodashGet(lodashFind(layers[activeStr], { id: 'Graticule' }) || {},@@ -762,6 +771,17 @@ const mapDispatchToProps = dispatch => ({toggleGif: () => {dispatch(toggleComponentGifActive());},+ refreshStateAfterGif: (activePalettes, rotation, isGraticule) => {+ if (activePalettes) {+ dispatch(refreshPalettes(activePalettes));+ }+ if (rotation) {+ dispatch(refreshRotation(rotation));+ }+ if (isGraticule) {+ dispatch(refreshGraticule(isGraticule));+ }+ },toggleCustomModal: (open, toggleBy) => {dispatch(toggleCustomModal(open, toggleBy));},@@ -796,6 +816,7 @@ RangeHandle.propTypes = {value: PropTypes.number};AnimationWidget.propTypes = {+ activePalettes: PropTypes.object,animationCustomModalOpen: PropTypes.bool,changeCustomInterval: PropTypes.func,currentDate: PropTypes.object,@@ -831,6 +852,8 @@ AnimationWidget.propTypes = {onUpdateStartAndEndDate: PropTypes.func,onUpdateStartDate: PropTypes.func,promiseImageryForTime: PropTypes.func,+ refreshStateAfterGif: PropTypes.func,+ rotation: PropTypes.number,screenWidth: PropTypes.number,selectDate: PropTypes.func,sliderLabel: PropTypes.string,diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex 10f260692..5244ab3c8 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -17,15 +17,16 @@ import {STATUS_REQUEST_URL,REQUEST_NOTIFICATIONS} from '../modules/notifications/constants';-import { clearCustoms } from '../modules/palettes/actions';-import { clearRotate } from '../modules/map/actions';-import { clearGraticule } from '../modules/layers/actions';+import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';+import { clearRotate, refreshRotation } from '../modules/map/actions';+import { clearGraticule, refreshGraticule } from '../modules/layers/actions';import { notificationWarnings } from '../modules/image-download/constants';import { Notify } from '../components/image-download/notify';import Promise from 'bluebird';import { hasCustomPaletteInActiveProjection } from '../modules/palettes/util';import { getLayers } from '../modules/layers/selectors';Promise.config({ cancellation: true });+const CUSTOM_MODAL_PROPS = {TOOLBAR_PROJECTION: {headerText: null,@@ -80,7 +81,8 @@ class toolbarContainer extends Component {}openImageDownload() {- const { openModal, hasCustomPalette, isRotated, hasGraticule } = this.props;+ const { openModal, hasCustomPalette, isRotated, hasGraticule, activePalettes, rotation, refreshStateAfterImageDownload } = this.props;+ console.log(hasCustomPalette, activePalettes);this.getPromise(hasCustomPalette, 'palette', clearCustoms, 'Notice').then(() => {this.getPromise(@@ -97,7 +99,7 @@ class toolbarContainer extends Component {).then(() => {openModal('TOOLBAR_SNAPSHOT',- CUSTOM_MODAL_PROPS.TOOLBAR_SNAPSHOT+ Object.assign({}, CUSTOM_MODAL_PROPS.TOOLBAR_SNAPSHOT, { onClose: () => refreshStateAfterImageDownload(hasCustomPalette ? activePalettes : undefined, rotation, hasGraticule) }));});});@@ -215,20 +217,24 @@ function mapStateToProps(state) {);const isCompareActive = compare.active;const isDataDownloadActive = data.active;+ const activePalettes = palettes[activeString];return {notificationType: type,notificationContentNumber: number,config: state.config,+ rotation: map.rotation,+ activePalettes,isImageDownloadActive: Boolean(lodashGet(state, 'map.ui.selected') &&- !isCompareActive &&- !isDataDownloadActive+ !isCompareActive &&+ !isDataDownloadActive),isCompareActive,hasCustomPalette: hasCustomPaletteInActiveProjection(activeLayersForProj,- palettes[activeString]+ activePalettes),+isRotated: Boolean(map.rotation !== 0),hasGraticule: Boolean(lodashGet(@@ -239,8 +245,23 @@ function mapStateToProps(state) {};}const mapDispatchToProps = dispatch => ({- openModal: (key, customParams) => {- dispatch(openCustomContent(key, customParams));+ refreshStateAfterImageDownload: (activePalettes, rotation, isGraticule) => {+ console.log(activePalettes, rotation, isGraticule);+ if (activePalettes) {+ dispatch(refreshPalettes(activePalettes));+ }+ if (rotation) {+ dispatch(refreshRotation(rotation));+ }+ if (isGraticule) {+ dispatch(refreshGraticule(isGraticule));+ }+ },+ openModal: (key, customParams, actions) => {+ dispatch(openCustomContent(+ key,+ customParams+ ));},notify: (type, action, title) => {return new Promise((resolve, reject, cancel) => {@@ -284,6 +305,7 @@ export default connect()(toolbarContainer);toolbarContainer.propTypes = {+ activePalettes: PropTypes.object,config: PropTypes.object,hasCustomPalette: PropTypes.bool,hasGraticule: PropTypes.bool,@@ -294,5 +316,7 @@ toolbarContainer.propTypes = {notificationType: PropTypes.string,notify: PropTypes.func,openModal: PropTypes.func,- requestNotifications: PropTypes.func+ refreshStateAfterImageDownload: PropTypes.func,+ requestNotifications: PropTypes.func,+ rotation: PropTypes.number};diff --git a/web/js/map/rotation.js b/web/js/map/rotation.jsindex 8b53bb02d..787b4623b 100644--- a/web/js/map/rotation.js+++ b/web/js/map/rotation.js@@ -251,4 +251,10 @@ export function MapRotate(ui, models, store) {duration: duration});};+ this.setRotation = function(val, duration, map) {+ map.getView().animate({+ rotation: val,+ duration: duration+ });+ };}diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 9c9d2b0a9..b18249438 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -49,7 +49,7 @@ import {isRenderable as isRenderableLayer} from '../modules/layers/selectors';-import { CLEAR_ROTATE, RENDERED, UPDATE_MAP_UI, FITTED_TO_LEADING_EXTENT } from '../modules/map/constants';+import { CLEAR_ROTATE, RENDERED, UPDATE_MAP_UI, FITTED_TO_LEADING_EXTENT, REFRESH_ROTATE } from '../modules/map/constants';import { getLeadingExtent } from '../modules/map/util';import { updateVectorSelection } from '../modules/vector-styles/util';@@ -103,6 +103,8 @@ export function mapui(models, config, store, ui) {}case CLEAR_ROTATE:return rotation.reset(self.selected);+ case REFRESH_ROTATE:+ return rotation.setRotation(action.rotation, 500, self.selected);case LOCATION_POP_ACTION: {const newState = util.fromQueryString(action.payload.search);const extent = lodashGet(action, 'payload.query.map.extent');diff --git a/web/js/modules/image-download/constants.js b/web/js/modules/image-download/constants.jsindex e12824976..b13155494 100644--- a/web/js/modules/image-download/constants.js+++ b/web/js/modules/image-download/constants.js@@ -49,10 +49,10 @@ const PALETTE_WARNING =const GRATICLE_WARNING ='The graticule layer cannot be used to take a snapshot. Would you ' +- 'like to hide this layer?';+ 'like to temporarily hide this layer?';const ROTATE_WARNING =- 'Image may not be downloaded when rotated. Would you like to reset rotation?';+ 'Image may not be downloaded when rotated. Would you like to temporarily reset rotation?';export const notificationWarnings = {palette: PALETTE_WARNING,diff --git a/web/js/modules/layers/actions.js b/web/js/modules/layers/actions.jsindex 54e13e746..b8cb35942 100644--- a/web/js/modules/layers/actions.js+++ b/web/js/modules/layers/actions.js@@ -78,10 +78,15 @@ export function addLayer(id, spec) {};}export function clearGraticule() {- return (dispatch, getState) => {+ return (dispatch) => {dispatch(toggleVisibility('Graticule', false));};}+export function refreshGraticule() {+ return (dispatch) => {+ dispatch(toggleVisibility('Graticule', true));+ };+}export function initSecondLayerGroup() {return {type: INIT_SECOND_LAYER_GROUPdiff --git a/web/js/modules/map/actions.js b/web/js/modules/map/actions.jsindex 731e5090d..f4e41ec15 100644--- a/web/js/modules/map/actions.js+++ b/web/js/modules/map/actions.js@@ -1,4 +1,4 @@-import { RUNNING_DATA, CLEAR_RUNNING_DATA, CLEAR_ROTATE, CHANGE_CURSOR } from './constants';+import { RUNNING_DATA, CLEAR_RUNNING_DATA, CLEAR_ROTATE, CHANGE_CURSOR, REFRESH_ROTATE } from './constants';export function runningData(payload) {return {@@ -18,6 +18,12 @@ export function clearRotate() {type: CLEAR_ROTATE};}+export function refreshRotation(number) {+ return {+ type: REFRESH_ROTATE,+ rotation: number+ };+}export function changeCursor(bool) {return {diff --git a/web/js/modules/map/constants.js b/web/js/modules/map/constants.jsindex ea507ea9d..8d21dc78f 100644--- a/web/js/modules/map/constants.js+++ b/web/js/modules/map/constants.js@@ -7,3 +7,4 @@ export const UPDATE_MAP_ROTATION = 'MAP/UPDATE_ROTATION';export const RENDERED = 'MAP/RENDERED';export const FITTED_TO_LEADING_EXTENT = 'MAP/FITTED_TO_LEADING_EXTENT';export const CHANGE_CURSOR = 'MAP/CHANGE_CURSOR';+export const REFRESH_ROTATE = 'MAP/REFRESH_ROTATE';diff --git a/web/js/modules/map/reducers.js b/web/js/modules/map/reducers.jsindex 1c5403d5c..74d96647d 100644--- a/web/js/modules/map/reducers.js+++ b/web/js/modules/map/reducers.js@@ -7,7 +7,8 @@ import {UPDATE_MAP_ROTATION,RENDERED,FITTED_TO_LEADING_EXTENT,- CHANGE_CURSOR+ CHANGE_CURSOR,+ REFRESH_ROTATE} from './constants';import update from 'immutability-helper';const INITIAL_STATE = {@@ -39,6 +40,7 @@ export default function mapReducer(state = INITIAL_STATE, action) {rotation: action.rotation});case UPDATE_MAP_ROTATION:+ case REFRESH_ROTATE:return update(state, { rotation: { $set: action.rotation } });case RENDERED:return lodashAssign({}, state, {diff --git a/web/js/modules/palettes/actions.js b/web/js/modules/palettes/actions.jsindex 927ba2a70..80480d37c 100644--- a/web/js/modules/palettes/actions.js+++ b/web/js/modules/palettes/actions.js@@ -12,8 +12,10 @@ import {setRange as setRangeSelector,setCustomSelector,clearCustomSelector,+ refreshDisabledSelector,setDisabledSelector} from './selectors';+/*** Request palette using core request utility*@@ -138,6 +140,9 @@ export function clearCustoms() {if (colormap.max || colormap.min || colormap.squash) {dispatch(setThresholdRangeAndSquash(key, props, index, groupName));}+ if (colormap.disabled) {+ dispatch(setToggledClassification(key, undefined, index, groupName));+ }});});};@@ -153,7 +158,6 @@ export function loadedCustomPalettes(customs) {custom: customs};}-// TODOexport function setToggledClassification(layerId, classIndex, index, groupName) {return (dispatch, getState) => {const state = getState();@@ -180,3 +184,47 @@ export function setToggledClassification(layerId, classIndex, index, groupName)});};};+export function refreshDisabledClassification(layerId, disabledArray, index, groupName) {+ return (dispatch, getState) => {+ const state = getState();+ const newActivePalettesObj = refreshDisabledSelector(+ layerId,+ disabledArray,+ index,+ state.palettes[groupName],+ state+ );+ let hasDisabled = false;+ newActivePalettesObj[layerId].maps.forEach(colorMap => {+ if (colorMap.disabled && colorMap.disabled.length) {+ hasDisabled = true;+ }+ });+ dispatch({+ type: SET_DISABLED_CLASSIFICATION,+ groupName: groupName,+ activeString: groupName,+ layerId,+ palettes: newActivePalettesObj,+ props: { disabled: hasDisabled }+ });+ };+};+export function refreshPalettes(activePalettes) {+ return (dispatch, getState) => {+ const groupName = getState().compare.activeString;+ lodashForOwn(activePalettes, function(value, key) {+ activePalettes[key].maps.forEach((colormap, index) => {+ if (colormap.custom) {+ dispatch(setCustomPalette(key, colormap.custom, index, groupName));+ }+ if (colormap.max || colormap.min || colormap.squash) {+ dispatch(setThresholdRangeAndSquash(key, { squash: colormap.squash, min: colormap.min, max: colormap.max }, index, groupName));+ }+ if (colormap.disabled) {+ dispatch(refreshDisabledClassification(key, colormap.disabled, index, groupName));+ }+ });+ });+ };+}diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.jsindex 7936ec917..32a5cc07d 100644--- a/web/js/modules/palettes/selectors.js+++ b/web/js/modules/palettes/selectors.js@@ -342,6 +342,27 @@ export function isActive(layerId, group, state) {group = group || state.compare.activeString;return state.palettes[group][layerId];}+export function refreshDisabledSelector(+ layerId,+ disabled,+ index,+ palettes,+ state+) {+ let newPalettes = prepare(layerId, palettes, state);+ newPalettes = update(newPalettes, {+ [layerId]: {+ maps: {+ [index]: {+ $merge: {+ disabled+ }+ }+ }+ }+ });+ return toggleLookup(layerId, newPalettes, state);+}export function initDisabledSelector(layerId,disabledStr,@@ -382,7 +403,7 @@ export function setDisabledSelector(maps: {[index]: {$merge: {- disabled: oldDisabled+ disabled: isNaN(classIndex) ? [] : oldDisabled}}}diff --git a/web/js/modules/palettes/util.js b/web/js/modules/palettes/util.jsindex 07ff9dbb5..f45b4b51f 100644--- a/web/js/modules/palettes/util.js+++ b/web/js/modules/palettes/util.js@@ -334,7 +334,6 @@ const createPaletteAttributeObject = function(def, value, attrObj, count) {*/export function loadPalettes(permlinkState, state) {var stateArray = [{ stateStr: 'l', groupStr: 'active' }];- const palettes = state.palettes;if (!isSupported()) {return state;}@@ -352,6 +351,7 @@ export function loadPalettes(permlinkState, state) {var max = [];var squash = [];var count = 0;+ console.log(layerDef);if (layerDef.custom) {lodashEach(layerDef.custom, function(value, index) {try {@@ -416,7 +416,7 @@ export function loadPalettes(permlinkState, state) {layerId,value,index,- palettes[stateObj.groupStr],+ state.palettes[stateObj.groupStr],state);state = update(state, {