@eeacms/volto-arcgis-block 0.1.266 → 0.1.268

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/CHANGELOG.md CHANGED
@@ -4,10 +4,23 @@ 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.268](https://github.com/eea/volto-arcgis-block/compare/0.1.267...0.1.268) - 21 March 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-2383-3050 (bug): allowed file size limit alert corrected. alerts text centered [Unai Bolivar - [`0666ab3`](https://github.com/eea/volto-arcgis-block/commit/0666ab320382db18367bf1076db91e6fe2f6145e)]
12
+ - CLMS-2383-3050 (chore): commented logs [Unai Bolivar - [`f68b1a9`](https://github.com/eea/volto-arcgis-block/commit/f68b1a90d4b77b73446cfd7b45ee310a6eb3dee1)]
13
+ - CLMS-2383-3050 (bug): corrected graphic overlay. corrected add to cart bug. CSV fileu upload disabled [Unai Bolivar - [`4f43430`](https://github.com/eea/volto-arcgis-block/commit/4f434304f4013725b86d302991d826cf861c9c57)]
14
+ ### [0.1.267](https://github.com/eea/volto-arcgis-block/compare/0.1.266...0.1.267) - 20 March 2024
15
+
16
+ #### :hammer_and_wrench: Others
17
+
18
+ - CLMS-BOOKMARK-MARKER (bug): marker is erased and widget closed if layers in menu widget are un checked [Unai Bolivar - [`0fb3ac9`](https://github.com/eea/volto-arcgis-block/commit/0fb3ac9e7c553b59b2af7fb5b2b0b213c8fa0885)]
7
19
  ### [0.1.266](https://github.com/eea/volto-arcgis-block/compare/0.1.265...0.1.266) - 19 March 2024
8
20
 
9
21
  #### :hammer_and_wrench: Others
10
22
 
23
+ - Merge pull request #732 from eea/develop [Unai Bolivar - [`5619658`](https://github.com/eea/volto-arcgis-block/commit/5619658a6e61305994ec50c7ead5bedf2d494d43)]
11
24
  - CLMS-2383-3050 (chore): added FAQ hyperlink [Unai Bolivar - [`445af32`](https://github.com/eea/volto-arcgis-block/commit/445af32d2a7c4326f3369657378bbe97b1cb4c2f)]
12
25
  - CLMS-2383-3050 (chore): fixed lint error 2 [Unai Bolivar - [`93114ff`](https://github.com/eea/volto-arcgis-block/commit/93114ff28cc2ad1414a079e09489a0c732e8d8ff)]
13
26
  - CLMS-2383-3050 (chore): fixed lint error [Unai Bolivar - [`0b53f2e`](https://github.com/eea/volto-arcgis-block/commit/0b53f2e4237aa111e667978c2f97459e1ba7c468)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.266",
3
+ "version": "0.1.268",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -212,7 +212,7 @@ class AreaWidget extends React.Component {
212
212
  //definitionExpression: 'LEVL_CODE=' + level,
213
213
  });
214
214
 
215
- this.removeFileUploadedLayer();
215
+ //this.removeFileUploadedLayer();
216
216
 
217
217
  this.nutsGroupLayer.add(layer);
218
218
 
@@ -223,6 +223,7 @@ class AreaWidget extends React.Component {
223
223
  }
224
224
 
225
225
  loadCountriesService(id) {
226
+ //debugger;
226
227
  document.querySelector('.esri-attribution__powered-by').style.display =
227
228
  'flex';
228
229
  var layer = new FeatureLayer({
@@ -235,7 +236,7 @@ class AreaWidget extends React.Component {
235
236
  popupEnabled: false,
236
237
  });
237
238
 
238
- this.removeFileUploadedLayer();
239
+ //this.removeFileUploadedLayer();
239
240
 
240
241
  this.nutsGroupLayer.add(layer);
241
242
 
@@ -253,24 +254,23 @@ class AreaWidget extends React.Component {
253
254
  };
254
255
 
255
256
  handleFileUpload = (e) => {
256
- //Store the file as Blob
257
- let fileBlob = e.target.files[0];
258
257
  //Get the file name
259
258
  const fileName = e.target.value.toLowerCase();
260
259
  //console.log('file name: ', fileName);
261
260
 
261
+ //Get the file size
262
+ const fileSize = e.target.files[0].size;
262
263
  //Get the file from the form
263
264
  const file = document.getElementById('uploadForm');
264
265
  //console.log('uploaded file from form: ', file);
265
266
 
266
267
  //List allowed file extensions
267
- let fileExtensions = ['zip', 'geojson', 'csv'];
268
+ let fileExtensions = ['zip', 'geojson'];
268
269
 
269
270
  // Get the file extension
270
271
  let fileExtension = fileName.split('.').pop();
271
272
 
272
273
  //console.log('file extension: ', fileExtension);
273
-
274
274
  //Check if the file format is not supported
275
275
  if (fileExtensions.indexOf(fileExtension) === -1) {
276
276
  this.setState({
@@ -280,12 +280,9 @@ class AreaWidget extends React.Component {
280
280
  return;
281
281
  }
282
282
 
283
- //Check if the file size is over the 10mb file size limit
284
- if (
285
- (file.size > 2000000 && fileExtension === 'zip') ||
286
- (file.size > 1000000 && fileExtension === 'geojson') ||
287
- (file.size > 1000000 && fileExtension === 'csv')
288
- ) {
283
+ // Check if the file is a geojson or CSV and the file size is over the 10mb file size limit
284
+ // or file is a shape file and the file size is over the 2mb file size limit
285
+ if (fileSize > 10485760 && fileExtension === 'geojson') {
289
286
  this.setState({
290
287
  showInfoPopup: true,
291
288
  infoPopupType: 'fileLimit',
@@ -293,31 +290,13 @@ class AreaWidget extends React.Component {
293
290
  return;
294
291
  }
295
292
 
296
- //Read the file
297
- let reader = new FileReader();
298
-
299
- reader.onload = (event) => {
300
- switch (fileExtension) {
301
- // case 'zip':
302
- // this.handleShp(event.target.result);
303
- // break;
304
- // case 'geojson':
305
- // let parsedData;
306
- // try {
307
- // parsedData = JSON.parse(event.target.result);
308
- // } catch (e) {
309
- // console.error('Failed to parse JSON', e);
310
- // return;
311
- // }
312
- // this.handleGeoJson(parsedData);
313
- // break;
314
- case 'csv':
315
- this.handleCsv(event.target.result);
316
- break;
317
- default:
318
- break;
319
- }
320
- };
293
+ if (fileSize > 2097152 && fileExtension === 'zip') {
294
+ this.setState({
295
+ showInfoPopup: true,
296
+ infoPopupType: 'shapefileLimit',
297
+ });
298
+ return;
299
+ }
321
300
 
322
301
  switch (fileExtension) {
323
302
  case 'zip':
@@ -328,14 +307,14 @@ class AreaWidget extends React.Component {
328
307
  this.generateFeatureCollection(fileName, file, 'geojson');
329
308
  //reader.readAsText(file);
330
309
  break;
331
- case 'csv':
332
- //this.generateFeatureCollection(
333
- // fileName,
334
- // file,
335
- // 'csv',
336
- //);
337
- reader.readAsText(fileBlob);
338
- break;
310
+ //case 'csv':
311
+ //this.generateFeatureCollection(
312
+ // fileName,
313
+ // file,
314
+ // 'csv',
315
+ //);
316
+ // reader.readAsText(fileBlob);
317
+ // break;
339
318
  default:
340
319
  break;
341
320
  }
@@ -383,27 +362,70 @@ class AreaWidget extends React.Component {
383
362
  return;
384
363
  //Create a feature layer from the feature collection
385
364
  this.addFeatureCollectionToMap(response.data.featureCollection);
365
+ //console.log(data);
366
+ //this.loadFileUploadService(response.data.featureCollection);
386
367
  } else {
387
368
  //console.error('Unexpected response structure:', response);
388
369
  }
389
370
  })
390
371
  .catch((error) => {
391
- //console.error('From generateFeatureCollection function', error);
372
+ //console.error('Failed to generate feature collection:', error);
392
373
  });
393
374
  }
394
375
 
376
+ loadFileUploadService(data) {
377
+ //debugger;
378
+ document.querySelector('.esri-attribution__powered-by').style.display =
379
+ 'flex';
380
+ const blob = new Blob([data], {
381
+ type: 'json',
382
+ });
383
+ const url = URL.createObjectURL(blob);
384
+
385
+ var layer = new FeatureLayer({
386
+ id: 9,
387
+ //url: this.props.urls.outsideEu,
388
+ url: url,
389
+ layerId: 9,
390
+ outFields: ['*'],
391
+ popupEnabled: false,
392
+ title: 'upload',
393
+ });
394
+
395
+ //this.removeFileUploadedLayer();
396
+
397
+ this.removeNutsLayers();
398
+
399
+ this.nutsGroupLayer.add(layer);
400
+
401
+ let index = this.getHighestIndex();
402
+
403
+ this.props.map.reorder(this.nutsGroupLayer, index + 1);
404
+ }
405
+
395
406
  // add the feature collection to the map and zoom to the feature collection extent
396
407
  // if you want to persist the feature collection when you reload browser, you could store the
397
408
  // collection in local storage by serializing the layer using featureLayer.toJson()
398
409
  // see the 'Feature Collection in Local Storage' sample for an example of how to work with local storage
399
410
  addFeatureCollectionToMap(featureCollection) {
411
+ //console.log('feature collection: ', featureCollection);
400
412
  let sourceGraphics = [];
413
+ const symbol = new SimpleFillSymbol({
414
+ //type: 'simple-fill',
415
+ color: [255, 255, 255, 0.5],
416
+ outline: {
417
+ color: [0, 0, 0],
418
+ width: 1,
419
+ },
420
+ });
401
421
  const layers = featureCollection.layers.map((layer) => {
402
422
  const graphics = layer.featureSet.features.map((feature) => {
423
+ feature.symbol = symbol;
403
424
  return Graphic.fromJSON(feature);
404
425
  });
405
426
  sourceGraphics = sourceGraphics.concat(graphics);
406
427
  const featureLayer = new FeatureLayer({
428
+ // id: 9,
407
429
  objectIdField: 'FID',
408
430
  source: graphics,
409
431
  legendEnabled: false,
@@ -411,12 +433,46 @@ class AreaWidget extends React.Component {
411
433
  fields: layer.layerDefinition.fields.map((field) => {
412
434
  return Field.fromJSON(field);
413
435
  }),
436
+ // layerId: 9,
437
+ // outFields: ['*'],
438
+ // popupEnabled: false,
414
439
  });
440
+ //featureLayer.renderer = {
441
+ // type: 'simple-fill',
442
+ // color: [255, 255, 255, 0.5],
443
+ // outline: {
444
+ // color: [0, 0, 0],
445
+ // width: 1,
446
+ // },
447
+ //}
448
+ //featureLayer.renderer = {
449
+ // type: "simple", // autocasts as new SimpleRenderer()
450
+ // symbol: {
451
+ // type: "simple-fill", // autocasts as new SimpleMarkerSymbol()
452
+ // //size: 20,
453
+ // color: [255, 255, 255, 0.5],
454
+ // outline: { // autocasts as new SimpleLineSymbol()
455
+ // width: 1,
456
+ // color: [0, 0, 0]
457
+ // }
458
+ // }
459
+ //};
460
+ //featureLayer.renderer = {
461
+ // type: "simple", // autocasts as new SimpleRenderer()
462
+ // symbol: {
463
+ // type: "simple-fill", // autocasts as new SimpleMarkerSymbol()
464
+ // size: 20,
465
+ // color: "green",
466
+ // outline: { // autocasts as new SimpleLineSymbol()
467
+ // width: 4.5,
468
+ // color: "blue"
469
+ // }
470
+ // }
471
+ //};
415
472
  return featureLayer;
416
473
  });
417
-
418
474
  //Check for the correct spatial reference
419
- //console.log("layer: ", layers);
475
+ //console.log('layer: ', layers);
420
476
  if (this.checkWkid(layers[0]?.spatialReference) === false) return;
421
477
 
422
478
  let geometry = new Extent(
@@ -437,15 +493,14 @@ class AreaWidget extends React.Component {
437
493
  this.removeNutsLayers();
438
494
 
439
495
  //Add uploaded layer to the map and zoom to the extent
440
- this.props.map.addMany(layers);
496
+ //this.props.map.addMany(layers);
497
+ this.props.view.graphics.addMany(sourceGraphics);
441
498
  this.props.view.goTo(sourceGraphics).catch((error) => {
442
499
  //console.error('From addFeatureCollectionToMap function', error);
443
500
  });
501
+ //console.log('source graphics: ', sourceGraphics);
444
502
  //Send the area to the parent component
445
- this.props.updateArea({
446
- origin: { x: geometry.extent.xmin, y: geometry.extent.ymin },
447
- end: { x: geometry.extent.xmax, y: geometry.extent.ymax },
448
- });
503
+ this.props.updateArea(sourceGraphics[0]);
449
504
  //Order the layer in the map
450
505
  let index = this.getHighestIndex();
451
506
  this.props.map.reorder(this.fileUploadLayer, index + 1);
@@ -566,16 +621,22 @@ class AreaWidget extends React.Component {
566
621
  removeNutsLayers() {
567
622
  //find all the radio buttons
568
623
  let radioButtons = document.querySelectorAll('fieldset.ccl-fieldset');
569
-
570
- // Isolate the the checked radio button
571
- let selectedRadioButton = Array.from(radioButtons).find(
572
- (radioButton) => radioButton.querySelector('input').checked,
624
+ let rectangleRadioButton = document.querySelector(
625
+ '#download_area_select_rectangle',
573
626
  );
627
+ // Isolate the the checked radio button
628
+ let selectedRadioButton = Array.from(radioButtons).find((radioButton) => {
629
+ let input = radioButton.querySelector('input');
630
+ return input && input.type === 'radio' && input.checked;
631
+ });
574
632
 
575
633
  //Uncheck the selected radio button
576
634
  if (selectedRadioButton) {
577
635
  selectedRadioButton.querySelector('input').checked = false;
578
636
  }
637
+ if (rectangleRadioButton.checked) {
638
+ rectangleRadioButton.checked = false;
639
+ }
579
640
 
580
641
  //Remove the layers in this.nutsGroupLayer from the map
581
642
  //this.nutsGroupLayer.removeAll();
@@ -586,9 +647,10 @@ class AreaWidget extends React.Component {
586
647
 
587
648
  removeFileUploadedLayer() {
588
649
  if (this.fileUploadLayer !== null) {
589
- this.props.map.removeMany(this.fileUploadLayer.layers);
590
- //this.props.view.graphics.removeMany(this.fileUploadLayer.sourceGraphics);
591
- this.fileUploadLayer = null;
650
+ // this.props.map.removeMany(this.fileUploadLayer.layers);
651
+ // //this.props.view.graphics.removeMany(this.fileUploadLayer.sourceGraphics);
652
+ // this.fileUploadLayer = null;
653
+ this.clearWidget();
592
654
  }
593
655
  }
594
656
 
@@ -772,7 +834,7 @@ class AreaWidget extends React.Component {
772
834
  let graphic = response.results.filter((result) => {
773
835
  let layer;
774
836
  if (
775
- 'nuts0 nuts1 nuts2 nuts3 countries'.includes(
837
+ 'nuts0 nuts1 nuts2 nuts3 countries upload'.includes(
776
838
  result.graphic.layer.id,
777
839
  )
778
840
  ) {
@@ -1051,9 +1113,7 @@ class AreaWidget extends React.Component {
1051
1113
  >
1052
1114
  <div className="field">
1053
1115
  <label className="file-upload">
1054
- <span>
1055
- File formats supported: shp(zip), geojson, csv
1056
- </span>
1116
+ <span>File formats supported: shp(zip), geojson</span>
1057
1117
  <input
1058
1118
  type="file"
1059
1119
  name="file"
@@ -1138,7 +1198,19 @@ class AreaWidget extends React.Component {
1138
1198
  <FontAwesomeIcon icon={['fas', 'info-circle']} />
1139
1199
  </span>
1140
1200
  <div className="drawRectanglePopup-text">
1141
- Uploading files larger than 10MB is not allowed.
1201
+ Uploading geojson or csv files larger than 10MB is not
1202
+ allowed.
1203
+ </div>
1204
+ </>
1205
+ )}
1206
+ {this.state.infoPopupType === 'shapefileLimit' && (
1207
+ <>
1208
+ <span className="drawRectanglePopup-icon">
1209
+ <FontAwesomeIcon icon={['fas', 'info-circle']} />
1210
+ </span>
1211
+ <div className="drawRectanglePopup-text">
1212
+ Uploading shapefiles files larger than 2MB is not
1213
+ allowed.
1142
1214
  </div>
1143
1215
  </>
1144
1216
  )}
@@ -31,7 +31,7 @@ export const AddCartItem = ({
31
31
  const { addCartItem, isLoggedIn } = useCartState();
32
32
 
33
33
  const checkArea = (e) => {
34
- let check = document.querySelector('.area-panel input:checked').value;
34
+ let check = document.querySelector('.area-panel input:checked')?.value;
35
35
  let area = {};
36
36
  if (check === 'area') {
37
37
  let graphics = mapViewer.view.graphics;
@@ -77,7 +77,7 @@ export const AddCartItem = ({
77
77
  const checkExtent = (e) => {
78
78
  let intersection = false;
79
79
  let areaExtent = null;
80
- let check = document.querySelector('.area-panel input:checked').value;
80
+ let check = document.querySelector('.area-panel input:checked')?.value;
81
81
  if (check === 'area') {
82
82
  areaExtent = new Extent({
83
83
  xmin: Math.min(areaData.end.x, areaData.origin.x),
@@ -3131,6 +3131,16 @@ class MenuWidget extends React.Component {
3131
3131
  }
3132
3132
  });
3133
3133
  if (layers.length === 0 && document.querySelector('.info-container')) {
3134
+ if (
3135
+ this.props.view.graphics.items.find((a) => {
3136
+ return a.attributes ? a.attributes.id === 'pixel-info' : false;
3137
+ })
3138
+ ) {
3139
+ let marker = this.props.view.graphics.items.find((a) => {
3140
+ return a.attributes && a.attributes.id === 'pixel-info';
3141
+ });
3142
+ this.props.view.graphics.remove(marker);
3143
+ }
3134
3144
  if (
3135
3145
  this.props.mapViewer.activeWidget?.container.current.className ===
3136
3146
  'info-container esri-component'
@@ -1396,7 +1396,8 @@ input[type='range']::-ms-track {
1396
1396
  }
1397
1397
 
1398
1398
  .drawRectanglePopup-text {
1399
- flex: auto;
1399
+ align-content: center;
1400
+ /* flex: auto; */
1400
1401
  font-family: 'Lato', sans-serif;
1401
1402
  font-size: 0.875rem;
1402
1403
  }