@eeacms/volto-arcgis-block 0.1.251 → 0.1.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env ADDED
@@ -0,0 +1,3 @@
1
+ # Jest configuration variables
2
+ # - possible values: ON, OFF
3
+ JEST_USE_SETUP=OFF
package/.eslintrc.js ADDED
@@ -0,0 +1,55 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const projectRootPath = fs.existsSync('./project')
5
+ ? fs.realpathSync('./project')
6
+ : fs.realpathSync('./../../../');
7
+ const packageJson = require(path.join(projectRootPath, 'package.json'));
8
+ const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
9
+
10
+ const pathsConfig = jsConfig.paths;
11
+
12
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
13
+
14
+ Object.keys(pathsConfig).forEach(pkg => {
15
+ if (pkg === '@plone/volto') {
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
17
+ }
18
+ });
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map(o => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+
29
+ module.exports = {
30
+ extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
+ settings: {
32
+ 'import/resolver': {
33
+ alias: {
34
+ map: [
35
+ ['@plone/volto', '@plone/volto/src'],
36
+ ...addonAliases,
37
+ ['@package', `${__dirname}/src`],
38
+ ['~', `${__dirname}/src`],
39
+ ],
40
+ extensions: ['.js', '.jsx', '.json'],
41
+ },
42
+ 'babel-plugin-root-import': {
43
+ rootPathSuffix: 'src',
44
+ },
45
+ },
46
+ },
47
+ rules: {
48
+ 'react/jsx-no-target-blank': [
49
+ 'error',
50
+ {
51
+ allowReferrer: true,
52
+ },
53
+ ],
54
+ }
55
+ };
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [0.1.252](https://github.com/eea/volto-arcgis-block/compare/0.1.251...0.1.252) - 25 January 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-2569 (bug): locales volto dot pot modified [Unai Bolivar - [`85f09ea`](https://github.com/eea/volto-arcgis-block/commit/85f09eae3ce52aaf301f558abb92998d04188f6a)]
12
+ - CLMS-2569 (bug): update needed pushed [Unai Bolivar - [`413899f`](https://github.com/eea/volto-arcgis-block/commit/413899fd23fe822fa4d31d1fef2b125e38ee3755)]
13
+ - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`b16da41`](https://github.com/eea/volto-arcgis-block/commit/b16da416aa6724eff1369d4a4293fd9800cdc718)]
14
+ - clms-2569 (bug): Layer Info widget is not working for the Hot Spots WMS service (RLC and LCC layers) [Unai Bolivar - [`5e209f8`](https://github.com/eea/volto-arcgis-block/commit/5e209f8ba09af43f08b32970e3c5ba5214c94c53)]
7
15
  ### [0.1.251](https://github.com/eea/volto-arcgis-block/compare/0.1.250...0.1.251) - 24 January 2024
8
16
 
9
17
  ### [0.1.250](https://github.com/eea/volto-arcgis-block/compare/0.1.249...0.1.250) - 18 January 2024
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' })
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -38,7 +40,9 @@ module.exports = {
38
40
  statements: 5,
39
41
  },
40
42
  },
41
- setupFilesAfterEnv: [
42
- '<rootDir>/node_modules/@eeacms/volto-arcgis-block/jest.setup.js',
43
- ],
44
- };
43
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
44
+ setupFilesAfterEnv: [
45
+ '<rootDir>/node_modules/@eeacms/volto-arcgis-block/jest.setup.js',
46
+ ],
47
+ }),
48
+ }
package/locales/volto.pot CHANGED
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Plone\n"
4
- "POT-Creation-Date: 2021-01-29T12:34:47.097Z\n"
4
+ "POT-Creation-Date: 2024-01-25T07:53:02.154Z\n"
5
5
  "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
6
  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
7
  "MIME-Version: 1.0\n"
@@ -12,3 +12,5 @@ msgstr ""
12
12
  "Language-Name: English\n"
13
13
  "Preferred-Encodings: utf-8\n"
14
14
  "Domain: volto\n"
15
+
16
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.251",
3
+ "version": "0.1.252",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -72,6 +72,7 @@
72
72
  "babel-plugin-transform-class-properties": "^6.24.1",
73
73
  "husky": "^8.0.3",
74
74
  "lint-staged": "13.1.4",
75
- "md5": "^2.3.0"
75
+ "md5": "^2.3.0",
76
+ "dotenv": "^16.3.2"
76
77
  }
77
78
  }
@@ -659,7 +659,7 @@ class AreaWidget extends React.Component {
659
659
  id="drawRectanglePopupWarning"
660
660
  href="https://land.copernicus.eu/en/how-to-guides/how-to-download-spatial-data/how-to-download-m2m"
661
661
  target="_blank"
662
- rel="noreferrer"
662
+ rel="noopener noreferrer"
663
663
  >
664
664
  To download the full dataset consult the "How to
665
665
  download M2M" How to guide.
@@ -191,6 +191,38 @@ class HotspotWidget extends React.Component {
191
191
  });
192
192
  }
193
193
 
194
+ addFilteredLayersData(
195
+ filteredLayersData,
196
+ bboxData,
197
+ typeLegend,
198
+ selectBoxTime,
199
+ ) {
200
+ //sweep the old filtered data
201
+ if (filteredLayersData[typeLegend] !== undefined) {
202
+ delete filteredLayersData[typeLegend];
203
+ }
204
+ //Find the bbox data for the chosen region
205
+ let klc_array = bboxData.find((e) => e.klc_code === this.dataKlc_code);
206
+
207
+ //Parse the bbox data into finer detail
208
+ let klc_bbox_coordinates = klc_array.bbox.split(',');
209
+ let xmin_ymin = klc_bbox_coordinates[0].split(' ');
210
+ let xmax_ymax = klc_bbox_coordinates[1].split(' ');
211
+
212
+ //Add the filtered data to the filteredLayersData object
213
+ filteredLayersData[typeLegend] = {
214
+ klc_code: this.dataKlc_code,
215
+ year: selectBoxTime,
216
+ bboxData: {
217
+ klc_array: klc_array,
218
+ klc_bbox_coordinates: {
219
+ xmin_ymin: xmin_ymin,
220
+ xmax_ymax: xmax_ymax,
221
+ },
222
+ },
223
+ };
224
+ }
225
+
194
226
  async handleApplyFilter(typeFilter) {
195
227
  let typeLegend;
196
228
  let activeLayers =
@@ -201,6 +233,7 @@ class HotspotWidget extends React.Component {
201
233
  this.props.hotspotData && this.props.hotspotData['filteredLayers']
202
234
  ? Object.keys(this.props.hotspotData['filteredLayers'])
203
235
  : [];
236
+ let filteredLayersData = this.props.hotspotData['filteredLayerData'] || [];
204
237
  let layersToAdd = {};
205
238
  let bookmarkHotspotFilter = JSON.parse(
206
239
  localStorage.getItem('bookmarkHotspotFilter'),
@@ -229,6 +262,13 @@ class HotspotWidget extends React.Component {
229
262
  }
230
263
  }
231
264
 
265
+ this.addFilteredLayersData(
266
+ filteredLayersData,
267
+ this.dataBBox,
268
+ typeLegend,
269
+ selectLccBoxTime,
270
+ );
271
+
232
272
  filterLayer = this.esriLayer_lcc;
233
273
 
234
274
  filterLayer.sublayers.items[0].name = this.addLegendName(typeLegend);
@@ -261,6 +301,14 @@ class HotspotWidget extends React.Component {
261
301
 
262
302
  let selectLcBoxTime = document.getElementById('select-klc-lcTime')
263
303
  .value;
304
+
305
+ this.addFilteredLayersData(
306
+ filteredLayersData,
307
+ this.dataBBox,
308
+ typeLegend,
309
+ selectLcBoxTime,
310
+ );
311
+
264
312
  //this.lcYear = selectLcBoxTime;
265
313
  this.setState({ lcYear: selectLcBoxTime });
266
314
  if (document.getElementById('select-klc-lcTime').value.match(/\d+/g)) {
@@ -347,11 +395,15 @@ class HotspotWidget extends React.Component {
347
395
  sessionStorage.setItem('hotspotFilterApplied', 'true');
348
396
  this.disableButton();
349
397
  this.props.mapLayersHandler(this.layers);
350
- this.filteredLayersToHotspotData(Object.keys(layersToAdd));
398
+ this.filteredLayersToHotspotData(
399
+ Object.keys(layersToAdd),
400
+ filteredLayersData,
401
+ );
351
402
  }
352
403
 
353
- filteredLayersToHotspotData(layerIds) {
404
+ filteredLayersToHotspotData(layerIds, layersData) {
354
405
  let updatedFilteredLayers = this.props.hotspotData['filteredLayers'] || {};
406
+ let filteredLayersData = this.props.hotspotData['filteredLayersData'] || {};
355
407
  let newHotspotData = this.props.hotspotData;
356
408
  layerIds.forEach((layerId) => {
357
409
  let layer = Object.entries(this.layers).find(
@@ -363,10 +415,20 @@ class HotspotWidget extends React.Component {
363
415
  delete updatedFilteredLayers[key];
364
416
  }
365
417
  });
366
-
367
418
  updatedFilteredLayers[layerId] = layer;
368
419
  });
420
+
421
+ Object.keys(layersData).forEach((layersDataKey) => {
422
+ Object.keys(filteredLayersData).forEach((filteredLayersDataKey) => {
423
+ if (layersDataKey === filteredLayersDataKey) {
424
+ delete filteredLayersData[filteredLayersDataKey];
425
+ }
426
+ });
427
+ filteredLayersData[layersDataKey] = layersData[layersDataKey];
428
+ });
429
+
369
430
  newHotspotData['filteredLayers'] = updatedFilteredLayers;
431
+ newHotspotData['filteredLayersData'] = filteredLayersData;
370
432
  return this.props.hotspotDataHandler(newHotspotData);
371
433
  }
372
434
 
@@ -101,7 +101,23 @@ class InfoWidget extends React.Component {
101
101
  let promises = [];
102
102
  let layerTypes = [];
103
103
  layers.forEach((layer, index) => {
104
- let title = this.getLayerTitle(layer);
104
+ let title;
105
+ if (this?.props?.hotspotData) {
106
+ let layerId = this.getLayerName(layer);
107
+ outerLoop: for (let key in this.props.hotspotData) {
108
+ let item = this.props.hotspotData[key];
109
+ for (let prop in item) {
110
+ if (prop === layerId) {
111
+ if (this.props.hotspotData[key][prop].Title !== undefined) {
112
+ title = this.props.hotspotData[key][prop].Title;
113
+ break outerLoop;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ } else {
119
+ title = this.getLayerTitle(layer);
120
+ }
105
121
  if (layer.isTimeSeries) {
106
122
  if (layer.url.toLowerCase().includes('wms')) {
107
123
  layerTypes.push({
@@ -246,12 +262,17 @@ class InfoWidget extends React.Component {
246
262
  } else {
247
263
  switch (layer.type) {
248
264
  case 'wms':
249
- if (data.type === 'FeatureCollection') {
265
+ if (
266
+ data &&
267
+ data.type &&
268
+ data.type === 'FeatureCollection'
269
+ ) {
250
270
  if (data.features.length) {
251
271
  properties = data.features[0].properties;
252
272
  properties = Object.entries(properties);
253
273
  }
254
274
  } else if (
275
+ data &&
255
276
  data.doctype &&
256
277
  data.doctype.name === 'html'
257
278
  ) {
@@ -268,6 +289,7 @@ class InfoWidget extends React.Component {
268
289
  properties = fields;
269
290
  }
270
291
  } else if (
292
+ data &&
271
293
  data.getElementsByTagName('FIELDS').length &&
272
294
  typeof data !== 'undefined'
273
295
  ) {
@@ -367,61 +389,115 @@ class InfoWidget extends React.Component {
367
389
  identifyWMS(layer, event) {
368
390
  let layerId = this.getLayerName(layer);
369
391
  let url = layer.featureInfoUrl ? layer.featureInfoUrl : layer.url;
370
- return this.wmsCapabilities(url).then((xml) => {
371
- let version = this.parseCapabilities(xml, 'wms_capabilities')[0]
372
- .attributes['version'];
373
- let format = this.parseFormat(xml, layerId);
374
- let times = '';
375
- let nTimes = 1;
376
- if (layer.isTimeSeries) {
377
- times = this.parseTime(xml, layerId);
378
- nTimes = times.length;
379
- }
380
- return esriRequest(url, {
381
- responseType: 'html',
382
- sync: 'true',
383
- query: {
384
- request: 'GetFeatureInfo',
385
- service: 'WMS',
386
- version: version,
387
- SRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
388
- CRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
389
- BBOX:
390
- '' +
391
- this.props.view.extent.xmin +
392
- ', ' +
393
- this.props.view.extent.ymin +
394
- ', ' +
395
- this.props.view.extent.xmax +
396
- ', ' +
397
- this.props.view.extent.ymax,
398
- HEIGHT: this.props.view.height,
399
- WIDTH: this.props.view.width,
400
- X: event.screenPoint.x,
401
- Y: event.screenPoint.y,
402
- QUERY_LAYERS: layerId,
403
- INFO_FORMAT: format,
404
- TIME: times ? times[0] + '/' + times[nTimes - 1] : '',
405
- FEATURE_COUNT: '' + nTimes,
406
- },
407
- })
408
- .then((response) => {
409
- let format = response.requestOptions.query.INFO_FORMAT;
410
- let data;
411
- if (format.includes('text')) {
412
- data = new window.DOMParser().parseFromString(
413
- response.data,
414
- 'text/html',
415
- );
416
- } else if (format.includes('json')) {
417
- data = JSON.parse(response.data);
392
+ if (this?.props?.hotspotData) {
393
+ for (let key in this.props.hotspotData) {
394
+ let item = this.props.hotspotData[key];
395
+ for (let prop in item) {
396
+ if (prop === layerId) {
397
+ return esriRequest(url, {
398
+ responseType: 'html',
399
+ sync: 'true',
400
+ query: {
401
+ request: 'GetFeatureInfo',
402
+ service: 'WMS',
403
+ version: '1.3.0',
404
+ SRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
405
+ CRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
406
+ BBOX:
407
+ '' +
408
+ this.props.view.extent.xmin +
409
+ ', ' +
410
+ this.props.view.extent.ymin +
411
+ ', ' +
412
+ this.props.view.extent.xmax +
413
+ ', ' +
414
+ this.props.view.extent.ymax,
415
+ HEIGHT: this.props.view.height,
416
+ WIDTH: this.props.view.width,
417
+ X: event.screenPoint.x,
418
+ Y: event.screenPoint.y,
419
+ QUERY_LAYERS: layerId,
420
+ INFO_FORMAT: 'application/json',
421
+ TIME: '/',
422
+ FEATURE_COUNT: '' + 1,
423
+ },
424
+ })
425
+ .then((response) => {
426
+ let format = response.requestOptions.query.INFO_FORMAT;
427
+ let data;
428
+ if (format.includes('text')) {
429
+ data = new window.DOMParser().parseFromString(
430
+ response.data,
431
+ 'text/html',
432
+ );
433
+ } else if (format.includes('json')) {
434
+ data = JSON.parse(response.data);
435
+ }
436
+ return data;
437
+ })
438
+ .then((data) => {
439
+ return data;
440
+ });
418
441
  }
419
- return data;
442
+ }
443
+ }
444
+ } else {
445
+ return this.wmsCapabilities(url).then((xml) => {
446
+ let version = this.parseCapabilities(xml, 'wms_capabilities')[0]
447
+ .attributes['version'];
448
+ let format = this.parseFormat(xml);
449
+ let times = '';
450
+ let nTimes = 1;
451
+ if (layer.isTimeSeries) {
452
+ times = this.parseTime(xml, layerId);
453
+ nTimes = times.length;
454
+ }
455
+ return esriRequest(url, {
456
+ responseType: 'html',
457
+ sync: 'true',
458
+ query: {
459
+ request: 'GetFeatureInfo',
460
+ service: 'WMS',
461
+ version: version,
462
+ SRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
463
+ CRS: 'EPSG:' + this.props.view.spatialReference.latestWkid,
464
+ BBOX:
465
+ '' +
466
+ this.props.view.extent.xmin +
467
+ ', ' +
468
+ this.props.view.extent.ymin +
469
+ ', ' +
470
+ this.props.view.extent.xmax +
471
+ ', ' +
472
+ this.props.view.extent.ymax,
473
+ HEIGHT: this.props.view.height,
474
+ WIDTH: this.props.view.width,
475
+ X: event.screenPoint.x,
476
+ Y: event.screenPoint.y,
477
+ QUERY_LAYERS: layerId,
478
+ INFO_FORMAT: format,
479
+ TIME: times ? times[0] + '/' + times[nTimes - 1] : '',
480
+ FEATURE_COUNT: '' + nTimes,
481
+ },
420
482
  })
421
- .then((data) => {
422
- return data;
423
- });
424
- });
483
+ .then((response) => {
484
+ let format = response.requestOptions.query.INFO_FORMAT;
485
+ let data;
486
+ if (format.includes('text')) {
487
+ data = new window.DOMParser().parseFromString(
488
+ response.data,
489
+ 'text/html',
490
+ );
491
+ } else if (format.includes('json')) {
492
+ data = JSON.parse(response.data);
493
+ }
494
+ return data;
495
+ })
496
+ .then((data) => {
497
+ return data;
498
+ });
499
+ });
500
+ }
425
501
  }
426
502
 
427
503
  wmsCapabilities(url) {
@@ -440,7 +516,8 @@ class InfoWidget extends React.Component {
440
516
  }
441
517
 
442
518
  parseCapabilities(xml, tag) {
443
- return xml.getElementsByTagName(tag);
519
+ let result = xml.getElementsByTagName(tag);
520
+ return result;
444
521
  }
445
522
 
446
523
  parseFormat(xml) {
@@ -356,7 +356,14 @@ class MapViewer extends React.Component {
356
356
 
357
357
  renderInfo() {
358
358
  if (this.view)
359
- return <InfoWidget view={this.view} map={this.map} mapViewer={this} />;
359
+ return (
360
+ <InfoWidget
361
+ view={this.view}
362
+ map={this.map}
363
+ mapViewer={this}
364
+ hotspotData={this.state.hotspotData}
365
+ />
366
+ );
360
367
  }
361
368
 
362
369
  renderPan() {
@@ -1350,7 +1350,7 @@ class MenuWidget extends React.Component {
1350
1350
  <a
1351
1351
  href={dataset.DatasetURL}
1352
1352
  target="_blank"
1353
- rel="noreferrer"
1353
+ rel="noopener noreferrer"
1354
1354
  onClick={(e) => e.stopPropagation()}
1355
1355
  onKeyDown={(e) => e.stopPropagation()}
1356
1356
  >
@@ -86,7 +86,7 @@ class InfoWidget extends React.Component {
86
86
  <a
87
87
  href={UseCase.Links_to_web_sites.split(' ')[0]}
88
88
  target="_blank"
89
- rel="noreferrer"
89
+ rel="noopener noreferrer"
90
90
  >
91
91
  {' '}
92
92
  here