@eeacms/volto-arcgis-block 0.1.13 → 0.1.17
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 +61 -0
- package/Jenkinsfile +28 -5
- package/package.json +6 -2
- package/src/components/MapViewer/AreaWidget.jsx +88 -37
- package/src/components/MapViewer/LegendWidget.jsx +2 -0
- package/src/components/MapViewer/MapViewer.jsx +8 -0
- package/src/components/MapViewer/MenuWidget.jsx +498 -108
- package/src/components/MapViewer/TimesliderWidget.jsx +81 -0
- package/src/components/MapViewer/css/ArcgisMap.css +50 -9
- package/src/components/UseCasesMapViewer/InfoWidget.jsx +30 -32
- package/src/components/UseCasesMapViewer/LayerControl.jsx +58 -23
- package/src/components/UseCasesMapViewer/LegendWidget.jsx +122 -0
- package/src/components/UseCasesMapViewer/NavigationControl.jsx +2 -2
- package/src/components/UseCasesMapViewer/UseCasesMapViewer.jsx +39 -51
- package/src/components/UseCasesMapViewer/config.js +15 -1
- package/src/components/UseCasesMapViewer/css/ArcgisMap.css +26 -0
- package/src/components/UseCasesMapViewer/map.css +0 -6
|
@@ -1,8 +1,226 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ReactDOM from 'react-dom';
|
|
2
|
+
import React, { createRef, useState } from 'react';
|
|
2
3
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
4
|
import { loadModules, loadCss } from 'esri-loader';
|
|
5
|
+
import useCartState from '@eeacms/volto-clms-utils/cart/useCartState';
|
|
6
|
+
import { useHistory } from 'react-router-dom';
|
|
7
|
+
import { useIntl } from 'react-intl';
|
|
8
|
+
import { Message, Modal } from 'semantic-ui-react';
|
|
4
9
|
import AreaWidget from './AreaWidget';
|
|
5
|
-
|
|
10
|
+
import TimesliderWidget from './TimesliderWidget';
|
|
11
|
+
var WMSLayer, WMTSLayer;
|
|
12
|
+
|
|
13
|
+
export const AddCartItem = ({
|
|
14
|
+
cartData,
|
|
15
|
+
mapViewer,
|
|
16
|
+
props,
|
|
17
|
+
download,
|
|
18
|
+
areaData,
|
|
19
|
+
dataset,
|
|
20
|
+
}) => {
|
|
21
|
+
const { addCartItem, isLoggedIn } = useCartState();
|
|
22
|
+
const [message, setMessage] = useState(0);
|
|
23
|
+
const [showMessage, setShowMessage] = useState(false);
|
|
24
|
+
const [modal, setModal] = useState(false);
|
|
25
|
+
const history = useHistory();
|
|
26
|
+
const { locale } = useIntl();
|
|
27
|
+
|
|
28
|
+
const checkArea = () => {
|
|
29
|
+
let check = document.querySelector('.area-panel input:checked').value;
|
|
30
|
+
let area;
|
|
31
|
+
if (check === 'area') {
|
|
32
|
+
let graphics = mapViewer.view.graphics;
|
|
33
|
+
if (graphics.length === 0) {
|
|
34
|
+
area = '';
|
|
35
|
+
} else {
|
|
36
|
+
area = 'Polygon';
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
if (areaData) {
|
|
40
|
+
area = areaData;
|
|
41
|
+
} else {
|
|
42
|
+
area = '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (download) {
|
|
46
|
+
setMessage(area ? 'Added to cart' : 'Select an area');
|
|
47
|
+
showMessageTimer();
|
|
48
|
+
if (area) {
|
|
49
|
+
let data = checkCartData(cartData, area);
|
|
50
|
+
addCartItem(data).then(() => {
|
|
51
|
+
history.push('/' + locale + '/cart');
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
setModal(false);
|
|
56
|
+
let data = checkCartData(cartData, area, dataset);
|
|
57
|
+
addCartItem(data).then(() => {
|
|
58
|
+
setMessage('Added to cart');
|
|
59
|
+
showMessageTimer();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const checkCartData = (cartData, area, dataset) => {
|
|
65
|
+
if (!dataset) {
|
|
66
|
+
dataset = cartData[0].Products[0].Datasets[0];
|
|
67
|
+
}
|
|
68
|
+
let id = dataset.DatasetId;
|
|
69
|
+
let name = dataset.DatasetTitle;
|
|
70
|
+
let datasetElem = document.querySelector('div[datasetid="' + id + '"]');
|
|
71
|
+
let datasetData = {
|
|
72
|
+
id: id,
|
|
73
|
+
UID: '5aa607ac07aa4a6da49dee6374ad649e',
|
|
74
|
+
area: area,
|
|
75
|
+
format: 'PDF',
|
|
76
|
+
name: name,
|
|
77
|
+
path: '213213',
|
|
78
|
+
resolution: '1080m',
|
|
79
|
+
size: '36 MB',
|
|
80
|
+
source: '234',
|
|
81
|
+
task_in_progress: false,
|
|
82
|
+
type: 'Raster',
|
|
83
|
+
unique_id:
|
|
84
|
+
'5becde46-9fdf-46ff-ad2c-c928a1ef0a3a5aa607ac07aa4a6da49dee6374ad649e',
|
|
85
|
+
version: '1.0.0',
|
|
86
|
+
year: '2021',
|
|
87
|
+
};
|
|
88
|
+
if (area === 'Polygon') {
|
|
89
|
+
datasetData.areaCoords = [
|
|
90
|
+
areaData.origin.x,
|
|
91
|
+
areaData.origin.y,
|
|
92
|
+
areaData.end.x,
|
|
93
|
+
areaData.end.y,
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
if (
|
|
97
|
+
dataset.IsTimeSeries &&
|
|
98
|
+
datasetElem
|
|
99
|
+
.querySelector('.map-dataset-checkbox input')
|
|
100
|
+
.hasAttribute('time-start')
|
|
101
|
+
) {
|
|
102
|
+
let datasetInput = datasetElem.querySelector(
|
|
103
|
+
'.map-dataset-checkbox input',
|
|
104
|
+
);
|
|
105
|
+
let time = {
|
|
106
|
+
start: parseInt(datasetInput.getAttribute('time-start')),
|
|
107
|
+
end: parseInt(datasetInput.getAttribute('time-end')),
|
|
108
|
+
};
|
|
109
|
+
datasetData.timeExtent = [time.start, time.end];
|
|
110
|
+
}
|
|
111
|
+
let data = [datasetData];
|
|
112
|
+
return data;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const downloadCancel = (mapViewer) => {
|
|
116
|
+
mapViewer.view.popup.close();
|
|
117
|
+
mapViewer.view.graphics.removeAll();
|
|
118
|
+
props.updateArea('');
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const showMessageTimer = () => {
|
|
122
|
+
setShowMessage(true);
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
setShowMessage(false);
|
|
125
|
+
}, 4000);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const showModal = () => {
|
|
129
|
+
setModal(true);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const closeModal = () => {
|
|
133
|
+
setModal(false);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<>
|
|
138
|
+
{showMessage && (
|
|
139
|
+
<Message floating size="small" timeout={5000}>
|
|
140
|
+
{message}
|
|
141
|
+
</Message>
|
|
142
|
+
)}
|
|
143
|
+
{download ? (
|
|
144
|
+
<div className="map-download-buttons">
|
|
145
|
+
<button
|
|
146
|
+
id="map_download_add"
|
|
147
|
+
className="ccl-button ccl-button-green"
|
|
148
|
+
onClick={() => checkArea()}
|
|
149
|
+
>
|
|
150
|
+
Add to cart
|
|
151
|
+
</button>
|
|
152
|
+
<button
|
|
153
|
+
id="map_download_cancel"
|
|
154
|
+
className="ccl-button ccl-button--default"
|
|
155
|
+
onClick={() => downloadCancel(mapViewer)}
|
|
156
|
+
>
|
|
157
|
+
Cancel
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
) : (
|
|
161
|
+
<>
|
|
162
|
+
<Modal size="tiny" open={modal}>
|
|
163
|
+
<Modal.Content>
|
|
164
|
+
<p>Do you want to add this dataset to the cart?</p>
|
|
165
|
+
</Modal.Content>
|
|
166
|
+
<Modal.Actions>
|
|
167
|
+
<div className="map-download-buttons">
|
|
168
|
+
<button
|
|
169
|
+
className="ccl-button ccl-button-green"
|
|
170
|
+
onClick={() => checkArea()}
|
|
171
|
+
>
|
|
172
|
+
Add to cart
|
|
173
|
+
</button>
|
|
174
|
+
<button
|
|
175
|
+
className="ccl-button ccl-button--default"
|
|
176
|
+
onClick={() => closeModal()}
|
|
177
|
+
>
|
|
178
|
+
Cancel
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
</Modal.Actions>
|
|
182
|
+
</Modal>
|
|
183
|
+
<div className={'map-menu-icons' + (isLoggedIn ? '' : ' locked')}>
|
|
184
|
+
<FontAwesomeIcon
|
|
185
|
+
className="map-menu-icon"
|
|
186
|
+
icon={['fas', 'download']}
|
|
187
|
+
onClick={() => {
|
|
188
|
+
isLoggedIn && showModal();
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
</>
|
|
193
|
+
)}
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export const CheckLogin = () => {
|
|
199
|
+
const { isLoggedIn } = useCartState();
|
|
200
|
+
const { locale } = useIntl();
|
|
201
|
+
return (
|
|
202
|
+
<>
|
|
203
|
+
{!isLoggedIn && (
|
|
204
|
+
<div className="login-block">
|
|
205
|
+
<div className="login-content">
|
|
206
|
+
<a
|
|
207
|
+
className="ccl-button ccl-button--default"
|
|
208
|
+
href={'/' + locale + '/login'}
|
|
209
|
+
>
|
|
210
|
+
Login to download the data
|
|
211
|
+
</a>
|
|
212
|
+
<p className="login-block-new">
|
|
213
|
+
New user?{' '}
|
|
214
|
+
<a href={'/' + locale + '/register'}>
|
|
215
|
+
Follow this link to register
|
|
216
|
+
</a>
|
|
217
|
+
</p>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
</>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
6
224
|
|
|
7
225
|
class MenuWidget extends React.Component {
|
|
8
226
|
/**
|
|
@@ -27,9 +245,12 @@ class MenuWidget extends React.Component {
|
|
|
27
245
|
}
|
|
28
246
|
|
|
29
247
|
loader() {
|
|
30
|
-
return loadModules(['esri/layers/WMSLayer']).then(
|
|
31
|
-
|
|
32
|
-
|
|
248
|
+
return loadModules(['esri/layers/WMSLayer', 'esri/layers/WMTSLayer']).then(
|
|
249
|
+
([_WMSLayer, _WMTSLayer]) => {
|
|
250
|
+
WMSLayer = _WMSLayer;
|
|
251
|
+
WMTSLayer = _WMTSLayer;
|
|
252
|
+
},
|
|
253
|
+
);
|
|
33
254
|
}
|
|
34
255
|
|
|
35
256
|
/**
|
|
@@ -45,6 +266,8 @@ class MenuWidget extends React.Component {
|
|
|
45
266
|
this.container.current
|
|
46
267
|
.querySelector('.esri-widget--button')
|
|
47
268
|
.classList.replace('esri-icon-left-arrow', 'esri-icon-drag-horizontal');
|
|
269
|
+
if (document.contains(document.querySelector('.timeslider-container')))
|
|
270
|
+
document.querySelector('.timeslider-container').style.display = 'none';
|
|
48
271
|
|
|
49
272
|
// By invoking the setState, we notify the state we want to reach
|
|
50
273
|
// and ensure that the component is rendered again
|
|
@@ -56,6 +279,8 @@ class MenuWidget extends React.Component {
|
|
|
56
279
|
this.container.current
|
|
57
280
|
.querySelector('.esri-widget--button')
|
|
58
281
|
.classList.replace('esri-icon-drag-horizontal', 'esri-icon-left-arrow');
|
|
282
|
+
if (document.contains(document.querySelector('.timeslider-container')))
|
|
283
|
+
document.querySelector('.timeslider-container').style.display = 'block';
|
|
59
284
|
|
|
60
285
|
// By invoking the setState, we notify the state we want to reach
|
|
61
286
|
// and ensure that the component is rendered again
|
|
@@ -82,7 +307,7 @@ class MenuWidget extends React.Component {
|
|
|
82
307
|
* @returns
|
|
83
308
|
*/
|
|
84
309
|
metodprocessJSON() {
|
|
85
|
-
if (!WMSLayer) return;
|
|
310
|
+
if (!WMSLayer && !WMTSLayer) return;
|
|
86
311
|
var components = [];
|
|
87
312
|
var index = 0;
|
|
88
313
|
for (var i in this.compCfg) {
|
|
@@ -171,7 +396,6 @@ class MenuWidget extends React.Component {
|
|
|
171
396
|
var idDatasetB = 'map_dataset_' + inheritedIndexProduct + '_0';
|
|
172
397
|
dataset_def.push(idDatasetB);
|
|
173
398
|
}
|
|
174
|
-
|
|
175
399
|
return (
|
|
176
400
|
<div
|
|
177
401
|
className="map-menu-product-dropdown"
|
|
@@ -259,7 +483,7 @@ class MenuWidget extends React.Component {
|
|
|
259
483
|
|
|
260
484
|
for (var i in dataset.Layer) {
|
|
261
485
|
if (dataset.Layer[i].Default_active === true) {
|
|
262
|
-
layer_default.push(dataset.Layer[i].LayerId);
|
|
486
|
+
layer_default.push(dataset.Layer[i].LayerId + '_' + checkIndex);
|
|
263
487
|
}
|
|
264
488
|
|
|
265
489
|
layers.push(
|
|
@@ -269,6 +493,7 @@ class MenuWidget extends React.Component {
|
|
|
269
493
|
inheritedIndexDataset,
|
|
270
494
|
dataset.ViewService,
|
|
271
495
|
checkIndex,
|
|
496
|
+
dataset.IsTimeSeries,
|
|
272
497
|
layer_default,
|
|
273
498
|
),
|
|
274
499
|
);
|
|
@@ -276,7 +501,7 @@ class MenuWidget extends React.Component {
|
|
|
276
501
|
}
|
|
277
502
|
|
|
278
503
|
if (!layer_default.length) {
|
|
279
|
-
layer_default.push(dataset.Layer[0].LayerId);
|
|
504
|
+
layer_default.push(dataset.Layer[0].LayerId + '_' + checkIndex);
|
|
280
505
|
}
|
|
281
506
|
// ./dataset-catalogue/dataset-info.html
|
|
282
507
|
// ./dataset-catalogue/dataset-download.html
|
|
@@ -285,6 +510,7 @@ class MenuWidget extends React.Component {
|
|
|
285
510
|
<div
|
|
286
511
|
className="ccl-form-group map-menu-dataset"
|
|
287
512
|
id={'dataset_' + inheritedIndexDataset}
|
|
513
|
+
datasetid={dataset.DatasetId}
|
|
288
514
|
key={'a' + datIndex}
|
|
289
515
|
>
|
|
290
516
|
<div className="map-dataset-checkbox" key={'b' + datIndex}>
|
|
@@ -308,20 +534,16 @@ class MenuWidget extends React.Component {
|
|
|
308
534
|
>
|
|
309
535
|
<span>{dataset.DatasetTitle}</span>
|
|
310
536
|
</label>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
<span className="map-menu-icon" aria-label="Dataset download">
|
|
322
|
-
<i className="fas fa-download"></i>
|
|
323
|
-
</span>
|
|
324
|
-
</div>
|
|
537
|
+
{!this.props.download && (
|
|
538
|
+
<AddCartItem
|
|
539
|
+
cartData={this.compCfg}
|
|
540
|
+
props={this.props}
|
|
541
|
+
mapViewer={this.props.mapViewer}
|
|
542
|
+
download={this.props.download}
|
|
543
|
+
areaData={this.props.area}
|
|
544
|
+
dataset={dataset}
|
|
545
|
+
/>
|
|
546
|
+
)}
|
|
325
547
|
</div>
|
|
326
548
|
<div
|
|
327
549
|
className="ccl-form map-menu-layers-container"
|
|
@@ -360,7 +582,14 @@ class MenuWidget extends React.Component {
|
|
|
360
582
|
* @param {*} parentIndex
|
|
361
583
|
* @returns
|
|
362
584
|
*/
|
|
363
|
-
metodProcessLayer(
|
|
585
|
+
metodProcessLayer(
|
|
586
|
+
layer,
|
|
587
|
+
layerIndex,
|
|
588
|
+
inheritedIndex,
|
|
589
|
+
urlWMS,
|
|
590
|
+
parentIndex,
|
|
591
|
+
isTimeSeries,
|
|
592
|
+
) {
|
|
364
593
|
//For Legend request
|
|
365
594
|
const legendRequest =
|
|
366
595
|
'request=GetLegendGraphic&version=1.0.0&format=image/png&layer=';
|
|
@@ -369,25 +598,40 @@ class MenuWidget extends React.Component {
|
|
|
369
598
|
|
|
370
599
|
//Add sublayers and popup enabled for layers
|
|
371
600
|
if (!this.layers.hasOwnProperty(layer.LayerId)) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
601
|
+
if (
|
|
602
|
+
urlWMS.toLowerCase().includes('/wms') ||
|
|
603
|
+
urlWMS.toLowerCase().includes('=wms')
|
|
604
|
+
) {
|
|
605
|
+
this.layers[layer.LayerId] = new WMSLayer({
|
|
606
|
+
url: urlWMS,
|
|
607
|
+
featureInfoFormat: 'text/html',
|
|
608
|
+
featureInfoUrl: urlWMS,
|
|
609
|
+
//id: layer.LayerId,
|
|
610
|
+
title: '',
|
|
611
|
+
legendEnabled: true,
|
|
612
|
+
sublayers: [
|
|
613
|
+
{
|
|
614
|
+
name: layer.LayerId,
|
|
615
|
+
title: layer.Title,
|
|
616
|
+
popupEnabled: true,
|
|
617
|
+
queryable: true,
|
|
618
|
+
visble: true,
|
|
619
|
+
legendEnabled: true,
|
|
620
|
+
legendUrl: urlWMS + legendRequest + layer.LayerId,
|
|
621
|
+
},
|
|
622
|
+
],
|
|
623
|
+
});
|
|
624
|
+
} else {
|
|
625
|
+
this.layers[layer.LayerId] = new WMTSLayer({
|
|
626
|
+
url: urlWMS,
|
|
627
|
+
//id: layer.LayerId,
|
|
628
|
+
title: '',
|
|
629
|
+
activeLayer: {
|
|
630
|
+
id: layer.LayerId,
|
|
382
631
|
title: layer.Title,
|
|
383
|
-
popupEnabled: true,
|
|
384
|
-
queryable: true,
|
|
385
|
-
visble: true,
|
|
386
|
-
legendEnabled: true,
|
|
387
|
-
legendUrl: urlWMS + legendRequest + layer.LayerId,
|
|
388
632
|
},
|
|
389
|
-
|
|
390
|
-
}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
391
635
|
}
|
|
392
636
|
|
|
393
637
|
return (
|
|
@@ -395,12 +639,14 @@ class MenuWidget extends React.Component {
|
|
|
395
639
|
className="ccl-form-group map-menu-layer"
|
|
396
640
|
id={'layer_' + inheritedIndexLayer}
|
|
397
641
|
key={'a' + layerIndex}
|
|
642
|
+
data-timeseries={isTimeSeries}
|
|
398
643
|
>
|
|
399
644
|
<input
|
|
400
645
|
type="checkbox"
|
|
401
|
-
id={layer.LayerId}
|
|
646
|
+
id={layer.LayerId + '_' + parentIndex}
|
|
402
647
|
parentid={parentIndex}
|
|
403
|
-
|
|
648
|
+
layerid={layer.LayerId}
|
|
649
|
+
name="layerCheckbox"
|
|
404
650
|
value="name"
|
|
405
651
|
className="ccl-checkbox ccl-required ccl-form-check-input"
|
|
406
652
|
key={'c' + layerIndex}
|
|
@@ -411,7 +657,7 @@ class MenuWidget extends React.Component {
|
|
|
411
657
|
></input>
|
|
412
658
|
<label
|
|
413
659
|
className="ccl-form-check-label"
|
|
414
|
-
htmlFor={layer.LayerId}
|
|
660
|
+
htmlFor={layer.LayerId + '_' + parentIndex}
|
|
415
661
|
key={'d' + layerIndex}
|
|
416
662
|
>
|
|
417
663
|
<span>{layer.Title}</span>
|
|
@@ -426,19 +672,31 @@ class MenuWidget extends React.Component {
|
|
|
426
672
|
*/
|
|
427
673
|
toggleLayer(elem) {
|
|
428
674
|
if (!this.visibleLayers) this.visibleLayers = {};
|
|
429
|
-
|
|
430
|
-
|
|
675
|
+
if (!this.timeLayers) this.timeLayers = {};
|
|
676
|
+
let parentId = elem.getAttribute('parentid');
|
|
677
|
+
let layerId = elem.getAttribute('layerid');
|
|
431
678
|
if (elem.checked) {
|
|
432
|
-
this.map.add(this.layers[
|
|
679
|
+
this.map.add(this.layers[layerId]);
|
|
433
680
|
this.visibleLayers[elem.id] = ['fas', 'eye'];
|
|
681
|
+
this.timeLayers[elem.id] = ['fas', 'step-forward'];
|
|
434
682
|
this.activeLayersJSON[elem.id] = this.addActiveLayer(
|
|
435
683
|
elem,
|
|
436
684
|
Object.keys(this.activeLayersJSON).length,
|
|
437
685
|
);
|
|
438
686
|
} else {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
687
|
+
let checkboxes = document.getElementsByName('layerCheckbox');
|
|
688
|
+
let repeatedLayers = [];
|
|
689
|
+
for (let checkbox = 0; checkbox < checkboxes.length - 1; checkbox++) {
|
|
690
|
+
if (checkboxes[checkbox].getAttribute('layerid') === layerId) {
|
|
691
|
+
if (checkboxes[checkbox].checked) repeatedLayers.push(repeatedLayers);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (repeatedLayers.length === 0) {
|
|
695
|
+
this.map.remove(this.layers[layerId]);
|
|
696
|
+
delete this.activeLayersJSON[elem.id];
|
|
697
|
+
delete this.visibleLayers[elem.id];
|
|
698
|
+
delete this.timeLayers[elem.id];
|
|
699
|
+
}
|
|
442
700
|
}
|
|
443
701
|
this.updateCheckDataset(parentId);
|
|
444
702
|
this.setState({});
|
|
@@ -468,17 +726,19 @@ class MenuWidget extends React.Component {
|
|
|
468
726
|
* @param {*} element
|
|
469
727
|
*/
|
|
470
728
|
toggleDataset(value, id, e) {
|
|
471
|
-
|
|
472
|
-
|
|
729
|
+
let layerdef = e.getAttribute('defcheck');
|
|
730
|
+
let splitdefCheck = layerdef.split(',');
|
|
473
731
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
732
|
+
let layerChecks = [];
|
|
733
|
+
let selector = [];
|
|
734
|
+
if (value) {
|
|
735
|
+
for (let i = 0; i < splitdefCheck.length; i++) {
|
|
736
|
+
selector = document.querySelector(`[id="${splitdefCheck[i]}"]`);
|
|
737
|
+
layerChecks.push(selector);
|
|
738
|
+
}
|
|
739
|
+
} else {
|
|
740
|
+
layerChecks = document.querySelectorAll(`[parentid=${id}]`);
|
|
480
741
|
}
|
|
481
|
-
|
|
482
742
|
layerChecks.forEach((element) => {
|
|
483
743
|
element.checked = value;
|
|
484
744
|
this.toggleLayer(element);
|
|
@@ -492,15 +752,19 @@ class MenuWidget extends React.Component {
|
|
|
492
752
|
* @param {*} element (checkbox)
|
|
493
753
|
*/
|
|
494
754
|
toggleProduct(value, id, element) {
|
|
495
|
-
|
|
496
|
-
|
|
755
|
+
let productDefCheck = element.target.getAttribute('defcheck');
|
|
756
|
+
let splitdefCheck = productDefCheck.split(',');
|
|
497
757
|
|
|
498
|
-
|
|
499
|
-
|
|
758
|
+
let datasetChecks = [];
|
|
759
|
+
let selector = [];
|
|
500
760
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
761
|
+
if (value) {
|
|
762
|
+
for (let i = 0; i < splitdefCheck.length; i++) {
|
|
763
|
+
selector = document.querySelector(`[id="${splitdefCheck[i]}"]`);
|
|
764
|
+
datasetChecks.push(selector);
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
datasetChecks = document.querySelectorAll(`[parentid=${id}]`);
|
|
504
768
|
}
|
|
505
769
|
datasetChecks.forEach((element) => {
|
|
506
770
|
element.checked = value;
|
|
@@ -539,6 +803,15 @@ class MenuWidget extends React.Component {
|
|
|
539
803
|
{elem.title}
|
|
540
804
|
</div>
|
|
541
805
|
<div className="active-layer-options" key={'c_' + elem.id}>
|
|
806
|
+
{elem.parentElement.dataset.timeseries === 'true' && (
|
|
807
|
+
<span className="active-layer-time">
|
|
808
|
+
<FontAwesomeIcon
|
|
809
|
+
className="map-menu-icon"
|
|
810
|
+
icon={this.timeLayers[elem.id]}
|
|
811
|
+
onClick={(e) => this.showTimeSlider(elem)}
|
|
812
|
+
/>
|
|
813
|
+
</span>
|
|
814
|
+
)}
|
|
542
815
|
<span className="active-layer-hide">
|
|
543
816
|
<FontAwesomeIcon
|
|
544
817
|
className="map-menu-icon"
|
|
@@ -553,6 +826,8 @@ class MenuWidget extends React.Component {
|
|
|
553
826
|
onClick={() => this.deleteCrossEvent(elem)}
|
|
554
827
|
/>
|
|
555
828
|
</span>
|
|
829
|
+
{this.timeLayers[elem.id][1] === 'stop' &&
|
|
830
|
+
this.renderTimeslider(elem, this.layers[elem.id])}
|
|
556
831
|
</div>
|
|
557
832
|
</div>
|
|
558
833
|
);
|
|
@@ -627,6 +902,97 @@ class MenuWidget extends React.Component {
|
|
|
627
902
|
this.draggingElement = e.target;
|
|
628
903
|
}
|
|
629
904
|
|
|
905
|
+
/**
|
|
906
|
+
* Method to show/hide time slider
|
|
907
|
+
* @param {*} e From the click event
|
|
908
|
+
* @param {*} id id from elem
|
|
909
|
+
*/
|
|
910
|
+
showTimeSlider(elem) {
|
|
911
|
+
let activeLayers = document.querySelectorAll('.active-layer');
|
|
912
|
+
if (this.timeLayers[elem.id][1] === 'step-forward') {
|
|
913
|
+
activeLayers.forEach((layer) => {
|
|
914
|
+
let layerId = layer.getAttribute('layer-id');
|
|
915
|
+
let order = this.activeLayersJSON[layerId].props['layer-order'];
|
|
916
|
+
if (elem.id === layerId) {
|
|
917
|
+
this.timeLayers[elem.id] = ['fas', 'stop'];
|
|
918
|
+
if (this.visibleLayers[layerId][1] === 'eye-slash') {
|
|
919
|
+
this.layers[layerId].visible = true;
|
|
920
|
+
this.visibleLayers[layerId] = ['fas', 'eye'];
|
|
921
|
+
}
|
|
922
|
+
document
|
|
923
|
+
.querySelector(
|
|
924
|
+
'.active-layer[layer-id="' + layerId + '"] .active-layer-hide',
|
|
925
|
+
)
|
|
926
|
+
.classList.add('locked');
|
|
927
|
+
document
|
|
928
|
+
.querySelector(
|
|
929
|
+
'.active-layer[layer-id="' + layerId + '"] .active-layer-delete',
|
|
930
|
+
)
|
|
931
|
+
.classList.add('locked');
|
|
932
|
+
document.querySelector('#products_label').classList.add('locked');
|
|
933
|
+
if (this.props.download)
|
|
934
|
+
document.querySelector('#download_label').classList.add('locked');
|
|
935
|
+
this.activeLayersJSON[elem.id] = this.addActiveLayer(elem, order);
|
|
936
|
+
} else {
|
|
937
|
+
if (this.visibleLayers[layerId][1] === 'eye') {
|
|
938
|
+
this.layers[layerId].visible = false;
|
|
939
|
+
this.visibleLayers[layerId] = ['fas', 'eye-slash'];
|
|
940
|
+
}
|
|
941
|
+
document
|
|
942
|
+
.querySelector('.active-layer[layer-id="' + layerId + '"]')
|
|
943
|
+
.classList.add('locked');
|
|
944
|
+
this.activeLayersJSON[layerId] = this.addActiveLayer(
|
|
945
|
+
document.getElementById(layerId),
|
|
946
|
+
order,
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
} else {
|
|
951
|
+
activeLayers.forEach((layer) => {
|
|
952
|
+
let layerId = layer.getAttribute('layer-id');
|
|
953
|
+
let order = this.activeLayersJSON[layerId].props['layer-order'];
|
|
954
|
+
if (elem.id === layerId) {
|
|
955
|
+
this.timeLayers[elem.id] = ['fas', 'step-forward'];
|
|
956
|
+
this.activeLayersJSON[elem.id] = this.addActiveLayer(elem, order);
|
|
957
|
+
document
|
|
958
|
+
.querySelector(
|
|
959
|
+
'.active-layer[layer-id="' + layerId + '"] .active-layer-hide',
|
|
960
|
+
)
|
|
961
|
+
.classList.remove('locked');
|
|
962
|
+
document
|
|
963
|
+
.querySelector(
|
|
964
|
+
'.active-layer[layer-id="' + layerId + '"] .active-layer-delete',
|
|
965
|
+
)
|
|
966
|
+
.classList.remove('locked');
|
|
967
|
+
document.querySelector('#products_label').classList.remove('locked');
|
|
968
|
+
if (this.props.download)
|
|
969
|
+
document
|
|
970
|
+
.querySelector('#download_label')
|
|
971
|
+
.classList.remove('locked');
|
|
972
|
+
if (
|
|
973
|
+
document.contains(document.querySelector('.timeslider-container'))
|
|
974
|
+
)
|
|
975
|
+
ReactDOM.unmountComponentAtNode(
|
|
976
|
+
document.querySelector('.esri-ui-bottom-right'),
|
|
977
|
+
);
|
|
978
|
+
} else {
|
|
979
|
+
if (this.visibleLayers[layerId][1] === 'eye-slash') {
|
|
980
|
+
this.layers[layerId].visible = true;
|
|
981
|
+
this.visibleLayers[layerId] = ['fas', 'eye'];
|
|
982
|
+
this.activeLayersJSON[layerId] = this.addActiveLayer(
|
|
983
|
+
document.getElementById(layerId),
|
|
984
|
+
order,
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
document
|
|
988
|
+
.querySelector('.active-layer[layer-id="' + layerId + '"]')
|
|
989
|
+
.classList.remove('locked');
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
this.setState({});
|
|
994
|
+
}
|
|
995
|
+
|
|
630
996
|
/**
|
|
631
997
|
* Method to show/hide layer from "Active Layers"
|
|
632
998
|
* @param {*} e From the click event
|
|
@@ -644,17 +1010,6 @@ class MenuWidget extends React.Component {
|
|
|
644
1010
|
this.activeLayersJSON[elem.id] = this.addActiveLayer(elem, 0);
|
|
645
1011
|
this.layersReorder();
|
|
646
1012
|
this.setState({});
|
|
647
|
-
|
|
648
|
-
/*
|
|
649
|
-
if (eye.className === 'fas fa-eye') {
|
|
650
|
-
eye.className = 'fas fa-eye fa-eye-slash';
|
|
651
|
-
|
|
652
|
-
} else {
|
|
653
|
-
eye.className = 'fas fa-eye';
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
this.layersReorder();
|
|
657
|
-
*/
|
|
658
1013
|
}
|
|
659
1014
|
|
|
660
1015
|
/**
|
|
@@ -676,9 +1031,9 @@ class MenuWidget extends React.Component {
|
|
|
676
1031
|
toggleTab(e) {
|
|
677
1032
|
if (!e.currentTarget.classList.contains('tab-selected')) {
|
|
678
1033
|
var tabsel = document.querySelector('.tab-selected');
|
|
679
|
-
var tab =
|
|
1034
|
+
var tab = e.currentTarget;
|
|
680
1035
|
var panelsel = document.querySelector('.panel-selected');
|
|
681
|
-
var panel = document.
|
|
1036
|
+
var panel = document.getElementById(tab.getAttribute('aria-controls'));
|
|
682
1037
|
|
|
683
1038
|
tabsel.className = 'tab';
|
|
684
1039
|
tabsel.setAttribute('aria-selected', 'false');
|
|
@@ -695,6 +1050,31 @@ class MenuWidget extends React.Component {
|
|
|
695
1050
|
}
|
|
696
1051
|
}
|
|
697
1052
|
|
|
1053
|
+
renderTimeslider(elem, layer) {
|
|
1054
|
+
if (this.props.view && layer) {
|
|
1055
|
+
let activeLayer = document.querySelector('#active_' + elem.id);
|
|
1056
|
+
let time = { elem: activeLayer };
|
|
1057
|
+
if (this.props.download) {
|
|
1058
|
+
let dataset = document.querySelector('.map-dataset-checkbox input');
|
|
1059
|
+
time.dataset = dataset;
|
|
1060
|
+
}
|
|
1061
|
+
if (activeLayer.hasAttribute('time-start')) {
|
|
1062
|
+
time.start = parseInt(activeLayer.getAttribute('time-start'));
|
|
1063
|
+
time.end = parseInt(activeLayer.getAttribute('time-end'));
|
|
1064
|
+
}
|
|
1065
|
+
ReactDOM.render(
|
|
1066
|
+
<TimesliderWidget
|
|
1067
|
+
view={this.props.view}
|
|
1068
|
+
map={this.map}
|
|
1069
|
+
layer={layer}
|
|
1070
|
+
download={this.props.download}
|
|
1071
|
+
time={time}
|
|
1072
|
+
/>,
|
|
1073
|
+
document.querySelector('.esri-ui-bottom-right'),
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
698
1078
|
/**
|
|
699
1079
|
* This method renders the component
|
|
700
1080
|
* @returns jsx
|
|
@@ -714,10 +1094,24 @@ class MenuWidget extends React.Component {
|
|
|
714
1094
|
onClick={(e) => this.toggleTab(e)}
|
|
715
1095
|
onKeyDown={(e) => this.toggleTab(e)}
|
|
716
1096
|
tabIndex="0"
|
|
1097
|
+
style={this.props.download ? { width: '33.333%' } : {}}
|
|
717
1098
|
>
|
|
718
1099
|
Products and datasets
|
|
719
1100
|
</span>
|
|
720
|
-
|
|
1101
|
+
<span
|
|
1102
|
+
className="tab"
|
|
1103
|
+
id="active_label"
|
|
1104
|
+
role="tab"
|
|
1105
|
+
aria-controls="active_panel"
|
|
1106
|
+
aria-selected="false"
|
|
1107
|
+
onClick={(e) => this.toggleTab(e)}
|
|
1108
|
+
onKeyDown={(e) => this.toggleTab(e)}
|
|
1109
|
+
tabIndex="0"
|
|
1110
|
+
style={this.props.download ? { width: '33.333%' } : {}}
|
|
1111
|
+
>
|
|
1112
|
+
Active on map
|
|
1113
|
+
</span>
|
|
1114
|
+
{this.props.download && (
|
|
721
1115
|
<span
|
|
722
1116
|
className="tab"
|
|
723
1117
|
id="download_label"
|
|
@@ -727,22 +1121,10 @@ class MenuWidget extends React.Component {
|
|
|
727
1121
|
onClick={(e) => this.toggleTab(e)}
|
|
728
1122
|
onKeyDown={(e) => this.toggleTab(e)}
|
|
729
1123
|
tabIndex="0"
|
|
1124
|
+
style={this.props.download ? { width: '33.333%' } : {}}
|
|
730
1125
|
>
|
|
731
1126
|
Download
|
|
732
1127
|
</span>
|
|
733
|
-
) : (
|
|
734
|
-
<span
|
|
735
|
-
className="tab"
|
|
736
|
-
id="active_label"
|
|
737
|
-
role="tab"
|
|
738
|
-
aria-controls="active_panel"
|
|
739
|
-
aria-selected="false"
|
|
740
|
-
onClick={(e) => this.toggleTab(e)}
|
|
741
|
-
onKeyDown={(e) => this.toggleTab(e)}
|
|
742
|
-
tabIndex="0"
|
|
743
|
-
>
|
|
744
|
-
Active on map
|
|
745
|
-
</span>
|
|
746
1128
|
)}
|
|
747
1129
|
</div>
|
|
748
1130
|
<div className="panels" id="paneles">
|
|
@@ -752,9 +1134,23 @@ class MenuWidget extends React.Component {
|
|
|
752
1134
|
role="tabpanel"
|
|
753
1135
|
aria-hidden="false"
|
|
754
1136
|
>
|
|
1137
|
+
{!this.props.download && <CheckLogin />}
|
|
755
1138
|
{this.metodprocessJSON()}
|
|
756
1139
|
</div>
|
|
757
|
-
|
|
1140
|
+
<div
|
|
1141
|
+
className="panel"
|
|
1142
|
+
id="active_panel"
|
|
1143
|
+
role="tabpanel"
|
|
1144
|
+
aria-hidden="true"
|
|
1145
|
+
>
|
|
1146
|
+
<div id="active_layers" className="map-active-layers">
|
|
1147
|
+
{this.activeLayersAsArray()}
|
|
1148
|
+
<span className="message" id="nolayers_message">
|
|
1149
|
+
No layers selected
|
|
1150
|
+
</span>
|
|
1151
|
+
</div>
|
|
1152
|
+
</div>
|
|
1153
|
+
{this.props.download && this.props.view && (
|
|
758
1154
|
<div
|
|
759
1155
|
className="panel"
|
|
760
1156
|
id="download_panel"
|
|
@@ -766,21 +1162,15 @@ class MenuWidget extends React.Component {
|
|
|
766
1162
|
map={this.props.map}
|
|
767
1163
|
mapViewer={this.props.mapViewer}
|
|
768
1164
|
download={this.props.download}
|
|
1165
|
+
updateArea={this.props.updateArea}
|
|
1166
|
+
/>
|
|
1167
|
+
<AddCartItem
|
|
1168
|
+
cartData={this.compCfg}
|
|
1169
|
+
props={this.props}
|
|
1170
|
+
mapViewer={this.props.mapViewer}
|
|
1171
|
+
download={this.props.download}
|
|
1172
|
+
areaData={this.props.area}
|
|
769
1173
|
/>
|
|
770
|
-
</div>
|
|
771
|
-
) : (
|
|
772
|
-
<div
|
|
773
|
-
className="panel"
|
|
774
|
-
id="active_panel"
|
|
775
|
-
role="tabpanel"
|
|
776
|
-
aria-hidden="true"
|
|
777
|
-
>
|
|
778
|
-
<div id="active_layers" className="map-active-layers">
|
|
779
|
-
{this.activeLayersAsArray()}
|
|
780
|
-
<span className="message" id="nolayers_message">
|
|
781
|
-
No layers selected
|
|
782
|
-
</span>
|
|
783
|
-
</div>
|
|
784
1174
|
</div>
|
|
785
1175
|
)}
|
|
786
1176
|
</div>
|