@eeacms/volto-arcgis-block 0.1.100 → 0.1.102

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,6 +4,20 @@ 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.102](https://github.com/eea/volto-arcgis-block/compare/0.1.101...0.1.102) - 21 February 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - SPRINT-42 FIX: Passed linting and precommit [ujbolivar - [`d79f9c1`](https://github.com/eea/volto-arcgis-block/commit/d79f9c105082f5d78a2982fd815ed981f65c7d94)]
12
+ - SPRINT-42 FIX: final touches before first commit for testing in development env [ujbolivar - [`ae24c5e`](https://github.com/eea/volto-arcgis-block/commit/ae24c5e02296f32f6a21ae88c1eca3377a58c3c3)]
13
+ - SPRINT-42 FIX: Solution to be uploaded for testing in development environment [ujbolivar - [`2d0b377`](https://github.com/eea/volto-arcgis-block/commit/2d0b37786cc17bedbd65fca1224518a43e738af4)]
14
+ - FIX: If user has selected the time slider, and has had to log in, when returning, timeslider should open automatically [ujbolivar - [`46ad898`](https://github.com/eea/volto-arcgis-block/commit/46ad89838768bc659303d7fdaeb6bb2a30606fd3)]
15
+ ### [0.1.101](https://github.com/eea/volto-arcgis-block/compare/0.1.100...0.1.101) - 20 February 2023
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - CLMS-1581 fix: hotspot functions properly on window reload [ujbolivar - [`11d5a63`](https://github.com/eea/volto-arcgis-block/commit/11d5a637161afdcf583adaa04802b999bcaae5ce)]
20
+ - CLMS-1581 FIX: CORB expects text/plain MIME for hotspot layers. Widget open / close behavior fixed. [ujbolivar - [`cc19efc`](https://github.com/eea/volto-arcgis-block/commit/cc19efc49d5f7c8d6fa0cf52a5c8b24d3f51ab98)]
7
21
  ### [0.1.100](https://github.com/eea/volto-arcgis-block/compare/0.1.99...0.1.100) - 17 February 2023
8
22
 
9
23
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -35,7 +35,7 @@ class HotspotWidget extends React.Component {
35
35
  this.getKLCNames = this.getKLCNames.bind(this);
36
36
  this.layerModelInit = this.layerModelInit.bind(this);
37
37
  this.handleApplyFilter = this.handleApplyFilter.bind(this);
38
- this.getLayerParameters();
38
+ //this.getLayerParameters();
39
39
  }
40
40
 
41
41
  loader() {
@@ -44,33 +44,42 @@ class HotspotWidget extends React.Component {
44
44
  });
45
45
  }
46
46
 
47
+ addLegendName(legend) {
48
+ let name = legend;
49
+ return name;
50
+ }
51
+
52
+ addLegendNameToUrl(legend) {
53
+ const legendLinkUrl =
54
+ 'https://geospatial.jrc.ec.europa.eu/geoserver/hotspots/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=';
55
+ return legendLinkUrl + legend;
56
+ }
57
+
47
58
  layerModelInit() {
48
59
  const serviceUrl =
49
60
  'https://geospatial.jrc.ec.europa.eu/geoserver/hotspots/wms';
50
61
 
51
62
  this.esriLayer_lcc = new WMSLayer({
52
63
  url: serviceUrl,
53
- // featureInfoFormat: "text/html",
64
+ //featureInfoFormat: "application/json",
54
65
  customLayerParameters: {},
55
66
  sublayers: [
56
67
  // LAND COVER CHANGE DATASET ________________________________________________________________________________________________________________
57
68
  {
58
- name: 'all_lcc_a_pol',
59
- legendUrl:
60
- 'https://geospatial.jrc.ec.europa.eu/geoserver/hotspots/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=all_lcc_a_pol',
69
+ name: this.addLegendName('all_lcc_a_pol'),
70
+ legendUrl: this.addLegendNameToUrl('all_lcc_a_pol'),
61
71
  },
62
72
  ],
63
73
  });
64
74
  this.esriLayer_lc = new WMSLayer({
65
75
  url: serviceUrl,
66
- // featureInfoFormat: "text/html",
76
+ //featureInfoFormat: "application/json",
67
77
  customLayerParameters: {},
68
78
  sublayers: [
69
79
  // PRESENT LAND COVER DATASET ________________________________________________________________________________________________________________
70
80
  {
71
- name: 'all_lcc_a_pol',
72
- legendUrl:
73
- 'https://geospatial.jrc.ec.europa.eu/geoserver/hotspots/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=all_lcc_a_pol',
81
+ name: this.addLegendName('all_present_lc_a_pol'),
82
+ legendUrl: this.addLegendNameToUrl('all_present_lc_a_pol'),
74
83
  },
75
84
  ],
76
85
  });
@@ -109,13 +118,18 @@ class HotspotWidget extends React.Component {
109
118
  .getElementById('select-klc-lccTime')
110
119
  .value.match(/\d+/g)
111
120
  .map(Number)[0];
112
- /* var typeLegend =
121
+ let typeLegend =
113
122
  document.getElementById('select-klc-highlights-lcc').value ===
114
123
  'Dichotomous'
115
124
  ? 'all_lcc_a_pol'
116
- : 'all_lcc_b_pol'; */
125
+ : 'all_lcc_b_pol';
117
126
  if (this.esriLayer_lcc !== null) {
118
- //this.esriLayer_lcc.sublayers.items[0].name = typeLegend;
127
+ this.esriLayer_lcc.sublayers.items[0].name = this.addLegendName(
128
+ typeLegend,
129
+ );
130
+ this.esriLayer_lcc.sublayers.items[0].legendUrl = this.addLegendNameToUrl(
131
+ typeLegend,
132
+ );
119
133
  this.esriLayer_lcc.customLayerParameters['CQL_FILTER'] =
120
134
  'klc_code LIKE ' +
121
135
  "'" +
@@ -128,17 +142,21 @@ class HotspotWidget extends React.Component {
128
142
  this.props.selectedLayers['lcc_filter'].visible = true;
129
143
  }
130
144
  } else {
131
- /* var typeLegend =
132
- document.getElementById('select-klc-highlights-lcc').value ===
133
- 'Dichotomous'
145
+ let typeLegend =
146
+ document.getElementById('select-klc-highlights-lc').value === 'Modular'
134
147
  ? 'all_present_lc_a_pol'
135
- : 'all_present_lc_b_pol'; */
148
+ : 'all_present_lc_b_pol';
136
149
  var selectBoxHighlightsLc = document
137
150
  .getElementById('select-klc-lcTime')
138
151
  .value.match(/\d+/g)
139
152
  .map(Number)[0];
140
153
  if (this.esriLayer_lc !== null) {
141
- //this.esriLayer_lc.sublayers.items[0].name = typeLegend;
154
+ this.esriLayer_lc.sublayers.items[0].name = this.addLegendName(
155
+ typeLegend,
156
+ );
157
+ this.esriLayer_lc.sublayers.items[0].legendUrl = this.addLegendNameToUrl(
158
+ typeLegend,
159
+ );
142
160
  this.esriLayer_lc.customLayerParameters['CQL_FILTER'] =
143
161
  'klc_code LIKE ' +
144
162
  "'" +
@@ -167,13 +185,10 @@ class HotspotWidget extends React.Component {
167
185
  * button is clicked. It controls the open
168
186
  * and close actions of the component
169
187
  */
188
+
170
189
  openMenu() {
171
190
  if (this.state.showMapMenu) {
172
- if (this.dataJSONNames)
173
- this.getKLCNames(
174
- this.dataJSONNames,
175
- this.dataJSONNames[0].node.klc_name,
176
- );
191
+ this.getKLCNames(this.dataJSONNames, this.dataJSONNames[0].node.klc_name);
177
192
  this.props.mapViewer.setActiveWidget();
178
193
  this.container.current.querySelector('.right-panel').style.display =
179
194
  'none';
@@ -187,7 +202,12 @@ class HotspotWidget extends React.Component {
187
202
  // and ensure that the component is rendered again
188
203
  this.setState({ showMapMenu: false });
189
204
  } else {
190
- this.getKLCNames(this.dataJSONNames, this.dataJSONNames[0].node.klc_name);
205
+ this.getLayerParameters();
206
+ if (this.getLayerParameters.length !== 0)
207
+ this.getKLCNames(
208
+ this.dataJSONNames,
209
+ this.dataJSONNames[0].node.klc_name,
210
+ );
191
211
  this.props.mapViewer.setActiveWidget(this);
192
212
  this.container.current.querySelector('.right-panel').style.display =
193
213
  'flex';
@@ -203,7 +223,7 @@ class HotspotWidget extends React.Component {
203
223
  }
204
224
  }
205
225
 
206
- async getLayerParameters() {
226
+ getLayerParameters() {
207
227
  fetch('https://land.copernicus.eu/global/hsm/all_geo_klc_json')
208
228
  .then((data) => {
209
229
  if (data.status === 200) {
@@ -464,10 +484,15 @@ class HotspotWidget extends React.Component {
464
484
  );
465
485
  }
466
486
 
487
+ /**
488
+ * This method is executed before the render method is executed
489
+ */
490
+
467
491
  /**
468
492
  * This method is executed after the rener method is executed
469
493
  */
470
494
  async componentDidMount() {
495
+ await this.getLayerParameters();
471
496
  await this.loader();
472
497
  this.props.view.ui.add(this.container.current, 'top-right');
473
498
  this.layerModelInit();
@@ -482,6 +482,35 @@ class MenuWidget extends React.Component {
482
482
  this.loadVisibility();
483
483
  }
484
484
 
485
+ /**
486
+ * Active on map is tab and time slider widget is opened by default if the user selected time slider and is coming back from the EU pass login
487
+ */
488
+
489
+ componentDidUpdate(prevProps) {
490
+ if (this.props !== prevProps) {
491
+ let isLoggedIn = document
492
+ .querySelector('[defcheck=' + this.props.elem.id + ']')
493
+ .parentElement.querySelector('.map-menu-icon-login')
494
+ .classList.contains('logged');
495
+ if (this.props.sliderIsActive && isLoggedIn) {
496
+ let event = new MouseEvent('click', {
497
+ view: window,
498
+ bubbles: true,
499
+ cancelable: false,
500
+ });
501
+ let el = document.getElementById('active_label');
502
+ el.dispatchEvent(event);
503
+ this.showTimeSlider();
504
+ }
505
+ }
506
+ }
507
+
508
+ setActiveSlider(val) {
509
+ if (!sessionStorage.key('sliderIsActive'))
510
+ sessionStorage.setItem('sliderIsActive', 'false');
511
+ sessionStorage.setItem('sliderIsActive', val);
512
+ }
513
+
485
514
  /**
486
515
  * Close opacity panel if user clicks outside
487
516
  */
@@ -1395,11 +1424,14 @@ class MenuWidget extends React.Component {
1395
1424
  let hotspotButton = document.querySelector('#hotspot_button');
1396
1425
  let checkedLayers = JSON.parse(sessionStorage.getItem('checkedLayers'));
1397
1426
  checkedLayers.forEach((key) => {
1427
+ // if key includes all_present_lc_a_pol or all_lcc_a_pol and if the activeWidget is not the hotspot widget, click on the hotspot button, else close the active widget and set the hotspot container to display to none
1398
1428
  if (
1399
1429
  key.includes('all_present_lc_a_pol') ||
1400
1430
  key.includes('all_lcc_a_pol')
1401
1431
  ) {
1402
- hotspotButton.click();
1432
+ if (!this.props.mapViewer.activeWidget) {
1433
+ hotspotButton.click();
1434
+ }
1403
1435
  }
1404
1436
  });
1405
1437
  }
@@ -1848,7 +1880,14 @@ class MenuWidget extends React.Component {
1848
1880
  * @param {*} e From the click event
1849
1881
  * @param {*} id id from elem
1850
1882
  */
1883
+
1851
1884
  showTimeSlider(elem, fromDownload) {
1885
+ if (
1886
+ sessionStorage.key('sliderIsActive') &&
1887
+ sessionStorage.getItem('sliderIsActive') === 'false'
1888
+ )
1889
+ this.setActiveSlider(true);
1890
+ else this.setActiveSlider(false);
1852
1891
  let activeLayers = document.querySelectorAll('.active-layer');
1853
1892
  let group = this.getGroup(elem);
1854
1893
  let groupLayers = this.getGroupLayers(group);