Interactive interface for browsing global, full-resolution satellite imagery
Fix data download bugs
Benjamin King924419acf8ae
diff --git a/e2e/features/data-download/data-download-test.js b/e2e/features/data-download/data-download-test.jsindex 719c48802..5ef5965fd 100644--- a/e2e/features/data-download/data-download-test.js+++ b/e2e/features/data-download/data-download-test.js@@ -1,13 +1,19 @@const reuseables = require('../../reuseables/skip-tour.js');const layersTab = '#layers-sidebar-tab';const dataDownloadTabButton = '#download-sidebar-tab';-const zoomInButton = '#wv-map-geographic > div.wv-map-zoom-in.wv-map-zoom.ui-button.ui-corner-all.ui-widget';-const zoomOutButton = '#wv-map-geographic > div.wv-map-zoom-out.wv-map-zoom.ui-button.ui-corner-all.ui-widget';-const downYearInputButton = '#date-selector-main > div > div.input-wrapper.input-wrapper-year > div.date-arrows.date-arrow-down';-const upYearInputButton = '#date-selector-main > div > div.input-wrapper.input-wrapper-year > div.date-arrows.date-arrow-up';+const zoomInButton =+ '#wv-map-geographic > div.wv-map-zoom-in.wv-map-zoom.ui-button.ui-corner-all.ui-widget';+const zoomOutButton =+ '#wv-map-geographic > div.wv-map-zoom-out.wv-map-zoom.ui-button.ui-corner-all.ui-widget';+const downYearInputButton =+ '#date-selector-main > div > div.input-wrapper.input-wrapper-year > div.date-arrows.date-arrow-down';+const upYearInputButton =+ '#date-selector-main > div > div.input-wrapper.input-wrapper-year > div.date-arrows.date-arrow-up';module.exports = {- 'Initial State - Data Download tab is available and in default state when clicked': function(client) {+ 'Initial State - Data Download tab is available and in default state when clicked': function(+ client+ ) {reuseables.loadAndSkipTour(client, client.globals.timeout);// Verify Data Download tab is in sidebar@@ -15,7 +21,9 @@ module.exports = {// Click Data Download tab to switch to Data with 'No Data Selected'client.click(dataDownloadTabButton);- client.expect.element('#compare-toggle-button > span').to.have.text.equal('No Data Selected');+ client.expect+ .element('#compare-toggle-button > span')+ .to.have.text.equal('No Data Selected');// All 6 default layers in Not Available for Downloadclient.elements('css selector', '.wv-datacategory > li', function(result) {@@ -23,24 +31,37 @@ module.exports = {});// No 'Searching for Data' CMR query indicator present- client.expect.element('#indicator').to.not.be.present;+ client.expect.element('#indicator').to.be.present;+ client.useCss().assert.containsText('#indicator span', 'No Data Available');},- 'No Results - No Data Available indicator displayed when no data': function(client) {+ 'No Results - No Data Available indicator displayed when no data': function(+ client+ ) {// December 31, 2022 no results- let queryString = '?now=2022-12-31T12&p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2022-12-31&v=-91.125,-53.3671875,82.40625,59.8359375&download=MOD04_L2';+ let queryString =+ '?now=2022-12-31T12&p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2022-12-31&v=-91.125,-53.3671875,82.40625,59.8359375&download=MOD04_L2';client.url(client.globals.url + queryString);// 'No Data Available' indicator present- client.expect.element('#indicator').to.be.present.after(client.globals.timeout);- client.expect.element('#indicator > span').to.have.text.equal('No Data Available').after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.be.present.after(client.globals.timeout);+ client.expect+ .element('#indicator > span')+ .to.have.text.equal('No Data Available')+ .after(client.globals.timeout);// On Valid Data Select, 'No Data Available' indicator disappears and data layer is in sidebar// Click from year 2022 down to 2013for (let i = 0; i <= 8; i++) {client.click(downYearInputButton);}- client.expect.element('#indicator').to.not.be.visible.after(client.globals.timeout);- client.expect.element('#wv-data-MOD04_L2MODIS_Terra_Aerosol').to.be.visible.after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.not.be.visible.after(client.globals.timeout);+ client.expect+ .element('#wv-data-MOD04_L2MODIS_Terra_Aerosol')+ .to.be.visible.after(client.globals.timeout);// On Valid Data Select, 'No Data Available' indicator appears// Click from year 2013 up to 2022@@ -48,7 +69,10 @@ module.exports = {client.click(upYearInputButton);}client.expect.element('#indicator').to.be.present;- client.expect.element('#indicator > span').to.have.text.equal('No Data Available').after(client.globals.timeout);+ client.expect+ .element('#indicator > span')+ .to.have.text.equal('No Data Available')+ .after(client.globals.timeout);// Click layers tab, indicator disappearsclient.click(layersTab);@@ -57,46 +81,78 @@ module.exports = {// Click data download tab, 'No Data Available' indicator appearsclient.click(dataDownloadTabButton);client.expect.element('#indicator').to.be.visible;- client.expect.element('#indicator > span').to.have.text.equal('No Data Available').after(client.globals.timeout);+ client.expect+ .element('#indicator > span')+ .to.have.text.equal('No Data Available')+ .after(client.globals.timeout);},- 'No data in view - Zoom out or move map indicator displayed when no data in view': function(client) {+ 'No data in view - Zoom out or move map indicator displayed when no data in view': function(+ client+ ) {// zoomed in so no data in view- let queryString = '?p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2013-08-15&v=-115.09722044197,32.076037619082,-112.11113645759,34.018420431582&download=MOD04_L2';+ let queryString =+ '?p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2013-08-15&v=-115.09722044197,32.076037619082,-112.11113645759,34.018420431582&download=MOD04_L2';client.url(client.globals.url + queryString);// 'Zoom out or move map' indicator present- client.expect.element('#indicator').to.be.present.after(client.globals.timeout);- client.expect.element('#indicator > span').to.have.text.equal('Zoom out or move map').after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.be.present.after(client.globals.timeout);+ client.expect+ .element('#indicator > span')+ .to.have.text.equal('Zoom out or move map')+ .after(client.globals.timeout);// Zoom out three times for a data point granule selection button to be visible and indicator disappearsclient.click(zoomOutButton);client.click(zoomOutButton);client.click(zoomOutButton);- client.expect.element('#indicator').to.not.be.visible.after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.not.be.visible.after(client.globals.timeout);// Zoom in data point granule selection button is not visible and indicator reappearsclient.click(zoomInButton);- client.expect.element('#indicator').to.be.visible.after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.be.visible.after(client.globals.timeout);// Click layers tab, indicator disappearsclient.click(layersTab);- client.expect.element('#indicator').to.not.be.visible.after(client.globals.timeout);+ client.expect+ .element('#indicator')+ .to.not.be.visible.after(client.globals.timeout);// Click data download tab, 'No Data Available' indicator appearsclient.click(dataDownloadTabButton);client.expect.element('#indicator').to.be.visible;- client.expect.element('#indicator > span').to.have.text.equal('Zoom out or move map').after(client.globals.timeout);+ client.expect+ .element('#indicator > span')+ .to.have.text.equal('Zoom out or move map')+ .after(client.globals.timeout);},- 'Query Timeout - No results received yet dialog box displayed': function(client) {+ 'Query Timeout - No results received yet dialog box displayed': function(+ client+ ) {// query timeout- let queryString = '?timeoutCMR=100&p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2013-09-29&v=-170.64093281444,-59.218903407221,20.468442185558,65.093596592779';+ let queryString =+ '?timeoutCMR=100&p=geographic&l=MODIS_Aqua_CorrectedReflectance_TrueColor(hidden),MODIS_Terra_CorrectedReflectance_TrueColor,MODIS_Terra_Aerosol,Coastlines&t=2013-09-29&v=-170.64093281444,-59.218903407221,20.468442185558,65.093596592779';client.url(client.globals.url + queryString);// Click Data Download tab and show 'No results received yet' dialog box- client.waitForElementVisible(dataDownloadTabButton, client.globals.timeout, function() {- client.click(dataDownloadTabButton);- client.expect.element('.wv-dialog').to.have.text.equal('No results received yet. This may be due to a connectivity issue. Please try again later.').after(client.globals.timeout);- });+ client.waitForElementVisible(+ dataDownloadTabButton,+ client.globals.timeout,+ function() {+ client.click(dataDownloadTabButton);+ client.expect+ .element('.wv-dialog')+ .to.have.text.equal(+ 'No results received yet. This may be due to a connectivity issue. Please try again later.'+ )+ .after(client.globals.timeout);+ }+ );},after: function(client) {client.end();diff --git a/web/js/location.js b/web/js/location.jsindex 0e0ed58eb..6311f22de 100644--- a/web/js/location.js+++ b/web/js/location.js@@ -20,6 +20,7 @@ import { mapLocationToAnimationState } from './modules/animation/util';import { mapLocationToSidebarState } from './modules/sidebar/util';import util from './util/util';import update from 'immutability-helper';+import { mapLocationToDataState } from './modules/data/util';/*** Override state with information from location.search when "REDUX-LOCATION-POP-ACTION"@@ -50,6 +51,10 @@ export const mapLocationToState = (state, location) => {parameters,stateFromLocation);+ stateFromLocation = mapLocationToDataState(+ parameters,+ stateFromLocation+ );stateFromLocation = mapLocationToPaletteState(parameters,stateFromLocation,@@ -108,7 +113,7 @@ const getParameters = function(config, parameters) {options: {serializeNeedsGlobalState: false,setAsEmptyItem: true,- serialize: (currentItemState) => {+ serialize: currentItemState => {return currentItemState? util.toISOStringSeconds(currentItemState): undefined;diff --git a/web/js/map/data/map.js b/web/js/map/data/map.jsindex 92f1c50ad..5bdd01c6d 100644--- a/web/js/map/data/map.js+++ b/web/js/map/data/map.js@@ -30,7 +30,9 @@ export function dataMap(store, maps, dataUi, ui) {const subscribeToStore = function(action) {switch (action.type) {case CHANGE_PROJECTION:- return updateProjection(action.id);+ return updateProjection();+ case 'MAP/UPDATE_MAP_UI':+ map = maps.selected;}};var init = function() {diff --git a/web/js/map/data/ui.js b/web/js/map/data/ui.jsindex 38a2ec3c4..dcab9c2a6 100644--- a/web/js/map/data/ui.js+++ b/web/js/map/data/ui.js@@ -12,6 +12,7 @@ import * as DATA_CONSTANTS from '../../modules/data/constants';import { CHANGE_TAB as CHANGE_SIDEBAR_TAB } from '../../modules/sidebar/constants';import { toggleGranule } from '../../modules/data/actions';import { SELECT_DATE } from '../../modules/date/constants';+import { LOCATION_POP_ACTION } from '../../redux-location-state-customs';export function dataUi(store, ui, config) {var queryActive = false;@@ -35,11 +36,13 @@ export function dataUi(store, ui, config) {self.EVENT_QUERY_RESULTS = 'queryResults';self.EVENT_QUERY_CANCEL = 'queryCancel';self.EVENT_QUERY_ERROR = 'queryError';+ self.EVENT_QUERY_TIMEOUT = 'queryTimeout';self.selector = '#wv-data';self.id = 'wv-data';const subscribeToStore = function(action) {switch (action.type) {+ case LOCATION_POP_ACTION:case CHANGE_SIDEBAR_TAB:return action.activeTab === 'download' ? onActivate() : mapController ? onDeactivate() : '';case DATA_CONSTANTS.DATA_GET_DATA_CLICK:@@ -120,29 +123,31 @@ export function dataUi(store, ui, config) {}};var init = function() {- const sidebarState = store.getState().sidebar;ui.events.on('last-action', subscribeToStore);+ ui.map.events.on('extent', self.onViewChange);self.events.on('query', onQuery)- .on('queryResults', onQueryResults)+ .on('queryResults', (results) => {+ onQueryResults(results);+ self.onViewChange(results);+ }).on('queryError', onQueryError).on('queryTimeout', onQueryTimeout);- if (sidebarState.activeTab === 'download') onActivate();};- self.onViewChange = function() {+ self.onViewChange = function(results) {+ results = results || lastResults;const state = store.getState();var map = ui.map.selected;-- if (!state.data.active || queryActive || !lastResults) {+ if (!state.data.active || queryActive || !results) {return;}- if (lastResults.granules.length === 0) {+ if (results.granules.length === 0) {return;}var hasCentroids = false;var inView = false;var extent = map.getView().calculateExtent(map.getSize());var crs = state.proj.selected.crs;- lodashEach(lastResults.granules, function(granule) {+ lodashEach(results.granules, function(granule) {if (granule.centroid && granule.centroid[crs]) {hasCentroids = true;if (olExtent.intersects(extent, granule.centroid[crs].getExtent())) {@@ -161,7 +166,7 @@ export function dataUi(store, ui, config) {downloadListPanel.refresh();}};- var onActivate = function() {+ var onActivate = self.onActivate = function() {self.active = true;self.events.trigger('activate');if (!mapController) {diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 4835362f0..474bce356 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -915,6 +915,7 @@ export function mapui(models, config, store, ui) {const onRenderComplete = () => {store.dispatch({ type: 'MAP/UPDATE_MAP_UI', ui: self, rotation: self.selected.getView().getRotation() });map.un('rendercomplete', onRenderComplete);+ if (store.getState().data.active) ui.data.onActivate();};map.on('rendercomplete', onRenderComplete);map.on('click', function(e) {diff --git a/web/js/modules/data/util.js b/web/js/modules/data/util.jsindex e69de29bb..41fdcbd64 100644--- a/web/js/modules/data/util.js+++ b/web/js/modules/data/util.js@@ -0,0 +1,21 @@+import update from 'immutability-helper';+/**+ * Update sidebar state when location-pop action occurs+ *+ * @param {Object} parameters | parameters parsed from permalink+ * @param {Object} stateFromLocation | State derived from permalink parsers+ * @param {Object} state | initial state before location POP action+ * @param {Object} config+ */+export function mapLocationToDataState(parameters, stateFromLocation) {+ if (parameters.download) {+ stateFromLocation = update(stateFromLocation, {+ data: { active: { $set: true } }+ });+ } else {+ stateFromLocation = update(stateFromLocation, {+ data: { active: { $set: false } }+ });+ }+ return stateFromLocation;+}diff --git a/web/js/modules/sidebar/util.js b/web/js/modules/sidebar/util.jsindex e55bef64b..78d1969e0 100644--- a/web/js/modules/sidebar/util.js+++ b/web/js/modules/sidebar/util.js@@ -29,6 +29,13 @@ export function mapLocationToSidebarState(stateFromLocation = update(stateFromLocation, {sidebar: { $set: sidebarState }});+ } else {+ let sidebarState = lodashAssign({}, state.sidebar, {+ activeTab: 'layers'+ });+ stateFromLocation = update(stateFromLocation, {+ sidebar: { $set: sidebarState }+ });}return stateFromLocation;}