@opengeoweb/layer-select 17.0.1 → 17.1.0

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/index.esm.js DELETED
@@ -1,3874 +0,0 @@
1
- import React from 'react';
2
- import { useSelector, useDispatch } from 'react-redux';
3
- import { CustomIconButton, FilterOption, ToolContainerDraggable, CustomAccordion, CustomTooltip, SearchHighlight, SearchField, CustomToggleButton, AlertBanner, ToggleMenu, CustomDialog, sessionStorageProvider } from '@opengeoweb/shared';
4
- import { uiTypes, serviceActions, selectorMemoizationOptions, serviceSelectors, uiActions, getUserAddedServices, setUserAddedServices, layerActions, uiSelectors, layerSelectors, mapListener, serviceListener, layersListener, openlayersListener, uiReducer, layerReducer, serviceReducer, mapReducer, useSetupDialog, mapSelectors, layerTypes, mapEnums } from '@opengeoweb/store';
5
- import { Filter, ArrowDropDownDown, LayersAdd, MeteoGate, Add, Cached, Edit, Visibility, Delete, Copy } from '@opengeoweb/theme';
6
- import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
7
- import { compact, countBy, partition } from 'lodash';
8
- import { snackbarListener, snackbarReducer, snackbarActions, snackbarTypes } from '@opengeoweb/snackbar';
9
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
- import { Switch, Grid, List, ToggleButtonGroup, ToggleButton, Box, Popper, Grow, Paper, ClickAwayListener, MenuList, MenuItem, Typography, useTheme, Backdrop, CircularProgress, Button, ListItem, ListItemText, LinearProgress, InputAdornment } from '@mui/material';
11
- import 'i18next';
12
- import { useTranslation } from 'react-i18next';
13
- import { List as List$1 } from 'react-window';
14
- import { getDimensionsList, LayerInfoButton, clearImageCacheForAllMaps } from '@opengeoweb/webmap-react';
15
- import { LayerType, webmapUtils, getWMSServiceId, queryWMSServiceInfo, queryWMSLayers, invalidateWMSGetCapabilities } from '@opengeoweb/webmap';
16
- import { useFormContext } from 'react-hook-form';
17
- import { ReactHookFormProvider, defaultFormOptions, ReactHookFormTextField } from '@opengeoweb/form-fields';
18
-
19
- var en = {
20
- "layer-select": "Layer Select",
21
- "select-all": "Select all",
22
- "groups-and-keywords-dialog-title": "Groups & Keywords",
23
- add: "add",
24
- remove: "remove",
25
- "layer-list-results": "results",
26
- groups: "Groups",
27
- keywords: "Keywords",
28
- "layer-select-button-tooltip": "Open the layer selector",
29
- all: "All",
30
- services: "Services",
31
- "add-a-new-service": "Add a new service",
32
- "update-service-title": "Update layers from WMS service",
33
- "edit-service-title": "Edit Service",
34
- "save-service-title": "Save service",
35
- "show-service-title": "Show Service",
36
- "service-has-active-layers-error": "Service has active layers. Cannot remove this service",
37
- "delete-service": "Delete Service",
38
- "copy-url-message": "Service URL copied to clipboard",
39
- "get-success-message": "Service \"{{serviceName}}\" has been saved successfully",
40
- "service-popup-helper-text": "Short description of what this service does",
41
- close: "close",
42
- cancel: "cancel",
43
- save: "save",
44
- "validations-name-existing": "This name already exists. Choose another name.",
45
- "validations-service-existing": "URL already exists.",
46
- "validations-service-valid-url": "Not a valid URL.",
47
- "validations-request-failed": "Download failed. Check the URL.",
48
- "validations-field-required": "This field is required",
49
- "service-url-label": "This service refers to this URL",
50
- "service-name-label": "Service name",
51
- "service-abstracts-label": "Abstracts",
52
- "service-successfully-updated": "Service \"{{serviceName}}\" has been succesfully updated",
53
- "unable-to-update-service": "Unable to update service, reason: \"{{message}}\"",
54
- "service-has-been-deleted": "Service \"{{serviceName}}\" has been deleted",
55
- "add-to-all-maps": "Add to all maps",
56
- "remove-from-all-maps": "Remove from all maps"
57
- };
58
- var fi = {
59
- "layer-select": "Layer Select",
60
- "select-all": "Valitse kaikki",
61
- "groups-and-keywords-dialog-title": "Ryhmät ja Avainsanat",
62
- add: "lisää",
63
- remove: "poista",
64
- "layer-list-results": "tulosta",
65
- groups: "Ryhmät",
66
- keywords: "Avainsanat",
67
- "layer-select-button-tooltip": "Avaa Layer Select",
68
- all: "Kaikki",
69
- services: "Palvelut",
70
- "add-a-new-service": "Lisää uusi pavelu",
71
- "update-service-title": "Päivitä karttatasot WMS palvelusta",
72
- "edit-service-title": "Muokkaa palvelua",
73
- "save-service-title": "Tallenna palvelu",
74
- "show-service-title": "Näytä palvelu",
75
- "service-has-active-layers-error": "Palvelu sisältää aktiivisia karttatasoja. Palvelua ei voi poistaa",
76
- "delete-service": "Poista palvelu",
77
- "copy-url-message": "Palvelun osoite kopioitu leikepöydälle",
78
- "get-success-message": "Palvelu \"{{serviceName}}\" tallennettu onnistuneesti",
79
- "service-popup-helper-text": "Lyhyt kuvaus siitä mitä palvelu tekee",
80
- close: "sulje",
81
- cancel: "peruuta",
82
- save: "tallenna",
83
- "validations-name-existing": "Nimi on jo käytössä. Valitse toinen nimi.",
84
- "validations-service-existing": "Osoite on jo käytössä.",
85
- "validations-service-valid-url": "Epäkelpo URL-osoite",
86
- "validations-request-failed": "Lataus epäonnistui. Tarkista URL-osoite",
87
- "validations-field-required": "Kenttä tulee täyttää",
88
- "service-url-label": "Tämä palvelu viittaa tähän URL-osoitteeseen",
89
- "service-name-label": "Palvelun nimi",
90
- "service-abstracts-label": "Tiivistelmä",
91
- "service-successfully-updated": "Palvelu \"{{serviceName}}\" päivitetty onnistuneesti",
92
- "unable-to-update-service": "Palvelun päivitys epäonnistui. Syy: \"{{message}}\"",
93
- "service-has-been-deleted": "Palvelu \"{{serviceName}}\" poistettu",
94
- "add-to-all-maps": "Lisää kaikkiin karttoihin",
95
- "remove-from-all-maps": "Poista kaikista kartoista"
96
- };
97
- var no = {
98
- "layer-select": "Datavelger",
99
- "select-all": "Velg alle",
100
- "groups-and-keywords-dialog-title": "Grupper & Nøkkelord",
101
- add: "legg til",
102
- remove: "fjern",
103
- "layer-list-results": "resultat",
104
- groups: "Grupper",
105
- keywords: "Nøkkelord",
106
- "layer-select-button-tooltip": "Åpne datavelger",
107
- all: "ALLE",
108
- services: "Tjenester",
109
- "add-a-new-service": "Legg til en ny tjeneste",
110
- "update-service-title": "Oppdater lag fra WMS-tjeneste",
111
- "edit-service-title": "Rediger tjeneste",
112
- "save-service-title": "Lagre tjeneste",
113
- "show-service-title": "Vis tjeneste",
114
- "service-has-active-layers-error": "Tjenesten har aktive lag. Kan ikke fjerne denne tjenesten",
115
- "delete-service": "Slett tjeneste",
116
- "copy-url-message": "Kopier tjeneste-URL til utklippstavle",
117
- "get-success-message": "Tjeneste \"{{serviceName}}\" har blitt lagret",
118
- "service-popup-helper-text": "Kort beskrivelse av hva denne tjenesten gjør",
119
- close: "lukk",
120
- cancel: "avbryt",
121
- save: "lagre",
122
- "validations-name-existing": "Dette navnet eksisterer fra før. Velg et annet navn.",
123
- "validations-service-existing": "URL eksisterer fra før.",
124
- "validations-service-valid-url": "Ikke en gyldig URL",
125
- "validations-request-failed": "Nedlasting feilet. Sjekk URLen",
126
- "validations-field-required": "Dette feltet er påkrevd",
127
- "service-url-label": "Denne tjenesten referer til denne URLen",
128
- "service-name-label": "Tjenestenavn",
129
- "service-abstracts-label": "Sammendrag",
130
- "service-successfully-updated": "Tjeneste \"{{serviceName}}\" har blitt oppdatert",
131
- "unable-to-update-service": "Kan ikke oppdatere tjeneste, grunn: \"{{message}}\"",
132
- "service-has-been-deleted": "Tjeneste \"{{serviceName}}\" har blitt slettet",
133
- "add-to-all-maps": "Legg til i alle kart",
134
- "remove-from-all-maps": "Fjern fra alle kart"
135
- };
136
- var nl = {
137
- "layer-select": "Layer Select",
138
- "select-all": "Selecteer alles",
139
- "groups-and-keywords-dialog-title": "Groepen & Trefwoorden",
140
- add: "toevoegen",
141
- remove: "verwijderen",
142
- "layer-list-results": "resultaten",
143
- groups: "Groepen",
144
- keywords: "Trefwoorden",
145
- "layer-select-button-tooltip": "Open de Layer Select",
146
- all: "Alle",
147
- services: "Services",
148
- "add-a-new-service": "Voeg een nieuwe service toe",
149
- "update-service-title": "Lagen bijwerken vanaf WMS service",
150
- "edit-service-title": "Service bewerken",
151
- "save-service-title": "Service opslaan",
152
- "show-service-title": "Service tonen",
153
- "service-has-active-layers-error": "Service heeft actieve lagen. Kan niet verwijderd worden",
154
- "delete-service": "Service verwijderen",
155
- "copy-url-message": "Service URL is naar het klembord gekopieerd",
156
- "get-success-message": "Service \"{{serviceName}}\" is succesvol opgeslagen",
157
- "service-popup-helper-text": "Korte beschrijving van wat de service doet",
158
- close: "sluiten",
159
- cancel: "annuleren",
160
- save: "opslaan",
161
- "validations-name-existing": "Deze naam is al in gebruik. Kies een andere naam.",
162
- "validations-service-existing": "URL is al in gebruik.",
163
- "validations-service-valid-url": "Geen geldige URL.",
164
- "validations-request-failed": "Download mislukt. Controleer de URL.",
165
- "validations-field-required": "Dit veld is verplicht",
166
- "service-url-label": "Deze service verwijst naar deze URL",
167
- "service-name-label": "Service naam",
168
- "service-abstracts-label": "Beschrijving",
169
- "service-successfully-updated": "Service \"{{serviceName}}\" is succesvol bijgewerkt",
170
- "unable-to-update-service": "Bijwerken service niet mogelijk, reden: \"{{message}}\"",
171
- "service-has-been-deleted": "Service \"{{serviceName}}\" is verwijderd",
172
- "add-to-all-maps": "Toevoegen aan alle kaarten",
173
- "remove-from-all-maps": "Verwijderen van alle kaarten"
174
- };
175
- var layerSelectTranslations = {
176
- en: en,
177
- fi: fi,
178
- no: no,
179
- nl: nl
180
- };
181
-
182
- /* *
183
- * Licensed under the Apache License, Version 2.0 (the "License");
184
- * you may not use this file except in compliance with the License.
185
- * You may obtain a copy of the License at
186
- *
187
- * http://www.apache.org/licenses/LICENSE-2.0
188
- *
189
- * Unless required by applicable law or agreed to in writing, software
190
- * distributed under the License is distributed on an "AS IS" BASIS,
191
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
- * See the License for the specific language governing permissions and
193
- * limitations under the License.
194
- *
195
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
196
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
197
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
198
- * */
199
-
200
- var getFilterId = function getFilterId(filterType, filterName) {
201
- return filterType + "-" + filterName;
202
- };
203
- var produceFilters = function produceFilters(filterNames, filterType, draft, layerSelectFilterAdapter) {
204
- filterNames.forEach(function (filterName) {
205
- layerSelectFilterAdapter.addOne(draft.filters.filters, {
206
- id: getFilterId(filterType, filterName),
207
- name: filterName,
208
- checked: true,
209
- type: filterType
210
- });
211
- });
212
- };
213
- var filterLayersFromService = function filterLayersFromService(serviceId, services, filterIds, allFiltersActive, searchString) {
214
- var mapStoreService = services[serviceId];
215
- if (!mapStoreService) {
216
- return [];
217
- }
218
- if (searchString === '' && allFiltersActive) {
219
- return mapStoreService.layers.filter(function (layer) {
220
- return layer.leaf;
221
- });
222
- }
223
- var searchStringArray = searchString.split(' ');
224
- return mapStoreService.layers.filter(function (layer) {
225
- return searchStringArray.every(function (search) {
226
- var _layer$keywords, _layer$name, _layer$title, _layer$abstract;
227
- var searchLowercase = search.toLowerCase();
228
- var layerFilterIds = layer.path.map(function (group) {
229
- return getFilterId('groups', group);
230
- }).concat(((_layer$keywords = layer.keywords) != null ? _layer$keywords : []).map(function (keyword) {
231
- return getFilterId('keywords', keyword);
232
- }));
233
- var isFilterInLayer = (layerFilterIds == null ? void 0 : layerFilterIds.some(function (id) {
234
- return filterIds.includes(id);
235
- })) || allFiltersActive;
236
- var isSearchTextInLayerFilter = layerFilterIds == null ? void 0 : layerFilterIds.some(function (filterId) {
237
- return filterId.toLowerCase().includes(searchLowercase);
238
- });
239
- var isSearchTextInLayerName = (_layer$name = layer.name) == null ? void 0 : _layer$name.toLowerCase().includes(searchLowercase);
240
- var isSearchTextInLayerText = (_layer$title = layer.title) == null ? void 0 : _layer$title.toLowerCase().includes(searchLowercase);
241
- var isSearchTextInLayerAbstract = (_layer$abstract = layer["abstract"]) == null ? void 0 : _layer$abstract.toLowerCase().includes(searchLowercase);
242
- var isSearchTextInServiceName = mapStoreService.name.toLowerCase().includes(searchLowercase);
243
- var isSearchTextInLayer = isSearchTextInLayerName || isSearchTextInLayerText || isSearchTextInLayerAbstract || isSearchTextInLayerFilter || isSearchTextInServiceName;
244
- return isFilterInLayer && isSearchTextInLayer;
245
- });
246
- }).filter(function (layer) {
247
- return layer.leaf;
248
- });
249
- };
250
- var isUserAddedService = function isUserAddedService(scope) {
251
- return scope === 'user';
252
- };
253
-
254
- /* *
255
- * Licensed under the Apache License, Version 2.0 (the "License");
256
- * you may not use this file except in compliance with the License.
257
- * You may obtain a copy of the License at
258
- *
259
- * http://www.apache.org/licenses/LICENSE-2.0
260
- *
261
- * Unless required by applicable law or agreed to in writing, software
262
- * distributed under the License is distributed on an "AS IS" BASIS,
263
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
264
- * See the License for the specific language governing permissions and
265
- * limitations under the License.
266
- *
267
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
268
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
269
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
270
- * */
271
-
272
- var layerSelectFilterAdapter = createEntityAdapter();
273
- var layerSelectActiveServicesAdapter = createEntityAdapter({
274
- selectId: function selectId(service) {
275
- return service.serviceId;
276
- }
277
- });
278
- var initialServicePopupState = {
279
- isOpen: false,
280
- url: '',
281
- serviceId: '',
282
- variant: 'add'
283
- };
284
- var initialState = {
285
- filters: {
286
- searchFilter: '',
287
- activeServices: layerSelectActiveServicesAdapter.getInitialState(),
288
- filters: layerSelectFilterAdapter.getInitialState()
289
- },
290
- allServicesEnabled: true,
291
- servicePopup: initialServicePopupState
292
- };
293
- var slice = createSlice({
294
- initialState: initialState,
295
- name: uiTypes.DialogTypes.LayerSelect,
296
- reducers: {
297
- setSearchFilter: function setSearchFilter(draft, action) {
298
- var filterText = action.payload.filterText;
299
- draft.filters.searchFilter = filterText;
300
- },
301
- closeServicePopupOpen: function closeServicePopupOpen(draft) {
302
- draft.servicePopup.isOpen = false;
303
- },
304
- toggleServicePopup: function toggleServicePopup(draft, action) {
305
- var _action$payload = action.payload,
306
- variant = _action$payload.variant,
307
- isOpen = _action$payload.isOpen;
308
- draft.servicePopup.isOpen = isOpen;
309
- draft.servicePopup.url = action.payload.url ? action.payload.url : '';
310
- draft.servicePopup.variant = variant;
311
- draft.servicePopup.serviceId = action.payload.serviceId ? action.payload.serviceId : '';
312
- },
313
- layerSelectRemoveService: function layerSelectRemoveService(draft, action) {
314
- var serviceId = action.payload.serviceId;
315
- layerSelectActiveServicesAdapter.removeOne(draft.filters.activeServices, serviceId);
316
- },
317
- enableActiveService: function enableActiveService(draft, action) {
318
- var activeServicesById = draft.filters.activeServices.entities;
319
- var activeServices = compact(Object.values(activeServicesById));
320
- var countPressedServices = activeServices.filter(function (service) {
321
- return service.enabled;
322
- }).length;
323
- var isAllServicesGoingToBeEnabled = countPressedServices === activeServices.length - 1;
324
- if (isAllServicesGoingToBeEnabled) {
325
- slice.caseReducers.enableAllActiveServices(draft);
326
- return;
327
- }
328
- var service = activeServicesById[action.payload.serviceId];
329
- service.enabled = true;
330
- },
331
- enableAllActiveServices: function enableAllActiveServices(draft) {
332
- var activeServices = draft.filters.activeServices.entities;
333
- var servicesToTurnOn = compact(Object.values(activeServices)).filter(function (service) {
334
- return !service.enabled;
335
- });
336
- var updates = servicesToTurnOn.map(function (service) {
337
- return {
338
- id: service.serviceId,
339
- changes: {
340
- enabled: true
341
- }
342
- };
343
- });
344
- layerSelectActiveServicesAdapter.updateMany(draft.filters.activeServices, updates);
345
- draft.allServicesEnabled = true;
346
- },
347
- onlyThisServiceEnabled: function onlyThisServiceEnabled(draft, action) {
348
- var activeServicesById = draft.filters.activeServices.entities;
349
- var services = compact(Object.values(activeServicesById));
350
- var servicesToTurnOff = services.filter(function (service) {
351
- return service.serviceId !== action.payload.serviceId;
352
- });
353
- var updates = servicesToTurnOff.map(function (service) {
354
- return {
355
- id: service.serviceId,
356
- changes: {
357
- enabled: false
358
- }
359
- };
360
- });
361
- layerSelectActiveServicesAdapter.updateMany(draft.filters.activeServices, updates);
362
- draft.allServicesEnabled = false;
363
- },
364
- disableActiveService: function disableActiveService(draft, action) {
365
- var activeServicesById = draft.filters.activeServices.entities;
366
- var countPressedServices = Object.values(activeServicesById).filter(function (service) {
367
- return service == null ? void 0 : service.enabled;
368
- }).length;
369
- var isAllServicesGoingToBeDisabled = countPressedServices === 1;
370
- if (isAllServicesGoingToBeDisabled) {
371
- slice.caseReducers.enableAllActiveServices(draft);
372
- return;
373
- }
374
- var service = activeServicesById[action.payload.serviceId];
375
- service.enabled = false;
376
- },
377
- toggleFilter: function toggleFilter(draft, action) {
378
- var _action$payload2 = action.payload,
379
- filterId = _action$payload2.filterId,
380
- only = _action$payload2.only;
381
- if (only) {
382
- Object.keys(draft.filters.filters.entities).forEach(function (filterId) {
383
- draft.filters.filters.entities[filterId].checked = false;
384
- });
385
- draft.filters.filters.entities[filterId].checked = true;
386
- } else {
387
- draft.filters.filters.entities[filterId].checked = !draft.filters.filters.entities[filterId].checked;
388
- }
389
- },
390
- toggleAllFilters: function toggleAllFilters(draft) {
391
- var allFiltersChecked = Object.values(draft.filters.filters.entities).every(function (filter) {
392
- return filter == null ? void 0 : filter.checked;
393
- });
394
- draft.filters.filters.ids.forEach(function (filterId) {
395
- draft.filters.filters.entities[filterId].checked = !allFiltersChecked;
396
- });
397
- }
398
- },
399
- extraReducers: function extraReducers(builder) {
400
- builder.addCase(serviceActions.serviceSetLayers, function (draft, action) {
401
- var _draft$filters$active;
402
- var _action$payload3 = action.payload,
403
- serviceId = _action$payload3.id,
404
- serviceUrl = _action$payload3.serviceUrl,
405
- serviceName = _action$payload3.name,
406
- scope = _action$payload3.scope,
407
- _abstract = _action$payload3["abstract"],
408
- layers = _action$payload3.layers,
409
- isUpdating = _action$payload3.isUpdating,
410
- type = _action$payload3.type;
411
- if (isUpdating) {
412
- return;
413
- }
414
- if (type === 'EDR') {
415
- // EDR services do not work yet in the layer-select, so skip them for now
416
- return;
417
- }
418
- var keywords = layers.reduce(function (keywords, layer) {
419
- if (layer.leaf) {
420
- var _layer$keywords;
421
- return keywords.concat((_layer$keywords = layer.keywords) != null ? _layer$keywords : []);
422
- }
423
- return keywords;
424
- }, []);
425
- var groups = layers.reduce(function (groups, layer) {
426
- if (layer.leaf) {
427
- var _layer$path;
428
- return groups.concat((_layer$path = layer.path) != null ? _layer$path : []);
429
- }
430
- return groups;
431
- }, []);
432
- if (!((_draft$filters$active = draft.filters.activeServices.entities[serviceId]) != null && (_draft$filters$active = _draft$filters$active.filterIds) != null && _draft$filters$active.length)) {
433
- // If the service has no filters yet, add them
434
- produceFilters(groups, 'groups', draft, layerSelectFilterAdapter);
435
- produceFilters(keywords, 'keywords', draft, layerSelectFilterAdapter);
436
- }
437
- var filterIds = groups.map(function (group) {
438
- return getFilterId('groups', group);
439
- }).concat(keywords.map(function (keyword) {
440
- return getFilterId('keywords', keyword);
441
- }));
442
- layerSelectActiveServicesAdapter.setOne(draft.filters.activeServices, {
443
- serviceId: serviceId,
444
- enabled: draft.allServicesEnabled,
445
- keywords: keywords,
446
- groups: groups,
447
- filterIds: filterIds,
448
- scope: scope,
449
- serviceName: serviceName,
450
- serviceUrl: serviceUrl,
451
- "abstract": _abstract,
452
- isLoading: false
453
- });
454
- }).addCase(serviceActions.fetchInitialServices, function (draft, action) {
455
- var services = action.payload.services;
456
- services.forEach(function (service) {
457
- var serviceId = service.id,
458
- serviceName = service.name,
459
- serviceUrl = service.url,
460
- _abstract2 = service["abstract"],
461
- scope = service.scope;
462
- layerSelectActiveServicesAdapter.setOne(draft.filters.activeServices, {
463
- serviceId: serviceId,
464
- enabled: draft.allServicesEnabled,
465
- filterIds: [],
466
- scope: scope,
467
- serviceName: serviceName,
468
- serviceUrl: serviceUrl,
469
- "abstract": _abstract2,
470
- isLoading: true
471
- });
472
- });
473
- });
474
- }
475
- });
476
- var layerSelectReducer = slice.reducer,
477
- layerSelectActions = slice.actions;
478
-
479
- /* *
480
- * Licensed under the Apache License, Version 2.0 (the "License");
481
- * you may not use this file except in compliance with the License.
482
- * You may obtain a copy of the License at
483
- *
484
- * http://www.apache.org/licenses/LICENSE-2.0
485
- *
486
- * Unless required by applicable law or agreed to in writing, software
487
- * distributed under the License is distributed on an "AS IS" BASIS,
488
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
489
- * See the License for the specific language governing permissions and
490
- * limitations under the License.
491
- *
492
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
493
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
494
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
495
- * */
496
-
497
- var useAppSelector = useSelector;
498
- var layerSelectStore = function layerSelectStore(store) {
499
- return store != null && store.layerSelect ? store.layerSelect : null;
500
- };
501
-
502
- /**
503
- * Returns search filter string
504
- *
505
- * Example getSearchFilter(store);
506
- * @param {object} store store: object - store object
507
- * @returns {array} returnType: string
508
- */
509
- var getSearchFilter = createSelector(layerSelectStore, function (store) {
510
- var _store$filters;
511
- return (store == null || (_store$filters = store.filters) == null ? void 0 : _store$filters.searchFilter) || '';
512
- });
513
-
514
- /**
515
- * Returns active services array
516
- *
517
- * Example getActiveServices(store);
518
- * @param {object} store store: object - store object
519
- * @returns {ActiveServiceObjectEntities} returnType: ActiveServiceObjectEntitiesobject of active services
520
- */
521
- // cast to usable type - selectEntities returns Dictionary<ActiveServiceObject> which is not usable inside of the code
522
- var getActiveServices = function getActiveServices(store) {
523
- return getActiveServicesDictionary(store);
524
- };
525
- var EMPTY_ACTIVE_SERVICES = {
526
- entities: {},
527
- ids: []
528
- };
529
- var _layerSelectActiveSer = layerSelectActiveServicesAdapter.getSelectors(function (store) {
530
- var _store$layerSelect;
531
- return (store == null || (_store$layerSelect = store.layerSelect) == null || (_store$layerSelect = _store$layerSelect.filters) == null ? void 0 : _store$layerSelect.activeServices) || EMPTY_ACTIVE_SERVICES;
532
- }),
533
- getActiveServicesDictionary = _layerSelectActiveSer.selectEntities,
534
- getActiveServiceById = _layerSelectActiveSer.selectById,
535
- getAllActiveServices = _layerSelectActiveSer.selectAll;
536
- var getEnabledServiceIds = createSelector(getAllActiveServices, function (services) {
537
- return services.filter(function (service) {
538
- return service.enabled;
539
- }).map(function (service) {
540
- return service.serviceId;
541
- });
542
- }, selectorMemoizationOptions);
543
-
544
- /**
545
- * Returns ids of all keywords
546
- *
547
- * Example getAllKeywordIds(store);
548
- * @param {object} store store: object - store object
549
- * @returns {array} returnType: array of all keyword ids
550
- */
551
- // cast to usable type - selectIds returns EntityId[] which is not usable inside of the code
552
- var getAllFilterIds = function getAllFilterIds(store) {
553
- return getAllFilterIdsEntity(store);
554
- };
555
- var EMPTY_FILTERS = {
556
- entities: {},
557
- ids: []
558
- };
559
- var _layerSelectFilterAda = layerSelectFilterAdapter.getSelectors(function (store) {
560
- var _store$layerSelect2;
561
- return (store == null || (_store$layerSelect2 = store.layerSelect) == null || (_store$layerSelect2 = _store$layerSelect2.filters) == null ? void 0 : _store$layerSelect2.filters) || EMPTY_FILTERS;
562
- }),
563
- getAllFilters = _layerSelectFilterAda.selectAll,
564
- getAllFilterIdsEntity = _layerSelectFilterAda.selectIds,
565
- getFilterById = _layerSelectFilterAda.selectById;
566
- var getCheckedFilterIds = createSelector(getAllFilters, function (filters) {
567
- return filters.filter(function (filter) {
568
- return filter == null ? void 0 : filter.checked;
569
- }).map(function (filter) {
570
- return filter.id;
571
- });
572
- }, selectorMemoizationOptions);
573
- var getFilters = createSelector(getAllActiveServices, getAllFilters, function (services, filters) {
574
- var enabledServices = services.filter(function (service) {
575
- return service.enabled;
576
- });
577
- var keywords = enabledServices.flatMap(function (service) {
578
- return service.keywords;
579
- });
580
- var groups = enabledServices.flatMap(function (service) {
581
- return service.groups;
582
- });
583
- var countEachKeyword = countBy(keywords);
584
- var countEachGroup = countBy(groups);
585
- var filtersWithCount = filters.map(function (filter) {
586
- var _countEachKeyword$fil;
587
- if (filter.type === 'groups') {
588
- var _countEachGroup$filte;
589
- return Object.assign({}, filter, {
590
- amountVisible: (_countEachGroup$filte = countEachGroup[filter.name]) != null ? _countEachGroup$filte : 0
591
- });
592
- }
593
- return Object.assign({}, filter, {
594
- amountVisible: (_countEachKeyword$fil = countEachKeyword[filter.name]) != null ? _countEachKeyword$fil : 0
595
- });
596
- });
597
- var _partition = partition(filtersWithCount, function (filter) {
598
- return filter.type === 'groups';
599
- }),
600
- groupsWithCount = _partition[0],
601
- keywordsWithCount = _partition[1];
602
- var groupsSorted = [].concat(groupsWithCount).sort(function (groupA, groupB) {
603
- return groupA.name.localeCompare(groupB.name);
604
- });
605
- var keywordsSorted = [].concat(keywordsWithCount).sort(function (groupA, groupB) {
606
- return groupA.name.localeCompare(groupB.name);
607
- });
608
- return {
609
- groups: groupsSorted,
610
- keywords: keywordsSorted
611
- };
612
- });
613
-
614
- /**
615
- * Returns if all keywords are checked
616
- *
617
- * Example isAllKeywordsChecked(store);
618
- * @param {object} store store: object - store object
619
- * @returns {array} returnType: boolean if all keywords are checked
620
- */
621
- var isAllFiltersChecked = createSelector(layerSelectStore, function (store) {
622
- var _store$filters2;
623
- return store == null || (_store$filters2 = store.filters) == null || (_store$filters2 = _store$filters2.filters) == null ? void 0 : _store$filters2.ids.every(function (filterId) {
624
- var _store$filters3;
625
- return store == null || (_store$filters3 = store.filters) == null || (_store$filters3 = _store$filters3.filters) == null || (_store$filters3 = _store$filters3.entities[filterId]) == null ? void 0 : _store$filters3.checked;
626
- });
627
- });
628
-
629
- /**
630
- * Returns a filtered active layer object based on the given filter settings
631
- * Example: layerSelectSelectors.getFilteredLayers(store, filteredSettings);
632
- * @param {object} store store: object - object from which the service state will be extracted
633
- * @returns {array} returnType: LayerWithServiceName - an array of all filtered activelayers
634
- */
635
- var getFilteredLayers = createSelector([getEnabledServiceIds, serviceSelectors.getServices, getCheckedFilterIds, isAllFiltersChecked, getSearchFilter], function (enabledServiceIds, servicesStore, checkedFilterIds, allFiltersActive, searchFilter) {
636
- return enabledServiceIds.reduce(function (layerList, serviceId) {
637
- return layerList.concat(filterLayersFromService(serviceId, servicesStore, checkedFilterIds, allFiltersActive, searchFilter).map(function (layer) {
638
- return Object.assign({}, layer, {
639
- serviceName: serviceId
640
- });
641
- }));
642
- }, []);
643
- }, selectorMemoizationOptions);
644
-
645
- /**
646
- * Returns service popup details
647
- *
648
- * Example getServicePopupDetails(store, 'server-id');
649
- * @param {object} store store: object - store object
650
- * @returns {object} returnType: object of active service
651
- */
652
- var getServicePopupDetails = function getServicePopupDetails(store) {
653
- var _store$layerSelect3;
654
- return (store == null || (_store$layerSelect3 = store.layerSelect) == null ? void 0 : _store$layerSelect3.servicePopup) || initialServicePopupState;
655
- };
656
-
657
- /**
658
- * Returns service with active filtered layers from seaerch
659
- *
660
- * Example getFilteredActiveServices(store);
661
- * @param {object} store store: object - store object
662
- * @returns {object} returnType: object of active service
663
- */
664
- var getFilteredActiveServices = createSelector([getFilteredLayers, getActiveServices, getSearchFilter], function (layers, activeServices, searchResult) {
665
- var servicesResult = searchResult.length ? layers.reduce(function (layers, _ref) {
666
- var serviceName = _ref.serviceName;
667
- return layers.includes(serviceName) ? layers : layers.concat(serviceName);
668
- }, []) : [];
669
- var updatedServices = Object.fromEntries(Object.entries(activeServices).map(function (_ref2) {
670
- var key = _ref2[0],
671
- service = _ref2[1];
672
- return [key, Object.assign({}, service, {
673
- isInSearch: servicesResult.includes(service.serviceId)
674
- })];
675
- }));
676
- return updatedServices;
677
- }, selectorMemoizationOptions);
678
-
679
- var selectors = /*#__PURE__*/Object.freeze({
680
- __proto__: null,
681
- getActiveServiceById: getActiveServiceById,
682
- getActiveServices: getActiveServices,
683
- getActiveServicesDictionary: getActiveServicesDictionary,
684
- getAllActiveServices: getAllActiveServices,
685
- getAllFilterIds: getAllFilterIds,
686
- getAllFilterIdsEntity: getAllFilterIdsEntity,
687
- getAllFilters: getAllFilters,
688
- getCheckedFilterIds: getCheckedFilterIds,
689
- getEnabledServiceIds: getEnabledServiceIds,
690
- getFilterById: getFilterById,
691
- getFilteredActiveServices: getFilteredActiveServices,
692
- getFilteredLayers: getFilteredLayers,
693
- getFilters: getFilters,
694
- getSearchFilter: getSearchFilter,
695
- getServicePopupDetails: getServicePopupDetails,
696
- isAllFiltersChecked: isAllFiltersChecked,
697
- useAppSelector: useAppSelector
698
- });
699
-
700
- var types = /*#__PURE__*/Object.freeze({
701
- __proto__: null
702
- });
703
-
704
- function _OverloadYield(e, d) {
705
- this.v = e, this.k = d;
706
- }
707
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
708
- try {
709
- var i = n[a](c),
710
- u = i.value;
711
- } catch (n) {
712
- return void e(n);
713
- }
714
- i.done ? t(u) : Promise.resolve(u).then(r, o);
715
- }
716
- function _asyncToGenerator(n) {
717
- return function () {
718
- var t = this,
719
- e = arguments;
720
- return new Promise(function (r, o) {
721
- var a = n.apply(t, e);
722
- function _next(n) {
723
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
724
- }
725
- function _throw(n) {
726
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
727
- }
728
- _next(void 0);
729
- });
730
- };
731
- }
732
- function _objectDestructuringEmpty(t) {
733
- if (null == t) throw new TypeError("Cannot destructure " + t);
734
- }
735
- function _regenerator() {
736
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
737
- var e,
738
- t,
739
- r = "function" == typeof Symbol ? Symbol : {},
740
- n = r.iterator || "@@iterator",
741
- o = r.toStringTag || "@@toStringTag";
742
- function i(r, n, o, i) {
743
- var c = n && n.prototype instanceof Generator ? n : Generator,
744
- u = Object.create(c.prototype);
745
- return _regeneratorDefine(u, "_invoke", function (r, n, o) {
746
- var i,
747
- c,
748
- u,
749
- f = 0,
750
- p = o || [],
751
- y = false,
752
- G = {
753
- p: 0,
754
- n: 0,
755
- v: e,
756
- a: d,
757
- f: d.bind(e, 4),
758
- d: function (t, r) {
759
- return i = t, c = 0, u = e, G.n = r, a;
760
- }
761
- };
762
- function d(r, n) {
763
- for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
764
- var o,
765
- i = p[t],
766
- d = G.p,
767
- l = i[2];
768
- r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
769
- }
770
- if (o || r > 1) return a;
771
- throw y = true, n;
772
- }
773
- return function (o, p, l) {
774
- if (f > 1) throw TypeError("Generator is already running");
775
- for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
776
- i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
777
- try {
778
- if (f = 2, i) {
779
- if (c || (o = "next"), t = i[o]) {
780
- if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
781
- if (!t.done) return t;
782
- u = t.value, c < 2 && (c = 0);
783
- } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
784
- i = e;
785
- } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
786
- } catch (t) {
787
- i = e, c = 1, u = t;
788
- } finally {
789
- f = 1;
790
- }
791
- }
792
- return {
793
- value: t,
794
- done: y
795
- };
796
- };
797
- }(r, o, i), true), u;
798
- }
799
- var a = {};
800
- function Generator() {}
801
- function GeneratorFunction() {}
802
- function GeneratorFunctionPrototype() {}
803
- t = Object.getPrototypeOf;
804
- var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
805
- return this;
806
- }), t),
807
- u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
808
- function f(e) {
809
- return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
810
- }
811
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
812
- return this;
813
- }), _regeneratorDefine(u, "toString", function () {
814
- return "[object Generator]";
815
- }), (_regenerator = function () {
816
- return {
817
- w: i,
818
- m: f
819
- };
820
- })();
821
- }
822
- function _regeneratorAsync(n, e, r, t, o) {
823
- var a = _regeneratorAsyncGen(n, e, r, t, o);
824
- return a.next().then(function (n) {
825
- return n.done ? n.value : a.next();
826
- });
827
- }
828
- function _regeneratorAsyncGen(r, e, t, o, n) {
829
- return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
830
- }
831
- function _regeneratorAsyncIterator(t, e) {
832
- function n(r, o, i, f) {
833
- try {
834
- var c = t[r](o),
835
- u = c.value;
836
- return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
837
- n("next", t, i, f);
838
- }, function (t) {
839
- n("throw", t, i, f);
840
- }) : e.resolve(u).then(function (t) {
841
- c.value = t, i(c);
842
- }, function (t) {
843
- return n("throw", t, i, f);
844
- });
845
- } catch (t) {
846
- f(t);
847
- }
848
- }
849
- var r;
850
- this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
851
- return this;
852
- })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
853
- function f() {
854
- return new e(function (e, r) {
855
- n(t, i, e, r);
856
- });
857
- }
858
- return r = r ? r.then(f, f) : f();
859
- }, true);
860
- }
861
- function _regeneratorDefine(e, r, n, t) {
862
- var i = Object.defineProperty;
863
- try {
864
- i({}, "", {});
865
- } catch (e) {
866
- i = 0;
867
- }
868
- _regeneratorDefine = function (e, r, n, t) {
869
- if (r) i ? i(e, r, {
870
- value: n,
871
- enumerable: !t,
872
- configurable: !t,
873
- writable: !t
874
- }) : e[r] = n;else {
875
- function o(r, n) {
876
- _regeneratorDefine(e, r, function (e) {
877
- return this._invoke(r, n, e);
878
- });
879
- }
880
- o("next", 0), o("throw", 1), o("return", 2);
881
- }
882
- }, _regeneratorDefine(e, r, n, t);
883
- }
884
- function _regeneratorKeys(e) {
885
- var n = Object(e),
886
- r = [];
887
- for (var t in n) r.unshift(t);
888
- return function e() {
889
- for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = false, e;
890
- return e.done = true, e;
891
- };
892
- }
893
- function _regeneratorValues(e) {
894
- if (null != e) {
895
- var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
896
- r = 0;
897
- if (t) return t.call(e);
898
- if ("function" == typeof e.next) return e;
899
- if (!isNaN(e.length)) return {
900
- next: function () {
901
- return e && r >= e.length && (e = void 0), {
902
- value: e && e[r++],
903
- done: !e
904
- };
905
- }
906
- };
907
- }
908
- throw new TypeError(typeof e + " is not iterable");
909
- }
910
- function _regeneratorRuntime() {
911
-
912
- var r = _regenerator(),
913
- e = r.m(_regeneratorRuntime),
914
- t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
915
- function n(r) {
916
- var e = "function" == typeof r && r.constructor;
917
- return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
918
- }
919
- var o = {
920
- throw: 1,
921
- return: 2,
922
- break: 3,
923
- continue: 3
924
- };
925
- function a(r) {
926
- var e, t;
927
- return function (n) {
928
- e || (e = {
929
- stop: function () {
930
- return t(n.a, 2);
931
- },
932
- catch: function () {
933
- return n.v;
934
- },
935
- abrupt: function (r, e) {
936
- return t(n.a, o[r], e);
937
- },
938
- delegateYield: function (r, o, a) {
939
- return e.resultName = o, t(n.d, _regeneratorValues(r), a);
940
- },
941
- finish: function (r) {
942
- return t(n.f, r);
943
- }
944
- }, t = function (r, t, o) {
945
- n.p = e.prev, n.n = e.next;
946
- try {
947
- return r(t, o);
948
- } finally {
949
- e.next = n.n;
950
- }
951
- }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
952
- try {
953
- return r.call(this, e);
954
- } finally {
955
- n.p = e.prev, n.n = e.next;
956
- }
957
- };
958
- }
959
- return (_regeneratorRuntime = function () {
960
- return {
961
- wrap: function (e, t, n, o) {
962
- return r.w(a(e), t, n, o && o.reverse());
963
- },
964
- isGeneratorFunction: n,
965
- mark: r.m,
966
- awrap: function (r, e) {
967
- return new _OverloadYield(r, e);
968
- },
969
- AsyncIterator: _regeneratorAsyncIterator,
970
- async: function (r, e, t, o, u) {
971
- return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
972
- },
973
- keys: _regeneratorKeys,
974
- values: _regeneratorValues
975
- };
976
- })();
977
- }
978
-
979
- var layerSelectListener = createListenerMiddleware();
980
- layerSelectListener.startListening({
981
- actionCreator: serviceActions.mapStoreRemoveService,
982
- effect: function () {
983
- var _effect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(action) {
984
- var serviceUrl, localStorageServices;
985
- return _regeneratorRuntime().wrap(function _callee$(_context) {
986
- while (1) switch (_context.prev = _context.next) {
987
- case 0:
988
- serviceUrl = action.payload.serviceUrl;
989
- localStorageServices = getUserAddedServices();
990
- delete localStorageServices[serviceUrl];
991
- setUserAddedServices(localStorageServices);
992
- case 4:
993
- case "end":
994
- return _context.stop();
995
- }
996
- }, _callee);
997
- }));
998
- function effect(_x) {
999
- return _effect.apply(this, arguments);
1000
- }
1001
- return effect;
1002
- }()
1003
- });
1004
- layerSelectListener.startListening({
1005
- actionCreator: layerSelectActions.layerSelectRemoveService,
1006
- effect: function () {
1007
- var _effect2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(action, listenerApi) {
1008
- var removedService, serviceId, serviceUrl, services, servicesEnabled;
1009
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1010
- while (1) switch (_context2.prev = _context2.next) {
1011
- case 0:
1012
- removedService = action.payload;
1013
- serviceId = removedService.serviceId, serviceUrl = removedService.serviceUrl;
1014
- services = getActiveServices(listenerApi.getState());
1015
- servicesEnabled = Object.values(services).find(function (service) {
1016
- return service == null ? void 0 : service.enabled;
1017
- });
1018
- if (servicesEnabled === undefined) {
1019
- Object.entries(services).map(function (_ref) {
1020
- var entryServiceId = _ref[0];
1021
- return listenerApi.dispatch(layerSelectActions.enableActiveService({
1022
- serviceId: entryServiceId
1023
- }));
1024
- });
1025
- }
1026
- listenerApi.dispatch(serviceActions.mapStoreRemoveService({
1027
- id: serviceId,
1028
- serviceUrl: serviceUrl
1029
- }));
1030
- case 6:
1031
- case "end":
1032
- return _context2.stop();
1033
- }
1034
- }, _callee2);
1035
- }));
1036
- function effect(_x2, _x3) {
1037
- return _effect2.apply(this, arguments);
1038
- }
1039
- return effect;
1040
- }()
1041
- });
1042
- layerSelectListener.startListening({
1043
- actionCreator: serviceActions.serviceSetLayers,
1044
- effect: function () {
1045
- var _effect3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(action) {
1046
- var _action$payload, scope, name, serviceUrl, _abstract, _Object$assign, localStorageServices;
1047
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1048
- while (1) switch (_context3.prev = _context3.next) {
1049
- case 0:
1050
- _action$payload = action.payload, scope = _action$payload.scope, name = _action$payload.name, serviceUrl = _action$payload.serviceUrl, _abstract = _action$payload["abstract"];
1051
- if (isUserAddedService(scope)) {
1052
- localStorageServices = getUserAddedServices();
1053
- setUserAddedServices(Object.assign({}, localStorageServices, (_Object$assign = {}, _Object$assign[serviceUrl] = {
1054
- name: name,
1055
- url: serviceUrl,
1056
- "abstract": _abstract
1057
- }, _Object$assign)));
1058
- }
1059
- case 2:
1060
- case "end":
1061
- return _context3.stop();
1062
- }
1063
- }, _callee3);
1064
- }));
1065
- function effect(_x4) {
1066
- return _effect3.apply(this, arguments);
1067
- }
1068
- return effect;
1069
- }()
1070
- });
1071
- layerSelectListener.startListening({
1072
- matcher: isAnyOf(uiActions.setToggleOpenDialog, uiActions.setActiveMapIdForDialog),
1073
- effect: function () {
1074
- var _effect4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(action, listenerApi) {
1075
- var payload;
1076
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
1077
- while (1) switch (_context4.prev = _context4.next) {
1078
- case 0:
1079
- payload = action.payload;
1080
- if (!payload.setOpen && payload.type === uiTypes.DialogTypes.LayerSelect) {
1081
- listenerApi.dispatch(layerActions.hideLayerInfo());
1082
- }
1083
- case 2:
1084
- case "end":
1085
- return _context4.stop();
1086
- }
1087
- }, _callee4);
1088
- }));
1089
- function effect(_x5, _x6) {
1090
- return _effect4.apply(this, arguments);
1091
- }
1092
- return effect;
1093
- }()
1094
- });
1095
- layerSelectListener.startListening({
1096
- matcher: isAnyOf(layerSelectActions.disableActiveService, layerSelectActions.onlyThisServiceEnabled, layerSelectActions.toggleFilter, layerSelectActions.setSearchFilter),
1097
- effect: function () {
1098
- var _effect5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(action, listenerApi) {
1099
- var filteredLayers, dialogInfo, layerWithData;
1100
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1101
- while (1) switch (_context5.prev = _context5.next) {
1102
- case 0:
1103
- if (uiSelectors.getisDialogOpen(listenerApi.getState(), uiTypes.DialogTypes.LayerInfo)) {
1104
- filteredLayers = getFilteredLayers(listenerApi.getState());
1105
- dialogInfo = layerSelectors.getActiveLayerInfo(listenerApi.getState());
1106
- layerWithData = dialogInfo && serviceSelectors.getLayerFromService(listenerApi.getState(), dialogInfo.serviceUrl, dialogInfo.layerName);
1107
- if (!filteredLayers.map(function (layer) {
1108
- return layer.title;
1109
- }).includes((layerWithData == null ? void 0 : layerWithData.title) || '')) {
1110
- listenerApi.dispatch(layerActions.hideLayerInfo());
1111
- }
1112
- }
1113
- case 1:
1114
- case "end":
1115
- return _context5.stop();
1116
- }
1117
- }, _callee5);
1118
- }));
1119
- function effect(_x7, _x8) {
1120
- return _effect5.apply(this, arguments);
1121
- }
1122
- return effect;
1123
- }()
1124
- });
1125
-
1126
- /* *
1127
- * Licensed under the Apache License, Version 2.0 (the "License");
1128
- * you may not use this file except in compliance with the License.
1129
- * You may obtain a copy of the License at
1130
- *
1131
- * http://www.apache.org/licenses/LICENSE-2.0
1132
- *
1133
- * Unless required by applicable law or agreed to in writing, software
1134
- * distributed under the License is distributed on an "AS IS" BASIS,
1135
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1136
- * See the License for the specific language governing permissions and
1137
- * limitations under the License.
1138
- *
1139
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1140
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1141
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1142
- * */
1143
-
1144
- var layerSelectReducersMap = {
1145
- webmap: mapReducer,
1146
- services: serviceReducer,
1147
- layers: layerReducer,
1148
- layerSelect: layerSelectReducer,
1149
- ui: uiReducer,
1150
- snackbar: snackbarReducer
1151
- };
1152
- var layerSelectMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, layerSelectListener.middleware, snackbarListener.middleware, openlayersListener.middleware];
1153
- var layerSelectRootReducer = combineReducers(layerSelectReducersMap);
1154
- var createMockStore = function createMockStore(mockState) {
1155
- return configureStore({
1156
- reducer: layerSelectRootReducer,
1157
- preloadedState: mockState,
1158
- middleware: function middleware(getDefaultMiddleware) {
1159
- return getDefaultMiddleware().concat(layerSelectMiddlewares);
1160
- }
1161
- });
1162
- };
1163
-
1164
- /* *
1165
- * Licensed under the Apache License, Version 2.0 (the "License");
1166
- * you may not use this file except in compliance with the License.
1167
- * You may obtain a copy of the License at
1168
- *
1169
- * http://www.apache.org/licenses/LICENSE-2.0
1170
- *
1171
- * Unless required by applicable law or agreed to in writing, software
1172
- * distributed under the License is distributed on an "AS IS" BASIS,
1173
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1174
- * See the License for the specific language governing permissions and
1175
- * limitations under the License.
1176
- *
1177
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1178
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1179
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1180
- * */
1181
-
1182
- var KeywordFilterButtonConnect = function KeywordFilterButtonConnect(_ref) {
1183
- var mapId = _ref.mapId,
1184
- _ref$source = _ref.source,
1185
- source = _ref$source === void 0 ? 'app' : _ref$source,
1186
- isMultiMap = _ref.isMultiMap;
1187
- var dispatch = useDispatch();
1188
- var dialogType = isMultiMap ? uiTypes.DialogTypes.KeywordFilter + "-" + mapId : uiTypes.DialogTypes.KeywordFilter;
1189
- var currentActiveMapId = useAppSelector(function (store) {
1190
- return uiSelectors.getDialogMapId(store, dialogType);
1191
- });
1192
- var isOpenInStore = useAppSelector(function (store) {
1193
- return uiSelectors.getisDialogOpen(store, dialogType);
1194
- });
1195
- var openFilterResultsDialog = React.useCallback(function () {
1196
- dispatch(uiActions.setActiveMapIdForDialog({
1197
- type: dialogType,
1198
- mapId: mapId,
1199
- setOpen: currentActiveMapId !== mapId ? true : !isOpenInStore,
1200
- source: source
1201
- }));
1202
- }, [currentActiveMapId, dispatch, isOpenInStore, mapId, source, dialogType]);
1203
- return /*#__PURE__*/jsx(CustomIconButton, {
1204
- "data-testid": "keywordFilterButton",
1205
- id: "keywordFilterButton",
1206
- isSelected: isOpenInStore,
1207
- onClick: openFilterResultsDialog,
1208
- variant: "tool",
1209
- children: /*#__PURE__*/jsx(Filter, {})
1210
- });
1211
- };
1212
-
1213
- /* *
1214
- * Licensed under the Apache License, Version 2.0 (the "License");
1215
- * you may not use this file except in compliance with the License.
1216
- * You may obtain a copy of the License at
1217
- *
1218
- * http://www.apache.org/licenses/LICENSE-2.0
1219
- *
1220
- * Unless required by applicable law or agreed to in writing, software
1221
- * distributed under the License is distributed on an "AS IS" BASIS,
1222
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223
- * See the License for the specific language governing permissions and
1224
- * limitations under the License.
1225
- *
1226
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1227
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1228
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1229
- * */
1230
-
1231
- var KeywordFilterResultsListItemConnect = function KeywordFilterResultsListItemConnect(_ref) {
1232
- var filter = _ref.filter;
1233
- var dispatch = useDispatch();
1234
- var toggleFilter = React.useCallback(function (filterId, only) {
1235
- dispatch(layerSelectActions.toggleFilter({
1236
- filterId: filterId,
1237
- only: only
1238
- }));
1239
- }, [dispatch]);
1240
- return /*#__PURE__*/jsx(FilterOption, {
1241
- checked: !!filter.checked,
1242
- label: filter.amountVisible ? filter.name + " (" + filter.amountVisible + ")" : filter.name,
1243
- onClick: function onClick(checked, only) {
1244
- toggleFilter(filter.id, only);
1245
- },
1246
- optionId: filter.id
1247
- });
1248
- };
1249
-
1250
- /* *
1251
- * Licensed under the Apache License, Version 2.0 (the "License");
1252
- * you may not use this file except in compliance with the License.
1253
- * You may obtain a copy of the License at
1254
- *
1255
- * http://www.apache.org/licenses/LICENSE-2.0
1256
- *
1257
- * Unless required by applicable law or agreed to in writing, software
1258
- * distributed under the License is distributed on an "AS IS" BASIS,
1259
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1260
- * See the License for the specific language governing permissions and
1261
- * limitations under the License.
1262
- *
1263
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1264
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1265
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1266
- * */
1267
-
1268
- var KeywordFilterSelectAllSwitchConnect = function KeywordFilterSelectAllSwitchConnect() {
1269
- var dispatch = useDispatch();
1270
- var allFiltersActive = useAppSelector(function (store) {
1271
- return isAllFiltersChecked(store);
1272
- });
1273
- var toggleFilters = React.useCallback(function () {
1274
- dispatch(layerSelectActions.toggleAllFilters());
1275
- }, [dispatch]);
1276
- return /*#__PURE__*/jsx(Switch, {
1277
- checked: allFiltersActive,
1278
- "data-testid": "customSwitch",
1279
- onChange: toggleFilters,
1280
- slotProps: {
1281
- input: {
1282
- 'aria-label': 'All'
1283
- }
1284
- }
1285
- });
1286
- };
1287
-
1288
- /* *
1289
- * Licensed under the Apache License, Version 2.0 (the "License");
1290
- * you may not use this file except in compliance with the License.
1291
- * You may obtain a copy of the License at
1292
- *
1293
- * http://www.apache.org/licenses/LICENSE-2.0
1294
- *
1295
- * Unless required by applicable law or agreed to in writing, software
1296
- * distributed under the License is distributed on an "AS IS" BASIS,
1297
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1298
- * See the License for the specific language governing permissions and
1299
- * limitations under the License.
1300
- *
1301
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1302
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
1303
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1304
- * */
1305
-
1306
- var LAYER_SELECT_NAMESPACE = 'layerselect';
1307
- var useLayerSelectTranslation = function useLayerSelectTranslation() {
1308
- return useTranslation(LAYER_SELECT_NAMESPACE);
1309
- };
1310
-
1311
- /* *
1312
- * Licensed under the Apache License, Version 2.0 (the "License");
1313
- * you may not use this file except in compliance with the License.
1314
- * You may obtain a copy of the License at
1315
- *
1316
- * http://www.apache.org/licenses/LICENSE-2.0
1317
- *
1318
- * Unless required by applicable law or agreed to in writing, software
1319
- * distributed under the License is distributed on an "AS IS" BASIS,
1320
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1321
- * See the License for the specific language governing permissions and
1322
- * limitations under the License.
1323
- *
1324
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1325
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1326
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1327
- * */
1328
-
1329
- var listStyle = {
1330
- padding: '0px'
1331
- };
1332
- var accordionDetailsStyle = {
1333
- margin: '0px',
1334
- padding: '0 12px'
1335
- };
1336
- var KeywordFilterResults = function KeywordFilterResults(_ref) {
1337
- var filters = _ref.filters,
1338
- bounds = _ref.bounds,
1339
- _ref$onClose = _ref.onClose,
1340
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
1341
- isOpen = _ref.isOpen,
1342
- _ref$onMouseDown = _ref.onMouseDown,
1343
- onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
1344
- _ref$order = _ref.order,
1345
- order = _ref$order === void 0 ? 0 : _ref$order,
1346
- _ref$source = _ref.source,
1347
- source = _ref$source === void 0 ? 'module' : _ref$source;
1348
- var _useLayerSelectTransl = useLayerSelectTranslation(),
1349
- t = _useLayerSelectTransl.t;
1350
- return /*#__PURE__*/jsxs(ToolContainerDraggable, {
1351
- bounds: bounds,
1352
- "data-testid": "keywordFilterResults",
1353
- isOpen: isOpen,
1354
- minHeight: 192,
1355
- minWidth: 312,
1356
- onClose: onClose,
1357
- onMouseDown: onMouseDown,
1358
- order: order,
1359
- source: source,
1360
- startSize: {
1361
- width: 349,
1362
- height: 600
1363
- },
1364
- title: t('groups-and-keywords-dialog-title'),
1365
- children: [/*#__PURE__*/jsxs(Grid, {
1366
- alignItems: "center",
1367
- container: true,
1368
- justifyContent: "space-between",
1369
- size: {
1370
- xs: 12
1371
- },
1372
- sx: {
1373
- backgroundColor: 'background.paper',
1374
- position: 'sticky',
1375
- top: 0,
1376
- zIndex: 100
1377
- },
1378
- children: [/*#__PURE__*/jsx(Grid, {
1379
- alignItems: "center",
1380
- container: true,
1381
- justifyContent: "flex-start",
1382
- size: {
1383
- xs: 6
1384
- },
1385
- sx: {
1386
- padding: '15px 15px 0 24px'
1387
- },
1388
- children: t('select-all')
1389
- }), /*#__PURE__*/jsx(Grid, {
1390
- alignContent: "center",
1391
- container: true,
1392
- justifyContent: "flex-end",
1393
- size: {
1394
- xs: 6
1395
- },
1396
- sx: {
1397
- padding: '15px 15px 0 15px'
1398
- },
1399
- children: /*#__PURE__*/jsx(KeywordFilterSelectAllSwitchConnect, {})
1400
- })]
1401
- }), /*#__PURE__*/jsx(CustomAccordion, {
1402
- detailsSx: accordionDetailsStyle,
1403
- title: t('groups'),
1404
- children: /*#__PURE__*/jsx(List, {
1405
- dense: true,
1406
- style: listStyle,
1407
- children: filters.groups.map(function (group) {
1408
- return /*#__PURE__*/jsx(KeywordFilterResultsListItemConnect, {
1409
- filter: group
1410
- }, group.id);
1411
- })
1412
- })
1413
- }), /*#__PURE__*/jsx(CustomAccordion, {
1414
- detailsSx: accordionDetailsStyle,
1415
- title: t('keywords'),
1416
- children: /*#__PURE__*/jsx(List, {
1417
- dense: true,
1418
- style: listStyle,
1419
- children: filters.keywords.map(function (keyword) {
1420
- return /*#__PURE__*/jsx(KeywordFilterResultsListItemConnect, {
1421
- filter: keyword
1422
- }, keyword.id);
1423
- })
1424
- })
1425
- })]
1426
- });
1427
- };
1428
-
1429
- /* *
1430
- * Licensed under the Apache License, Version 2.0 (the "License");
1431
- * you may not use this file except in compliance with the License.
1432
- * You may obtain a copy of the License at
1433
- *
1434
- * http://www.apache.org/licenses/LICENSE-2.0
1435
- *
1436
- * Unless required by applicable law or agreed to in writing, software
1437
- * distributed under the License is distributed on an "AS IS" BASIS,
1438
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439
- * See the License for the specific language governing permissions and
1440
- * limitations under the License.
1441
- *
1442
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1443
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1444
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1445
- * */
1446
-
1447
- var KeywordFilterResultsConnect = function KeywordFilterResultsConnect(_ref) {
1448
- var bounds = _ref.bounds,
1449
- mapId = _ref.mapId,
1450
- isMultiMap = _ref.isMultiMap;
1451
- var dialogType = isMultiMap ? uiTypes.DialogTypes.KeywordFilter + "-" + mapId : uiTypes.DialogTypes.KeywordFilter;
1452
- var _useSetupDialog = useSetupDialog(dialogType),
1453
- dialogOrder = _useSetupDialog.dialogOrder,
1454
- onCloseDialog = _useSetupDialog.onCloseDialog,
1455
- setDialogOrder = _useSetupDialog.setDialogOrder,
1456
- isDialogOpen = _useSetupDialog.isDialogOpen,
1457
- uiSource = _useSetupDialog.uiSource;
1458
- var filters = useAppSelector(getFilters);
1459
- return /*#__PURE__*/jsx(KeywordFilterResults, {
1460
- bounds: bounds,
1461
- filters: filters,
1462
- isOpen: isDialogOpen,
1463
- onClose: onCloseDialog,
1464
- onMouseDown: setDialogOrder,
1465
- order: dialogOrder,
1466
- source: uiSource
1467
- });
1468
- };
1469
-
1470
- /* *
1471
- * Licensed under the Apache License, Version 2.0 (the "License");
1472
- * you may not use this file except in compliance with the License.
1473
- * You may obtain a copy of the License at
1474
- *
1475
- * http://www.apache.org/licenses/LICENSE-2.0
1476
- *
1477
- * Unless required by applicable law or agreed to in writing, software
1478
- * distributed under the License is distributed on an "AS IS" BASIS,
1479
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1480
- * See the License for the specific language governing permissions and
1481
- * limitations under the License.
1482
- *
1483
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1484
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1485
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1486
- * */
1487
- var LayerAddRemoveButton = function LayerAddRemoveButton(_ref) {
1488
- var layer = _ref.layer,
1489
- serviceUrl = _ref.serviceUrl,
1490
- allLayers = _ref.allLayers,
1491
- allMapIds = _ref.allMapIds,
1492
- addLayer = _ref.addLayer,
1493
- addLayerToAllMaps = _ref.addLayerToAllMaps,
1494
- deleteLayer = _ref.deleteLayer,
1495
- removeLayerFromAllMaps = _ref.removeLayerFromAllMaps,
1496
- mapLayers = _ref.mapLayers;
1497
- var _useLayerSelectTransl = useLayerSelectTranslation(),
1498
- t = _useLayerSelectTransl.t;
1499
- var _React$useState = React.useState(false),
1500
- open = _React$useState[0],
1501
- setOpen = _React$useState[1];
1502
- var anchorRef = React.useRef(null);
1503
- var foundLayerIndex = React.useMemo(function () {
1504
- return mapLayers.findIndex(function (lr) {
1505
- return lr.name === layer.name && lr.service === serviceUrl;
1506
- });
1507
- }, [mapLayers, layer.name, serviceUrl]);
1508
- var foundLayer = foundLayerIndex !== -1 && mapLayers[foundLayerIndex];
1509
- var layerExistsInWorkspace = React.useMemo(function () {
1510
- return allLayers.find(function (current) {
1511
- return current.name === layer.name && current.service === serviceUrl;
1512
- });
1513
- }, [allLayers, layer.name, serviceUrl]);
1514
- var existsInAllMaps = React.useMemo(function () {
1515
- return allMapIds.every(function (mapId) {
1516
- return allLayers.some(function (current) {
1517
- return current.mapId === mapId && current.name === layer.name && current.service === serviceUrl;
1518
- });
1519
- });
1520
- }, [allMapIds, allLayers, layer.name, serviceUrl]);
1521
- var handleToggle = function handleToggle() {
1522
- setOpen(function (prevOpen) {
1523
- return !prevOpen;
1524
- });
1525
- };
1526
- var handleClose = function handleClose(event) {
1527
- var _anchorRef$current;
1528
- if ((_anchorRef$current = anchorRef.current) != null && _anchorRef$current.contains(event.target)) {
1529
- return;
1530
- }
1531
- setOpen(false);
1532
- };
1533
- var handleAddAll = function handleAddAll() {
1534
- addLayerToAllMaps({
1535
- serviceUrl: serviceUrl,
1536
- layerName: layer.name
1537
- });
1538
- setOpen(false);
1539
- };
1540
- var handleRemoveAll = function handleRemoveAll(id) {
1541
- removeLayerFromAllMaps(id);
1542
- setOpen(false);
1543
- };
1544
- return /*#__PURE__*/jsxs(Fragment, {
1545
- children: [/*#__PURE__*/jsxs(ToggleButtonGroup, {
1546
- fullWidth: true,
1547
- ref: anchorRef,
1548
- style: {
1549
- height: '32px'
1550
- },
1551
- children: [/*#__PURE__*/jsx(ToggleButton, {
1552
- className: "tool",
1553
- "data-testid": "layerAddRemoveButton-" + layer.name,
1554
- fullWidth: true,
1555
- onClick: function onClick() {
1556
- !foundLayer ? addLayer({
1557
- serviceUrl: serviceUrl,
1558
- layerName: layer.name
1559
- }) : deleteLayer({
1560
- layerId: foundLayer.id,
1561
- layerIndex: foundLayerIndex
1562
- });
1563
- },
1564
- onMouseDown: function onMouseDown(e) {
1565
- e.stopPropagation();
1566
- },
1567
- selected: !!foundLayer,
1568
- style: {
1569
- borderRadius: '3px 0 0 3px',
1570
- height: 'inherit',
1571
- minWidth: '62px',
1572
- fontSize: '12px'
1573
- },
1574
- value: "selected",
1575
- children: !foundLayer ? t('add') : t('remove')
1576
- }), /*#__PURE__*/jsx(Box, {
1577
- sx: {
1578
- minWidth: '1px',
1579
- backgroundColor: foundLayer || layerExistsInWorkspace ? 'geowebColors.buttons.primary.default.borderColor' : 'geowebColors.buttons.secondary.default.fill'
1580
- }
1581
- }), /*#__PURE__*/jsx(ToggleButton, {
1582
- className: "tool",
1583
- "data-testid": "layerAddRemoveButton-dropdown-" + layer.name,
1584
- onClick: handleToggle,
1585
- onMouseDown: function onMouseDown(e) {
1586
- e.stopPropagation();
1587
- },
1588
- selected: !!layerExistsInWorkspace,
1589
- style: {
1590
- marginLeft: '0',
1591
- minWidth: '32px',
1592
- borderRadius: '0 3px 3px 0',
1593
- height: 'inherit'
1594
- },
1595
- value: "dropdown",
1596
- children: /*#__PURE__*/jsx(ArrowDropDownDown, {
1597
- style: {
1598
- marginRight: '1px'
1599
- }
1600
- })
1601
- })]
1602
- }), /*#__PURE__*/jsx(Popper, {
1603
- anchorEl: anchorRef.current,
1604
- open: open,
1605
- placement: "bottom-end",
1606
- role: undefined,
1607
- style: {
1608
- zIndex: 1300
1609
- },
1610
- transition: true,
1611
- children: function children(_ref2) {
1612
- var TransitionProps = _ref2.TransitionProps,
1613
- placement = _ref2.placement;
1614
- return /*#__PURE__*/jsx(Grow, Object.assign({}, TransitionProps, {
1615
- style: {
1616
- transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom'
1617
- },
1618
- children: /*#__PURE__*/jsx(Paper, {
1619
- children: /*#__PURE__*/jsx(ClickAwayListener, {
1620
- onClickAway: handleClose,
1621
- children: /*#__PURE__*/jsxs(MenuList, {
1622
- autoFocusItem: true,
1623
- children: [/*#__PURE__*/jsx(MenuItem, {
1624
- disabled: existsInAllMaps,
1625
- onClick: handleAddAll,
1626
- children: t('add-to-all-maps')
1627
- }), /*#__PURE__*/jsx(MenuItem, {
1628
- disabled: !layerExistsInWorkspace,
1629
- onClick: function onClick() {
1630
- layerExistsInWorkspace && handleRemoveAll(layerExistsInWorkspace.id);
1631
- },
1632
- children: t('remove-from-all-maps')
1633
- })]
1634
- })
1635
- })
1636
- })
1637
- }));
1638
- }
1639
- })]
1640
- });
1641
- };
1642
-
1643
- /* *
1644
- * Licensed under the Apache License, Version 2.0 (the "License");
1645
- * you may not use this file except in compliance with the License.
1646
- * You may obtain a copy of the License at
1647
- *
1648
- * http://www.apache.org/licenses/LICENSE-2.0
1649
- *
1650
- * Unless required by applicable law or agreed to in writing, software
1651
- * distributed under the License is distributed on an "AS IS" BASIS,
1652
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1653
- * See the License for the specific language governing permissions and
1654
- * limitations under the License.
1655
- *
1656
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1657
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1658
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1659
- * */
1660
-
1661
- var LayerListDimensions = function LayerListDimensions(_ref) {
1662
- var dimensions = _ref.dimensions;
1663
- if (!(dimensions != null && dimensions.length)) {
1664
- return null;
1665
- }
1666
- return /*#__PURE__*/jsx(Fragment, {
1667
- children: dimensions.map(function (dimension) {
1668
- return /*#__PURE__*/jsx(CustomTooltip, {
1669
- title: dimension.label + ": " + dimension.value,
1670
- children: /*#__PURE__*/jsx("span", {
1671
- style: {
1672
- marginRight: 4
1673
- },
1674
- children: dimension.icon
1675
- })
1676
- }, dimension.label);
1677
- })
1678
- });
1679
- };
1680
-
1681
- /* *
1682
- * Licensed under the Apache License, Version 2.0 (the "License");
1683
- * you may not use this file except in compliance with the License.
1684
- * You may obtain a copy of the License at
1685
- *
1686
- * http://www.apache.org/licenses/LICENSE-2.0
1687
- *
1688
- * Unless required by applicable law or agreed to in writing, software
1689
- * distributed under the License is distributed on an "AS IS" BASIS,
1690
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1691
- * See the License for the specific language governing permissions and
1692
- * limitations under the License.
1693
- *
1694
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1695
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1696
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1697
- * */
1698
-
1699
- var buttonLarge = 80;
1700
- var buttonSmall = 60;
1701
- var layerSelectColumnsLarge = {
1702
- column1: {
1703
- width: 112
1704
- },
1705
- column2: {
1706
- marginTop: '6px',
1707
- width: "calc(100% - 112px)",
1708
- height: '36px',
1709
- paddingLeft: '20px'
1710
- },
1711
- column3: {
1712
- height: '12px'
1713
- },
1714
- column4: {
1715
- height: '24px'
1716
- },
1717
- column5: {
1718
- height: '24px',
1719
- width: 140
1720
- },
1721
- column6: {
1722
- height: '24px',
1723
- width: "calc(100% - 140px)"
1724
- },
1725
- column7: {
1726
- height: '48px',
1727
- width: buttonLarge,
1728
- marginRight: 1,
1729
- marginLeft: 2
1730
- },
1731
- column8: {
1732
- width: "calc(100% - " + buttonLarge + "px - 32px)"
1733
- },
1734
- column9: {
1735
- width: "calc(" + buttonLarge + "px + 32px)"
1736
- }
1737
- };
1738
- var layerSelectColumnsSmall = {
1739
- column1: {
1740
- width: '100%'
1741
- },
1742
- column2: {
1743
- marginTop: '4px',
1744
- width: "calc(100% - 20px)"
1745
- },
1746
- column3: {
1747
- height: '12px'
1748
- },
1749
- column4: {
1750
- height: '48px'
1751
- },
1752
- column5: {
1753
- height: '24px',
1754
- width: '100%'
1755
- },
1756
- column6: {
1757
- height: '24px',
1758
- width: '100%'
1759
- },
1760
- column7: {
1761
- height: '48px',
1762
- width: buttonSmall,
1763
- marginRight: 0,
1764
- marginLeft: 1
1765
- },
1766
- column8: {
1767
- width: "calc(100% - " + buttonSmall + "px - 50px)"
1768
- },
1769
- column9: {
1770
- width: "calc(" + buttonSmall + "px + 50px)"
1771
- }
1772
- };
1773
- var breakpoint = 500;
1774
- var widthToColumns = function widthToColumns(width) {
1775
- if (width <= breakpoint) {
1776
- return layerSelectColumnsSmall;
1777
- }
1778
- return layerSelectColumnsLarge;
1779
- };
1780
- var rowHeightLarge = 68;
1781
- var rowHeightSmall = 136;
1782
- var widthToRowHeight = function widthToRowHeight(width) {
1783
- if (width <= breakpoint) {
1784
- return rowHeightSmall;
1785
- }
1786
- return rowHeightLarge;
1787
- };
1788
- var sortByService = function sortByService(serviceObj) {
1789
- return Object.entries(serviceObj).sort(function (_ref, _ref2) {
1790
- var serviceA = _ref[1];
1791
- var serviceB = _ref2[1];
1792
- return serviceA.serviceName.localeCompare(serviceB == null ? void 0 : serviceB.serviceName);
1793
- }).reduce(function (result, _ref3) {
1794
- var _Object$assign;
1795
- var key = _ref3[0],
1796
- value = _ref3[1];
1797
- return Object.assign({}, result, (_Object$assign = {}, _Object$assign[key] = value, _Object$assign));
1798
- }, {});
1799
- };
1800
-
1801
- /* *
1802
- * Licensed under the Apache License, Version 2.0 (the "License");
1803
- * you may not use this file except in compliance with the License.
1804
- * You may obtain a copy of the License at
1805
- *
1806
- * http://www.apache.org/licenses/LICENSE-2.0
1807
- *
1808
- * Unless required by applicable law or agreed to in writing, software
1809
- * distributed under the License is distributed on an "AS IS" BASIS,
1810
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1811
- * See the License for the specific language governing permissions and
1812
- * limitations under the License.
1813
- *
1814
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1815
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1816
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1817
- * */
1818
-
1819
- var layerInfoStyle = {
1820
- fontSize: '10px',
1821
- textOverflow: 'ellipsis',
1822
- overflow: 'hidden',
1823
- whiteSpace: 'nowrap',
1824
- lineHeight: 1
1825
- };
1826
- var LayerListRow = function LayerListRow(_ref) {
1827
- var _layer$keywords, _layer$keywords2;
1828
- var layer = _ref.layer,
1829
- service = _ref.service,
1830
- allLayers = _ref.allLayers,
1831
- allMapIds = _ref.allMapIds,
1832
- addLayer = _ref.addLayer,
1833
- addLayerToAllMaps = _ref.addLayerToAllMaps,
1834
- deleteLayer = _ref.deleteLayer,
1835
- removeLayerFromAllMaps = _ref.removeLayerFromAllMaps,
1836
- mapLayers = _ref.mapLayers,
1837
- layerSelectWidth = _ref.layerSelectWidth,
1838
- searchFilter = _ref.searchFilter,
1839
- _ref$hasActiveLayer = _ref.hasActiveLayer,
1840
- hasActiveLayer = _ref$hasActiveLayer === void 0 ? false : _ref$hasActiveLayer,
1841
- onToggleActiveLayer = _ref.onToggleActiveLayer;
1842
- var _useLayerSelectTransl = useLayerSelectTranslation(),
1843
- t = _useLayerSelectTransl.t;
1844
- var rowHeight = widthToRowHeight(layerSelectWidth);
1845
- var columns = widthToColumns(layerSelectWidth);
1846
- var dimensions = getDimensionsList(layer.dimensions);
1847
- return /*#__PURE__*/jsxs(Grid, {
1848
- alignItems: "center",
1849
- container: true,
1850
- "data-testid": "layerListLayerRow",
1851
- justifyContent: "center",
1852
- sx: {
1853
- backgroundColor: 'geowebColors.cards.cardContainer',
1854
- padding: '8px',
1855
- marginBottom: '4px',
1856
- height: rowHeight,
1857
- border: 'solid 1px',
1858
- borderColor: 'geowebColors.cards.cardContainerBorder'
1859
- },
1860
- children: [/*#__PURE__*/jsxs(Grid, {
1861
- container: true,
1862
- sx: columns.column8,
1863
- children: [/*#__PURE__*/jsx(Grid, {
1864
- size: {
1865
- xs: 12
1866
- },
1867
- children: /*#__PURE__*/jsx(Box, {
1868
- sx: {
1869
- fontSize: '12px',
1870
- height: '14px',
1871
- lineHeight: '14px',
1872
- fontWeight: 500,
1873
- textOverflow: 'ellipsis',
1874
- overflow: 'hidden'
1875
- },
1876
- children: /*#__PURE__*/jsx(SearchHighlight, {
1877
- search: searchFilter,
1878
- text: layer.title
1879
- })
1880
- })
1881
- }), /*#__PURE__*/jsxs(Grid, {
1882
- container: true,
1883
- direction: "column",
1884
- sx: columns.column1,
1885
- children: [/*#__PURE__*/jsx(Box, {
1886
- sx: {
1887
- fontSize: '12px',
1888
- height: '18px',
1889
- lineHeight: '18px',
1890
- textOverflow: 'ellipsis',
1891
- overflow: 'hidden'
1892
- },
1893
- children: /*#__PURE__*/jsx(SearchHighlight, {
1894
- search: searchFilter,
1895
- text: service.name
1896
- })
1897
- }), /*#__PURE__*/jsx(LayerInfoButton, {
1898
- isActive: hasActiveLayer,
1899
- onClick: onToggleActiveLayer
1900
- })]
1901
- }), /*#__PURE__*/jsxs(Grid, {
1902
- sx: columns.column2,
1903
- children: [/*#__PURE__*/jsx(Grid, {
1904
- sx: columns.column3,
1905
- children: !!layer["abstract"] && /*#__PURE__*/jsx(Typography, {
1906
- "data-testid": "layerAbstract",
1907
- sx: layerInfoStyle,
1908
- children: /*#__PURE__*/jsx(SearchHighlight, {
1909
- search: searchFilter,
1910
- text: layer["abstract"]
1911
- })
1912
- })
1913
- }), /*#__PURE__*/jsxs(Grid, {
1914
- container: true,
1915
- sx: columns.column4,
1916
- children: [/*#__PURE__*/jsx(Grid, {
1917
- sx: columns.column5,
1918
- children: /*#__PURE__*/jsx(LayerListDimensions, {
1919
- dimensions: dimensions
1920
- })
1921
- }), /*#__PURE__*/jsxs(Grid, {
1922
- sx: columns.column6,
1923
- children: [layer.path.length > 0 && /*#__PURE__*/jsxs(Typography, {
1924
- sx: layerInfoStyle,
1925
- children: [t('groups'), ":", ' ', /*#__PURE__*/jsx(SearchHighlight, {
1926
- search: searchFilter,
1927
- text: layer.path.join(' / ')
1928
- })]
1929
- }), ((_layer$keywords = layer.keywords) == null ? void 0 : _layer$keywords.length) > 0 && /*#__PURE__*/jsxs(Typography, {
1930
- sx: layerInfoStyle,
1931
- children: [t('keywords'), ":", ' ', /*#__PURE__*/jsx(SearchHighlight, {
1932
- search: searchFilter,
1933
- text: ((_layer$keywords2 = layer.keywords) != null ? _layer$keywords2 : []).slice().sort(function (textA, textB) {
1934
- return textA.localeCompare(textB);
1935
- }).join(', ')
1936
- })]
1937
- })]
1938
- })]
1939
- })]
1940
- })]
1941
- }), /*#__PURE__*/jsx(Grid, {
1942
- alignItems: "center",
1943
- container: true,
1944
- justifyContent: "flex-end",
1945
- sx: columns.column9,
1946
- children: /*#__PURE__*/jsx(Box, {
1947
- alignItems: "flex-start",
1948
- sx: (columns.column7, {
1949
- width: '100%',
1950
- paddingLeft: '16px'
1951
- }),
1952
- children: /*#__PURE__*/jsx(LayerAddRemoveButton, {
1953
- addLayer: addLayer,
1954
- addLayerToAllMaps: addLayerToAllMaps,
1955
- allLayers: allLayers,
1956
- allMapIds: allMapIds,
1957
- deleteLayer: deleteLayer,
1958
- layer: layer,
1959
- mapLayers: mapLayers,
1960
- removeLayerFromAllMaps: removeLayerFromAllMaps,
1961
- serviceUrl: service.serviceUrl
1962
- })
1963
- })
1964
- })]
1965
- });
1966
- };
1967
-
1968
- /* *
1969
- * Licensed under the Apache License, Version 2.0 (the "License");
1970
- * you may not use this file except in compliance with the License.
1971
- * You may obtain a copy of the License at
1972
- *
1973
- * http://www.apache.org/licenses/LICENSE-2.0
1974
- *
1975
- * Unless required by applicable law or agreed to in writing, software
1976
- * distributed under the License is distributed on an "AS IS" BASIS,
1977
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1978
- * See the License for the specific language governing permissions and
1979
- * limitations under the License.
1980
- *
1981
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1982
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1983
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1984
- * */
1985
-
1986
- var LayerRow = function LayerRow(_ref) {
1987
- var index = _ref.index,
1988
- style = _ref.style,
1989
- services = _ref.services,
1990
- filteredLayers = _ref.filteredLayers,
1991
- allLayers = _ref.allLayers,
1992
- allMapIds = _ref.allMapIds,
1993
- addLayer = _ref.addLayer,
1994
- addLayerToAllMaps = _ref.addLayerToAllMaps,
1995
- deleteLayer = _ref.deleteLayer,
1996
- removeLayerFromAllMaps = _ref.removeLayerFromAllMaps,
1997
- mapLayers = _ref.mapLayers,
1998
- searchFilter = _ref.searchFilter,
1999
- isLayerInfoVisibleInStore = _ref.isLayerInfoVisibleInStore,
2000
- _onToggleActiveLayer = _ref.onToggleActiveLayer,
2001
- currentLayerInfo = _ref.currentLayerInfo,
2002
- layerSelectWidth = _ref.layerSelectWidth,
2003
- rowMargin = _ref.rowMargin;
2004
- var layer = filteredLayers[index];
2005
- var service = services[layer.serviceName];
2006
- if (!service) {
2007
- return /*#__PURE__*/jsx("div", {
2008
- style: style
2009
- });
2010
- }
2011
- var isActiveLayer = isLayerInfoVisibleInStore && (currentLayerInfo == null ? void 0 : currentLayerInfo.serviceUrl) === service.serviceUrl && (currentLayerInfo == null ? void 0 : currentLayerInfo.layerName) === layer.name;
2012
- var rowStyle = Object.assign({}, style, {
2013
- boxSizing: 'border-box',
2014
- paddingBottom: rowMargin
2015
- });
2016
- return /*#__PURE__*/jsx("div", {
2017
- style: rowStyle,
2018
- children: /*#__PURE__*/jsx(LayerListRow, {
2019
- addLayer: addLayer,
2020
- addLayerToAllMaps: addLayerToAllMaps,
2021
- allLayers: allLayers,
2022
- allMapIds: allMapIds,
2023
- deleteLayer: deleteLayer,
2024
- hasActiveLayer: isActiveLayer,
2025
- layer: layer,
2026
- layerSelectWidth: layerSelectWidth,
2027
- mapLayers: mapLayers,
2028
- onToggleActiveLayer: function onToggleActiveLayer() {
2029
- return _onToggleActiveLayer({
2030
- serviceUrl: service.serviceUrl,
2031
- layerName: layer.name,
2032
- isActiveLayer: isActiveLayer
2033
- });
2034
- },
2035
- removeLayerFromAllMaps: removeLayerFromAllMaps,
2036
- searchFilter: searchFilter,
2037
- service: service
2038
- })
2039
- }, layer.name);
2040
- };
2041
- var LayerList = function LayerList(_ref2) {
2042
- var services = _ref2.services,
2043
- filteredLayers = _ref2.filteredLayers,
2044
- layerSelectHeight = _ref2.layerSelectHeight,
2045
- serviceListHeight = _ref2.serviceListHeight,
2046
- layerSelectWidth = _ref2.layerSelectWidth,
2047
- allLayers = _ref2.allLayers,
2048
- allMapIds = _ref2.allMapIds,
2049
- addLayer = _ref2.addLayer,
2050
- addLayerToAllMaps = _ref2.addLayerToAllMaps,
2051
- deleteLayer = _ref2.deleteLayer,
2052
- removeLayerFromAllMaps = _ref2.removeLayerFromAllMaps,
2053
- mapLayers = _ref2.mapLayers,
2054
- searchFilter = _ref2.searchFilter,
2055
- isLayerInfoVisibleInStore = _ref2.isLayerInfoVisibleInStore,
2056
- onToggleActiveLayer = _ref2.onToggleActiveLayer,
2057
- currentLayerInfo = _ref2.currentLayerInfo;
2058
- var _useLayerSelectTransl = useLayerSelectTranslation(),
2059
- t = _useLayerSelectTransl.t;
2060
- var rowMargin = 4;
2061
- var rowHeight = widthToRowHeight(layerSelectWidth);
2062
- var layerSelectFilterHeight = 155 + serviceListHeight;
2063
- var minHeight = 320;
2064
- var listHeight = layerSelectHeight - layerSelectFilterHeight < minHeight ? minHeight : layerSelectHeight - layerSelectFilterHeight;
2065
- return /*#__PURE__*/jsxs(Box, {
2066
- "data-testid": "layerList",
2067
- children: [/*#__PURE__*/jsxs(Box, {
2068
- sx: {
2069
- marginBottom: '4px',
2070
- fontSize: '12px'
2071
- },
2072
- children: [filteredLayers.length, " ", t('layer-list-results')]
2073
- }), /*#__PURE__*/jsx(List$1, {
2074
- defaultHeight: minHeight,
2075
- rowComponent: LayerRow,
2076
- rowCount: filteredLayers.length,
2077
- rowHeight: rowHeight + rowMargin,
2078
- rowProps: {
2079
- services: services,
2080
- filteredLayers: filteredLayers,
2081
- allLayers: allLayers,
2082
- allMapIds: allMapIds,
2083
- addLayer: addLayer,
2084
- addLayerToAllMaps: addLayerToAllMaps,
2085
- deleteLayer: deleteLayer,
2086
- removeLayerFromAllMaps: removeLayerFromAllMaps,
2087
- mapLayers: mapLayers,
2088
- searchFilter: searchFilter,
2089
- isLayerInfoVisibleInStore: isLayerInfoVisibleInStore,
2090
- onToggleActiveLayer: onToggleActiveLayer,
2091
- currentLayerInfo: currentLayerInfo,
2092
- layerSelectWidth: layerSelectWidth,
2093
- rowMargin: rowMargin
2094
- },
2095
- style: {
2096
- height: listHeight,
2097
- width: '100%'
2098
- }
2099
- })]
2100
- });
2101
- };
2102
-
2103
- /* *
2104
- * Licensed under the Apache License, Version 2.0 (the "License");
2105
- * you may not use this file except in compliance with the License.
2106
- * You may obtain a copy of the License at
2107
- *
2108
- * http://www.apache.org/licenses/LICENSE-2.0
2109
- *
2110
- * Unless required by applicable law or agreed to in writing, software
2111
- * distributed under the License is distributed on an "AS IS" BASIS,
2112
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2113
- * See the License for the specific language governing permissions and
2114
- * limitations under the License.
2115
- *
2116
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2117
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2118
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2119
- * */
2120
-
2121
- var LayerListConnect = function LayerListConnect(_ref) {
2122
- var mapId = _ref.mapId,
2123
- layerSelectHeight = _ref.layerSelectHeight,
2124
- serviceListHeight = _ref.serviceListHeight,
2125
- layerSelectWidth = _ref.layerSelectWidth;
2126
- var dispatch = useDispatch();
2127
- var services = useAppSelector(function (store) {
2128
- return serviceSelectors.getServices(store);
2129
- });
2130
- var mapLayers = useAppSelector(function (store) {
2131
- return mapSelectors.getMapLayersWithoutDimensionCurrentValue(store, mapId);
2132
- });
2133
- var allLayers = useAppSelector(function (store) {
2134
- return layerSelectors.getAllLayers(store);
2135
- });
2136
- var allMapIds = useAppSelector(function (store) {
2137
- return mapSelectors.getAllMapIds(store);
2138
- });
2139
- var _addLayer = function addLayer(_ref2, mapId) {
2140
- var serviceUrl = _ref2.serviceUrl,
2141
- layerName = _ref2.layerName;
2142
- var layer = {
2143
- service: serviceUrl,
2144
- name: layerName,
2145
- id: webmapUtils.generateLayerId(),
2146
- layerType: LayerType.mapLayer
2147
- };
2148
- addMapLayer({
2149
- mapId: mapId,
2150
- layerId: layer.id,
2151
- layer: layer,
2152
- origin: layerTypes.LayerActionOrigin.layerManager
2153
- });
2154
- };
2155
- var addMapLayer = React.useCallback(function (_ref3) {
2156
- var mapId = _ref3.mapId,
2157
- layerId = _ref3.layerId,
2158
- layer = _ref3.layer,
2159
- origin = _ref3.origin;
2160
- return dispatch(layerActions.addLayer({
2161
- mapId: mapId,
2162
- layerId: layerId,
2163
- layer: layer,
2164
- origin: origin
2165
- }));
2166
- }, [dispatch]);
2167
- var addLayerToAllMaps = function addLayerToAllMaps(_ref4) {
2168
- var serviceUrl = _ref4.serviceUrl,
2169
- layerName = _ref4.layerName;
2170
- allMapIds.forEach(function (mapId) {
2171
- if (allLayers.find(function (layer) {
2172
- return layer.name === layerName && layer.service === serviceUrl && layer.mapId === mapId;
2173
- })) {
2174
- return;
2175
- }
2176
- _addLayer({
2177
- serviceUrl: serviceUrl,
2178
- layerName: layerName
2179
- }, mapId);
2180
- });
2181
- };
2182
- var deleteLayer = React.useCallback(function (_ref5) {
2183
- var layerId = _ref5.layerId,
2184
- layerIndex = _ref5.layerIndex;
2185
- return dispatch(layerActions.layerDelete({
2186
- mapId: mapId,
2187
- layerId: layerId,
2188
- layerIndex: layerIndex,
2189
- origin: layerTypes.LayerActionOrigin.layerManager
2190
- }));
2191
- }, [dispatch, mapId]);
2192
- var removeLayerFromAllMaps = React.useCallback(function (layerId) {
2193
- var _allLayers$find;
2194
- if (!layerId) {
2195
- return;
2196
- }
2197
- var layerName = (_allLayers$find = allLayers.find(function (layer) {
2198
- return layer.id === layerId;
2199
- })) == null ? void 0 : _allLayers$find.name;
2200
- layerName && allLayers.filter(function (layer) {
2201
- return layer.name === layerName;
2202
- }).forEach(function (layer) {
2203
- layer.mapId && layer.id && dispatch(layerActions.layerDelete({
2204
- mapId: layer.mapId,
2205
- layerId: layer.id
2206
- }));
2207
- });
2208
- }, [dispatch, allLayers]);
2209
- var filteredLayers = useAppSelector(function (store) {
2210
- return getFilteredLayers(store);
2211
- });
2212
- var searchFilter = useAppSelector(function (store) {
2213
- return getSearchFilter(store);
2214
- });
2215
- var isLayerInfoVisibleInStore = useAppSelector(function (store) {
2216
- return uiSelectors.getisDialogOpen(store, uiTypes.DialogTypes.LayerInfo);
2217
- });
2218
- var currentLayerInfo = useAppSelector(function (store) {
2219
- return layerSelectors.getActiveLayerInfo(store);
2220
- });
2221
- var onToggleActiveLayer = React.useCallback(function (_ref6) {
2222
- var serviceUrl = _ref6.serviceUrl,
2223
- layerName = _ref6.layerName,
2224
- isActiveLayer = _ref6.isActiveLayer;
2225
- if (!isActiveLayer) {
2226
- dispatch(layerActions.showLayerInfo({
2227
- layerName: layerName,
2228
- serviceUrl: serviceUrl,
2229
- mapId: mapId
2230
- }));
2231
- } else {
2232
- dispatch(layerActions.hideLayerInfo());
2233
- }
2234
- }, [mapId, dispatch]);
2235
- return /*#__PURE__*/jsx(LayerList, {
2236
- addLayer: function addLayer(params) {
2237
- return _addLayer(params, mapId);
2238
- },
2239
- addLayerToAllMaps: addLayerToAllMaps,
2240
- allLayers: allLayers,
2241
- allMapIds: allMapIds,
2242
- currentLayerInfo: currentLayerInfo,
2243
- deleteLayer: deleteLayer,
2244
- filteredLayers: filteredLayers,
2245
- isLayerInfoVisibleInStore: isLayerInfoVisibleInStore,
2246
- layerSelectHeight: layerSelectHeight,
2247
- layerSelectWidth: layerSelectWidth,
2248
- mapLayers: mapLayers,
2249
- onToggleActiveLayer: onToggleActiveLayer,
2250
- removeLayerFromAllMaps: removeLayerFromAllMaps,
2251
- searchFilter: searchFilter,
2252
- serviceListHeight: serviceListHeight,
2253
- services: services
2254
- });
2255
- };
2256
-
2257
- /* *
2258
- * Licensed under the Apache License, Version 2.0 (the "License");
2259
- * you may not use this file except in compliance with the License.
2260
- * You may obtain a copy of the License at
2261
- *
2262
- * http://www.apache.org/licenses/LICENSE-2.0
2263
- *
2264
- * Unless required by applicable law or agreed to in writing, software
2265
- * distributed under the License is distributed on an "AS IS" BASIS,
2266
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2267
- * See the License for the specific language governing permissions and
2268
- * limitations under the License.
2269
- *
2270
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2271
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
2272
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2273
- * */
2274
-
2275
- var style$2 = {
2276
- width: 'auto !important',
2277
- height: 'auto !important',
2278
- padding: 0
2279
- };
2280
- var LayerSelectButtonConnect = function LayerSelectButtonConnect(_ref) {
2281
- var mapId = _ref.mapId,
2282
- _ref$source = _ref.source,
2283
- source = _ref$source === void 0 ? 'app' : _ref$source,
2284
- tooltipTitle = _ref.tooltipTitle,
2285
- _ref$icon = _ref.icon,
2286
- icon = _ref$icon === void 0 ? /*#__PURE__*/jsx(LayersAdd, {
2287
- "data-testid": "layerSelectButtonConnectIcon"
2288
- }) : _ref$icon,
2289
- _ref$isMultiMap = _ref.isMultiMap,
2290
- isMultiMap = _ref$isMultiMap === void 0 ? false : _ref$isMultiMap;
2291
- var _useLayerSelectTransl = useLayerSelectTranslation(),
2292
- t = _useLayerSelectTransl.t;
2293
- var dispatch = useDispatch();
2294
- var dialogType = isMultiMap ? uiTypes.DialogTypes.LayerSelect + "-" + mapId : uiTypes.DialogTypes.LayerSelect;
2295
- var currentActiveMapId = useAppSelector(function (store) {
2296
- return uiSelectors.getDialogMapId(store, dialogType);
2297
- });
2298
- var isOpenInStore = useAppSelector(function (store) {
2299
- return uiSelectors.getisDialogOpen(store, dialogType);
2300
- });
2301
- var openLayerSelectDialog = React.useCallback(function () {
2302
- dispatch(uiActions.setActiveMapIdForDialog({
2303
- type: dialogType,
2304
- mapId: mapId,
2305
- setOpen: currentActiveMapId !== mapId ? true : !isOpenInStore,
2306
- source: source
2307
- }));
2308
- }, [currentActiveMapId, dispatch, isOpenInStore, mapId, source, dialogType]);
2309
- return /*#__PURE__*/jsx(CustomIconButton, {
2310
- "data-testid": "layerSelectButton",
2311
- id: "layerSelectButton",
2312
- onClick: openLayerSelectDialog,
2313
- sx: style$2,
2314
- tooltipTitle: tooltipTitle || t('layer-select-button-tooltip'),
2315
- children: icon
2316
- });
2317
- };
2318
-
2319
- /* *
2320
- * Licensed under the Apache License, Version 2.0 (the "License");
2321
- * you may not use this file except in compliance with the License.
2322
- * You may obtain a copy of the License at
2323
- *
2324
- * http://www.apache.org/licenses/LICENSE-2.0
2325
- *
2326
- * Unless required by applicable law or agreed to in writing, software
2327
- * distributed under the License is distributed on an "AS IS" BASIS,
2328
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2329
- * See the License for the specific language governing permissions and
2330
- * limitations under the License.
2331
- *
2332
- * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2333
- * Copyright 2025 - Finnish Meteorological Institute (FMI)
2334
- * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
2335
- * */
2336
-
2337
- var DataExplorerButtonConnect = function DataExplorerButtonConnect(_ref) {
2338
- var mapId = _ref.mapId,
2339
- _ref$source = _ref.source,
2340
- source = _ref$source === void 0 ? 'app' : _ref$source;
2341
- var dispatch = useDispatch();
2342
- var dialogType = uiTypes.DialogTypes.DataExplorer;
2343
- var currentActiveMapId = useSelector(function (store) {
2344
- return uiSelectors.getDialogMapId(store, dialogType);
2345
- });
2346
- var isOpenInStore = useSelector(function (store) {
2347
- return uiSelectors.getisDialogOpen(store, dialogType);
2348
- });
2349
- var openDataExplorerDialog = React.useCallback(function () {
2350
- dispatch(uiActions.setActiveMapIdForDialog({
2351
- type: dialogType,
2352
- setOpen: currentActiveMapId !== mapId ? true : !isOpenInStore,
2353
- source: source,
2354
- mapId: mapId,
2355
- origin: mapEnums.MapActionOrigin.map
2356
- }));
2357
- }, [dispatch, dialogType, currentActiveMapId, mapId, isOpenInStore, source]);
2358
- return /*#__PURE__*/jsx(CustomTooltip, {
2359
- title: "MeteoGate Data Explorer",
2360
- children: /*#__PURE__*/jsx(CustomIconButton, {
2361
- "data-testid": "dataExplorerButton",
2362
- isSelected: currentActiveMapId !== mapId ? false : isOpenInStore,
2363
- onClick: openDataExplorerDialog,
2364
- variant: "tool",
2365
- children: /*#__PURE__*/jsx(MeteoGate, {
2366
- sx: {}
2367
- })
2368
- })
2369
- });
2370
- };
2371
-
2372
- /* *
2373
- * Licensed under the Apache License, Version 2.0 (the "License");
2374
- * you may not use this file except in compliance with the License.
2375
- * You may obtain a copy of the License at
2376
- *
2377
- * http://www.apache.org/licenses/LICENSE-2.0
2378
- *
2379
- * Unless required by applicable law or agreed to in writing, software
2380
- * distributed under the License is distributed on an "AS IS" BASIS,
2381
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2382
- * See the License for the specific language governing permissions and
2383
- * limitations under the License.
2384
- *
2385
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2386
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2387
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2388
- * */
2389
-
2390
- var SearchFieldConnect = function SearchFieldConnect() {
2391
- var dispatch = useDispatch();
2392
- var searchFilter = useAppSelector(function (store) {
2393
- return getSearchFilter(store);
2394
- });
2395
- var toggleServicePopup = function toggleServicePopup(url) {
2396
- dispatch(layerSelectActions.toggleServicePopup({
2397
- isOpen: true,
2398
- url: url,
2399
- variant: 'save'
2400
- }));
2401
- };
2402
- var setSearchFilter = function setSearchFilter(filterText) {
2403
- dispatch(layerSelectActions.setSearchFilter({
2404
- filterText: filterText
2405
- }));
2406
- };
2407
- return /*#__PURE__*/jsx(SearchField, {
2408
- onOpenServicePopup: toggleServicePopup,
2409
- searchFilter: searchFilter,
2410
- setSearchFilter: setSearchFilter
2411
- });
2412
- };
2413
-
2414
- /* *
2415
- * Licensed under the Apache License, Version 2.0 (the "License");
2416
- * you may not use this file except in compliance with the License.
2417
- * You may obtain a copy of the License at
2418
- *
2419
- * http://www.apache.org/licenses/LICENSE-2.0
2420
- *
2421
- * Unless required by applicable law or agreed to in writing, software
2422
- * distributed under the License is distributed on an "AS IS" BASIS,
2423
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2424
- * See the License for the specific language governing permissions and
2425
- * limitations under the License.
2426
- *
2427
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2428
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2429
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2430
- * */
2431
-
2432
- var style$1 = {
2433
- borderRadius: '20px!important',
2434
- marginRight: '4px',
2435
- whiteSpace: 'nowrap',
2436
- height: '24px!important',
2437
- padding: '5px 12px!important',
2438
- textTransform: 'none!important',
2439
- fontWeight: 'normal',
2440
- marginBottom: '4px'
2441
- };
2442
- var ServiceChip = function ServiceChip(_ref) {
2443
- var _ref$all = _ref.all,
2444
- all = _ref$all === void 0 ? false : _ref$all,
2445
- service = _ref.service,
2446
- isSelected = _ref.isSelected,
2447
- isDisabled = _ref.isDisabled,
2448
- toggleChip = _ref.toggleChip,
2449
- isInSearch = _ref.isInSearch;
2450
- var _useLayerSelectTransl = useLayerSelectTranslation(),
2451
- t = _useLayerSelectTransl.t;
2452
- var _useTheme = useTheme(),
2453
- geowebColors = _useTheme.palette.geowebColors;
2454
- var chip = all ? 'all' : service == null ? void 0 : service.serviceUrl;
2455
- return /*#__PURE__*/jsx(CustomTooltip, {
2456
- title: service != null && service["abstract"] ? "Abstract: " + service["abstract"] : '',
2457
- children: /*#__PURE__*/jsx("span", {
2458
- children: /*#__PURE__*/jsx(CustomToggleButton, {
2459
- "data-testid": all ? 'serviceChipAll' : 'serviceChip',
2460
- disabled: isDisabled,
2461
- onClick: function onClick() {
2462
- return toggleChip(chip);
2463
- },
2464
- onKeyDown: function onKeyDown() {
2465
- return toggleChip(chip);
2466
- },
2467
- selected: Boolean(isSelected),
2468
- sx: Object.assign({}, style$1, isInSearch && Object.assign({
2469
- backgroundColor: geowebColors.chip.highlightDefault.rgba + "!important",
2470
- '&:hover': {
2471
- backgroundColor: geowebColors.chip.highlightDefaultMouseOver.rgba + "!important"
2472
- }
2473
- }, isSelected && {
2474
- backgroundColor: geowebColors.chip.highlightActiveDefault.rgba + "!important",
2475
- '&:hover': {
2476
- backgroundColor: geowebColors.chip.highlightActiveMouseOver.rgba + "!important"
2477
- }
2478
- })),
2479
- tabIndex: 0,
2480
- variant: "boxed",
2481
- children: service ? service.serviceName : t('all')
2482
- })
2483
- })
2484
- });
2485
- };
2486
-
2487
- /* *
2488
- * Licensed under the Apache License, Version 2.0 (the "License");
2489
- * you may not use this file except in compliance with the License.
2490
- * You may obtain a copy of the License at
2491
- *
2492
- * http://www.apache.org/licenses/LICENSE-2.0
2493
- *
2494
- * Unless required by applicable law or agreed to in writing, software
2495
- * distributed under the License is distributed on an "AS IS" BASIS,
2496
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2497
- * See the License for the specific language governing permissions and
2498
- * limitations under the License.
2499
- *
2500
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2501
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2502
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2503
- * */
2504
-
2505
- var ServiceChipConnect = function ServiceChipConnect(_ref) {
2506
- var service = _ref.service,
2507
- isAllSelected = _ref.isAllSelected;
2508
- var dispatch = useDispatch();
2509
- var serviceId = service.serviceId;
2510
- var isInSearch = service.isInSearch || false;
2511
- var toggleChip = function toggleChip() {
2512
- if (service.enabled) {
2513
- if (isAllSelected) {
2514
- dispatch(layerSelectActions.onlyThisServiceEnabled({
2515
- serviceId: serviceId
2516
- }));
2517
- return;
2518
- }
2519
- dispatch(layerSelectActions.disableActiveService({
2520
- serviceId: serviceId
2521
- }));
2522
- return;
2523
- }
2524
- dispatch(layerSelectActions.enableActiveService({
2525
- serviceId: serviceId
2526
- }));
2527
- };
2528
- return /*#__PURE__*/jsx(ServiceChip, {
2529
- isDisabled: service.isLoading,
2530
- isInSearch: isInSearch,
2531
- isSelected: isAllSelected ? false : service.enabled,
2532
- service: service,
2533
- toggleChip: toggleChip
2534
- });
2535
- };
2536
- var AllChipConnect = function AllChipConnect(_ref2) {
2537
- var isAllSelected = _ref2.isAllSelected;
2538
- var dispatch = useDispatch();
2539
- return /*#__PURE__*/jsx(ServiceChip, {
2540
- isSelected: isAllSelected,
2541
- toggleChip: function toggleChip() {
2542
- if (!isAllSelected) {
2543
- dispatch(layerSelectActions.enableAllActiveServices());
2544
- }
2545
- }
2546
- });
2547
- };
2548
-
2549
- /* *
2550
- * Licensed under the Apache License, Version 2.0 (the "License");
2551
- * you may not use this file except in compliance with the License.
2552
- * You may obtain a copy of the License at
2553
- *
2554
- * http://www.apache.org/licenses/LICENSE-2.0
2555
- *
2556
- * Unless required by applicable law or agreed to in writing, software
2557
- * distributed under the License is distributed on an "AS IS" BASIS,
2558
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2559
- * See the License for the specific language governing permissions and
2560
- * limitations under the License.
2561
- *
2562
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2563
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2564
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2565
- * */
2566
-
2567
- var ServiceList = function ServiceList(_ref) {
2568
- var _ref$current;
2569
- var activeServicesById = _ref.activeServicesById,
2570
- setHeight = _ref.setHeight;
2571
- var ref = React.useRef(null);
2572
- var _React$useState = React.useState(0),
2573
- serviceListHeight = _React$useState[0],
2574
- setServiceListHeight = _React$useState[1];
2575
- var clientHeight = (ref == null || (_ref$current = ref.current) == null ? void 0 : _ref$current.clientHeight) && ref.current.clientHeight;
2576
- React.useEffect(function () {
2577
- var _ref$current2;
2578
- if (ref != null && (_ref$current2 = ref.current) != null && _ref$current2.clientHeight) {
2579
- setServiceListHeight(ref.current.clientHeight);
2580
- }
2581
- }, [activeServicesById, clientHeight]);
2582
- React.useEffect(function () {
2583
- setHeight(serviceListHeight);
2584
- }, [serviceListHeight, setHeight]);
2585
- var activeServicesIds = Object.keys(activeServicesById);
2586
- var activeServices = Object.values(activeServicesById);
2587
- var isAllSelected = activeServices.every(function (activeService) {
2588
- return activeService.enabled;
2589
- });
2590
- return /*#__PURE__*/jsx(Box, {
2591
- "data-testid": "serviceList",
2592
- sx: {
2593
- marginTop: '8px',
2594
- width: '100%',
2595
- overflow: 'hidden'
2596
- },
2597
- children: /*#__PURE__*/jsxs(Box, {
2598
- ref: ref,
2599
- sx: {
2600
- width: '100%',
2601
- display: 'block',
2602
- alignItems: 'center',
2603
- "float": 'left',
2604
- paddingLeft: '48px',
2605
- paddingRight: '40px',
2606
- marginBottom: '8px',
2607
- fontSize: '0.875rem'
2608
- },
2609
- children: [!!(activeServicesIds != null && activeServicesIds.length) && /*#__PURE__*/jsx(AllChipConnect, {
2610
- isAllSelected: isAllSelected
2611
- }), activeServices.map(function (service) {
2612
- return /*#__PURE__*/jsx(ServiceChipConnect, {
2613
- isAllSelected: isAllSelected,
2614
- service: service
2615
- }, service.serviceUrl);
2616
- })]
2617
- })
2618
- });
2619
- };
2620
-
2621
- /* *
2622
- * Licensed under the Apache License, Version 2.0 (the "License");
2623
- * you may not use this file except in compliance with the License.
2624
- * You may obtain a copy of the License at
2625
- *
2626
- * http://www.apache.org/licenses/LICENSE-2.0
2627
- *
2628
- * Unless required by applicable law or agreed to in writing, software
2629
- * distributed under the License is distributed on an "AS IS" BASIS,
2630
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2631
- * See the License for the specific language governing permissions and
2632
- * limitations under the License.
2633
- *
2634
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2635
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2636
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2637
- * */
2638
-
2639
- var ServiceListConnect = function ServiceListConnect(_ref) {
2640
- var setHeight = _ref.setHeight;
2641
- var filteredActiveServices = useAppSelector(function (store) {
2642
- return getFilteredActiveServices(store);
2643
- });
2644
- return /*#__PURE__*/jsx(ServiceList, {
2645
- activeServicesById: sortByService(filteredActiveServices),
2646
- setHeight: setHeight
2647
- });
2648
- };
2649
-
2650
- /* *
2651
- * Licensed under the Apache License, Version 2.0 (the "License");
2652
- * you may not use this file except in compliance with the License.
2653
- * You may obtain a copy of the License at
2654
- *
2655
- * http://www.apache.org/licenses/LICENSE-2.0
2656
- *
2657
- * Unless required by applicable law or agreed to in writing, software
2658
- * distributed under the License is distributed on an "AS IS" BASIS,
2659
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2660
- * See the License for the specific language governing permissions and
2661
- * limitations under the License.
2662
- *
2663
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2664
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
2665
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2666
- * */
2667
-
2668
- var styles = {
2669
- servicesContainer: {
2670
- width: '360px',
2671
- maxHeight: '412px',
2672
- top: '140px',
2673
- backgroundColor: 'geowebColors.background.surface',
2674
- boxShadow: 6,
2675
- overflow: 'auto'
2676
- },
2677
- header: {
2678
- position: 'sticky',
2679
- top: 0,
2680
- padding: '12px',
2681
- backgroundColor: 'geowebColors.background.surface',
2682
- zIndex: 100
2683
- },
2684
- text: {
2685
- fontSize: 'default',
2686
- opacity: 0.67
2687
- },
2688
- loading: {
2689
- position: 'absolute',
2690
- zIndex: 101
2691
- },
2692
- footer: {
2693
- display: 'flex',
2694
- justifyContent: 'center',
2695
- alignItems: 'center',
2696
- position: 'sticky',
2697
- bottom: 0,
2698
- backgroundColor: 'geowebColors.background.surface',
2699
- zIndex: 100
2700
- },
2701
- button: {
2702
- margin: '16px',
2703
- width: '80%',
2704
- fontSize: '12px',
2705
- textTransform: 'none'
2706
- }
2707
- };
2708
- var stopTabPropagation = function stopTabPropagation(event) {
2709
- if (event.key === 'Tab') {
2710
- event.stopPropagation();
2711
- }
2712
- };
2713
- var ServiceOptionsDialog = function ServiceOptionsDialog(_ref) {
2714
- var services = _ref.services,
2715
- layerSelectRemoveService = _ref.layerSelectRemoveService,
2716
- layerSelectReloadService = _ref.layerSelectReloadService,
2717
- selectedLayers = _ref.selectedLayers,
2718
- setServicePopupInfo = _ref.setServicePopupInfo,
2719
- _ref$isLoading = _ref.isLoading,
2720
- isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
2721
- error = _ref.error;
2722
- var _useLayerSelectTransl = useLayerSelectTranslation(),
2723
- t = _useLayerSelectTransl.t;
2724
- var openAddService = function openAddService() {
2725
- setServicePopupInfo({
2726
- isOpen: true,
2727
- variant: 'add'
2728
- });
2729
- };
2730
- var dialogRef = React.useRef(null);
2731
- React.useEffect(function () {
2732
- var _dialogRef$current;
2733
- (_dialogRef$current = dialogRef.current) == null || _dialogRef$current.focus();
2734
- }, []);
2735
- return /*#__PURE__*/jsxs(Box, {
2736
- "data-testid": "ServiceDialog",
2737
- onKeyDown: function onKeyDown(event) {
2738
- if (event.key !== 'Escape') {
2739
- event.stopPropagation();
2740
- }
2741
- },
2742
- ref: dialogRef,
2743
- sx: styles.servicesContainer,
2744
- tabIndex: -1,
2745
- children: [/*#__PURE__*/jsxs(Box, {
2746
- sx: styles.header,
2747
- children: [/*#__PURE__*/jsx(Box, {
2748
- sx: styles.text,
2749
- children: t('services')
2750
- }), error ? /*#__PURE__*/jsx(AlertBanner, {
2751
- shouldClose: true,
2752
- title: error
2753
- }) : null]
2754
- }), /*#__PURE__*/jsx(Backdrop, {
2755
- open: isLoading,
2756
- sx: Object.assign({}, styles.loading, {
2757
- backgroundSize: 'cover'
2758
- }),
2759
- children: /*#__PURE__*/jsx(CircularProgress, {})
2760
- }), /*#__PURE__*/jsx(Rows, {
2761
- layerSelectReloadService: layerSelectReloadService,
2762
- layerSelectRemoveService: layerSelectRemoveService,
2763
- selectedLayers: selectedLayers,
2764
- services: services,
2765
- setServicePopupInfo: setServicePopupInfo
2766
- }), /*#__PURE__*/jsx(Box, {
2767
- sx: styles.footer,
2768
- children: /*#__PURE__*/jsx(Button, {
2769
- "data-testid": "openAddServiceButton",
2770
- onClick: openAddService,
2771
- onKeyDown: stopTabPropagation,
2772
- startIcon: /*#__PURE__*/jsx(Add, {}),
2773
- sx: styles.button,
2774
- variant: "tertiary",
2775
- children: t('add-a-new-service')
2776
- })
2777
- })]
2778
- });
2779
- };
2780
- var deleteServiceTitle = function deleteServiceTitle(t, hasActiveLayers) {
2781
- return hasActiveLayers ? t('service-has-active-layers-error') : t('delete-service');
2782
- };
2783
- var tooltipPlacement = function tooltipPlacement() {
2784
- return 'left';
2785
- };
2786
- var tooltipPopperProps = {
2787
- disablePortal: true,
2788
- sx: {
2789
- '& .MuiTooltip-tooltip': {
2790
- width: '200px',
2791
- display: 'flex',
2792
- justifyContent: 'center',
2793
- alignItems: 'center'
2794
- }
2795
- }
2796
- };
2797
- var Rows = function Rows(_ref2) {
2798
- var services = _ref2.services,
2799
- layerSelectReloadService = _ref2.layerSelectReloadService,
2800
- layerSelectRemoveService = _ref2.layerSelectRemoveService,
2801
- setServicePopupInfo = _ref2.setServicePopupInfo,
2802
- selectedLayers = _ref2.selectedLayers;
2803
- var _useLayerSelectTransl2 = useLayerSelectTranslation(),
2804
- t = _useLayerSelectTransl2.t;
2805
- var checkIfServiceHasActiveLayers = function checkIfServiceHasActiveLayers(serviceUrl) {
2806
- var foundService = selectedLayers.find(function (object) {
2807
- return object.service === serviceUrl;
2808
- });
2809
- if (foundService) {
2810
- return true;
2811
- }
2812
- return false;
2813
- };
2814
- var sortedServices = sortByService(services);
2815
- return /*#__PURE__*/jsx(List, {
2816
- disablePadding: true,
2817
- children: Object.keys(sortedServices).map(function (serviceId) {
2818
- var _services$serviceId = services[serviceId],
2819
- serviceUrl = _services$serviceId.serviceUrl,
2820
- serviceName = _services$serviceId.serviceName,
2821
- scope = _services$serviceId.scope;
2822
- var serviceHasActiveLayers = checkIfServiceHasActiveLayers(serviceUrl);
2823
- var userAddedService = isUserAddedService(scope);
2824
- return /*#__PURE__*/jsx(ListItem, {
2825
- secondaryAction: /*#__PURE__*/jsx(Box, {
2826
- sx: {
2827
- marginRight: '0px',
2828
- width: 96,
2829
- button: {
2830
- marginLeft: 1
2831
- }
2832
- },
2833
- children: /*#__PURE__*/jsxs(Grid, {
2834
- container: true,
2835
- justifyContent: "left",
2836
- sx: {
2837
- marginRight: '0px',
2838
- width: 96,
2839
- button: {
2840
- marginLeft: 1
2841
- }
2842
- },
2843
- children: [/*#__PURE__*/jsx(CustomTooltip, {
2844
- "data-testid": "updateServiceTooltip",
2845
- placement: tooltipPlacement(),
2846
- slotProps: {
2847
- popper: tooltipPopperProps
2848
- },
2849
- title: t('update-service-title'),
2850
- children: /*#__PURE__*/jsx(CustomIconButton, {
2851
- "aria-label": "Update layers from WMS service",
2852
- "data-testid": "updateServiceButton",
2853
- onClick: function onClick() {
2854
- layerSelectReloadService(serviceUrl);
2855
- },
2856
- onKeyDown: stopTabPropagation,
2857
- children: /*#__PURE__*/jsx(Cached, {})
2858
- })
2859
- }), userAddedService ? /*#__PURE__*/jsx(CustomTooltip, {
2860
- placement: tooltipPlacement(),
2861
- slotProps: {
2862
- popper: tooltipPopperProps
2863
- },
2864
- title: t('edit-service-title'),
2865
- children: /*#__PURE__*/jsx("span", {
2866
- children: /*#__PURE__*/jsx(CustomIconButton, {
2867
- "aria-label": "edit service",
2868
- "data-testid": "openEditServiceButton",
2869
- onClick: function onClick() {
2870
- setServicePopupInfo({
2871
- isOpen: true,
2872
- serviceId: serviceId,
2873
- serviceUrl: serviceUrl,
2874
- variant: 'edit'
2875
- });
2876
- },
2877
- onKeyDown: stopTabPropagation,
2878
- children: /*#__PURE__*/jsx(Edit, {})
2879
- })
2880
- })
2881
- }) : /*#__PURE__*/jsx(CustomTooltip, {
2882
- placement: tooltipPlacement(),
2883
- slotProps: {
2884
- popper: tooltipPopperProps
2885
- },
2886
- title: t('show-service-title'),
2887
- children: /*#__PURE__*/jsx("span", {
2888
- children: /*#__PURE__*/jsx(CustomIconButton, {
2889
- "aria-label": "show service",
2890
- "data-testid": "openShowServiceButton",
2891
- onClick: function onClick() {
2892
- setServicePopupInfo({
2893
- isOpen: true,
2894
- serviceId: serviceId,
2895
- serviceUrl: serviceUrl,
2896
- variant: 'show'
2897
- });
2898
- },
2899
- onKeyDown: stopTabPropagation,
2900
- children: /*#__PURE__*/jsx(Visibility, {})
2901
- })
2902
- })
2903
- }), !!userAddedService && /*#__PURE__*/jsx(Box, {
2904
- children: /*#__PURE__*/jsx(CustomTooltip, {
2905
- "data-testid": "removeServiceTooltip",
2906
- placement: tooltipPlacement(),
2907
- slotProps: {
2908
- popper: tooltipPopperProps
2909
- },
2910
- title: deleteServiceTitle(t, serviceHasActiveLayers),
2911
- children: /*#__PURE__*/jsx("span", {
2912
- children: /*#__PURE__*/jsx(CustomIconButton, {
2913
- "aria-label": "delete service",
2914
- "data-testid": "removeServiceButton",
2915
- disabled: serviceHasActiveLayers,
2916
- onClick: function onClick() {
2917
- return layerSelectRemoveService(serviceId, serviceUrl, serviceName);
2918
- },
2919
- onKeyDown: stopTabPropagation,
2920
- children: /*#__PURE__*/jsx(Delete, {})
2921
- })
2922
- })
2923
- })
2924
- })]
2925
- })
2926
- }),
2927
- children: /*#__PURE__*/jsx(ListItemText, {
2928
- style: {
2929
- fontSize: '16px'
2930
- },
2931
- children: /*#__PURE__*/jsx(Typography, {
2932
- noWrap: true,
2933
- style: {
2934
- textOverflow: 'ellipsis',
2935
- paddingRight: '70px'
2936
- },
2937
- children: serviceName
2938
- })
2939
- })
2940
- }, serviceUrl);
2941
- })
2942
- });
2943
- };
2944
-
2945
- var validateServiceName = function validateServiceName(t, value, services, ownServiceName) {
2946
- if (ownServiceName === void 0) {
2947
- ownServiceName = '';
2948
- }
2949
- var serviceName = value == null ? void 0 : value.toLowerCase();
2950
- var foundName = Object.keys(services).find(function (serviceId) {
2951
- var _services$serviceId;
2952
- return ((_services$serviceId = services[serviceId]) == null ? void 0 : _services$serviceId.serviceName.toLowerCase()) === serviceName && serviceName !== ownServiceName.toLocaleLowerCase();
2953
- });
2954
- return foundName === undefined ? true : t('validations-name-existing');
2955
- };
2956
- var isValidUrl = function isValidUrl(url) {
2957
- if (url === '' || url === null || typeof url === 'undefined') {
2958
- return false;
2959
- }
2960
- var matcher = /^(?:\w+:)?\/\/([^\s.]+\.\S{2}|[0-9a-zA-Z]+[:?\d]*)\S*$/;
2961
- if (!matcher.test(url)) {
2962
- return false;
2963
- }
2964
- return true;
2965
- };
2966
- var validateServiceUrl = function validateServiceUrl(t, value, services) {
2967
- var serviceUrl = value;
2968
- // validate valid url
2969
- var isServiceUrlValid = isValidUrl(serviceUrl);
2970
- if (!isServiceUrlValid) {
2971
- return t('validations-service-valid-url');
2972
- }
2973
- // check url existing
2974
- var foundUrl = Object.keys(services).find(function (serviceId) {
2975
- var _services$serviceId2;
2976
- return ((_services$serviceId2 = services[serviceId]) == null ? void 0 : _services$serviceId2.serviceUrl) === serviceUrl;
2977
- });
2978
- if (foundUrl) {
2979
- return t('validations-service-existing');
2980
- }
2981
- return true;
2982
- };
2983
- var loadWMSService = /*#__PURE__*/function () {
2984
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(serviceUrl, forceReload) {
2985
- var layers, service;
2986
- return _regeneratorRuntime().wrap(function _callee$(_context) {
2987
- while (1) switch (_context.prev = _context.next) {
2988
- case 0:
2989
- if (forceReload === void 0) {
2990
- forceReload = false;
2991
- }
2992
- if (!forceReload) {
2993
- _context.next = 4;
2994
- break;
2995
- }
2996
- _context.next = 4;
2997
- return invalidateWMSGetCapabilities(serviceUrl);
2998
- case 4:
2999
- _context.next = 6;
3000
- return queryWMSLayers(serviceUrl);
3001
- case 6:
3002
- layers = _context.sent;
3003
- _context.next = 9;
3004
- return queryWMSServiceInfo(serviceUrl);
3005
- case 9:
3006
- service = _context.sent;
3007
- return _context.abrupt("return", {
3008
- id: service.id || getWMSServiceId(serviceUrl),
3009
- name: service.title,
3010
- serviceUrl: serviceUrl,
3011
- "abstract": service["abstract"],
3012
- layers: layers,
3013
- scope: 'user'
3014
- });
3015
- case 11:
3016
- case "end":
3017
- return _context.stop();
3018
- }
3019
- }, _callee);
3020
- }));
3021
- return function loadWMSService(_x, _x2) {
3022
- return _ref.apply(this, arguments);
3023
- };
3024
- }();
3025
-
3026
- var getService = function getService(services, serviceUrl) {
3027
- var serviceIds = Object.keys(services);
3028
- var serviceIndex = serviceIds.findIndex(function (serviceId) {
3029
- var _services$serviceId;
3030
- return ((_services$serviceId = services[serviceId]) == null ? void 0 : _services$serviceId.serviceUrl) === serviceUrl;
3031
- });
3032
- if (serviceIndex < 0) {
3033
- return null;
3034
- }
3035
- return services[serviceIds[serviceIndex]];
3036
- };
3037
- var getServiceSuccesUpdateMessage = function getServiceSuccesUpdateMessage(serviceName) {
3038
- return {
3039
- type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
3040
- key: 'service-successfully-updated',
3041
- params: {
3042
- serviceName: serviceName
3043
- }
3044
- };
3045
- };
3046
- var ServiceOptionsDialogConnect = function ServiceOptionsDialogConnect(_ref) {
3047
- var mapId = _ref.mapId;
3048
- var _React$useState = React.useState(false),
3049
- isLoading = _React$useState[0],
3050
- setIsLoading = _React$useState[1];
3051
- var _React$useState2 = React.useState(undefined),
3052
- error = _React$useState2[0],
3053
- setError = _React$useState2[1];
3054
- var dispatch = useDispatch();
3055
- var _useLayerSelectTransl = useLayerSelectTranslation(),
3056
- t = _useLayerSelectTransl.t;
3057
- var serviceSetLayers = React.useCallback(function (payload) {
3058
- dispatch(serviceActions.serviceSetLayers(Object.assign({}, payload, {
3059
- isUpdating: true
3060
- })));
3061
- }, [dispatch]);
3062
- var setServicePopupInfo = React.useCallback(function (popupInfo) {
3063
- var payload = Object.assign({}, popupInfo, {
3064
- variant: popupInfo.variant || 'default'
3065
- });
3066
- dispatch(layerSelectActions.toggleServicePopup(payload));
3067
- }, [dispatch]);
3068
- var showSnackbar = React.useCallback(function (message) {
3069
- dispatch(snackbarActions.openSnackbar(message));
3070
- }, [dispatch]);
3071
- var services = useAppSelector(function (store) {
3072
- return getActiveServices(store);
3073
- });
3074
- var selectedLayers = useAppSelector(function (store) {
3075
- return mapSelectors.getMapLayersWithoutDimensionCurrentValue(store, mapId);
3076
- });
3077
- var layerSelectRemoveService = React.useCallback(function (serviceId, serviceUrl, serviceName) {
3078
- var message = {
3079
- type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
3080
- key: 'service-has-been-deleted',
3081
- params: {
3082
- serviceName: serviceName
3083
- }
3084
- };
3085
- showSnackbar(message);
3086
- dispatch(layerSelectActions.layerSelectRemoveService({
3087
- serviceId: serviceId,
3088
- serviceUrl: serviceUrl
3089
- }));
3090
- }, [dispatch, showSnackbar]);
3091
- var layerSelectReloadService = React.useCallback(/*#__PURE__*/function () {
3092
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(serviceUrl) {
3093
- var layersForService, service, serviceTitle;
3094
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3095
- while (1) switch (_context.prev = _context.next) {
3096
- case 0:
3097
- setIsLoading(true);
3098
- setError(undefined);
3099
- _context.prev = 2;
3100
- _context.next = 5;
3101
- return loadWMSService(serviceUrl, true);
3102
- case 5:
3103
- layersForService = _context.sent;
3104
- service = getService(services, serviceUrl);
3105
- serviceSetLayers({
3106
- id: layersForService.id,
3107
- name: (service == null ? void 0 : service.serviceName) || layersForService.name,
3108
- serviceUrl: serviceUrl,
3109
- "abstract": (service == null ? void 0 : service["abstract"]) || layersForService["abstract"],
3110
- layers: layersForService.layers,
3111
- scope: (service == null ? void 0 : service.scope) || 'user',
3112
- isUpdating: true
3113
- });
3114
- clearImageCacheForAllMaps();
3115
- serviceTitle = (service == null ? void 0 : service.serviceName) || layersForService.name;
3116
- showSnackbar(getServiceSuccesUpdateMessage(serviceTitle));
3117
- _context.next = 16;
3118
- break;
3119
- case 13:
3120
- _context.prev = 13;
3121
- _context.t0 = _context["catch"](2);
3122
- setError(t('unable-to-update-service', {
3123
- message: _context.t0.message
3124
- }));
3125
- case 16:
3126
- _context.prev = 16;
3127
- setIsLoading(false);
3128
- return _context.finish(16);
3129
- case 19:
3130
- case "end":
3131
- return _context.stop();
3132
- }
3133
- }, _callee, null, [[2, 13, 16, 19]]);
3134
- }));
3135
- return function (_x) {
3136
- return _ref2.apply(this, arguments);
3137
- };
3138
- }(), [serviceSetLayers, services, showSnackbar, t]);
3139
- return /*#__PURE__*/jsx(ServiceOptionsDialog, {
3140
- error: error,
3141
- isLoading: isLoading,
3142
- layerSelectReloadService: layerSelectReloadService,
3143
- layerSelectRemoveService: layerSelectRemoveService,
3144
- selectedLayers: selectedLayers,
3145
- services: services,
3146
- setServicePopupInfo: setServicePopupInfo
3147
- });
3148
- };
3149
-
3150
- /* *
3151
- * Licensed under the Apache License, Version 2.0 (the "License");
3152
- * you may not use this file except in compliance with the License.
3153
- * You may obtain a copy of the License at
3154
- *
3155
- * http://www.apache.org/licenses/LICENSE-2.0
3156
- *
3157
- * Unless required by applicable law or agreed to in writing, software
3158
- * distributed under the License is distributed on an "AS IS" BASIS,
3159
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3160
- * See the License for the specific language governing permissions and
3161
- * limitations under the License.
3162
- *
3163
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3164
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3165
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3166
- * */
3167
-
3168
- var ServiceOptionsButton = function ServiceOptionsButton(_ref) {
3169
- var mapId = _ref.mapId;
3170
- return /*#__PURE__*/jsx(ToggleMenu, {
3171
- buttonTestId: "serviceOptionsButton",
3172
- menuPosition: "bottom",
3173
- children: /*#__PURE__*/jsx(ServiceOptionsDialogConnect, {
3174
- mapId: mapId
3175
- })
3176
- });
3177
- };
3178
-
3179
- /* *
3180
- * Licensed under the Apache License, Version 2.0 (the "License");
3181
- * you may not use this file except in compliance with the License.
3182
- * You may obtain a copy of the License at
3183
- *
3184
- * http://www.apache.org/licenses/LICENSE-2.0
3185
- *
3186
- * Unless required by applicable law or agreed to in writing, software
3187
- * distributed under the License is distributed on an "AS IS" BASIS,
3188
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3189
- * See the License for the specific language governing permissions and
3190
- * limitations under the License.
3191
- *
3192
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3193
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
3194
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3195
- * */
3196
-
3197
- var LayerSelect = function LayerSelect(_ref) {
3198
- var mapId = _ref.mapId,
3199
- bounds = _ref.bounds,
3200
- _ref$onClose = _ref.onClose,
3201
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
3202
- showTitle = _ref.showTitle,
3203
- isOpen = _ref.isOpen,
3204
- _ref$onMouseDown = _ref.onMouseDown,
3205
- _onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
3206
- _ref$order = _ref.order,
3207
- order = _ref$order === void 0 ? 0 : _ref$order,
3208
- _ref$source = _ref.source,
3209
- source = _ref$source === void 0 ? 'module' : _ref$source,
3210
- _ref$startSize = _ref.startSize,
3211
- startSize = _ref$startSize === void 0 ? {
3212
- width: 750,
3213
- height: 500
3214
- } : _ref$startSize,
3215
- _ref$isMultiMap = _ref.isMultiMap,
3216
- isMultiMap = _ref$isMultiMap === void 0 ? false : _ref$isMultiMap,
3217
- _ref$hasDataExplorer = _ref.hasDataExplorer,
3218
- hasDataExplorer = _ref$hasDataExplorer === void 0 ? false : _ref$hasDataExplorer;
3219
- var initialServiceListHeight = hasDataExplorer ? 52 : 37;
3220
- var _React$useState = React.useState(startSize.height),
3221
- height = _React$useState[0],
3222
- setHeight = _React$useState[1];
3223
- var _React$useState2 = React.useState(startSize.width),
3224
- width = _React$useState2[0],
3225
- setWidth = _React$useState2[1];
3226
- var _React$useState3 = React.useState(initialServiceListHeight),
3227
- serviceListHeight = _React$useState3[0],
3228
- setServiceListHeight = _React$useState3[1];
3229
- var onChangeSize = function onChangeSize(_ref2) {
3230
- var height = _ref2.height,
3231
- width = _ref2.width;
3232
- setHeight(height);
3233
- setWidth(width);
3234
- };
3235
- var handleHeightChange = function handleHeightChange(height) {
3236
- if (height > initialServiceListHeight) {
3237
- setServiceListHeight(height);
3238
- }
3239
- };
3240
- return /*#__PURE__*/jsxs(ToolContainerDraggable, {
3241
- bounds: bounds,
3242
- "data-testid": "layerSelectWindow",
3243
- isOpen: isOpen,
3244
- minHeight: 126,
3245
- minWidth: 320,
3246
- onClose: onClose,
3247
- onMouseDown: function onMouseDown(event) {
3248
- var target = event.target;
3249
- var isButtonInScrollableList = target.closest('.layerInfoButton') || target.closest('.layerAddRemoveButton');
3250
-
3251
- // don't propagate when clicking on layerInfoButton or addRemoveButton
3252
- if (isButtonInScrollableList) {
3253
- event.stopPropagation();
3254
- return;
3255
- }
3256
- _onMouseDown(event);
3257
- },
3258
- onResizeStop: function onResizeStop(_event, _direction, node) {
3259
- var width = node.offsetWidth,
3260
- height = node.offsetHeight;
3261
- onChangeSize({
3262
- width: width,
3263
- height: height
3264
- });
3265
- },
3266
- order: order,
3267
- source: source,
3268
- startPosition: {
3269
- top: 150,
3270
- left: 100
3271
- },
3272
- startSize: {
3273
- width: width,
3274
- height: height
3275
- },
3276
- title: showTitle ? "Layer Select " + mapId : 'Layer Select',
3277
- children: [/*#__PURE__*/jsx(Box, {
3278
- sx: {
3279
- padding: '4px 16px 0 16px'
3280
- },
3281
- children: /*#__PURE__*/jsx(SearchFieldConnect, {})
3282
- }), /*#__PURE__*/jsx(Box, {
3283
- sx: {
3284
- "float": 'left',
3285
- position: 'absolute',
3286
- margin: '8px 8px 0 16px',
3287
- zIndex: 2
3288
- },
3289
- children: /*#__PURE__*/jsxs(Grid, {
3290
- container: true,
3291
- children: [/*#__PURE__*/jsx(Grid, {
3292
- size: 12,
3293
- children: /*#__PURE__*/jsx(KeywordFilterButtonConnect, {
3294
- isMultiMap: isMultiMap,
3295
- mapId: mapId,
3296
- source: source
3297
- })
3298
- }), !!hasDataExplorer && /*#__PURE__*/jsx(Grid, {
3299
- size: 12,
3300
- children: /*#__PURE__*/jsx(DataExplorerButtonConnect, {
3301
- mapId: mapId
3302
- })
3303
- })]
3304
- })
3305
- }), /*#__PURE__*/jsx(Box, {
3306
- sx: {
3307
- position: 'absolute',
3308
- margin: '8px 0 0 calc(100% - 40px)',
3309
- zIndex: 2
3310
- },
3311
- children: /*#__PURE__*/jsx(ServiceOptionsButton, {
3312
- mapId: mapId
3313
- })
3314
- }), /*#__PURE__*/jsx(Box, {
3315
- sx: hasDataExplorer ? {
3316
- minHeight: '52px'
3317
- } : {},
3318
- children: /*#__PURE__*/jsx(ServiceListConnect, {
3319
- setHeight: handleHeightChange
3320
- })
3321
- }), /*#__PURE__*/jsx(Box, {
3322
- sx: {
3323
- padding: '0 16px'
3324
- },
3325
- children: /*#__PURE__*/jsx(LayerListConnect, {
3326
- layerSelectHeight: height,
3327
- layerSelectWidth: width,
3328
- mapId: mapId,
3329
- serviceListHeight: serviceListHeight
3330
- })
3331
- })]
3332
- });
3333
- };
3334
-
3335
- var style = {
3336
- textField: {
3337
- width: '100%',
3338
- marginBottom: 2
3339
- }
3340
- };
3341
- var getSuccesMessage = function getSuccesMessage(serviceName, t) {
3342
- return t('get-success-message', {
3343
- serviceName: serviceName
3344
- });
3345
- };
3346
- var getTitleForVariant = function getTitleForVariant(t, variant) {
3347
- switch (variant) {
3348
- case 'add':
3349
- return t('add-a-new-service');
3350
- case 'edit':
3351
- return t('edit-service-title');
3352
- case 'save':
3353
- return t('save-service-title');
3354
- default:
3355
- return 'Service';
3356
- }
3357
- };
3358
- var FormFields = /*#__PURE__*/function (FormFields) {
3359
- FormFields["serviceUrl"] = "serviceUrl";
3360
- FormFields["serviceName"] = "serviceName";
3361
- FormFields["serviceAbstracts"] = "serviceAbstracts";
3362
- return FormFields;
3363
- }(FormFields || {});
3364
- var InitialValidationsTrigger = function InitialValidationsTrigger(_ref) {
3365
- var trigger = _ref.trigger,
3366
- getValues = _ref.getValues,
3367
- onValidField = _ref.onValidField;
3368
- React.useEffect(function () {
3369
- var value = getValues(FormFields.serviceUrl);
3370
- if (value) {
3371
- void trigger(FormFields.serviceUrl).then(function (isValid) {
3372
- return isValid && onValidField(value);
3373
- });
3374
- }
3375
- // eslint-disable-next-line react-hooks/exhaustive-deps
3376
- }, []);
3377
- return null;
3378
- };
3379
- var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
3380
- var servicePopupVariant = _ref2.servicePopupVariant,
3381
- _ref2$hideBackdrop = _ref2.hideBackdrop,
3382
- hideBackdrop = _ref2$hideBackdrop === void 0 ? false : _ref2$hideBackdrop,
3383
- isOpen = _ref2.isOpen,
3384
- closePopup = _ref2.closePopup,
3385
- shouldDisableAutoFocus = _ref2.shouldDisableAutoFocus,
3386
- services = _ref2.services,
3387
- serviceSetLayers = _ref2.serviceSetLayers,
3388
- serviceUrl = _ref2.serviceUrl,
3389
- serviceName = _ref2.serviceName,
3390
- _ref2$showSnackbar = _ref2.showSnackbar,
3391
- showSnackbar = _ref2$showSnackbar === void 0 ? function () {} : _ref2$showSnackbar;
3392
- var _useLayerSelectTransl = useLayerSelectTranslation(),
3393
- t = _useLayerSelectTransl.t;
3394
- var _useFormContext = useFormContext(),
3395
- errors = _useFormContext.formState.errors,
3396
- handleSubmit = _useFormContext.handleSubmit,
3397
- setError = _useFormContext.setError,
3398
- clearErrors = _useFormContext.clearErrors,
3399
- watch = _useFormContext.watch,
3400
- trigger = _useFormContext.trigger,
3401
- getValues = _useFormContext.getValues,
3402
- setValue = _useFormContext.setValue;
3403
- var _React$useState = React.useState(false),
3404
- isLoading = _React$useState[0],
3405
- setIsLoading = _React$useState[1];
3406
- var _React$useState2 = React.useState(false),
3407
- shouldForceReload = _React$useState2[0],
3408
- setShouldForceReload = _React$useState2[1];
3409
- var fetchServiceData = /*#__PURE__*/function () {
3410
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(newServiceUrl) {
3411
- var service;
3412
- return _regeneratorRuntime().wrap(function _callee$(_context) {
3413
- while (1) switch (_context.prev = _context.next) {
3414
- case 0:
3415
- _context.prev = 0;
3416
- setIsLoading(true);
3417
- _context.next = 4;
3418
- return loadWMSService(newServiceUrl, true);
3419
- case 4:
3420
- service = _context.sent;
3421
- setValue(FormFields.serviceName, service.name);
3422
- setValue(FormFields.serviceAbstracts, service["abstract"] || '');
3423
- setIsLoading(false);
3424
- setShouldForceReload(false);
3425
- _context.next = 16;
3426
- break;
3427
- case 11:
3428
- _context.prev = 11;
3429
- _context.t0 = _context["catch"](0);
3430
- setIsLoading(false);
3431
- setShouldForceReload(true);
3432
- setError(FormFields.serviceUrl, {
3433
- message: t('validations-request-failed'),
3434
- type: 'SYSTEM'
3435
- });
3436
- case 16:
3437
- case "end":
3438
- return _context.stop();
3439
- }
3440
- }, _callee, null, [[0, 11]]);
3441
- }));
3442
- return function fetchServiceData(_x) {
3443
- return _ref3.apply(this, arguments);
3444
- };
3445
- }();
3446
- var addNewService = /*#__PURE__*/function () {
3447
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(formValues) {
3448
- var service;
3449
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
3450
- while (1) switch (_context2.prev = _context2.next) {
3451
- case 0:
3452
- clearErrors(FormFields.serviceUrl);
3453
- setIsLoading(true);
3454
- _context2.prev = 2;
3455
- _context2.next = 5;
3456
- return loadWMSService(formValues.serviceUrl, shouldForceReload);
3457
- case 5:
3458
- service = _context2.sent;
3459
- serviceSetLayers({
3460
- id: service.id,
3461
- name: formValues.serviceName,
3462
- serviceUrl: formValues.serviceUrl,
3463
- "abstract": formValues.serviceAbstracts,
3464
- layers: service.layers,
3465
- scope: 'user'
3466
- });
3467
- setIsLoading(false);
3468
- showSnackbar(getSuccesMessage(formValues.serviceName, t));
3469
- closePopup();
3470
- _context2.next = 16;
3471
- break;
3472
- case 12:
3473
- _context2.prev = 12;
3474
- _context2.t0 = _context2["catch"](2);
3475
- setIsLoading(false);
3476
- setError(FormFields.serviceUrl, {
3477
- message: t('validations-request-failed'),
3478
- type: 'SYSTEM'
3479
- });
3480
- case 16:
3481
- case "end":
3482
- return _context2.stop();
3483
- }
3484
- }, _callee2, null, [[2, 12]]);
3485
- }));
3486
- return function addNewService(_x2) {
3487
- return _ref4.apply(this, arguments);
3488
- };
3489
- }();
3490
- var onValidateServiceUrl = function onValidateServiceUrl(value) {
3491
- return validateServiceUrl(t, value, services);
3492
- };
3493
- var onFocusServiceUrl = function onFocusServiceUrl() {
3494
- var hasValue = getValues(FormFields.serviceUrl);
3495
- if (!errors[FormFields.serviceUrl] && hasValue) {
3496
- void trigger(FormFields.serviceUrl);
3497
- }
3498
- };
3499
- var onBlurServiceUrl = function onBlurServiceUrl() {
3500
- void trigger(FormFields.serviceUrl).then(function () {
3501
- var hasValue = getValues(FormFields.serviceUrl);
3502
- if (!errors[FormFields.serviceUrl] && hasValue) {
3503
- void fetchServiceData(getValues(FormFields.serviceUrl));
3504
- }
3505
- });
3506
- };
3507
- var onKeyDownServiceUrl = function onKeyDownServiceUrl(event) {
3508
- if (event.key === 'Enter') {
3509
- onBlurServiceUrl();
3510
- }
3511
- };
3512
- var onValidateServiceName = function onValidateServiceName(value) {
3513
- return validateServiceName(t, value, services, serviceName);
3514
- };
3515
- var getFormAreRequiredFieldsEmpty = function getFormAreRequiredFieldsEmpty() {
3516
- var serviceNameField = watch(FormFields.serviceName);
3517
- var serviceUrlField = watch(FormFields.serviceUrl);
3518
- return serviceNameField === '' || serviceNameField === undefined || serviceUrlField === '' || serviceUrlField === undefined;
3519
- };
3520
- var getFormHasformErrors = function getFormHasformErrors() {
3521
- var totalErrors = Object.keys(errors).length;
3522
- if (totalErrors > 0) {
3523
- // prevent SYSTEM error types from blocking the save button
3524
- if (totalErrors === 1 && errors.serviceUrl) {
3525
- return errors.serviceUrl.type !== undefined && errors.serviceUrl.type !== 'SYSTEM';
3526
- }
3527
- return true;
3528
- }
3529
- return false;
3530
- };
3531
- var isSubmitDisabled = getFormHasformErrors() || getFormAreRequiredFieldsEmpty();
3532
- var isShowPopup = servicePopupVariant === 'show';
3533
- var isServiceUrlDisabled = isShowPopup || servicePopupVariant === 'edit';
3534
- return /*#__PURE__*/jsx(CustomDialog, {
3535
- actions: isShowPopup ? /*#__PURE__*/jsx(Button, {
3536
- onClick: function onClick() {
3537
- return closePopup();
3538
- },
3539
- sx: {
3540
- width: {
3541
- xs: '100%',
3542
- sm: '117px'
3543
- }
3544
- },
3545
- variant: "tertiary",
3546
- children: t('close')
3547
- }) : /*#__PURE__*/jsxs(Fragment, {
3548
- children: [/*#__PURE__*/jsx(Button, {
3549
- "data-testid": "closePopupButtonCancel",
3550
- onClick: closePopup,
3551
- sx: {
3552
- width: {
3553
- xs: '100%',
3554
- sm: '117px'
3555
- }
3556
- },
3557
- variant: "tertiary",
3558
- children: t('cancel')
3559
- }), /*#__PURE__*/jsx(Button, {
3560
- "data-testid": "saveServiceButton",
3561
- disabled: isSubmitDisabled || isLoading,
3562
- form: "servicePopupForm",
3563
- sx: {
3564
- marginLeft: {
3565
- xs: '0px!important',
3566
- sm: '8px!important'
3567
- },
3568
- width: {
3569
- xs: '100%',
3570
- sm: '117px'
3571
- }
3572
- },
3573
- type: "submit",
3574
- variant: "primary",
3575
- children: t('save')
3576
- })]
3577
- }),
3578
- "data-testid": "servicePopup",
3579
- fullWidth: true,
3580
- hideBackdrop: hideBackdrop,
3581
- maxWidth: "xs",
3582
- onClose: function onClose() {
3583
- return closePopup == null ? void 0 : closePopup();
3584
- },
3585
- open: isOpen,
3586
- sx: {
3587
- '& .MuiDialog-paper': {
3588
- backgroundColor: "geowebColors.cards.cardContainer",
3589
- maxWidth: 458
3590
- }
3591
- },
3592
- title: getTitleForVariant(t, servicePopupVariant),
3593
- children: /*#__PURE__*/jsxs("form", {
3594
- id: "servicePopupForm",
3595
- onSubmit: handleSubmit(/*#__PURE__*/function () {
3596
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(formValues) {
3597
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3598
- while (1) switch (_context3.prev = _context3.next) {
3599
- case 0:
3600
- return _context3.abrupt("return", addNewService(formValues));
3601
- case 1:
3602
- case "end":
3603
- return _context3.stop();
3604
- }
3605
- }, _callee3);
3606
- }));
3607
- return function (_x3) {
3608
- return _ref5.apply(this, arguments);
3609
- };
3610
- }()),
3611
- children: [!!isLoading && /*#__PURE__*/jsx(Box, {
3612
- sx: {
3613
- position: 'relative'
3614
- },
3615
- children: /*#__PURE__*/jsx(LinearProgress, {
3616
- color: "secondary",
3617
- "data-testid": "loadingIndicator",
3618
- sx: {
3619
- position: 'absolute',
3620
- width: '100%',
3621
- top: 8
3622
- }
3623
- })
3624
- }), /*#__PURE__*/jsx(ReactHookFormTextField, {
3625
- autoFocus: !shouldDisableAutoFocus,
3626
- defaultValue: serviceUrl,
3627
- disabled: isServiceUrlDisabled || isLoading,
3628
- inputSlotProps: {
3629
- disableUnderline: isShowPopup,
3630
- endAdornment: isShowPopup && /*#__PURE__*/jsx(InputAdornment, {
3631
- position: "end",
3632
- children: /*#__PURE__*/jsx(CustomIconButton, {
3633
- "aria-label": "copy url",
3634
- onClick: function onClick() {
3635
- void navigator.clipboard.writeText(serviceUrl);
3636
- showSnackbar(t('copy-url-message'));
3637
- },
3638
- sx: {
3639
- marginTop: 0.5
3640
- },
3641
- children: /*#__PURE__*/jsx(Copy, {})
3642
- })
3643
- })
3644
- },
3645
- isReadOnly: isShowPopup,
3646
- label: t('service-url-label'),
3647
- name: FormFields.serviceUrl,
3648
- onBlur: onBlurServiceUrl,
3649
- onFocus: onFocusServiceUrl,
3650
- onKeyDown: onKeyDownServiceUrl,
3651
- rules: {
3652
- required: true,
3653
- validate: Object.assign({}, !isServiceUrlDisabled && {
3654
- onValidateServiceUrl: onValidateServiceUrl
3655
- })
3656
- },
3657
- sx: style.textField
3658
- }), /*#__PURE__*/jsx(ReactHookFormTextField, {
3659
- defaultValue: serviceName,
3660
- disabled: isShowPopup || isLoading,
3661
- inputSlotProps: {
3662
- disableUnderline: isShowPopup
3663
- },
3664
- isReadOnly: isShowPopup,
3665
- label: t('service-name-label'),
3666
- name: FormFields.serviceName,
3667
- rules: {
3668
- required: true,
3669
- validate: {
3670
- onValidateServiceName: onValidateServiceName
3671
- }
3672
- },
3673
- sx: style.textField
3674
- }), /*#__PURE__*/jsx(ReactHookFormTextField, {
3675
- defaultValue: "",
3676
- disabled: isShowPopup || isLoading,
3677
- helperText: !isShowPopup ? t('service-popup-helper-text') : '',
3678
- inputSlotProps: {
3679
- disableUnderline: isShowPopup
3680
- },
3681
- isReadOnly: isShowPopup,
3682
- label: t('service-abstracts-label'),
3683
- multiline: true,
3684
- name: FormFields.serviceAbstracts,
3685
- rows: 4,
3686
- sx: style.textField
3687
- }), !isServiceUrlDisabled && /*#__PURE__*/jsx(InitialValidationsTrigger, {
3688
- getValues: getValues,
3689
- onValidField: fetchServiceData,
3690
- trigger: trigger
3691
- })]
3692
- })
3693
- });
3694
- };
3695
- var ServicePopup = function ServicePopup(_ref6) {
3696
- var props = Object.assign({}, (_objectDestructuringEmpty(_ref6), _ref6));
3697
- return /*#__PURE__*/jsx(ReactHookFormProvider, {
3698
- options: Object.assign({}, defaultFormOptions, {
3699
- defaultValues: {
3700
- serviceUrl: props.serviceUrl,
3701
- serviceName: props.serviceName,
3702
- serviceAbstracts: props.serviceAbstracts
3703
- }
3704
- }),
3705
- children: /*#__PURE__*/jsx(ServicePopupUnwrapped, Object.assign({}, props))
3706
- });
3707
- };
3708
-
3709
- /* *
3710
- * Licensed under the Apache License, Version 2.0 (the "License");
3711
- * you may not use this file except in compliance with the License.
3712
- * You may obtain a copy of the License at
3713
- *
3714
- * http://www.apache.org/licenses/LICENSE-2.0
3715
- *
3716
- * Unless required by applicable law or agreed to in writing, software
3717
- * distributed under the License is distributed on an "AS IS" BASIS,
3718
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3719
- * See the License for the specific language governing permissions and
3720
- * limitations under the License.
3721
- *
3722
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3723
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
3724
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3725
- * */
3726
-
3727
- // Extracted from ServicePopupDialog as the getActiveServices and getActiveServiceById selectors
3728
- // Result in many rerenders. By extracting we're able to only render this component and these selectors
3729
- // when the dialog is open
3730
- var ServicePopupDialogConnect = function ServicePopupDialogConnect(_ref) {
3731
- var isOpen = _ref.isOpen,
3732
- _ref$serviceId = _ref.serviceId,
3733
- serviceId = _ref$serviceId === void 0 ? '' : _ref$serviceId,
3734
- variant = _ref.variant,
3735
- _ref$url = _ref.url,
3736
- url = _ref$url === void 0 ? '' : _ref$url,
3737
- setServicePopupClosed = _ref.setServicePopupClosed;
3738
- var dispatch = useDispatch();
3739
- var services = useAppSelector(function (store) {
3740
- return getActiveServices(store);
3741
- });
3742
- var activeService = useAppSelector(function (store) {
3743
- return getActiveServiceById(store, serviceId);
3744
- });
3745
- var serviceSetLayers = React.useCallback(function (payload) {
3746
- dispatch(serviceActions.serviceSetLayers(payload));
3747
- }, [dispatch]);
3748
- var showSnackbar = React.useCallback(function (message) {
3749
- dispatch(snackbarActions.openSnackbar({
3750
- type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
3751
- message: message
3752
- }));
3753
- }, [dispatch]);
3754
- return /*#__PURE__*/jsx(ServicePopup, {
3755
- closePopup: setServicePopupClosed,
3756
- isOpen: isOpen,
3757
- serviceAbstracts: activeService == null ? void 0 : activeService["abstract"],
3758
- serviceId: serviceId,
3759
- serviceName: activeService == null ? void 0 : activeService.serviceName,
3760
- servicePopupVariant: variant,
3761
- serviceSetLayers: serviceSetLayers,
3762
- serviceUrl: url || (activeService == null ? void 0 : activeService.serviceUrl),
3763
- services: services,
3764
- showSnackbar: showSnackbar
3765
- });
3766
- };
3767
-
3768
- /* *
3769
- * Licensed under the Apache License, Version 2.0 (the "License");
3770
- * you may not use this file except in compliance with the License.
3771
- * You may obtain a copy of the License at
3772
- *
3773
- * http://www.apache.org/licenses/LICENSE-2.0
3774
- *
3775
- * Unless required by applicable law or agreed to in writing, software
3776
- * distributed under the License is distributed on an "AS IS" BASIS,
3777
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3778
- * See the License for the specific language governing permissions and
3779
- * limitations under the License.
3780
- *
3781
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3782
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
3783
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3784
- * */
3785
-
3786
- var ServicePopupConnect = function ServicePopupConnect() {
3787
- var dispatch = useDispatch();
3788
- var _useAppSelector = useAppSelector(function (store) {
3789
- return getServicePopupDetails(store);
3790
- }),
3791
- isOpen = _useAppSelector.isOpen,
3792
- url = _useAppSelector.url,
3793
- serviceId = _useAppSelector.serviceId,
3794
- variant = _useAppSelector.variant;
3795
- var setServicePopupClosed = React.useCallback(function () {
3796
- dispatch(layerSelectActions.closeServicePopupOpen());
3797
- }, [dispatch]);
3798
- if (!isOpen) {
3799
- return null;
3800
- }
3801
- return /*#__PURE__*/jsx(ServicePopupDialogConnect, {
3802
- isOpen: isOpen,
3803
- serviceId: serviceId,
3804
- setServicePopupClosed: setServicePopupClosed,
3805
- url: url,
3806
- variant: variant
3807
- });
3808
- };
3809
-
3810
- /* *
3811
- * Licensed under the Apache License, Version 2.0 (the "License");
3812
- * you may not use this file except in compliance with the License.
3813
- * You may obtain a copy of the License at
3814
- *
3815
- * http://www.apache.org/licenses/LICENSE-2.0
3816
- *
3817
- * Unless required by applicable law or agreed to in writing, software
3818
- * distributed under the License is distributed on an "AS IS" BASIS,
3819
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3820
- * See the License for the specific language governing permissions and
3821
- * limitations under the License.
3822
- *
3823
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3824
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3825
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
3826
- * */
3827
-
3828
- /**
3829
- * LayerSelectConnect is a component that is opened from LayerManager
3830
- * It's used to add Services and Layers to the application
3831
- * It doesn't expect any props, its subcomponents only read and write to redux store
3832
- *
3833
- * ``` <LayerSelectConnect />```
3834
- */
3835
- var LayerSelectConnect = function LayerSelectConnect(_ref) {
3836
- var _ref$mapId = _ref.mapId,
3837
- initialMapId = _ref$mapId === void 0 ? null : _ref$mapId,
3838
- bounds = _ref.bounds,
3839
- _ref$showTitle = _ref.showTitle,
3840
- showTitle = _ref$showTitle === void 0 ? false : _ref$showTitle,
3841
- _ref$isMultiMap = _ref.isMultiMap,
3842
- isMultiMap = _ref$isMultiMap === void 0 ? false : _ref$isMultiMap;
3843
- var dialogType = isMultiMap ? uiTypes.DialogTypes.LayerSelect + "-" + initialMapId : uiTypes.DialogTypes.LayerSelect;
3844
- var mapId = useAppSelector(function (store) {
3845
- return uiSelectors.getDialogMapId(store, dialogType);
3846
- });
3847
- var _useSetupDialog = useSetupDialog(dialogType),
3848
- dialogOrder = _useSetupDialog.dialogOrder,
3849
- isDialogOpen = _useSetupDialog.isDialogOpen,
3850
- onCloseDialog = _useSetupDialog.onCloseDialog,
3851
- setDialogOrder = _useSetupDialog.setDialogOrder,
3852
- uiSource = _useSetupDialog.uiSource;
3853
- var config = sessionStorageProvider.getConfig();
3854
- var hasDataExplorer = !!config.GW_DATA_EXPLORER_CONFIGURATION_FILENAME;
3855
- return /*#__PURE__*/jsxs(Fragment, {
3856
- children: [/*#__PURE__*/jsx(LayerSelect, {
3857
- bounds: bounds,
3858
- hasDataExplorer: hasDataExplorer,
3859
- isMultiMap: isMultiMap,
3860
- isOpen: isDialogOpen,
3861
- mapId: mapId || initialMapId,
3862
- onClose: onCloseDialog,
3863
- onMouseDown: setDialogOrder,
3864
- order: dialogOrder,
3865
- showTitle: showTitle,
3866
- source: uiSource
3867
- }), /*#__PURE__*/jsx(KeywordFilterResultsConnect, {
3868
- isMultiMap: isMultiMap,
3869
- mapId: mapId || initialMapId
3870
- }), /*#__PURE__*/jsx(ServicePopupConnect, {})]
3871
- });
3872
- };
3873
-
3874
- export { AllChipConnect, DataExplorerButtonConnect, KeywordFilterButtonConnect, KeywordFilterResults, KeywordFilterResultsConnect, KeywordFilterResultsListItemConnect, KeywordFilterSelectAllSwitchConnect, LAYER_SELECT_NAMESPACE, LayerAddRemoveButton, LayerList, LayerListConnect, LayerListDimensions, LayerListRow, LayerSelectButtonConnect, LayerSelectConnect, SearchFieldConnect, ServiceChip, ServiceChipConnect, ServiceList, ServiceListConnect, ServiceOptionsButton, ServiceOptionsDialog, ServiceOptionsDialogConnect, ServicePopup, ServicePopupConnect, ServicePopupDialogConnect, createMockStore, getServiceSuccesUpdateMessage, getSuccesMessage, isUserAddedService, layerSelectActions, initialState as layerSelectInitialState, layerSelectListener, layerSelectMiddlewares, layerSelectReducer, layerSelectReducersMap, selectors as layerSelectSelectors, layerSelectTranslations, types as layerSelectTypes, useAppSelector };