@opengeoweb/core 4.6.0 → 4.6.1

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 CHANGED
@@ -7,7 +7,7 @@ import _, { debounce, isEqual, groupBy, throttle, range } from 'lodash';
7
7
  import { takeLatest, put, select, call, takeEvery, all, delay } from 'redux-saga/effects';
8
8
  import { connect, useDispatch, useSelector, Provider } from 'react-redux';
9
9
  import { CustomTooltip, ToolButton, ToolContainerDraggable, IS_JEST, TooltipSelect, AlertIcon, useControlledTooltip, tooltipContainerStyles, sliderHeaderStyle, CustomSlider, ToggleMenu, ManagerButton, CustomAccordion, EnableButton, ManagerDeleteButton, AlertBanner, calculateDialogSizeAndPosition, useIsMounted, CustomToggleButton, useMakeSureContainerStaysInsideWindow, withEggs } from '@opengeoweb/shared';
10
- import { Pause, Play, Add, Copy, Both, None, DragHandle as DragHandle$1, Cached, CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, Filter, Search, Clear, Close, Info, DimensionsOther, DimensionsElevation, DimensionsRefTime, DimensionsTime, Edit, Visibility, Delete, Home, Minus, Layers, Equalizer, Link, LinkOff, AutoUpdateActive, AutoUpdateInActive, TextIcon, Speed, FastForward, Clock, Now, Animation, Options, StepForward, StepBackward, dragHandlePath, ChevronDown, ChevronUp, List as List$1, ChevronRight, ChevronLeft, Resize, ThemeWrapper, lightTheme } from '@opengeoweb/theme';
10
+ import { Pause, Play, Add, Copy, Both, None, DragHandle as DragHandle$1, Cached, CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, Filter, Search, Clear, Close, Info, DimensionsOther, DimensionsElevation, DimensionsRefTime, DimensionsTime, Edit, Visibility, Delete, Home, Minus, Layers, Equalizer, Link, LinkOff, AutoUpdateActive, AutoUpdateInActive, TextIcon, Speed, FastForward, Clock, Now, Animation, Options, StepForward, StepBackward, dragHandlePath, ChevronDown, ChevronUp, List as List$1, ChevronRight, ChevronLeft, Resize, ExitDomain, ThemeWrapper, lightTheme } from '@opengeoweb/theme';
11
11
  import { Paper, Box, Typography, IconButton, Grid, MenuItem, Button, Popper, FormControl, InputLabel, List, ListItem, ListItemText, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, DialogActions, LinearProgress, InputAdornment, Backdrop, ListItemSecondaryAction, ListItemIcon, Checkbox, Switch, styled, Slider, Menu, useTheme, Snackbar } from '@mui/material';
12
12
  import { legendImageStore, WMImageEventType, getLegendGraphicURLForLayer, WMGetServiceFromStore, LayerType as LayerType$1, clearImageCache, getMapImageStore, WMBBOX, debug, DebugType, WMJSMap, WMLayer } from '@opengeoweb/webmap';
13
13
  import { ReactSortable } from 'react-sortablejs';
@@ -25,6 +25,8 @@ import proj4 from 'proj4';
25
25
  import * as turf from '@turf/turf';
26
26
  import Draggable from 'react-draggable';
27
27
  import { Resizable } from 're-resizable';
28
+ import axios from 'axios';
29
+ import { useDebounce } from '@opengeoweb/api';
28
30
  import { createStore } from '@redux-eggs/redux-toolkit';
29
31
  import { getSagaExtension } from '@redux-eggs/saga-extension';
30
32
 
@@ -4422,17 +4424,54 @@ var FilterType;
4422
4424
  FilterType["Group"] = "groups";
4423
4425
  })(FilterType || (FilterType = {}));
4424
4426
 
4427
+ /* *
4428
+ * Licensed under the Apache License, Version 2.0 (the "License");
4429
+ * you may not use this file except in compliance with the License.
4430
+ * You may obtain a copy of the License at
4431
+ *
4432
+ * http://www.apache.org/licenses/LICENSE-2.0
4433
+ *
4434
+ * Unless required by applicable law or agreed to in writing, software
4435
+ * distributed under the License is distributed on an "AS IS" BASIS,
4436
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4437
+ * See the License for the specific language governing permissions and
4438
+ * limitations under the License.
4439
+ *
4440
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
4441
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
4442
+ * */
4443
+ var getFilterId = function getFilterId(filterType, filterName) {
4444
+ return "".concat(filterType, "-").concat(filterName);
4445
+ };
4446
+ var produceFilters = function produceFilters(filterNames, filterType, draft, layerSelectFilterAdapter) {
4447
+ filterNames.forEach(function (filterName) {
4448
+ var id = getFilterId(filterType, filterName);
4449
+
4450
+ if (!draft.filters.filters.entities[id]) {
4451
+ // If this filter doesn't exit yet, add it
4452
+ layerSelectFilterAdapter.addOne(draft.filters.filters, {
4453
+ id: id,
4454
+ name: filterName,
4455
+ amount: 1,
4456
+ amountVisible: 1,
4457
+ checked: true,
4458
+ type: filterType
4459
+ });
4460
+ } else {
4461
+ // If it exists already, up the amounts
4462
+ draft.filters.filters.entities[id].amount += 1;
4463
+ draft.filters.filters.entities[id].amountVisible += 1;
4464
+ }
4465
+ });
4466
+ };
4467
+
4468
+ var layerSelectFilterAdapter = createEntityAdapter();
4469
+ var layerSelectActiveServicesAdapter = createEntityAdapter();
4425
4470
  var initialState$1 = {
4426
4471
  filters: {
4427
4472
  searchFilter: '',
4428
- activeServices: {
4429
- byId: {},
4430
- allIds: []
4431
- },
4432
- filters: {
4433
- byId: {},
4434
- allIds: []
4435
- }
4473
+ activeServices: layerSelectActiveServicesAdapter.getInitialState(),
4474
+ filters: layerSelectFilterAdapter.getInitialState()
4436
4475
  },
4437
4476
  allServicesEnabled: true,
4438
4477
  activeLayerInfo: {
@@ -4456,6 +4495,8 @@ var slice$1 = createSlice({
4456
4495
  draft.allServicesEnabled = allServicesEnabled;
4457
4496
  },
4458
4497
  addFiltersAndActiveServices: function addFiltersAndActiveServices(draft, action) {
4498
+ var _a, _b;
4499
+
4459
4500
  var _action$payload = action.payload,
4460
4501
  serviceId = _action$payload.serviceId,
4461
4502
  serviceName = _action$payload.serviceName,
@@ -4463,59 +4504,59 @@ var slice$1 = createSlice({
4463
4504
  _abstract = _action$payload["abstract"],
4464
4505
  keywords = _action$payload.keywords,
4465
4506
  scope = _action$payload.scope,
4466
- groups = _action$payload.groups;
4467
-
4468
- if (!draft.filters.activeServices.byId[serviceId]) {
4469
- draft.filters.activeServices.byId[serviceId] = {};
4470
-
4471
- var addFilters = function addFilters(filterNames, filterType) {
4472
- filterNames.forEach(function (filterName) {
4473
- var id = "".concat(filterType, "-").concat(filterName);
4474
-
4475
- if (!draft.filters.filters.byId[id]) {
4476
- draft.filters.filters.byId[id] = {
4477
- id: id,
4478
- name: filterName,
4479
- amount: 1,
4480
- amountVisible: 1,
4481
- checked: true,
4482
- type: filterType
4483
- };
4484
- draft.filters.filters.allIds.push(id);
4485
- } else {
4486
- draft.filters.filters.byId[id].amount += 1;
4487
- draft.filters.filters.byId[id].amountVisible += 1;
4488
- }
4489
- });
4507
+ groups = _action$payload.groups,
4508
+ isLoading = _action$payload.isLoading;
4509
+
4510
+ if (isLoading) {
4511
+ // If service is still loading, add without filters
4512
+ draft.filters.activeServices.entities[serviceId] = {
4513
+ serviceId: serviceId,
4514
+ enabled: draft.allServicesEnabled,
4515
+ filterIds: [],
4516
+ scope: scope,
4517
+ serviceName: serviceName,
4518
+ serviceUrl: serviceUrl,
4519
+ "abstract": _abstract,
4520
+ isLoading: isLoading
4490
4521
  };
4522
+ }
4491
4523
 
4492
- addFilters(groups, FilterType.Group);
4493
- addFilters(keywords, FilterType.Keyword);
4524
+ if (!isLoading) {
4525
+ // If service is done loading, add with filters
4526
+ if (!((_b = (_a = draft.filters.activeServices.entities[serviceId]) === null || _a === void 0 ? void 0 : _a.filterIds) === null || _b === void 0 ? void 0 : _b.length)) {
4527
+ // If the service has no filters yet, add them
4528
+ produceFilters(groups, FilterType.Group, draft, layerSelectFilterAdapter);
4529
+ produceFilters(keywords, FilterType.Keyword, draft, layerSelectFilterAdapter);
4530
+ }
4531
+
4532
+ var filterIds = groups.map(function (group) {
4533
+ return getFilterId(FilterType.Group, group);
4534
+ }).concat(keywords.map(function (keyword) {
4535
+ return getFilterId(FilterType.Keyword, keyword);
4536
+ }));
4537
+ draft.filters.activeServices.entities[serviceId] = {
4538
+ serviceId: serviceId,
4539
+ enabled: draft.allServicesEnabled,
4540
+ filterIds: filterIds,
4541
+ scope: scope,
4542
+ serviceName: serviceName,
4543
+ serviceUrl: serviceUrl,
4544
+ "abstract": _abstract,
4545
+ isLoading: isLoading
4546
+ };
4494
4547
  }
4495
4548
 
4496
- var filterIds = groups.map(function (group) {
4497
- return "".concat(FilterType.Group, "-").concat(group);
4498
- }).concat(keywords.map(function (keyword) {
4499
- return "".concat(FilterType.Keyword, "-").concat(keyword);
4500
- }));
4501
- draft.filters.activeServices.byId[serviceId] = {
4502
- serviceId: serviceId,
4503
- enabled: draft.allServicesEnabled,
4504
- filterIds: filterIds,
4505
- scope: scope,
4506
- serviceName: serviceName,
4507
- serviceUrl: serviceUrl,
4508
- "abstract": _abstract
4509
- };
4510
- if (!draft.filters.activeServices.allIds.includes(serviceId)) draft.filters.activeServices.allIds.push(serviceId);
4549
+ if (!draft.filters.activeServices.ids.includes(serviceId)) {
4550
+ draft.filters.activeServices.ids.push(serviceId);
4551
+ }
4511
4552
  },
4512
4553
  layerSelectRemoveService: function layerSelectRemoveService(draft, action) {
4513
4554
  var serviceId = action.payload.serviceId; // 1. Find a service that is to be removed
4514
4555
 
4515
- var foundService = draft.filters.activeServices.byId[serviceId]; // 2. Go through all keywords for removed service, and decrement the amount of all found keywords
4556
+ var foundService = draft.filters.activeServices.entities[serviceId]; // 2. Go through all keywords for removed service, and decrement the amount of all found keywords
4516
4557
 
4517
4558
  foundService.filterIds.forEach(function (filterId) {
4518
- var foundObject = draft.filters.filters.byId[filterId];
4559
+ var foundObject = draft.filters.filters.entities[filterId];
4519
4560
 
4520
4561
  if (foundObject && foundObject.amount) {
4521
4562
  foundObject.amount -= 1;
@@ -4523,23 +4564,20 @@ var slice$1 = createSlice({
4523
4564
  }
4524
4565
 
4525
4566
  if (foundObject && foundObject.amount === 0) {
4526
- delete draft.filters.filters.byId[filterId];
4527
- draft.filters.filters.allIds = draft.filters.filters.allIds.filter(function (serviceId) {
4567
+ delete draft.filters.filters.entities[filterId];
4568
+ draft.filters.filters.ids = draft.filters.filters.ids.filter(function (serviceId) {
4528
4569
  return serviceId !== filterId;
4529
4570
  });
4530
4571
  }
4531
4572
  }); // Finally remove object from activeServices, so if the service is added again later on, new object and keywords will be re-added
4532
4573
 
4533
- delete draft.filters.activeServices.byId[serviceId];
4534
- draft.filters.activeServices.allIds = draft.filters.activeServices.allIds.filter(function (id) {
4535
- return id !== serviceId;
4536
- });
4574
+ layerSelectActiveServicesAdapter.removeOne(draft.filters.activeServices, serviceId);
4537
4575
  },
4538
4576
  enableActiveService: function enableActiveService(draft, action) {
4539
4577
  var _action$payload2 = action.payload,
4540
4578
  serviceId = _action$payload2.serviceId,
4541
4579
  keywords = _action$payload2.filters;
4542
- draft.filters.activeServices.byId[serviceId].enabled = true;
4580
+ draft.filters.activeServices.entities[serviceId].enabled = true;
4543
4581
 
4544
4582
  var _iterator = _createForOfIteratorHelper(keywords),
4545
4583
  _step;
@@ -4547,7 +4585,7 @@ var slice$1 = createSlice({
4547
4585
  try {
4548
4586
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
4549
4587
  var keyword = _step.value;
4550
- draft.filters.filters.byId[keyword].amountVisible += 1;
4588
+ draft.filters.filters.entities[keyword].amountVisible += 1;
4551
4589
  }
4552
4590
  } catch (err) {
4553
4591
  _iterator.e(err);
@@ -4559,7 +4597,7 @@ var slice$1 = createSlice({
4559
4597
  var _action$payload3 = action.payload,
4560
4598
  serviceId = _action$payload3.serviceId,
4561
4599
  keywords = _action$payload3.filters;
4562
- draft.filters.activeServices.byId[serviceId].enabled = false;
4600
+ draft.filters.activeServices.entities[serviceId].enabled = false;
4563
4601
 
4564
4602
  var _iterator2 = _createForOfIteratorHelper(keywords),
4565
4603
  _step2;
@@ -4567,7 +4605,7 @@ var slice$1 = createSlice({
4567
4605
  try {
4568
4606
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4569
4607
  var keyword = _step2.value;
4570
- draft.filters.filters.byId[keyword].amountVisible -= 1;
4608
+ draft.filters.filters.entities[keyword].amountVisible -= 1;
4571
4609
  }
4572
4610
  } catch (err) {
4573
4611
  _iterator2.e(err);
@@ -4578,15 +4616,15 @@ var slice$1 = createSlice({
4578
4616
  toggleFilter: function toggleFilter(draft, action) {
4579
4617
  var filterIds = action.payload.filterIds;
4580
4618
  filterIds.forEach(function (filterId) {
4581
- draft.filters.filters.byId[filterId].checked = !draft.filters.filters.byId[filterId].checked;
4619
+ draft.filters.filters.entities[filterId].checked = !draft.filters.filters.entities[filterId].checked;
4582
4620
  });
4583
4621
  },
4584
4622
  enableOnlyOneFilter: function enableOnlyOneFilter(draft, action) {
4585
4623
  var filterId = action.payload.filterId;
4586
- draft.filters.filters.allIds.forEach(function (filterId) {
4587
- draft.filters.filters.byId[filterId].checked = false;
4624
+ draft.filters.filters.ids.forEach(function (filterId) {
4625
+ draft.filters.filters.entities[filterId].checked = false;
4588
4626
  });
4589
- draft.filters.filters.byId[filterId].checked = true;
4627
+ draft.filters.filters.entities[filterId].checked = true;
4590
4628
  },
4591
4629
  setActiveLayerInfo: function setActiveLayerInfo(draft, action) {
4592
4630
  var layer = action.payload.layer;
@@ -4682,21 +4720,32 @@ var layerSelectStore = function layerSelectStore(store) {
4682
4720
 
4683
4721
 
4684
4722
  var getSearchFilter = createSelector(layerSelectStore, function (store) {
4685
- return store ? store.filters.searchFilter : '';
4723
+ var _a;
4724
+
4725
+ return ((_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.searchFilter) || '';
4686
4726
  });
4687
4727
  /**
4688
4728
  * Returns active services array
4689
4729
  *
4690
4730
  * Example getActiveServices(store);
4691
4731
  * @param {object} store store: object - store object
4692
- * @returns {object} returnType: object of active services
4732
+ * @returns {ActiveServiceObjectEntities} returnType: ActiveServiceObjectEntitiesobject of active services
4693
4733
  */
4734
+ // cast to usable type - selectEntities returns Dictionary<ActiveServiceObject> which is not usable inside of the code
4694
4735
 
4695
- var getActiveServices = createSelector(layerSelectStore, function (store) {
4696
- var _a;
4736
+ var getActiveServices = function getActiveServices(store) {
4737
+ return getActiveServicesDictionary(store);
4738
+ };
4697
4739
 
4698
- return store ? (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.activeServices.byId : {};
4699
- }, selectorMemoizationOptions);
4740
+ var _layerSelectActiveSer = layerSelectActiveServicesAdapter.getSelectors(function (store) {
4741
+ var _a, _b;
4742
+
4743
+ return ((_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.activeServices) || {
4744
+ entities: {},
4745
+ ids: []
4746
+ };
4747
+ }),
4748
+ getActiveServicesDictionary = _layerSelectActiveSer.selectEntities;
4700
4749
  /**
4701
4750
  * Returns active services by id
4702
4751
  *
@@ -4706,10 +4755,11 @@ var getActiveServices = createSelector(layerSelectStore, function (store) {
4706
4755
  * @returns {object} returnType: object of active service
4707
4756
  */
4708
4757
 
4758
+
4709
4759
  var getActiveServiceById = function getActiveServiceById(store, serviceId) {
4710
- var _a, _b;
4760
+ var _a, _b, _c;
4711
4761
 
4712
- var enabledServices = ((_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.activeServices.byId[serviceId]) || {};
4762
+ var enabledServices = ((_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.activeServices) === null || _c === void 0 ? void 0 : _c.entities[serviceId]) || {};
4713
4763
  return enabledServices;
4714
4764
  };
4715
4765
  /**
@@ -4723,10 +4773,10 @@ var getActiveServiceById = function getActiveServiceById(store, serviceId) {
4723
4773
  var getEnabledServiceIds = createSelector(layerSelectStore, function (store) {
4724
4774
  var _a, _b;
4725
4775
 
4726
- var enabledServices = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.activeServices.allIds.filter(function (serviceId) {
4727
- var _a;
4776
+ var enabledServices = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.activeServices.ids.filter(function (serviceId) {
4777
+ var _a, _b, _c;
4728
4778
 
4729
- return (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.activeServices.byId[serviceId].enabled;
4779
+ return (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.activeServices) === null || _b === void 0 ? void 0 : _b.entities[serviceId]) === null || _c === void 0 ? void 0 : _c.enabled;
4730
4780
  })) !== null && _b !== void 0 ? _b : [];
4731
4781
  return enabledServices;
4732
4782
  }, selectorMemoizationOptions);
@@ -4739,17 +4789,17 @@ var getEnabledServiceIds = createSelector(layerSelectStore, function (store) {
4739
4789
  */
4740
4790
 
4741
4791
  var getCheckedFilterIds = createSelector(layerSelectStore, function (store) {
4742
- var _a, _b;
4792
+ var _a, _b, _c;
4743
4793
 
4744
- var checkedFilters = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters.allIds.filter(function (filterId) {
4745
- var _a, _b;
4794
+ var checkedFilters = (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.ids.filter(function (filterId) {
4795
+ var _a, _b, _c;
4746
4796
 
4747
- return (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters.byId[filterId]) === null || _b === void 0 ? void 0 : _b.checked;
4748
- })) !== null && _b !== void 0 ? _b : [];
4797
+ return (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.entities[filterId]) === null || _c === void 0 ? void 0 : _c.checked;
4798
+ })) !== null && _c !== void 0 ? _c : [];
4749
4799
  return checkedFilters.map(function (filterId) {
4750
- var _a;
4800
+ var _a, _b, _c;
4751
4801
 
4752
- return (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters.byId[filterId].id;
4802
+ return (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.entities[filterId]) === null || _c === void 0 ? void 0 : _c.id;
4753
4803
  });
4754
4804
  }, selectorMemoizationOptions);
4755
4805
  /**
@@ -4759,12 +4809,21 @@ var getCheckedFilterIds = createSelector(layerSelectStore, function (store) {
4759
4809
  * @param {object} store store: object - store object
4760
4810
  * @returns {array} returnType: array of all keyword ids
4761
4811
  */
4812
+ // cast to usable type - selectIds returns EntityId[] which is not usable inside of the code
4813
+
4814
+ var getAllFilterIds = function getAllFilterIds(store) {
4815
+ return getAllFilterIdsEntity(store);
4816
+ };
4762
4817
 
4763
- var getAllFilterIds = createSelector(layerSelectStore, function (store) {
4818
+ var _layerSelectFilterAda = layerSelectFilterAdapter.getSelectors(function (store) {
4764
4819
  var _a, _b;
4765
4820
 
4766
- return (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters.allIds) !== null && _b !== void 0 ? _b : [];
4767
- }, selectorMemoizationOptions);
4821
+ return ((_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.filters) || {
4822
+ entities: {},
4823
+ ids: []
4824
+ };
4825
+ }),
4826
+ getAllFilterIdsEntity = _layerSelectFilterAda.selectIds;
4768
4827
  /**
4769
4828
  * Returns all filters
4770
4829
  *
@@ -4773,40 +4832,43 @@ var getAllFilterIds = createSelector(layerSelectStore, function (store) {
4773
4832
  * @returns {array} returnType: array of all filters
4774
4833
  */
4775
4834
 
4776
- var getAllFilters = createSelector(layerSelectStore, function (store) {
4777
- var filters = store === null || store === void 0 ? void 0 : store.filters.filters.byId;
4778
-
4779
- if (filters) {
4780
- return Object.values(filters);
4781
- }
4782
4835
 
4783
- return [];
4784
- });
4785
- /**
4786
- * Returns if all keywords are checked
4787
- *
4788
- * Example isAllKeywordsChecked(store);
4789
- * @param {object} store store: object - store object
4790
- * @returns {array} returnType: boolean if all keywords are checked
4791
- */
4836
+ var _layerSelectFilterAda2 = layerSelectFilterAdapter.getSelectors(function (store) {
4837
+ var _a, _b;
4792
4838
 
4839
+ return ((_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.filters) || {
4840
+ entities: {},
4841
+ ids: []
4842
+ };
4843
+ }),
4844
+ getAllFilters = _layerSelectFilterAda2.selectAll;
4793
4845
  var isAllFiltersChecked = createSelector(layerSelectStore, function (store) {
4794
4846
  var _a, _b;
4795
4847
 
4796
- return (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.allIds.every(function (filterId) {
4848
+ return (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.ids.every(function (filterId) {
4797
4849
  var _a, _b, _c;
4798
4850
 
4799
- return (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.byId[filterId]) === null || _c === void 0 ? void 0 : _c.checked;
4851
+ return (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.filters) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.entities[filterId]) === null || _c === void 0 ? void 0 : _c.checked;
4800
4852
  });
4801
4853
  });
4802
4854
  /**
4803
- * Returns the active layer info
4855
+ * Gets a KeywordObject by its id
4804
4856
  *
4805
- * Example getActiveLayerInfo(store);
4806
- * @param {object} store store: object - store object
4807
- * @returns {object} returnType: ActiveLayerObject
4857
+ * Example: keywordObject = getKeywordObjectById(store, 'keywordId')
4858
+ * @param {object} store object from which the keyword state will be extracted
4859
+ * @param {string} filterId Id of the keyword
4860
+ * @returns {object} object containing keyword information (id, amount, amountVisible, checked)
4808
4861
  */
4809
4862
 
4863
+ var _layerSelectFilterAda3 = layerSelectFilterAdapter.getSelectors(function (store) {
4864
+ var _a, _b;
4865
+
4866
+ return ((_b = (_a = store === null || store === void 0 ? void 0 : store.layerSelect) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.filters) || {
4867
+ entities: {},
4868
+ ids: []
4869
+ };
4870
+ });
4871
+ _layerSelectFilterAda3.selectById;
4810
4872
  var getActiveLayerInfo = createSelector(layerSelectStore, function (store) {
4811
4873
  return store === null || store === void 0 ? void 0 : store.activeLayerInfo;
4812
4874
  });
@@ -8483,7 +8545,8 @@ function newServiceAddedSaga(capturedAction) {
8483
8545
  keywords: keywords,
8484
8546
  scope: scope,
8485
8547
  groups: groups,
8486
- "abstract": _abstract
8548
+ "abstract": _abstract,
8549
+ isLoading: false
8487
8550
  }));
8488
8551
 
8489
8552
  case 8:
@@ -8608,7 +8671,7 @@ function layerSelectRemoveServiceSaga(capturedAction) {
8608
8671
  results = _context3.sent;
8609
8672
  services = results;
8610
8673
  servicesEnabled = Object.values(services).find(function (service) {
8611
- return service.enabled;
8674
+ return service === null || service === void 0 ? void 0 : service.enabled;
8612
8675
  });
8613
8676
 
8614
8677
  if (!(servicesEnabled === undefined)) {
@@ -8624,7 +8687,7 @@ function layerSelectRemoveServiceSaga(capturedAction) {
8624
8687
 
8625
8688
  return put(layerSelectActions.enableActiveService({
8626
8689
  serviceId: serviceId,
8627
- filters: service.filterIds
8690
+ filters: service === null || service === void 0 ? void 0 : service.filterIds
8628
8691
  }));
8629
8692
  }));
8630
8693
 
@@ -12071,18 +12134,36 @@ var useFetchServices = function useFetchServices(dialogType) {
12071
12134
  var serviceSetLayers = React.useCallback(function (payload) {
12072
12135
  dispatch(serviceActions.serviceSetLayers(payload));
12073
12136
  }, [dispatch]);
12137
+ var addFiltersAndActiveServices = React.useCallback(function (payload) {
12138
+ dispatch(layerSelectActions.addFiltersAndActiveServices(payload));
12139
+ }, [dispatch]);
12074
12140
  React.useEffect(function () {
12075
12141
  if (isOpenInStore && preloadedServices && preloadedServices.length > 0) {
12076
12142
  mergePresetsAndUserAddedServices(preloadedServices, getUserAddedServices()).forEach(function (service) {
12143
+ var wmService = WMGetServiceFromStore(service.url);
12144
+ var scope = service.scope ? service.scope : 'system';
12145
+
12146
+ if (isMounted.current) {
12147
+ addFiltersAndActiveServices({
12148
+ serviceId: wmService.id,
12149
+ serviceName: service.name,
12150
+ serviceUrl: service.url,
12151
+ keywords: [],
12152
+ scope: scope,
12153
+ groups: [],
12154
+ "abstract": service["abstract"] || wmService["abstract"],
12155
+ isLoading: true
12156
+ });
12157
+ }
12158
+
12077
12159
  getLayersFlattenedFromService(service.url).then(function (layers) {
12078
12160
  if (isMounted.current) {
12079
- var wmService = WMGetServiceFromStore(service.url);
12080
12161
  serviceSetLayers({
12081
12162
  id: wmService.id,
12082
12163
  name: service.name,
12083
12164
  serviceUrl: service.url,
12084
12165
  layers: layers,
12085
- scope: service.scope ? service.scope : 'system',
12166
+ scope: scope,
12086
12167
  // first try to load the user abstract, otherwise the service abstract
12087
12168
  "abstract": service["abstract"] || wmService["abstract"]
12088
12169
  });
@@ -12091,9 +12172,8 @@ var useFetchServices = function useFetchServices(dialogType) {
12091
12172
  return null;
12092
12173
  });
12093
12174
  });
12094
- } // eslint-disable-next-line react-hooks/exhaustive-deps
12095
-
12096
- }, [isOpenInStore, preloadedServices, serviceSetLayers]);
12175
+ }
12176
+ }, [addFiltersAndActiveServices, isMounted, isOpenInStore, preloadedServices, serviceSetLayers]);
12097
12177
  };
12098
12178
  var mergePresetsAndUserAddedServices = function mergePresetsAndUserAddedServices(presets, userAddedServices) {
12099
12179
  return Object.values(Object.assign(Object.assign({}, presets.reduce(function (byUrl, preset) {
@@ -12395,7 +12475,9 @@ var validateServiceName = function validateServiceName(value, services) {
12395
12475
  var ownServiceName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
12396
12476
  var serviceName = value === null || value === void 0 ? void 0 : value.toLowerCase();
12397
12477
  var foundName = Object.keys(services).find(function (serviceId) {
12398
- return services[serviceId].serviceName.toLowerCase() === serviceName && serviceName !== ownServiceName.toLocaleLowerCase();
12478
+ var _a;
12479
+
12480
+ return ((_a = services[serviceId]) === null || _a === void 0 ? void 0 : _a.serviceName.toLowerCase()) === serviceName && serviceName !== ownServiceName.toLocaleLowerCase();
12399
12481
  });
12400
12482
  return foundName === undefined ? true : VALIDATIONS_NAME_EXISTING;
12401
12483
  };
@@ -12425,7 +12507,9 @@ var validateServiceUrl = function validateServiceUrl(value, services) {
12425
12507
 
12426
12508
 
12427
12509
  var foundUrl = Object.keys(services).find(function (serviceId) {
12428
- return services[serviceId].serviceUrl === serviceUrl;
12510
+ var _a;
12511
+
12512
+ return ((_a = services[serviceId]) === null || _a === void 0 ? void 0 : _a.serviceUrl) === serviceUrl;
12429
12513
  });
12430
12514
 
12431
12515
  if (foundUrl) {
@@ -13630,7 +13714,7 @@ var sortByService = function sortByService(serviceObj) {
13630
13714
  var _ref4 = _slicedToArray(_ref2, 2),
13631
13715
  b = _ref4[1];
13632
13716
 
13633
- return a.serviceName.localeCompare(b.serviceName);
13717
+ return a.serviceName.localeCompare(b === null || b === void 0 ? void 0 : b.serviceName);
13634
13718
  }).reduce(function (r, _ref5) {
13635
13719
  var _ref6 = _slicedToArray(_ref5, 2),
13636
13720
  key = _ref6[0],
@@ -13953,7 +14037,7 @@ var ServiceChip = function ServiceChip(_ref) {
13953
14037
  var chip = all ? 'all' : service && service.serviceUrl;
13954
14038
  return /*#__PURE__*/React.createElement(CustomTooltip, {
13955
14039
  title: (service === null || service === void 0 ? void 0 : service["abstract"]) ? "Abstract: ".concat(service["abstract"]) : ''
13956
- }, /*#__PURE__*/React.createElement(CustomToggleButton, {
14040
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(CustomToggleButton, {
13957
14041
  variant: "boxed",
13958
14042
  selected: isSelected,
13959
14043
  tabIndex: 0,
@@ -13966,7 +14050,7 @@ var ServiceChip = function ServiceChip(_ref) {
13966
14050
  },
13967
14051
  disabled: isDisabled,
13968
14052
  sx: style
13969
- }, service ? service.serviceName : 'All'));
14053
+ }, service ? service.serviceName : 'All')));
13970
14054
  };
13971
14055
 
13972
14056
  var ServiceChipConnect = function ServiceChipConnect(_ref) {
@@ -14107,7 +14191,7 @@ var ServiceList = function ServiceList(_ref) {
14107
14191
  all: true,
14108
14192
  isSelected: isAllSelected
14109
14193
  }), Object.keys(activeServices).map(function (serviceId) {
14110
- var _a;
14194
+ var _a, _b;
14111
14195
 
14112
14196
  var service = activeServices[serviceId];
14113
14197
  return /*#__PURE__*/React.createElement(ServiceChipConnect, {
@@ -14116,7 +14200,7 @@ var ServiceList = function ServiceList(_ref) {
14116
14200
  service: service,
14117
14201
  isSelected: (_a = activeServices[serviceId]) === null || _a === void 0 ? void 0 : _a.enabled,
14118
14202
  isAllSelected: isAllSelected,
14119
- isDisabled: activeServices[serviceId] === undefined
14203
+ isDisabled: activeServices[serviceId] === undefined || ((_b = activeServices[serviceId]) === null || _b === void 0 ? void 0 : _b.isLoading) === true
14120
14204
  });
14121
14205
  })));
14122
14206
  };
@@ -14369,7 +14453,9 @@ var Rows = function Rows(_ref2) {
14369
14453
  var getService = function getService(services, serviceUrl) {
14370
14454
  var serviceIds = Object.keys(services);
14371
14455
  var serviceIndex = serviceIds.findIndex(function (serviceId) {
14372
- return services[serviceId].serviceUrl === serviceUrl;
14456
+ var _a;
14457
+
14458
+ return ((_a = services[serviceId]) === null || _a === void 0 ? void 0 : _a.serviceUrl) === serviceUrl;
14373
14459
  });
14374
14460
  if (serviceIndex < 0) return null;
14375
14461
  return services[serviceIds[serviceIndex]];
@@ -15200,7 +15286,8 @@ var MapControls = function MapControls(_a) {
15200
15286
  left: 0,
15201
15287
  margin: 1,
15202
15288
  zIndex: 50,
15203
- top: '96px'
15289
+ top: '96px',
15290
+ userSelect: 'none'
15204
15291
  }
15205
15292
  }, props), /*#__PURE__*/React.createElement(Grid, {
15206
15293
  sx: {
@@ -23915,13 +24002,389 @@ var TimeSliderClockConnect = function TimeSliderClockConnect(_ref) {
23915
24002
  });
23916
24003
  };
23917
24004
 
24005
+ /* *
24006
+ * Licensed under the Apache License, Version 2.0 (the "License");
24007
+ * you may not use this file except in compliance with the License.
24008
+ * You may obtain a copy of the License at
24009
+ *
24010
+ * http://www.apache.org/licenses/LICENSE-2.0
24011
+ *
24012
+ * Unless required by applicable law or agreed to in writing, software
24013
+ * distributed under the License is distributed on an "AS IS" BASIS,
24014
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24015
+ * See the License for the specific language governing permissions and
24016
+ * limitations under the License.
24017
+ *
24018
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
24019
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
24020
+ * */
24021
+ /**
24022
+ * Get the title for this WMS layer based on its layerId. If not defined, layerId is used instead.
24023
+ * @param layerId
24024
+ * @returns Title for the layer
24025
+ */
24026
+
24027
+ var getTitle = function getTitle(layerId) {
24028
+ var wmjsLayer = getWMLayerById(layerId);
24029
+ return wmjsLayer ? wmjsLayer.title || wmjsLayer.name : layerId;
24030
+ };
24031
+ /**
24032
+ * Make a list of GFI Layers to display.
24033
+ * @param layers
24034
+ * @param mapId
24035
+ * @returns
24036
+ */
24037
+
24038
+
24039
+ var getLayersToUpdate = function getLayersToUpdate(layers, mapId) {
24040
+ var wmjsMap = getWMJSMapById(mapId);
24041
+ if (!wmjsMap || !layers || layers.length === 0) return [];
24042
+ return layers.filter(function (layer) {
24043
+ return layer && layer.enabled && !!getWMLayerById(layer.id);
24044
+ }).map(function (layer) {
24045
+ /*
24046
+ We need a wmjsLayer to build the getfeatureinfo url (getWMSGetFeatureInfoRequestURL function).
24047
+ But it seems that its dimension are lazely updated (by ReactMapView).
24048
+ Therefore make a clone of this layer and set its dimensions based on the layer object.
24049
+ Otherwise we risk making a getfeatureinfo call with outdated dimension values.
24050
+ */
24051
+ var wmjsLayer = getWMLayerById(layer.id).cloneLayer();
24052
+ layer.dimensions && layer.dimensions.forEach(function (dim) {
24053
+ var wmDim = wmjsLayer.getDimension(dim.name);
24054
+
24055
+ if (wmDim && wmDim.getValue() !== dim.currentValue) {
24056
+ wmDim.setValue(dim.currentValue);
24057
+ }
24058
+ });
24059
+ return {
24060
+ layerId: layer.id,
24061
+ url: wmjsMap.getWMSGetFeatureInfoRequestURL(wmjsLayer, "".concat(wmjsMap.getMapPin().getXY().x), "".concat(wmjsMap.getMapPin().getXY().y), 'text/html'),
24062
+ title: getTitle(layer.id)
24063
+ };
24064
+ });
24065
+ };
24066
+
24067
+ var GetFeatureInfoDialog = function GetFeatureInfoDialog(_ref) {
24068
+ var layers = _ref.layers,
24069
+ isOpen = _ref.isOpen,
24070
+ onClose = _ref.onClose,
24071
+ _ref$onMouseDown = _ref.onMouseDown,
24072
+ onMouseDown = _ref$onMouseDown === void 0 ? function () {} : _ref$onMouseDown,
24073
+ mapId = _ref.mapId,
24074
+ _ref$showMapId = _ref.showMapId,
24075
+ showMapId = _ref$showMapId === void 0 ? false : _ref$showMapId,
24076
+ _ref$order = _ref.order,
24077
+ order = _ref$order === void 0 ? 0 : _ref$order,
24078
+ _ref$source = _ref.source,
24079
+ source = _ref$source === void 0 ? 'app' : _ref$source,
24080
+ mapPinLocation = _ref.mapPinLocation;
24081
+
24082
+ /* Ref and state for maplocation */
24083
+ var mapLocationWasChanged = React__default.useRef(false);
24084
+
24085
+ var _React$useState = React__default.useState(false),
24086
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24087
+ isInitialMapLocationChanged = _React$useState2[0],
24088
+ setInitialMapLocationIsChanged = _React$useState2[1];
24089
+ /* Ref, state and update function for results per layer map */
24090
+
24091
+
24092
+ var gfiResultMap = React__default.useRef(new Map()).current;
24093
+
24094
+ var _React$useState3 = React__default.useState(),
24095
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
24096
+ triggerRerender = _React$useState4[1];
24097
+
24098
+ var updateLayerResult = function updateLayerResult(_ref2) {
24099
+ var layerId = _ref2.layerId,
24100
+ data = _ref2.data,
24101
+ isLoading = _ref2.isLoading;
24102
+ gfiResultMap.set(layerId, {
24103
+ data: data,
24104
+ isLoading: isLoading
24105
+ });
24106
+ triggerRerender("".concat(layerId).concat(isLoading));
24107
+ };
24108
+ /* Build a layerlist array with a set of arguments per layer to do the query for */
24109
+
24110
+
24111
+ var layerToUpdateList = getLayersToUpdate(layers, mapId);
24112
+ /*
24113
+ Build a string based on the GFI urls. If this changes for whatever reason we need to update.
24114
+ These strings can change very often, therefore they need to be debounced and only use the most recent result must be used.
24115
+ */
24116
+
24117
+ var debouncedlayerListString = useDebounce(layerToUpdateList.map(function (layer) {
24118
+ return layer.url;
24119
+ }).join(','), 100);
24120
+ /* Do a GFI call to the server and use the updateLayerResult to provide the results. */
24121
+
24122
+ var fetchLayerInfo = function fetchLayerInfo(url, layerId) {
24123
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
24124
+ var _yield$axios$get, data, errorMessage;
24125
+
24126
+ return regeneratorRuntime.wrap(function _callee$(_context) {
24127
+ while (1) {
24128
+ switch (_context.prev = _context.next) {
24129
+ case 0:
24130
+ _context.prev = 0;
24131
+ updateLayerResult({
24132
+ layerId: layerId,
24133
+ data: '',
24134
+ isLoading: true
24135
+ });
24136
+ _context.next = 4;
24137
+ return axios.get(url);
24138
+
24139
+ case 4:
24140
+ _yield$axios$get = _context.sent;
24141
+ data = _yield$axios$get.data;
24142
+ updateLayerResult({
24143
+ layerId: layerId,
24144
+ data: data,
24145
+ isLoading: false
24146
+ });
24147
+ _context.next = 13;
24148
+ break;
24149
+
24150
+ case 9:
24151
+ _context.prev = 9;
24152
+ _context.t0 = _context["catch"](0);
24153
+ errorMessage = _context.t0.message();
24154
+ updateLayerResult({
24155
+ layerId: layerId,
24156
+ data: errorMessage,
24157
+ isLoading: false
24158
+ });
24159
+
24160
+ case 13:
24161
+ case "end":
24162
+ return _context.stop();
24163
+ }
24164
+ }
24165
+ }, _callee, null, [[0, 9]]);
24166
+ }));
24167
+ };
24168
+ /* Wait till the user has clicked the map. */
24169
+
24170
+
24171
+ React__default.useEffect(function () {
24172
+ if (mapLocationWasChanged.current !== false) {
24173
+ setInitialMapLocationIsChanged(true);
24174
+ }
24175
+
24176
+ mapLocationWasChanged.current = true;
24177
+ }, [mapPinLocation]);
24178
+ /* For each changed getfeature url string, load new data using WMS GetFeatureInfo */
24179
+
24180
+ React__default.useEffect(function () {
24181
+ if (isInitialMapLocationChanged && isOpen) {
24182
+ layerToUpdateList.forEach(function (_ref3) {
24183
+ var url = _ref3.url,
24184
+ layerId = _ref3.layerId;
24185
+ fetchLayerInfo(url, layerId);
24186
+ });
24187
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
24188
+
24189
+ }, [debouncedlayerListString]);
24190
+ var hasLayers = layers && layers.length > 0;
24191
+ return /*#__PURE__*/React__default.createElement(ToolContainerDraggable, {
24192
+ startPosition: {
24193
+ right: 10,
24194
+ top: 80
24195
+ },
24196
+ minWidth: 300,
24197
+ onClose: onClose,
24198
+ title: showMapId ? "Event marker info ".concat(mapId) : 'Event marker info',
24199
+ headerSize: "small",
24200
+ initialMaxHeight: 440,
24201
+ isOpen: isOpen,
24202
+ "data-testid": "moveable-getfeatureinfo",
24203
+ bounds: "parent",
24204
+ onMouseDown: onMouseDown,
24205
+ order: order,
24206
+ source: source
24207
+ }, /*#__PURE__*/React__default.createElement(Box, {
24208
+ sx: {
24209
+ padding: 0
24210
+ }
24211
+ }, isOpen && hasLayers && isInitialMapLocationChanged && /*#__PURE__*/React__default.createElement(Box, {
24212
+ "data-testid": "GetFeatureInfoList"
24213
+ }, layerToUpdateList.map(function (layer) {
24214
+ var layerId = layer.layerId,
24215
+ title = layer.title,
24216
+ url = layer.url;
24217
+ var result = gfiResultMap.get(layerId);
24218
+ if (!result) return null;
24219
+ return /*#__PURE__*/React__default.createElement(Grid, {
24220
+ key: layerId,
24221
+ sx: {
24222
+ margin: '4px 6px 4px 6px',
24223
+ padding: '6px',
24224
+ backgroundColor: 'geowebColors.cards.cardContainer',
24225
+ border: 'solid 1px',
24226
+ borderColor: 'geowebColors.cards.cardContainerBorder'
24227
+ }
24228
+ }, /*#__PURE__*/React__default.createElement(Typography, {
24229
+ variant: "subtitle1"
24230
+ }, title, "\xA0", /*#__PURE__*/React__default.createElement(IconButton, {
24231
+ sx: {
24232
+ "float": 'right'
24233
+ },
24234
+ size: "small",
24235
+ "aria-label": "Open layer featureinfo in another page",
24236
+ onClick: function onClick() {
24237
+ window.open(url);
24238
+ }
24239
+ }, /*#__PURE__*/React__default.createElement(ExitDomain, null))), !result.isLoading ? /*#__PURE__*/React__default.createElement("div", {
24240
+ style: {
24241
+ fontSize: '11px',
24242
+ padding: '6px',
24243
+ margin: '0',
24244
+ fontFamily: 'Roboto,Helvetica,Arial,sans-serif',
24245
+ fontWeight: '400',
24246
+ lineHeight: '1.75',
24247
+ letterSpacing: '0.25px'
24248
+ },
24249
+ "data-testid": "layer-result-ready-".concat(layerId),
24250
+ // eslint-disable-next-line react/no-danger
24251
+ dangerouslySetInnerHTML: {
24252
+ __html: result.data.replace(/<hr\/>/g, '')
24253
+ }
24254
+ }) : /*#__PURE__*/React__default.createElement("div", {
24255
+ "data-testid": "layer-result-loading-".concat(layerId)
24256
+ }, /*#__PURE__*/React__default.createElement(CircularProgress, {
24257
+ "data-testid": "spinner",
24258
+ color: "inherit"
24259
+ })));
24260
+ })), hasLayers && !isInitialMapLocationChanged && /*#__PURE__*/React__default.createElement(Typography, {
24261
+ "data-testid": "click-on-map-for-info",
24262
+ variant: "subtitle1",
24263
+ sx: {
24264
+ padding: '10px'
24265
+ }
24266
+ }, "Click on the map for info."), !hasLayers && /*#__PURE__*/React__default.createElement(Typography, {
24267
+ "data-testid": "NoLayers",
24268
+ variant: "subtitle1",
24269
+ sx: {
24270
+ padding: '10px'
24271
+ }
24272
+ }, "No layers added to the map.")));
24273
+ };
24274
+
24275
+ /* *
24276
+ * Licensed under the Apache License, Version 2.0 (the "License");
24277
+ * you may not use this file except in compliance with the License.
24278
+ * You may obtain a copy of the License at
24279
+ *
24280
+ * http://www.apache.org/licenses/LICENSE-2.0
24281
+ *
24282
+ * Unless required by applicable law or agreed to in writing, software
24283
+ * distributed under the License is distributed on an "AS IS" BASIS,
24284
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24285
+ * See the License for the specific language governing permissions and
24286
+ * limitations under the License.
24287
+ *
24288
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
24289
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
24290
+ * */
24291
+
24292
+ var GetFeatureInfoConnect = function GetFeatureInfoConnect(_ref) {
24293
+ var _ref$showMapId = _ref.showMapId,
24294
+ showMapId = _ref$showMapId === void 0 ? false : _ref$showMapId,
24295
+ mapId = _ref.mapId;
24296
+ var dispatch = useDispatch();
24297
+ var getFeatureInfoType = "getfeatureinfo-".concat(mapId);
24298
+ var isMapPinVisible = useSelector(function (store) {
24299
+ return getDisplayMapPin(store, mapId);
24300
+ });
24301
+ var mapPinLocation = useSelector(function (store) {
24302
+ return getPinLocation(store, mapId);
24303
+ });
24304
+ var toggleMapPinIsVisible = React.useCallback(function (displayMapPin) {
24305
+ dispatch(mapActions$1.toggleMapPinIsVisible({
24306
+ mapId: mapId,
24307
+ displayMapPin: displayMapPin
24308
+ }));
24309
+ }, [dispatch, mapId]);
24310
+ var mapLayers = useSelector(function (store) {
24311
+ return getMapLayers(store, mapId);
24312
+ });
24313
+
24314
+ var _useSetupDialog = useSetupDialog(getFeatureInfoType),
24315
+ dialogOrder = _useSetupDialog.dialogOrder,
24316
+ isDialogOpen = _useSetupDialog.isDialogOpen,
24317
+ uiSource = _useSetupDialog.uiSource,
24318
+ setDialogOrder = _useSetupDialog.setDialogOrder,
24319
+ onCloseDialog = _useSetupDialog.onCloseDialog;
24320
+
24321
+ React.useEffect(function () {
24322
+ toggleMapPinIsVisible(isDialogOpen);
24323
+ }, [isDialogOpen, toggleMapPinIsVisible, isMapPinVisible]);
24324
+ return /*#__PURE__*/React.createElement(GetFeatureInfoDialog, {
24325
+ layers: mapLayers,
24326
+ isOpen: isDialogOpen,
24327
+ onClose: onCloseDialog,
24328
+ mapId: mapId,
24329
+ showMapId: showMapId,
24330
+ onMouseDown: setDialogOrder,
24331
+ order: dialogOrder,
24332
+ source: uiSource,
24333
+ mapPinLocation: mapPinLocation
24334
+ });
24335
+ };
24336
+
24337
+ /* *
24338
+ * Licensed under the Apache License, Version 2.0 (the "License");
24339
+ * you may not use this file except in compliance with the License.
24340
+ * You may obtain a copy of the License at
24341
+ *
24342
+ * http://www.apache.org/licenses/LICENSE-2.0
24343
+ *
24344
+ * Unless required by applicable law or agreed to in writing, software
24345
+ * distributed under the License is distributed on an "AS IS" BASIS,
24346
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24347
+ * See the License for the specific language governing permissions and
24348
+ * limitations under the License.
24349
+ *
24350
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
24351
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
24352
+ * */
24353
+
24354
+ var GetFeatureInfoButtonConnect = function GetFeatureInfoButtonConnect(_ref) {
24355
+ var mapId = _ref.mapId,
24356
+ _ref$source = _ref.source,
24357
+ source = _ref$source === void 0 ? 'app' : _ref$source;
24358
+ var dispatch = useDispatch();
24359
+ var gfiType = "getfeatureinfo-".concat(mapId);
24360
+ var isOpenInStore = useSelector(function (store) {
24361
+ return getisDialogOpen(store, gfiType);
24362
+ });
24363
+ var openGfiDialog = React.useCallback(function () {
24364
+ dispatch(uiActions.setActiveMapIdForDialog({
24365
+ type: gfiType,
24366
+ mapId: mapId,
24367
+ setOpen: !isOpenInStore,
24368
+ source: source,
24369
+ origin: MapActionOrigin.map
24370
+ }));
24371
+ }, [mapId, dispatch, isOpenInStore, source, gfiType]);
24372
+ return /*#__PURE__*/React.createElement(MapControlButton, {
24373
+ title: "Get information for a specific location",
24374
+ "data-testid": "open-getfeatureinfo",
24375
+ onClick: openGfiDialog,
24376
+ isActive: isOpenInStore
24377
+ }, /*#__PURE__*/React.createElement(Info, null));
24378
+ };
24379
+
23918
24380
  var titleStyle = function titleStyle(theme) {
23919
24381
  return {
23920
24382
  position: 'absolute',
23921
24383
  padding: '5px',
23922
24384
  zIndex: 50,
23923
24385
  color: theme.palette.common.black,
23924
- whiteSpace: 'nowrap'
24386
+ whiteSpace: 'nowrap',
24387
+ userSelect: 'none'
23925
24388
  };
23926
24389
  };
23927
24390
 
@@ -23966,8 +24429,10 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
23966
24429
  shouldShowLayerManager = _a.shouldShowLayerManager,
23967
24430
  _a$showClock = _a.showClock,
23968
24431
  showClock = _a$showClock === void 0 ? true : _a$showClock,
24432
+ _a$displayGetFeatureI = _a.displayGetFeatureInfoButtonInMap,
24433
+ displayGetFeatureInfoButtonInMap = _a$displayGetFeatureI === void 0 ? false : _a$displayGetFeatureI,
23969
24434
  children = _a.children,
23970
- props = __rest(_a, ["id", "title", "layers", "shouldAutoUpdate", "shouldAnimate", "bbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "showClock", "children"]);
24435
+ props = __rest(_a, ["id", "title", "layers", "shouldAutoUpdate", "shouldAnimate", "bbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "showClock", "displayGetFeatureInfoButtonInMap", "children"]);
23971
24436
 
23972
24437
  var dispatch = useDispatch();
23973
24438
  var mapId = React__default.useRef(id || generateMapId()).current;
@@ -24033,6 +24498,8 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
24033
24498
  multiLegend: multiLegend
24034
24499
  }), displayDimensionSelectButtonInMap && /*#__PURE__*/React__default.createElement(MultiDimensionSelectMapButtonsConnect, {
24035
24500
  mapId: mapId
24501
+ }), displayGetFeatureInfoButtonInMap && /*#__PURE__*/React__default.createElement(GetFeatureInfoButtonConnect, {
24502
+ mapId: mapId
24036
24503
  })), !disableTimeSlider && /*#__PURE__*/React__default.createElement(Box, {
24037
24504
  sx: {
24038
24505
  position: 'absolute',
@@ -24055,6 +24522,9 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
24055
24522
  multiLegend: multiLegend
24056
24523
  }), showClock && /*#__PURE__*/React__default.createElement(TimeSliderClockConnect, {
24057
24524
  mapId: mapId
24525
+ }), displayGetFeatureInfoButtonInMap && /*#__PURE__*/React__default.createElement(GetFeatureInfoConnect, {
24526
+ showMapId: true,
24527
+ mapId: mapId
24058
24528
  }), /*#__PURE__*/React__default.createElement(DockedLayerManagerConnect, {
24059
24529
  mapId: mapId,
24060
24530
  bounds: "parent"
@@ -24392,7 +24862,8 @@ var componentsLookUp = function componentsLookUp(_ref) {
24392
24862
  var mapPreset = initialProps.mapPreset;
24393
24863
  return /*#__PURE__*/React__default.createElement(ConfigurableMapConnect, Object.assign({}, mapPreset, {
24394
24864
  id: id,
24395
- "data-testid": "coreConfigurableMapConnect"
24865
+ "data-testid": "coreConfigurableMapConnect",
24866
+ displayGetFeatureInfoButtonInMap: true
24396
24867
  }));
24397
24868
  }
24398
24869