Interactive interface for browsing global, full-resolution satellite imagery
Fix data download bugs
Benjamin King020c7989ac3b
diff --git a/web/js/map/data/ui.js b/web/js/map/data/ui.jsindex dcab9c2a6..3333a1c27 100644--- a/web/js/map/data/ui.js+++ b/web/js/map/data/ui.js@@ -1,5 +1,6 @@import lodashSize from 'lodash/size';import lodashEach from 'lodash/each';+import lodashFind from 'lodash/find';import googleTagManager from 'googleTagManager';import * as olExtent from 'ol/extent';import { dataHandlerGetByName } from './handler';@@ -13,6 +14,9 @@ import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../../modules/sidebar/constantimport { toggleGranule } from '../../modules/data/actions';import { SELECT_DATE } from '../../modules/date/constants';import { LOCATION_POP_ACTION } from '../../redux-location-state-customs';+import { getLayers } from '../../modules/layers/selectors';+import { getDataProductsFromActiveLayers } from '../../modules/data/selectors';+import * as LAYER_CONSTANTS from '../../modules/layers/constants';export function dataUi(store, ui, config) {var queryActive = false;@@ -53,11 +57,34 @@ export function dataUi(store, ui, config) {case DATA_CONSTANTS.DATA_GRANULE_UNSELECT:self.events.on('granuleUnselect', action.granule);return updateSelection();+ case LAYER_CONSTANTS.REMOVE_LAYER:+ case LAYER_CONSTANTS.RESET_LAYERS:+ case LAYER_CONSTANTS.ADD_LAYER:+ case LAYER_CONSTANTS.REORDER_LAYER_GROUP:+ case LAYER_CONSTANTS.ADD_LAYERS_FOR_EVENT:+ return updateLayers();case SELECT_DATE:case DATA_CONSTANTS.SELECT_PRODUCT:return query();}};+ var updateLayers = function() {+ const state = store.getState();+ const { layers, compare, proj, data } = state;+ const activeString = compare.activeString;+ const activeLayers = getLayers(layers[activeString], { proj: proj.id }, state);++ // If a layer was removed and the product no longer exists,+ // remove any selected items in that product+ // FIXME: This is a hack for now and should be cleaned up when+ // everything changes to models.+ var products = getDataProductsFromActiveLayers(activeLayers, config, proj.id);+ lodashEach(data.selectedGranules, function(selected) {+ if (!products[selected.product] && !lodashFind(activeLayers, { product: selected.product })) {+ store.dispatch(toggleGranule(selected));+ }+ });+ };var query = function() {const state = store.getState();const dataState = state.data;diff --git a/web/js/modules/layers/actions.js b/web/js/modules/layers/actions.jsindex 1ba58207f..54e13e746 100644--- a/web/js/modules/layers/actions.js+++ b/web/js/modules/layers/actions.js@@ -17,6 +17,7 @@ import {UPDATE_OPACITY,ADD_LAYERS_FOR_EVENT} from './constants';+import { selectProduct } from '../data/actions';export function resetLayers(activeString) {return (dispatch, getState) => {@@ -119,7 +120,7 @@ export function toggleVisibility(id, visible) {}export function removeLayer(id) {return (dispatch, getState) => {- const { layers, compare } = getState();+ const { layers, compare, data } = getState();const activeString = compare.activeString;const index = lodashFindIndex(layers[activeString], {id: id@@ -127,8 +128,11 @@ export function removeLayer(id) {if (index === -1) {return console.warn('Invalid layer ID: ' + id);}- const def = layers[activeString][index];+ const def = layers[activeString][index];+ if (def.product && def.product === data.selectedProduct) {+ dispatch(selectProduct('')); // Clear selected Data product+ }dispatch({type: REMOVE_LAYER,id,