Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Get map layers with or without geodata (#77)
Browse files Browse the repository at this point in the history
* Get map layers with or without geodata

* Fix get map layers

* Fix yarn audit

* Fix test error

* Fix frozen lockfile error

* Fix test

* Fix audit

* Fix test

* Fix undefined should not be argument for axios request

* files clean up

* fixed tests & group map layers

Co-authored-by: Daniela Barborova <daniela.barborova@accenture.com>
  • Loading branch information
srezacova and bariela authored Nov 24, 2021
1 parent 6fad219 commit de37234
Show file tree
Hide file tree
Showing 9 changed files with 478 additions and 435 deletions.
5 changes: 4 additions & 1 deletion api/src/actions/mapLayersActions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const model = require('../models/mapLayerModel');
const { getLayerGeoDataWithUrl } = require('../models/layerGeoDataModel');

/**
* Returns map layers from mapLayers collection with link to GeoJson file from layerGeoData collection
*/
const getMapLayersWithGeoData = async () => {
// find all available geoData
const haveGeoData = await getLayerGeoDataWithUrl();
Expand Down Expand Up @@ -34,7 +37,7 @@ const getMapLayersWithGeoData = async () => {
const layersWithGeoDataUrl = layers.map((layer) => {
if (layer.layerType === 'group') {
const sublayers = layer.layers.map((lr) => {
if (geoData[lr.geoDataUrl]) {
if (geoData[lr.geoReferenceId]) {
return {
...lr,
geoDataUrl: geoData[lr.geoReferenceId].geoDataUrl,
Expand Down
4 changes: 2 additions & 2 deletions api/src/tests/staticLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('GET /api/staticLayers', () => {
expect(res.body[0].geoReferenceId).toEqual(undefined);
});

it.only('should return all layers in db sorted by title with data from layerGeoData collection', async () => {
it('should return all layers in db sorted by title with data from layerGeoData collection', async () => {
await LayerGeoData.create(layerGeoDataInDb);
// saved in reverse order to check the sorting
await MapLayer.create(mapLayersInDb[1]);
Expand All @@ -54,10 +54,10 @@ describe('GET /api/staticLayers', () => {
expect(res.status).toEqual(200);
expect(res.body).toHaveLength(1);
expect(res.body[0].referenceId).toEqual(mapLayersInDb[2].referenceId);
expect(res.body[0].metadata.geoMetadata).toEqual(layerGeoDataInDb.metadata);
res.body[0].layers.forEach((layer) => {
expect(layer.geoDataUrl).toEqual(layerGeoDataInDb.geoDataUrl);
expect(layer.format).toEqual(layerGeoDataInDb.format);
expect(layer.metadata.geoMetadata).toEqual(layerGeoDataInDb.metadata);
});
});
});
195 changes: 101 additions & 94 deletions api/yarn.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion frontend/src/axiosRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export const getAttributesData = async (searchParams) => {

export const getGeoData = async (url) => {
const response = await axios.get(url);
return response.data;
if (response && response.data) {
return response.data;
}
return [];
};

export const checkAuthorization = async () => {
Expand Down
280 changes: 148 additions & 132 deletions frontend/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion initial-data-load/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"@azure/storage-queue": "^12.2.0",
"@hapi/joi": "^17.1.1",
"axios": "^0.21.1",
"axios": "^0.21.2",
"azure-storage": "^2.10.3",
"bottleneck": "^2.19.5",
"csvtojson": "^2.0.10",
Expand Down
227 changes: 117 additions & 110 deletions initial-data-load/yarn.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion url-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"dependencies": {
"@hapi/joi": "^17.1.1",
"axios": "^0.21.1",
"axios": "^0.21.2",
"azure-storage": "^2.10.1",
"bottleneck": "^2.19.5",
"dotenv": "^6.0.0",
Expand Down
193 changes: 100 additions & 93 deletions url-loader/yarn.lock

Large diffs are not rendered by default.

0 comments on commit de37234

Please sign in to comment.