@eeacms/volto-arcgis-block 0.1.106 → 0.1.108

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,19 @@ 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.108](https://github.com/eea/volto-arcgis-block/compare/0.1.107...0.1.108) - 27 February 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Delete comment [Amanda Rodriguez - [`873a594`](https://github.com/eea/volto-arcgis-block/commit/873a594332908ee6d39dfbbc2239a06455a9ebc6)]
12
+ - CLMS-1831 [Amanda Rodriguez - [`0df846a`](https://github.com/eea/volto-arcgis-block/commit/0df846a7fce73e2d6b395b26677175702cc49b36)]
13
+ - CLMS-1843 [Amanda Rodriguez - [`839a331`](https://github.com/eea/volto-arcgis-block/commit/839a331049cf47d396300c2825eef6666e159609)]
14
+ - Time slider bug fix [Amanda Rodriguez - [`d383ee3`](https://github.com/eea/volto-arcgis-block/commit/d383ee38625ee2a528e07babf65340717aab9034)]
15
+ ### [0.1.107](https://github.com/eea/volto-arcgis-block/compare/0.1.106...0.1.107) - 23 February 2023
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - SPRINT-42 FIX: Display timeslider and calendar is user logs in after selecting a layer's timeslider function [ujbolivar - [`b554678`](https://github.com/eea/volto-arcgis-block/commit/b554678ed043043f50d4010424eacb709e91e80c)]
7
20
  ### [0.1.106](https://github.com/eea/volto-arcgis-block/compare/0.1.105...0.1.106) - 23 February 2023
8
21
 
9
22
  #### :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.106",
3
+ "version": "0.1.108",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -78,9 +78,7 @@ export const AddCartItem = ({
78
78
  if (hasTimeStart) {
79
79
  let datasetInput = document.querySelector(
80
80
  '#active_' +
81
- datasetElem
82
- .querySelector('.map-dataset-checkbox input')
83
- .getAttribute('defcheck'),
81
+ datasetElem.querySelector('.map-menu-layer input:checked').id,
84
82
  );
85
83
  let time = {
86
84
  start: parseInt(datasetInput.getAttribute('time-start')),
@@ -117,9 +115,7 @@ export const AddCartItem = ({
117
115
  let datasetElem = document.querySelector('[datasetid="' + id + '"]');
118
116
  let datasetActive = document.querySelector(
119
117
  '#active_' +
120
- datasetElem
121
- .querySelector('.map-dataset-checkbox input')
122
- .getAttribute('defcheck'),
118
+ datasetElem.querySelector('.map-menu-layer input:checked').id,
123
119
  );
124
120
  return datasetActive ? datasetActive.hasAttribute('time-start') : false;
125
121
  };
@@ -139,11 +135,11 @@ export const AddCartItem = ({
139
135
  if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
140
136
  document.getElementById('active_label').click();
141
137
  if (!document.querySelector('.timeslider-container')) {
142
- let layerId = document
143
- .querySelector(
144
- '[datasetid="' + dataset.DatasetId + '"] input',
145
- )
146
- .getAttribute('defcheck');
138
+ let layerId = document.querySelector(
139
+ '[datasetid="' +
140
+ dataset.DatasetId +
141
+ '"] .map-menu-layer input:checked',
142
+ ).id;
147
143
  document
148
144
  .querySelector(
149
145
  "[layer-id='" + layerId + "'] .active-layer-time",
@@ -177,11 +173,11 @@ export const AddCartItem = ({
177
173
  if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
178
174
  document.getElementById('active_label').click();
179
175
  if (!document.querySelector('.timeslider-container')) {
180
- let layerId = document
181
- .querySelector(
182
- '[datasetid="' + dataset.DatasetId + '"] input',
183
- )
184
- .getAttribute('defcheck');
176
+ let layerId = document.querySelector(
177
+ '[datasetid="' +
178
+ dataset.DatasetId +
179
+ '"] .map-menu-layer input:checked',
180
+ ).id;
185
181
  document
186
182
  .querySelector(
187
183
  "[layer-id='" + layerId + "'] .active-layer-time",
@@ -205,11 +201,11 @@ export const AddCartItem = ({
205
201
  if (dataset.IsTimeSeries && !checkTimeData(dataset)) {
206
202
  document.getElementById('active_label').click();
207
203
  if (!document.querySelector('.timeslider-container')) {
208
- let layerId = document
209
- .querySelector(
210
- '[datasetid="' + dataset.DatasetId + '"] input',
211
- )
212
- .getAttribute('defcheck');
204
+ let layerId = document.querySelector(
205
+ '[datasetid="' +
206
+ dataset.DatasetId +
207
+ '"] .map-menu-layer input:checked',
208
+ ).id;
213
209
  document
214
210
  .querySelector(
215
211
  "[layer-id='" + layerId + "'] .active-layer-time",
@@ -394,76 +390,136 @@ class MenuWidget extends React.Component {
394
390
  this.setState({ noServiceModal: true });
395
391
  };
396
392
 
393
+ getCookie(name) {
394
+ var dc = document.cookie;
395
+ var prefix = name + '=';
396
+ var begin = dc.indexOf('; ' + prefix);
397
+ if (begin === -1) {
398
+ begin = dc.indexOf(prefix);
399
+ if (begin !== 0) return null;
400
+ } else {
401
+ begin += 2;
402
+ var end = document.cookie.indexOf(';', begin);
403
+ if (end === -1) {
404
+ end = dc.length;
405
+ }
406
+ }
407
+ return decodeURI(dc.substring(begin + prefix.length, end));
408
+ }
409
+
397
410
  /**
398
411
  * Method that will be invoked when the
399
412
  * button is clicked. It controls the open
400
413
  * and close actions of the component
401
414
  */
402
415
  openMenu() {
403
- if (this.state.showMapMenu) {
404
- this.container.current.querySelector('#tabcontainer').style.display =
405
- 'none';
406
- this.container.current.querySelector('#paneles').style.display = 'none';
407
- this.container.current
408
- .querySelector('.esri-widget--button')
409
- .classList.replace('esri-icon-close', 'esri-icon-drag-horizontal');
410
- if (document.contains(document.querySelector('.timeslider-container'))) {
411
- document.querySelector('.timeslider-container').style.display = 'none';
416
+ setTimeout(() => {
417
+ if (this.state.showMapMenu) {
418
+ this.container.current.querySelector('#tabcontainer').style.display =
419
+ 'none';
420
+ this.container.current.querySelector('#paneles').style.display = 'none';
421
+ this.container.current
422
+ .querySelector('.esri-widget--button')
423
+ .classList.replace('esri-icon-close', 'esri-icon-drag-horizontal');
424
+ if (
425
+ document.contains(document.querySelector('.timeslider-container'))
426
+ ) {
427
+ document.querySelector('.timeslider-container').style.display =
428
+ 'none';
429
+ }
430
+ if (
431
+ document.querySelector('.opacity-panel').style.display === 'block'
432
+ ) {
433
+ this.closeOpacity();
434
+ }
435
+
436
+ // By invoking the setState, we notify the state we want to reach
437
+ // and ensure that the component is rendered again
438
+ this.setState({ showMapMenu: false });
439
+ } else {
440
+ this.container.current.querySelector('#tabcontainer').style.display =
441
+ 'block';
442
+ this.container.current.querySelector('#paneles').style.display =
443
+ 'block';
444
+ this.container.current
445
+ .querySelector('.esri-widget--button')
446
+ .classList.replace('esri-icon-drag-horizontal', 'esri-icon-close');
447
+ if (document.contains(document.querySelector('.timeslider-container')))
448
+ document.querySelector('.timeslider-container').style.display =
449
+ 'block';
450
+
451
+ // By invoking the setState, we notify the state we want to reach
452
+ // and ensure that the component is rendered again
453
+ this.setState({ showMapMenu: true });
412
454
  }
413
- if (document.querySelector('.opacity-panel').style.display === 'block') {
414
- this.closeOpacity();
455
+ if (this.loadFirst) {
456
+ this.checkUrl();
457
+ this.loadFirst = false;
458
+ this.zoomTooltips();
415
459
  }
416
460
 
417
- // By invoking the setState, we notify the state we want to reach
418
- // and ensure that the component is rendered again
419
- this.setState({ showMapMenu: false });
420
- } else {
421
- this.container.current.querySelector('#tabcontainer').style.display =
422
- 'block';
423
- this.container.current.querySelector('#paneles').style.display = 'block';
424
- this.container.current
425
- .querySelector('.esri-widget--button')
426
- .classList.replace('esri-icon-drag-horizontal', 'esri-icon-close');
427
- if (document.contains(document.querySelector('.timeslider-container')))
428
- document.querySelector('.timeslider-container').style.display = 'block';
429
-
430
- // By invoking the setState, we notify the state we want to reach
431
- // and ensure that the component is rendered again
432
- this.setState({ showMapMenu: true });
433
- }
434
- if (this.loadFirst) {
435
- this.checkUrl();
436
- this.loadFirst = false;
437
- this.zoomTooltips();
438
- }
461
+ let authToken = this.getAuthToken();
462
+ let timeSliderTag = this.getTimeSliderTag();
463
+ let checkedLayers = JSON.parse(sessionStorage.getItem('checkedLayers'));
439
464
 
440
- // CLMS-1389
441
- // "Active on map" section and the time slider opened by default if download and timeseries == true
442
- if (this.layers)
443
- if (this.props.download && this.layers) {
444
- let layerid = Object.keys(this.layers)[0];
465
+ // "Active on map" section and the time slider opened by default if user is logged in and timeSliderTag is true
445
466
 
446
- if (
447
- layerid &&
448
- this.layers[layerid].isTimeSeries &&
449
- !this.container.current
450
- .querySelector('.esri-widget')
451
- .classList.contains('esri-icon-drag-horizontal')
452
- ) {
453
- // select active on map tab
454
- let event = new MouseEvent('click', {
455
- view: window,
456
- bubbles: true,
457
- cancelable: false,
458
- });
459
- let el = document.getElementById('active_label');
460
- el.dispatchEvent(event);
461
-
462
- //open time slider
463
- let layerElem = document.getElementById(layerid);
464
- this.showTimeSlider(layerElem, true);
467
+ if (checkedLayers) {
468
+ if (authToken && timeSliderTag) {
469
+ for (let i = 0; i < checkedLayers.length; i++) {
470
+ let layerid = checkedLayers[i];
471
+ if (
472
+ layerid &&
473
+ this.layers[layerid].isTimeSeries &&
474
+ !this.container.current
475
+ .querySelector('.esri-widget')
476
+ .classList.contains('esri-icon-drag-horizontal')
477
+ ) {
478
+ // select active on map tab
479
+ let event = new MouseEvent('click', {
480
+ view: window,
481
+ bubbles: true,
482
+ cancelable: false,
483
+ });
484
+ let el = document.getElementById('active_label');
485
+ el.dispatchEvent(event);
486
+
487
+ //open time slider
488
+ let layerElem = document.getElementById(layerid);
489
+ this.showTimeSlider(layerElem, true);
490
+ break;
491
+ }
492
+ }
465
493
  }
466
494
  }
495
+ // CLMS-1389
496
+ // "Active on map" section and the time slider opened by default if download and timeseries == true
497
+
498
+ if (this.layers)
499
+ if (this.props.download && this.layers) {
500
+ let layerid = Object.keys(this.layers)[0];
501
+ if (
502
+ layerid &&
503
+ this.layers[layerid].isTimeSeries &&
504
+ !this.container.current
505
+ .querySelector('.esri-widget')
506
+ .classList.contains('esri-icon-drag-horizontal')
507
+ ) {
508
+ // select active on map tab
509
+ let event = new MouseEvent('click', {
510
+ view: window,
511
+ bubbles: true,
512
+ cancelable: false,
513
+ });
514
+ let el = document.getElementById('active_label');
515
+ el.dispatchEvent(event);
516
+
517
+ //open time slider
518
+ let layerElem = document.getElementById(layerid);
519
+ this.showTimeSlider(layerElem, true);
520
+ }
521
+ }
522
+ }, 1000);
467
523
  }
468
524
 
469
525
  /**
@@ -501,8 +557,26 @@ class MenuWidget extends React.Component {
501
557
 
502
558
  setSliderTag(val) {
503
559
  if (!sessionStorage.key('timeSliderTag'))
504
- sessionStorage.setItem('timeSliderTag', 'false');
505
- sessionStorage.setItem('timeSliderTag', val);
560
+ sessionStorage.setItem('timeSliderTag', 'true');
561
+ else sessionStorage.setItem('timeSliderTag', val);
562
+ }
563
+
564
+ getAuthToken() {
565
+ let tokenResult = null;
566
+ if (this.getCookie('auth_token')) {
567
+ tokenResult = true;
568
+ } else {
569
+ tokenResult = false;
570
+ }
571
+ return tokenResult;
572
+ }
573
+
574
+ getTimeSliderTag() {
575
+ let tagResult = true;
576
+ if (!sessionStorage.key('timeSliderTag')) {
577
+ tagResult = false;
578
+ }
579
+ return tagResult;
506
580
  }
507
581
 
508
582
  /**
@@ -850,7 +924,7 @@ class MenuWidget extends React.Component {
850
924
  */
851
925
  updateCheckProduct(productid) {
852
926
  let datasetChecks = Array.from(
853
- document.querySelectorAll('[parentid=' + productid + ']'),
927
+ document.querySelectorAll('[parentid="' + productid + '"]'),
854
928
  );
855
929
  let productCheck = document.querySelector('#' + productid);
856
930
  let trueCheck = datasetChecks.filter((elem) => elem.checked).length;
@@ -1102,7 +1176,7 @@ class MenuWidget extends React.Component {
1102
1176
  updateCheckDataset(id) {
1103
1177
  let datasetCheck = document.querySelector('#' + id);
1104
1178
  let layerChecks = Array.from(
1105
- document.querySelectorAll('[parentid=' + id + ']'),
1179
+ document.querySelectorAll('[parentid="' + id + '"]'),
1106
1180
  );
1107
1181
 
1108
1182
  let trueChecks = layerChecks.filter((elem) => elem.checked).length;
@@ -1882,10 +1956,10 @@ class MenuWidget extends React.Component {
1882
1956
  showTimeSlider(elem, fromDownload) {
1883
1957
  if (
1884
1958
  sessionStorage.key('timeSliderTag') &&
1885
- sessionStorage.getItem('timeSliderTag') === 'false'
1959
+ sessionStorage.getItem('timeSliderTag') === 'true'
1886
1960
  )
1887
- this.setSliderTag(true);
1888
- else this.setSliderTag(false);
1961
+ this.setSliderTag(false);
1962
+ else this.setSliderTag(true);
1889
1963
  let activeLayers = document.querySelectorAll('.active-layer');
1890
1964
  let group = this.getGroup(elem);
1891
1965
  let groupLayers = this.getGroupLayers(group);
@@ -1980,6 +2054,9 @@ class MenuWidget extends React.Component {
1980
2054
  ReactDOM.unmountComponentAtNode(
1981
2055
  document.querySelector('.esri-ui-bottom-right'),
1982
2056
  );
2057
+ if (document.querySelector('.drawRectanglePopup-block'))
2058
+ document.querySelector('.drawRectanglePopup-block').style.display =
2059
+ 'block';
1983
2060
  } else {
1984
2061
  if (this.visibleLayers[layerId][1] === 'eye-slash') {
1985
2062
  this.layers[layerId].visible = true;
@@ -2406,7 +2483,14 @@ class MenuWidget extends React.Component {
2406
2483
  hotspotLayers.length === 0 &&
2407
2484
  document.querySelector('.hotspot-container')
2408
2485
  ) {
2409
- this.props.mapViewer.closeActiveWidget();
2486
+ if (
2487
+ this.props.mapViewer.activeWidget &&
2488
+ this.props.mapViewer.activeWidget.container.current.classList.contains(
2489
+ 'hotspot-container',
2490
+ )
2491
+ ) {
2492
+ this.props.mapViewer.closeActiveWidget();
2493
+ }
2410
2494
  document.querySelector('.hotspot-container').style.display = 'none';
2411
2495
  } else if (this.props.view && hotspotLayers.length > 0) {
2412
2496
  document.querySelector('.hotspot-container').style.display = 'flex';
@@ -2438,14 +2522,12 @@ class MenuWidget extends React.Component {
2438
2522
  time.start = parseInt(activeLayer.getAttribute('time-start'));
2439
2523
  time.end = parseInt(activeLayer.getAttribute('time-end'));
2440
2524
  }
2441
- let isLoggedIn = document
2442
- .querySelector('[defcheck=' + elem.id + ']')
2443
- .parentElement.querySelector('.map-menu-icon-login')
2444
- .classList.contains('logged');
2525
+ let isLoggedIn = document.querySelector('.map-menu-icon-login.logged');
2445
2526
  ReactDOM.render(
2446
2527
  <TimesliderWidget
2447
2528
  view={this.props.view}
2448
2529
  map={this.map}
2530
+ mapViewer={this.props.mapViewer}
2449
2531
  layer={layer}
2450
2532
  download={this.props.download}
2451
2533
  time={time}
@@ -24,7 +24,8 @@ class TimesliderWidget extends React.Component {
24
24
  timeSelectedValuesC: [], //To compare time slider stored values with new selected values
25
25
  showDatePanel: false,
26
26
  lockDatePanel: true,
27
- showCalendar: false,
27
+ showCalendar:
28
+ this.props.fromDownload || this.props.download ? true : false,
28
29
  dateStart: this.props.time.start ? new Date(this.props.time.start) : null,
29
30
  dateEnd: this.props.time.end ? new Date(this.props.time.end) : null,
30
31
  periodicity: null,
@@ -43,6 +44,13 @@ class TimesliderWidget extends React.Component {
43
44
  this.layerName = this.layer.activeLayer.id; //WMTS
44
45
  }
45
46
  this.drag = {};
47
+ if (
48
+ this.props.fromDownload &&
49
+ document.querySelector('.drawRectanglePopup-block')
50
+ ) {
51
+ document.querySelector('.drawRectanglePopup-block').style.display =
52
+ 'none';
53
+ }
46
54
  }
47
55
 
48
56
  loader() {
@@ -244,8 +252,6 @@ class TimesliderWidget extends React.Component {
244
252
  }
245
253
  this.setState({
246
254
  lockDatePanel: false,
247
- showCalendar:
248
- this.props.fromDownload || this.props.download ? true : false,
249
255
  });
250
256
  }
251
257
  },
@@ -297,6 +303,7 @@ class TimesliderWidget extends React.Component {
297
303
 
298
304
  this.getCapabilities(this.layer.url, serviceType).then((xml) => {
299
305
  let times = {};
306
+ let periodicity;
300
307
  if (this.layer.type === 'wms') {
301
308
  times = this.parseTimeWMS(xml);
302
309
  } else if (this.layer.type === 'wmts') {
@@ -326,6 +333,8 @@ class TimesliderWidget extends React.Component {
326
333
  unit: 'minutes',
327
334
  },
328
335
  };
336
+
337
+ periodicity = times[this.layerName].period;
329
338
  } else if (times[this.layerName].hasOwnProperty('array')) {
330
339
  // Dates array
331
340
  this.TimesliderWidget.fullTimeExtent = new TimeExtent({
@@ -350,19 +359,20 @@ class TimesliderWidget extends React.Component {
350
359
  timeDict[time[i]] = times[this.layerName].array[i];
351
360
  }
352
361
  }
353
- }
354
362
 
355
- let periodicity = Math.floor(
356
- (Date.parse(times[this.layerName].array[1]) -
357
- Date.parse(times[this.layerName].array[0])) /
358
- 86400000,
359
- );
360
- if (periodicity === 0) {
361
- periodicity =
362
- (new Date(times[this.layerName].array[1]).getHours() -
363
- new Date(times[this.layerName].array[0]).getHours()) /
364
- 24;
363
+ periodicity = Math.floor(
364
+ (Date.parse(times[this.layerName].array[1]) -
365
+ Date.parse(times[this.layerName].array[0])) /
366
+ 86400000,
367
+ );
368
+ if (periodicity === 0) {
369
+ periodicity =
370
+ (new Date(times[this.layerName].array[1]).getHours() -
371
+ new Date(times[this.layerName].array[0]).getHours()) /
372
+ 24;
373
+ }
365
374
  }
375
+
366
376
  this.setState({ periodicity: periodicity });
367
377
 
368
378
  this.TimesliderWidget.watch('timeExtent', (timeExtent) => {
@@ -415,17 +425,17 @@ class TimesliderWidget extends React.Component {
415
425
 
416
426
  getPeriodicity() {
417
427
  let period = this.state.periodicity;
418
- if (period === 1 / 24) {
428
+ if (period === 1 / 24 || period === 'PT1H') {
419
429
  return 'hourly';
420
- } else if (period === 1) {
430
+ } else if (period === 1 || period === 'P1D') {
421
431
  return 'daily';
422
- } else if (period === 7) {
432
+ } else if (period === 7 || period === 'P7D' || period === 'P1W') {
423
433
  return 'weekly';
424
- } else if (period === 10) {
434
+ } else if (period === 10 || period === 'P10D') {
425
435
  return '10-daily';
426
- } else if (period >= 28 && period <= 31) {
436
+ } else if ((period >= 28 && period <= 31) || period === 'P1M') {
427
437
  return 'monthly';
428
- } else if (period === 365 || period === 366) {
438
+ } else if (period === 365 || period === 366 || period === 'P1Y') {
429
439
  return 'yearly';
430
440
  } else {
431
441
  return 'not regular';
@@ -490,6 +500,18 @@ class TimesliderWidget extends React.Component {
490
500
  dateEnd: end,
491
501
  showCalendar: false,
492
502
  });
503
+ if (this.props.fromDownload) {
504
+ this.props.time.elem.querySelector('.active-layer-time').click();
505
+ document.getElementById('products_label').click();
506
+ if (
507
+ this.props.mapViewer.activeWidget &&
508
+ !this.props.mapViewer.activeWidget.container.current.classList.contains(
509
+ 'area-container',
510
+ )
511
+ ) {
512
+ document.getElementById('map_area_button').click();
513
+ }
514
+ }
493
515
  }
494
516
 
495
517
  handleInputChange(e) {
@@ -513,7 +535,7 @@ class TimesliderWidget extends React.Component {
513
535
  let inputEnd;
514
536
  let timeStart;
515
537
  let timeEnd;
516
- if (this.state.showCalendar) {
538
+ if (!this.state.lockDatePanel && this.state.showCalendar) {
517
539
  inputStart = this.formatDate(
518
540
  this.state.inputStart
519
541
  ? this.state.inputStart
@@ -573,7 +595,7 @@ class TimesliderWidget extends React.Component {
573
595
  )}
574
596
  </div>
575
597
  )}
576
- {this.state.showCalendar && (
598
+ {!this.state.lockDatePanel && this.state.showCalendar && (
577
599
  <div className="timeslider-calendar-container">
578
600
  <div className="timeslider-calendar-header">
579
601
  <b>Select temporal interval to download</b>