@eeacms/volto-arcgis-block 0.1.336 → 0.1.338

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,7 +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.336](https://github.com/eea/volto-arcgis-block/compare/0.1.335...0.1.336) - 10 February 2025
7
+ ### [0.1.338](https://github.com/eea/volto-arcgis-block/compare/0.1.337...0.1.338) - 18 February 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-282421 (feat): Ticket complete [Unai Bolivar - [`7ed8b6d`](https://github.com/eea/volto-arcgis-block/commit/7ed8b6d1a6bfe918b7e7f916ea65f51b031d34a4)]
12
+ - CLMS-282421 (feat): WMS service upload ticket is done. [Unai Bolivar - [`ff4c428`](https://github.com/eea/volto-arcgis-block/commit/ff4c42837bebf2974c1b799df497ede8e7defae4)]
13
+ - CLMS-282421 (feat): WMS service upload is finalized. Styles for widget are done. Working on pop up. [Unai Bolivar - [`d482874`](https://github.com/eea/volto-arcgis-block/commit/d482874f9257ecc51bbd3a76a4c419cbaa1abb5b)]
14
+ - CLMS-282421 (feat): WMS service upload is finalized. Halfway through the finishing touches. [Unai Bolivar - [`4c0b0d1`](https://github.com/eea/volto-arcgis-block/commit/4c0b0d15b8ed9d098032d15717060f21b3cb4585)]
15
+ - CLMS-282421 (feat): WMS service upload is finalized. Need to apply some style corrections. [Unai Bolivar - [`043f786`](https://github.com/eea/volto-arcgis-block/commit/043f786f574a4b742bfe2c87c12ba3ff1480375b)]
16
+ - filled in new script with base structure [Unai Bolivar - [`2b68aa7`](https://github.com/eea/volto-arcgis-block/commit/2b68aa7982a97f44ee0cb4d54988d7773cd440f1)]
17
+ - created new script [Unai Bolivar - [`eb2c984`](https://github.com/eea/volto-arcgis-block/commit/eb2c98424dc7850cd777e942f87e87182071c252)]
18
+ ### [0.1.337](https://github.com/eea/volto-arcgis-block/compare/0.1.336...0.1.337) - 18 February 2025
19
+
20
+ ### [0.1.336](https://github.com/eea/volto-arcgis-block/compare/0.1.335...0.1.336) - 11 February 2025
8
21
 
9
22
  ### [0.1.335](https://github.com/eea/volto-arcgis-block/compare/0.1.334...0.1.335) - 7 February 2025
10
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.336",
3
+ "version": "0.1.338",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -21,6 +21,7 @@ import HotspotWidget from './HotspotWidget';
21
21
  import PanWidget from './PanWidget';
22
22
  import BookmarkWidget from './BookmarkWidget';
23
23
  import LoadingSpinner from './LoadingSpinner';
24
+ import UploadWidget from './UploadWidget';
24
25
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable';
25
26
  //import { getTaxonomy } from '@eeacms/volto-taxonomy/actions';
26
27
 
@@ -450,6 +451,17 @@ class MapViewer extends React.Component {
450
451
  );
451
452
  }
452
453
 
454
+ renderUploadService() {
455
+ if (this.view)
456
+ return (
457
+ <UploadWidget
458
+ mapviewer_config={this.props.mapviewer_config}
459
+ view={this.view}
460
+ map={this.map}
461
+ mapViewer={this}
462
+ />
463
+ );
464
+ }
453
465
  /**
454
466
  * This method renders the map viewer, invoking if necessary the methods
455
467
  * to render the other widgets to display
@@ -482,6 +494,7 @@ class MapViewer extends React.Component {
482
494
  {this.renderMenu()}
483
495
  {this.renderBookmark()}
484
496
  {this.renderLoadingSpinner()}
497
+ {this.renderUploadService()}
485
498
  </div>
486
499
  </div>
487
500
  );
@@ -4289,6 +4289,8 @@ class MenuWidget extends React.Component {
4289
4289
  let productElem = document.querySelector(
4290
4290
  '[productid="' + product.ProductId + '"]',
4291
4291
  );
4292
+ let productCheckbox = document.querySelector('#map_' + productElem.id);
4293
+ let defaultActive = null;
4292
4294
  for (let k = 0; k < product.Datasets.length; k++) {
4293
4295
  const dataset = product.Datasets[k];
4294
4296
  let datasetChecked = false;
@@ -4322,6 +4324,12 @@ class MenuWidget extends React.Component {
4322
4324
  datasetElem.removeAttribute('style');
4323
4325
  productElem.removeAttribute('style');
4324
4326
  componentElem.removeAttribute('style');
4327
+ if (!defaultActive) {
4328
+ defaultActive = 'map_' + datasetElem.id;
4329
+ }
4330
+ if (dataset.Default_active) {
4331
+ defaultActive = 'map_' + datasetElem.id;
4332
+ }
4325
4333
  } else if (
4326
4334
  datasetChecked ||
4327
4335
  (dataset?.DatasetTitle?.toUpperCase().includes(searchText) &&
@@ -4343,10 +4351,17 @@ class MenuWidget extends React.Component {
4343
4351
  datasetElem.removeAttribute('style');
4344
4352
  productElem.removeAttribute('style');
4345
4353
  componentElem.removeAttribute('style');
4354
+ if (!defaultActive) {
4355
+ defaultActive = 'map_' + datasetElem.id;
4356
+ }
4357
+ if (dataset.Default_active) {
4358
+ defaultActive = 'map_' + datasetElem.id;
4359
+ }
4346
4360
  } else {
4347
4361
  datasetElem.setAttribute('style', 'display: none;');
4348
4362
  }
4349
4363
  }
4364
+ productCheckbox.setAttribute('defcheck', defaultActive);
4350
4365
  if (productChecked) {
4351
4366
  productElem
4352
4367
  .querySelector('.ccl-expandable__button')
@@ -0,0 +1,265 @@
1
+ import React, { createRef } from 'react';
2
+ import { loadModules } from 'esri-loader';
3
+ // import { FontAwesomeIcon } from '@eeacms/volto-clms-utils/components';
4
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
+
6
+ var WMSLayer;
7
+
8
+ class UploadWidget extends React.Component {
9
+ /**
10
+ * Creator of the Upload widget class
11
+ * @param {*} props
12
+ */
13
+ constructor(props) {
14
+ super(props);
15
+ //We create a reference to a DOM element to be mounted
16
+ this.container = createRef();
17
+ //Initially, we set the state of the component to
18
+ //not be showing the basemap panel
19
+ this.state = {
20
+ showMapMenu: false,
21
+ showInfoPopup: false,
22
+ infoPopupType: '',
23
+ wmsServiceUrl: '',
24
+ };
25
+ this.menuClass =
26
+ 'esri-icon-sketch-rectangle esri-widget--button esri-widget esri-interactive';
27
+ this.mapviewer_config = this.props.mapviewer_config;
28
+ this.fileInput = createRef();
29
+ }
30
+
31
+ loader() {
32
+ return loadModules(['esri/layers/WMSLayer']).then(([_WMSLayer]) => {
33
+ [WMSLayer] = [_WMSLayer];
34
+ });
35
+ }
36
+
37
+ /**
38
+ * Method that will be invoked when the
39
+ * button is clicked. It controls the open
40
+ * and close actions of the component
41
+ */
42
+ openMenu() {
43
+ if (this.state.showMapMenu) {
44
+ this.props.mapViewer.setActiveWidget();
45
+ this.container.current.querySelector('.right-panel').style.display =
46
+ 'none';
47
+ this.container.current.querySelector(
48
+ '.right-panel-content',
49
+ ).style.overflowY = 'auto';
50
+ this.container.current.querySelector(
51
+ '.right-panel-content',
52
+ ).style.display = 'none';
53
+ this.container.current.querySelector(
54
+ '.right-panel-content',
55
+ ).style.alignItems = 'none';
56
+ this.container.current.querySelector('.upload-panel').style.display =
57
+ 'none';
58
+ this.container.current.querySelector('.upload-panel').style.flexWrap =
59
+ 'none';
60
+ this.container.current
61
+ .querySelector('.esri-widget--button')
62
+ .classList.remove('active-widget');
63
+ document
64
+ .querySelector('.esri-ui-top-right.esri-ui-corner')
65
+ .classList.remove('show-panel');
66
+ // By invoking the setState, we notify the state we want to reach
67
+ // and ensure that the component is rendered again
68
+ this.setState({
69
+ showMapMenu: false,
70
+ showInfoPopup: false,
71
+ infoPopupType: '',
72
+ });
73
+ this.clearWidget();
74
+ } else {
75
+ this.props.mapViewer.setActiveWidget(this);
76
+ this.container.current.querySelector('.right-panel').style.display =
77
+ 'flex';
78
+ this.container.current.querySelector(
79
+ '.right-panel-content',
80
+ ).style.overflowY = 'hidden';
81
+ this.container.current.querySelector(
82
+ '.right-panel-content',
83
+ ).style.display = 'flex';
84
+ this.container.current.querySelector(
85
+ '.right-panel-content',
86
+ ).style.alignItems = 'center';
87
+ this.container.current.querySelector('.upload-panel').style.display =
88
+ 'flex';
89
+ this.container.current.querySelector('.upload-panel').style.flexWrap =
90
+ 'wrap';
91
+ this.container.current
92
+ .querySelector('.esri-widget--button')
93
+ .classList.add('active-widget');
94
+ document
95
+ .querySelector('.esri-ui-top-right.esri-ui-corner')
96
+ .classList.add('show-panel');
97
+ // By invoking the setState, we notify the state we want to reach
98
+ // and ensure that the component is rendered again
99
+ this.setState({
100
+ showMapMenu: true,
101
+ showInfoPopup: false,
102
+ infoPopupType: '',
103
+ });
104
+ }
105
+ }
106
+
107
+ clearWidget() {
108
+ window.document.querySelector('.pan-container').style.display = 'none';
109
+ this.props.mapViewer.view.popup.close();
110
+ const { wmsLayer } = this.state;
111
+ if (wmsLayer) {
112
+ this.props.view.map.remove(wmsLayer);
113
+ // this.props.view.graphics.removeAll();
114
+ }
115
+ this.setState({
116
+ wmsLayer: null,
117
+ wmsServiceUrl: '',
118
+ });
119
+
120
+ document.querySelector('.esri-attribution__powered-by').style.display =
121
+ 'none';
122
+ }
123
+
124
+ handleWmsServiceUrlChange = (event) => {
125
+ this.setState({ wmsServiceUrl: event.target.value });
126
+ };
127
+
128
+ handleUploadService = async () => {
129
+ const { wmsServiceUrl, wmsLayer } = this.state;
130
+ if (wmsLayer) {
131
+ this.props.view.map.remove(wmsLayer);
132
+ }
133
+
134
+ try {
135
+ const newWmsLayer = new WMSLayer({
136
+ url: wmsServiceUrl,
137
+ });
138
+
139
+ await newWmsLayer.load();
140
+ this.props.view.map.add(newWmsLayer);
141
+ this.setState({
142
+ wmsLayer: newWmsLayer,
143
+ showInfoPopup: false,
144
+ infoPopupType: '',
145
+ wmsServiceUrl: '',
146
+ });
147
+ } catch (error) {
148
+ this.setState({
149
+ showInfoPopup: true,
150
+ infoPopupType: 'uploadError',
151
+ wmsServiceUrl: '',
152
+ });
153
+ }
154
+ };
155
+ /**
156
+ * This method is executed after the render method is executed
157
+ */
158
+ async componentDidMount() {
159
+ await this.loader();
160
+ this.props.view.when(() => {
161
+ this.container.current !== null &&
162
+ this.props.view.ui.add(this.container.current, 'top-right');
163
+ });
164
+ }
165
+
166
+ /**
167
+ * This method renders the component
168
+ * @returns jsx
169
+ */
170
+ render() {
171
+ return (
172
+ <>
173
+ <div ref={this.container} className="upload-container">
174
+ <div tooltip="Add Map service" direction="left" type="widget">
175
+ <div
176
+ className={this.menuClass}
177
+ id="map_upload_button"
178
+ aria-label="WMS service upload"
179
+ onClick={this.openMenu.bind(this)}
180
+ onKeyDown={(e) => {
181
+ if (
182
+ !e.altKey &&
183
+ e.code !== 'Tab' &&
184
+ !e.ctrlKey &&
185
+ e.code !== 'Delete' &&
186
+ !e.shiftKey &&
187
+ !e.code.startsWith('F')
188
+ ) {
189
+ this.openMenu(this);
190
+ }
191
+ }}
192
+ tabIndex="0"
193
+ role="button"
194
+ ></div>
195
+ </div>
196
+ <div className="right-panel">
197
+ <div className="right-panel-header">
198
+ <span>Add map service</span>
199
+ <span
200
+ className="map-menu-icon esri-icon-close"
201
+ onClick={this.openMenu.bind(this)}
202
+ onKeyDown={(e) => {
203
+ if (
204
+ !e.altKey &&
205
+ e.code !== 'Tab' &&
206
+ !e.ctrlKey &&
207
+ e.code !== 'Delete' &&
208
+ !e.shiftKey &&
209
+ !e.code.startsWith('F')
210
+ ) {
211
+ this.openMenu(this);
212
+ }
213
+ }}
214
+ tabIndex="0"
215
+ role="button"
216
+ ></span>
217
+ </div>
218
+ <div className="right-panel-content">
219
+ <div className="upload-panel">
220
+ <div className="ccl-form">
221
+ <div className="field">
222
+ <label>
223
+ Map service address
224
+ <input
225
+ type="text"
226
+ placeholder="Add map service URL (https://...)"
227
+ value={this.state.wmsServiceUrl}
228
+ onChange={this.handleWmsServiceUrlChange}
229
+ />
230
+ </label>
231
+ </div>
232
+ <button
233
+ className="esri-button"
234
+ onClick={this.handleUploadService}
235
+ >
236
+ Upload service
237
+ </button>
238
+ </div>
239
+ </div>
240
+ </div>
241
+ </div>
242
+ {this.state.showInfoPopup && (
243
+ <div className="map-container popup-block">
244
+ <div className="drawRectanglePopup-block">
245
+ <div className="drawRectanglePopup-content">
246
+ {this.state.infoPopupType === 'uploadError' && (
247
+ <>
248
+ <span className="drawRectanglePopup-icon">
249
+ <FontAwesomeIcon icon={['fas', 'info-circle']} />
250
+ </span>
251
+ <div className="drawRectanglePopup-text">
252
+ Error uploading the map service.
253
+ </div>
254
+ </>
255
+ )}
256
+ </div>
257
+ </div>
258
+ </div>
259
+ )}
260
+ </div>
261
+ </>
262
+ );
263
+ }
264
+ }
265
+ export default UploadWidget;
@@ -97,6 +97,10 @@
97
97
  order: 7;
98
98
  }
99
99
 
100
+ .upload-container {
101
+ order: 8;
102
+ }
103
+
100
104
  /* Basemap */
101
105
  .basemap-container {
102
106
  display: flex;
@@ -464,6 +468,37 @@ label.ccl-form-radio-label span.nuts-menu-icon {
464
468
  color: red;
465
469
  font-size: 15px;
466
470
  }
471
+ /* WMS Upload */
472
+ div.upload-container.esri-component
473
+ > div.right-panel
474
+ > div.right-panel-content {
475
+ display: unset !important;
476
+ }
477
+
478
+ .upload-container {
479
+ display: flex;
480
+ box-shadow: none !important;
481
+ }
482
+
483
+ .upload-container input::placeholder {
484
+ color: #999;
485
+ font-size: 0.875rem;
486
+ }
487
+
488
+ .upload-container .esri-button:hover {
489
+ border: none;
490
+ background-color: #a0b128;
491
+ }
492
+
493
+ .upload-container .esri-button {
494
+ border-color: #a0b128;
495
+ background-color: white;
496
+ color: #a0b128;
497
+ }
498
+
499
+ .upload-panel {
500
+ display: unset !important;
501
+ }
467
502
  /* Left menu */
468
503
  .map-menu {
469
504
  position: relative;