Skip to content

Commit

Permalink
Refactor image download panel and toolbar container
Browse files Browse the repository at this point in the history
  • Loading branch information
PatchesMaps committed Nov 25, 2024
1 parent f15bef4 commit ffbc50f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/js/components/image-download/image-download-panel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { getActivePalettes } from '../../modules/palettes/selectors';
import PropTypes from 'prop-types';
import googleTagManager from 'googleTagManager';
import { getActivePalettes } from '../../modules/palettes/selectors';
import {
imageSizeValid,
getDimensions,
Expand Down
2 changes: 1 addition & 1 deletion web/js/containers/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
requestNotifications,
setNotifications,
} from '../modules/notifications/actions';
import { clearCustoms, refreshPalettes } from '../modules/palettes/actions';
import { refreshPalettes } from '../modules/palettes/actions';
import { clearRotate, refreshRotation } from '../modules/map/actions';
import {
showLayers, hideLayers,
Expand Down
7 changes: 4 additions & 3 deletions web/js/modules/image-download/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
each as lodashEach,
get as lodashGet,
} from 'lodash';
import { transform } from 'ol/proj';
Expand Down Expand Up @@ -189,7 +188,7 @@ export function imageUtilGetLayers(products, proj, activePalettes) {
} else if (layer.projections[proj].layer) {
layerId = layer.projections[proj].layer;
}
const disabled = activePalettes[layer.id]?.maps?.[0]?.disabled;
const disabled = activePalettes?.[layer.id]?.maps?.[0]?.disabled;
if (Array.isArray(disabled)) {
return `${layerId}(disabled=${disabled.join('-')})`;
}
Expand Down Expand Up @@ -333,12 +332,14 @@ export function getDownloadUrl(url, proj, layerDefs, bbox, dimensions, dateTime,
`BBOX=${bboxWMS13(bbox, crs)}`,
`CRS=${crs}`,
`LAYERS=${layersArray.join(',')}`,
`colormaps=${colormaps.join(',')}`,
`WRAP=${layerWraps.join(',')}`,
`FORMAT=${imgFormat}`,
`WIDTH=${width}`,
`HEIGHT=${height}`,
];
if (Array.isArray(colormaps) && colormaps.length > 0) {
params.push(`colormaps=${colormaps.join(',')}`);
}
if (granuleDates.length > 0) {
params.push(`granule_dates=${granuleDates}`);
}
Expand Down
3 changes: 2 additions & 1 deletion web/js/modules/image-download/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ test('Download URL [imagedownload-url]', () => {
{ id: 1, longitude: 2.7117, latitude: -19.1609 },
{ id: 2, longitude: 71.173, latitude: -39.0961 },
];
const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers);
const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, locationMarkers, undefined);
const expectedURL = 'http://localhost:3002/api/v1/snapshot'
+ '?REQUEST=GetSnapshot'
+ '&TIME=2019-06-24T00:00:00Z'
Expand All @@ -228,6 +228,7 @@ test('Download URL [imagedownload-url]', () => {
+ '&WRAP=day'
+ '&FORMAT=image/jpeg'
+ '&WIDTH=300&HEIGHT=300'
+ '&colormaps='
+ '&MARKER=2.7117,-19.1609,71.173,-39.0961';
expect(dlURL.includes(expectedURL)).toBe(true);
});

0 comments on commit ffbc50f

Please sign in to comment.