@opengeoweb/time-series 15.1.0 → 15.3.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.
Files changed (30) hide show
  1. package/index.esm.js +1170 -763
  2. package/package.json +11 -12
  3. package/src/lib/TimeSeriesDemo.stories.d.ts +1 -0
  4. package/src/lib/components/TimeSeries/TimeSeriesChart.d.ts +13 -0
  5. package/src/lib/components/TimeSeries/TimeSeriesConnectWrapper.d.ts +2 -2
  6. package/src/lib/components/TimeSeries/TimeSeriesView.d.ts +2 -0
  7. package/src/lib/components/TimeSeriesManager/ParameterInfo/ParameterInfoButtonConnect.d.ts +1 -2
  8. package/src/lib/components/TimeSeriesManager/ParameterList.d.ts +1 -0
  9. package/src/lib/components/TimeSeriesManager/PlotRows.d.ts +1 -0
  10. package/src/lib/components/TimeSeriesManager/TimeSeriesManager.d.ts +1 -0
  11. package/src/lib/components/TimeSeriesManager/TimeSeriesManagerMapButtonConnect.d.ts +0 -2
  12. package/src/lib/components/TimeSeriesManager/TimeSeriesManagerRowAccordion.d.ts +1 -0
  13. package/src/lib/components/TimeSeriesSelect/ServiceChips/ServiceChipConnect.d.ts +2 -0
  14. package/src/lib/components/TimeSeriesSelect/ServiceOptionsConnect.d.ts +5 -1
  15. package/src/lib/components/TimeSeriesSelect/ServicePopup/ServicePopupConnect.d.ts +5 -1
  16. package/src/lib/components/TimeSeriesSelect/ServicePopup/ServicePopupDialogConnect.d.ts +1 -0
  17. package/src/lib/components/TimeSeriesSelect/TimeSeriesSearchConnect.d.ts +4 -1
  18. package/src/lib/components/TimeSeriesSelect/TimeSeriesSelect.d.ts +1 -0
  19. package/src/lib/components/TimeSeriesSelect/TimeSeriesSelectButtonConnect.d.ts +1 -0
  20. package/src/lib/components/TimeSeriesSelect/TimeSeriesSelectList.d.ts +1 -0
  21. package/src/lib/components/TimeSeriesSelect/TimeSeriesSelectListConnect.d.ts +1 -0
  22. package/src/lib/components/TimeSeriesSelect/TimeSeriesServiceList.d.ts +1 -0
  23. package/src/lib/components/TimeSeriesSelect/TimeSeriesServiceListConnect.d.ts +4 -1
  24. package/src/lib/store/reducer.d.ts +48 -37
  25. package/src/lib/store/selectors.d.ts +71 -81
  26. package/src/lib/store/store.d.ts +1 -1
  27. package/src/lib/store/types.d.ts +22 -1
  28. package/src/lib/utils/edrUtils.d.ts +3 -2
  29. package/src/lib/utils/timeseries-api/hooks.d.ts +2 -1
  30. package/src/lib/components/TimeSeries/LocationDropdown/LocationDropdownRenderRow.d.ts +0 -3
package/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import React, { useCallback, useState, useMemo, useEffect, memo } from 'react';
3
3
  import { useDispatch, useSelector } from 'react-redux';
4
4
  import { CustomIconButton, dateUtils, TooltipSelect, CustomAccordion, CustomTooltip, CustomToggleButton, ToolContainerDraggable, ToggleMenu, CustomDialog, SearchField, SearchHighlight, AlertBanner, useConfirmationDialog, SwitchButton, useResizeObserver } from '@opengeoweb/shared';
5
5
  import { snackbarActions, snackbarTypes, snackbarListener, snackbarReducer } from '@opengeoweb/snackbar';
6
- import { mapUtils, selectorMemoizationOptions, genericSelectors, uiSelectors, uiTypes, uiActions, useSetupDialog, mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, uiReducer, syncGroupsReducer, layerReducer, serviceReducer, mapReducer, loadingIndicatorActions, syncGroupsActions, genericActions, mapActions, layerActions } from '@opengeoweb/store';
6
+ import { mapUtils, selectorMemoizationOptions, genericSelectors, uiSelectors, uiTypes, uiActions, useSetupDialog, mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, uiReducer, syncGroupsReducer, layerReducer, serviceReducer, mapReducer, loadingIndicatorActions, syncGroupsActions, genericActions, useSyncgroupTimeState, mapActions, layerActions } from '@opengeoweb/store';
7
7
  import { useTheme, MenuItem, LinearProgress, Grid, Box, Typography, ClickAwayListener, Input, Collapse, Button, List, ListItem, ListItemText, InputAdornment, ListItemButton, styled, Card, Stack, Tooltip, ListItemIcon, Checkbox } from '@mui/material';
8
8
  import { isString, trim, trimStart, compact, chain, groupBy, countBy, sortBy, uniqBy, isEqual } from 'lodash';
9
9
  import { ReactSortable } from 'react-sortablejs';
@@ -11,7 +11,7 @@ import { Info, ArrowDropDownDown, Copy, Delete, Visibility, VisibilityOff, TimeS
11
11
  import i18n from 'i18next';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import '@opengeoweb/core';
14
- import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
14
+ import { createEntityAdapter, createSlice, createAction, createSelector, createListenerMiddleware, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
15
15
  import { produce } from 'immer';
16
16
  import { v4 } from 'uuid';
17
17
  import { center } from '@turf/turf';
@@ -21,8 +21,7 @@ import { handleResponse } from '@opengeoweb/api';
21
21
  import Box$1 from '@mui/material/Box';
22
22
  import { useFormContext } from 'react-hook-form';
23
23
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormTextField, ReactHookFormSelect } from '@opengeoweb/form-fields';
24
- import AutoSizer from 'react-virtualized-auto-sizer';
25
- import { VariableSizeList, FixedSizeList } from 'react-window';
24
+ import { List as List$1, useListRef } from 'react-window';
26
25
  import { webmapUtils } from '@opengeoweb/webmap';
27
26
  import ReactECharts from 'echarts-for-react';
28
27
 
@@ -1121,9 +1120,15 @@ date) {
1121
1120
  };
1122
1121
  // 1 day to past, 10 days to future
1123
1122
  var clipInterval = [1 * 24, 10 * 24];
1124
- var constructTimeInterval = function constructTimeInterval(collection, instance, parameter) {
1123
+ var constructTimeInterval = function constructTimeInterval(collection, instance, syncgroupTimeState) {
1125
1124
  var _instance$extent$temp, _instance$extent2, _collection$extent4;
1126
1125
  var interval = (_instance$extent$temp = (_instance$extent2 = instance.extent) == null || (_instance$extent2 = _instance$extent2.temporal) == null ? void 0 : _instance$extent2.interval[0]) != null ? _instance$extent$temp : collection == null || (_collection$extent4 = collection.extent) == null || (_collection$extent4 = _collection$extent4.temporal) == null ? void 0 : _collection$extent4.interval[0];
1126
+ // If syncgroupTimeState is set, use this instead of the fixed timerange.
1127
+ if ((syncgroupTimeState == null ? void 0 : syncgroupTimeState.start) !== undefined && (syncgroupTimeState == null ? void 0 : syncgroupTimeState.end) !== undefined) {
1128
+ var timeRangeStartIso = dateUtils.dateToString(dateUtils.fromUnix(syncgroupTimeState.start));
1129
+ var timeRangeEndIso = dateUtils.dateToString(dateUtils.fromUnix(syncgroupTimeState.end));
1130
+ return timeRangeStartIso + "/" + timeRangeEndIso;
1131
+ }
1127
1132
  var _clipEdrInterval = clipEdrInterval(interval, clipInterval[0], clipInterval[1]),
1128
1133
  start = _clipEdrInterval[0],
1129
1134
  end = _clipEdrInterval[1];
@@ -1181,23 +1186,7 @@ var getLocationPositionPath = function getLocationPositionPath(collectionId, ins
1181
1186
  return "/collections/" + collectionId;
1182
1187
  };
1183
1188
 
1184
- /* *
1185
- * Licensed under the Apache License, Version 2.0 (the "License");
1186
- * you may not use this file except in compliance with the License.
1187
- * You may obtain a copy of the License at
1188
- *
1189
- * http://www.apache.org/licenses/LICENSE-2.0
1190
- *
1191
- * Unless required by applicable law or agreed to in writing, software
1192
- * distributed under the License is distributed on an "AS IS" BASIS,
1193
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1194
- * See the License for the specific language governing permissions and
1195
- * limitations under the License.
1196
- *
1197
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1198
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
1199
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1200
- * */
1189
+ var _excluded$3 = ["services"];
1201
1190
  var patchableParameterProperties = {
1202
1191
  color: true,
1203
1192
  plotType: true,
@@ -1218,156 +1207,78 @@ var timeseriesSelectServiceFilterChipsAdapter = createEntityAdapter({
1218
1207
  }
1219
1208
  });
1220
1209
  var initialState = {
1221
- plotPreset: undefined,
1222
- services: undefined,
1223
- timeseriesSelect: {
1224
- currentParameterInfo: undefined,
1225
- filters: {
1226
- searchFilter: '',
1227
- serviceFilterChips: timeseriesSelectServiceFilterChipsAdapter.getInitialState(),
1228
- allServiceFilterChipsEnabled: true
1210
+ byId: {},
1211
+ services: []
1212
+ };
1213
+ var createPanelState = function createPanelState() {
1214
+ return {
1215
+ plotPreset: undefined,
1216
+ timeseriesSelect: {
1217
+ currentParameterInfo: undefined,
1218
+ filters: {
1219
+ searchFilter: '',
1220
+ serviceFilterChips: timeseriesSelectServiceFilterChipsAdapter.getInitialState(),
1221
+ allServiceFilterChipsEnabled: true
1222
+ },
1223
+ servicePopup: {
1224
+ isOpen: false,
1225
+ variant: 'add'
1226
+ }
1229
1227
  },
1230
- servicePopup: {
1231
- isOpen: false,
1232
- variant: 'add'
1228
+ locationData: {
1229
+ isMapPinDisabled: false,
1230
+ shouldHideLocationMarkers: false,
1231
+ isLegendVisible: true
1233
1232
  }
1234
- },
1235
- locationData: {
1236
- isMapPinDisabled: false,
1237
- shouldHideLocationMarkers: false,
1238
- isLegendVisible: true
1239
- }
1233
+ };
1240
1234
  };
1241
- var slice = createSlice({
1242
- initialState: initialState,
1243
- name: 'timeseries',
1235
+ var initialPanelState = createPanelState();
1236
+ var panelSlice = createSlice({
1237
+ initialState: createPanelState(),
1238
+ name: 'timeseriesPanel',
1244
1239
  reducers: {
1245
1240
  loadUserAddedTimeSeriesServices: function loadUserAddedTimeSeriesServices(draft, payloadAction) {
1246
- var _draft$services, _draft$services3;
1247
- // Make sure to initialize services to empty array (if not set)
1248
- if (!((_draft$services = draft.services) != null && _draft$services.length)) {
1249
- draft.services = [];
1250
- }
1251
- var newServices = [];
1252
- payloadAction.payload.forEach(function (service) {
1253
- var _draft$services2;
1254
- var existingService = (_draft$services2 = draft.services) == null ? void 0 : _draft$services2.find(function (el) {
1255
- return el.url === service.url;
1241
+ var _draft$timeseriesSele, _draft$timeseriesSele2;
1242
+ var servicesPayload = Array.isArray(payloadAction.payload) ? payloadAction.payload : payloadAction.payload.timeSeriesServices;
1243
+ var existingIds = new Set((_draft$timeseriesSele = (_draft$timeseriesSele2 = draft.timeseriesSelect) == null ? void 0 : _draft$timeseriesSele2.filters.serviceFilterChips.ids) != null ? _draft$timeseriesSele : []);
1244
+ var newServices = servicesPayload.map(function (service) {
1245
+ var _service$scope;
1246
+ var id = service.scope === 'system' ? service.id : generateServiceId();
1247
+ return Object.assign({}, service, {
1248
+ id: id,
1249
+ scope: (_service$scope = service.scope) != null ? _service$scope : 'user'
1256
1250
  });
1257
- if (!existingService) {
1258
- var newService = Object.assign({}, service, {
1259
- id: service.scope === 'system' ? service.id : generateServiceId(),
1260
- scope: 'user'
1261
- });
1262
- newServices.push(newService);
1263
- }
1264
- });
1265
- (_draft$services3 = draft.services) == null || _draft$services3.push.apply(_draft$services3, newServices);
1266
- // Add filterchips for any new services that were added
1267
- timeSeriesReducer(draft, {
1268
- payload: newServices.map(function (service) {
1269
- return {
1270
- serviceId: service.id,
1271
- serviceName: service.name,
1272
- serviceUrl: service.url,
1273
- type: service.type,
1274
- scope: service.scope
1275
- };
1276
- }),
1277
- type: timeSeriesActions.setServiceFilterChipsInStore.type
1251
+ }).filter(function (service) {
1252
+ return !existingIds.has(service.id);
1278
1253
  });
1254
+ if (newServices.length) {
1255
+ panelSlice.caseReducers.setServiceFilterChipsInStore(draft, {
1256
+ payload: newServices.map(function (service) {
1257
+ return {
1258
+ serviceId: service.id,
1259
+ serviceName: service.name,
1260
+ serviceUrl: service.url,
1261
+ type: service.type,
1262
+ scope: service.scope || 'user'
1263
+ };
1264
+ }),
1265
+ type: timeSeriesActions.setServiceFilterChipsInStore.type
1266
+ });
1267
+ }
1279
1268
  },
1280
1269
  registerTimeSeriesPreset: function registerTimeSeriesPreset(draft, action) {
1281
- var _draft$services4, _timeSeriesPresetWith;
1282
- // Make sure to initialize services to empty array (if not set)
1283
- if (!((_draft$services4 = draft.services) != null && _draft$services4.length)) {
1284
- draft.services = [];
1285
- }
1286
- var newServicesAdded = [];
1287
- var timeSeriesPresetWithParameterIds = produce(action.payload, function (draftPreset) {
1288
- var _draftPreset$services;
1289
- if (!draftPreset.plotPreset) {
1290
- console.warn('missing draft plotpresets', draftPreset);
1291
- return;
1292
- }
1293
- // Make sure to initialize services to empty array (if not set)
1294
- if (!((_draftPreset$services = draftPreset.services) != null && _draftPreset$services.length)) {
1295
- draftPreset.services = [];
1296
- }
1297
- draftPreset.plotPreset.parameters.forEach(function (draftParameter) {
1298
- // Add parameter id to plotPreset.parameters
1299
- draftParameter.id = generateParameterId();
1300
- // Add opacity value to plotPreset.parameters
1301
- draftParameter.opacity = draftParameter.opacity || 70;
1302
- // Check if service is already in the services list
1303
- var serviceFromStore = getServiceById(draft.services, draftParameter.serviceId);
1304
- if (!serviceFromStore) {
1305
- var _draft$services5;
1306
- // The service is not in the store. Add it based on the preset
1307
- var serviceFromAction = getServiceById(draftPreset.services, draftParameter.serviceId);
1308
- if (!serviceFromAction) {
1309
- console.error("A parameter from the preset has a service with id " + draftParameter.serviceId + " which is not in the store or in the preset");
1310
- return;
1311
- }
1312
- // Now check if the url is already in the store, it might be there with a different id
1313
- var reUseAbleService = (_draft$services5 = draft.services) == null ? void 0 : _draft$services5.find(function (storeService) {
1314
- return storeService.url === serviceFromAction.url;
1315
- });
1316
- if (!reUseAbleService) {
1317
- var _draft$services6;
1318
- // The url and or serviceId were not yet in the services state
1319
- (_draft$services6 = draft.services) == null || _draft$services6.push(Object.assign({}, serviceFromAction, {
1320
- scope: 'system'
1321
- }));
1322
- newServicesAdded.push({
1323
- serviceId: serviceFromAction.id,
1324
- serviceUrl: serviceFromAction.url,
1325
- serviceName: serviceFromAction.name,
1326
- type: serviceFromAction.type,
1327
- scope: 'system'
1328
- });
1329
- } else {
1330
- // The same url is already in the store, but has the wrong id. Adjust the parameters serviceId.
1331
- draftParameter.serviceId = reUseAbleService.id;
1332
- // Make sure the service has correct scope as it might have been added by user previously
1333
- reUseAbleService.scope = 'system';
1334
- }
1335
- }
1336
- });
1337
- });
1338
- // Check if all the services from the preset are now in the store. Some services might not be used in the parameter.
1339
- timeSeriesPresetWithParameterIds == null || (_timeSeriesPresetWith = timeSeriesPresetWithParameterIds.services) == null || _timeSeriesPresetWith.forEach(function (serviceFromPreset) {
1340
- var _draft$services7;
1341
- var serviceFromAction = (_draft$services7 = draft.services) == null ? void 0 : _draft$services7.find(function (serviceFromStore) {
1342
- return serviceFromPreset.url === serviceFromStore.url;
1343
- });
1344
- // The service from the preset was not added yet because it was not used in any parameter
1345
- if (!serviceFromAction) {
1346
- var _draft$services8, _draft$services9;
1347
- // Check if the id was already taken, if it was generate a new one.
1348
- var uniqueServiceId = (_draft$services8 = draft.services) != null && _draft$services8.find(function (service) {
1349
- return serviceFromPreset.id === service.id;
1350
- }) ? generateServiceId() : serviceFromPreset.id;
1351
- // Finally push the new (and unused) service to the store
1352
- (_draft$services9 = draft.services) == null || _draft$services9.push(Object.assign({}, serviceFromPreset, {
1353
- id: uniqueServiceId,
1354
- scope: 'system'
1355
- }));
1356
- newServicesAdded.push({
1357
- serviceId: uniqueServiceId,
1358
- serviceUrl: serviceFromPreset.url,
1359
- serviceName: serviceFromPreset.name,
1360
- type: serviceFromPreset.type,
1361
- scope: 'system'
1362
- });
1363
- } else {
1364
- // Make sure the service has correct scope as it might have been added by user previously
1365
- serviceFromAction.scope = 'system';
1366
- }
1270
+ var _action$payload$servi;
1271
+ draft.plotPreset = action.payload.plotPreset;
1272
+ var newServicesAdded = ((_action$payload$servi = action.payload.services) != null ? _action$payload$servi : []).map(function (service) {
1273
+ return {
1274
+ serviceId: service.id,
1275
+ serviceUrl: service.url,
1276
+ serviceName: service.name,
1277
+ type: service.type,
1278
+ scope: service.scope || 'system'
1279
+ };
1367
1280
  });
1368
- draft.plotPreset = timeSeriesPresetWithParameterIds.plotPreset;
1369
- // Add filterchips for any new services that were added
1370
- timeSeriesReducer(draft, {
1281
+ panelSlice.caseReducers.setServiceFilterChipsInStore(draft, {
1371
1282
  payload: newServicesAdded,
1372
1283
  type: timeSeriesActions.setServiceFilterChipsInStore.type
1373
1284
  });
@@ -1482,8 +1393,8 @@ var slice = createSlice({
1482
1393
  },
1483
1394
  // Select a filter chip - if this means all will be selected, ensure all gets set to selected
1484
1395
  setServiceFilterChipSelected: function setServiceFilterChipSelected(draft, action) {
1485
- var _draft$timeseriesSele;
1486
- var serviceFilterChipsById = (_draft$timeseriesSele = draft.timeseriesSelect) == null ? void 0 : _draft$timeseriesSele.filters.serviceFilterChips.entities;
1396
+ var _draft$timeseriesSele3;
1397
+ var serviceFilterChipsById = (_draft$timeseriesSele3 = draft.timeseriesSelect) == null ? void 0 : _draft$timeseriesSele3.filters.serviceFilterChips.entities;
1487
1398
  if (serviceFilterChipsById) {
1488
1399
  var activeServices = compact(Object.values(serviceFilterChipsById));
1489
1400
  var countSelectedServices = activeServices.filter(function (service) {
@@ -1491,7 +1402,10 @@ var slice = createSlice({
1491
1402
  }).length;
1492
1403
  var isAllServicesGoingToBeEnabled = countSelectedServices === activeServices.length - 1;
1493
1404
  if (isAllServicesGoingToBeEnabled) {
1494
- slice.caseReducers.setAllServiceFilterChipSelected(draft);
1405
+ panelSlice.caseReducers.setAllServiceFilterChipSelected(draft, {
1406
+ type: timeSeriesActions.setAllServiceFilterChipSelected.type,
1407
+ payload: {}
1408
+ });
1495
1409
  return;
1496
1410
  }
1497
1411
  var service = serviceFilterChipsById[action.payload.serviceId];
@@ -1499,7 +1413,7 @@ var slice = createSlice({
1499
1413
  }
1500
1414
  },
1501
1415
  // Select all filter chips
1502
- setAllServiceFilterChipSelected: function setAllServiceFilterChipSelected(draft) {
1416
+ setAllServiceFilterChipSelected: function setAllServiceFilterChipSelected(draft, _action) {
1503
1417
  if (draft.timeseriesSelect) {
1504
1418
  var serviceFilterChipsById = draft.timeseriesSelect.filters.serviceFilterChips.entities;
1505
1419
  var servicesToTurnOn = compact(Object.values(serviceFilterChipsById)).filter(function (service) {
@@ -1533,6 +1447,10 @@ var slice = createSlice({
1533
1447
  };
1534
1448
  });
1535
1449
  timeseriesSelectServiceFilterChipsAdapter.updateMany(draft.timeseriesSelect.filters.serviceFilterChips, updates);
1450
+ var selectedService = serviceFilterChipsById[action.payload.serviceId];
1451
+ if (selectedService) {
1452
+ selectedService.enabled = true;
1453
+ }
1536
1454
  draft.timeseriesSelect.filters.allServiceFilterChipsEnabled = false;
1537
1455
  }
1538
1456
  },
@@ -1545,7 +1463,10 @@ var slice = createSlice({
1545
1463
  }).length;
1546
1464
  var isAllServicesGoingToBeDisabled = countPressedServices === 1;
1547
1465
  if (isAllServicesGoingToBeDisabled) {
1548
- slice.caseReducers.setAllServiceFilterChipSelected(draft);
1466
+ panelSlice.caseReducers.setAllServiceFilterChipSelected(draft, {
1467
+ type: timeSeriesActions.setAllServiceFilterChipSelected.type,
1468
+ payload: {}
1469
+ });
1549
1470
  return;
1550
1471
  }
1551
1472
  var service = serviceFilterChipsById[action.payload.serviceId];
@@ -1555,11 +1476,11 @@ var slice = createSlice({
1555
1476
  setServiceFilterChipsInStore: function setServiceFilterChipsInStore(draft, action) {
1556
1477
  action.payload.forEach(function (service) {
1557
1478
  if (draft.timeseriesSelect) {
1558
- var _draft$timeseriesSele2;
1479
+ var _draft$timeseriesSele4;
1559
1480
  draft.timeseriesSelect.filters.serviceFilterChips.entities[service.serviceId] = {
1560
1481
  serviceId: service.serviceId,
1561
1482
  serviceName: service.serviceName || service.serviceId,
1562
- enabled: (_draft$timeseriesSele2 = draft.timeseriesSelect) == null ? void 0 : _draft$timeseriesSele2.filters.allServiceFilterChipsEnabled,
1483
+ enabled: (_draft$timeseriesSele4 = draft.timeseriesSelect) == null ? void 0 : _draft$timeseriesSele4.filters.allServiceFilterChipsEnabled,
1563
1484
  scope: service.scope || 'system',
1564
1485
  type: service.type,
1565
1486
  serviceUrl: service.serviceUrl,
@@ -1586,90 +1507,41 @@ var slice = createSlice({
1586
1507
  }
1587
1508
  },
1588
1509
  addServices: function addServices(draft, action) {
1589
- var _draft$services0;
1590
- if (!((_draft$services0 = draft.services) != null && _draft$services0.length)) {
1591
- draft.services = action.payload.timeSeriesServices;
1592
- } else {
1593
- var filteredServices = action.payload.timeSeriesServices.reduce(function (acc, service) {
1594
- if (!draft.services.some(function (existingService) {
1595
- return existingService.url === service.url;
1596
- })) {
1597
- var hasDuplicateId = draft.services.some(function (existingService) {
1598
- return existingService.id === service.id;
1599
- });
1600
- if (hasDuplicateId) {
1601
- acc.push(Object.assign({}, service, {
1602
- id: generateServiceId()
1603
- }));
1604
- } else {
1605
- acc.push(service);
1606
- }
1607
- }
1608
- return acc;
1609
- }, []);
1610
- draft.services = [].concat(draft.services, filteredServices);
1611
- }
1612
- var newServicesAdded = draft.services.map(function (service) {
1510
+ var newServicesAdded = action.payload.timeSeriesServices.map(function (service) {
1613
1511
  return {
1614
1512
  serviceId: service.id,
1615
1513
  serviceUrl: service.url,
1616
1514
  serviceName: service.name,
1617
1515
  type: service.type,
1618
- scope: 'system'
1516
+ scope: service.scope || 'system'
1619
1517
  };
1620
1518
  });
1621
1519
  // Add filterchips for any new services that were added
1622
- timeSeriesReducer(draft, {
1520
+ panelSlice.caseReducers.setServiceFilterChipsInStore(draft, {
1623
1521
  payload: newServicesAdded,
1624
1522
  type: timeSeriesActions.setServiceFilterChipsInStore.type
1625
1523
  });
1626
1524
  },
1627
1525
  upsertService: function upsertService(draft, action) {
1628
- var _draft$services1;
1629
- var newService = {
1630
- id: action.payload.id || generateServiceId(),
1631
- description: action.payload.description,
1632
- url: action.payload.url,
1633
- name: action.payload.name,
1634
- type: action.payload.type,
1635
- scope: 'user'
1636
- };
1637
- if (!((_draft$services1 = draft.services) != null && _draft$services1.length)) {
1638
- draft.services = [newService];
1639
- } else if (action.payload.isUpdate) {
1640
- var index = draft.services.findIndex(function (el) {
1641
- return el.id === action.payload.id;
1642
- });
1643
- if (index >= 0) {
1644
- draft.services[index] = newService;
1645
- }
1646
- } else {
1647
- draft.services = [].concat(draft.services, [newService]);
1648
- }
1649
1526
  // Add filterchips for any new services that were added
1650
- timeSeriesReducer(draft, {
1527
+ panelSlice.caseReducers.setServiceFilterChipsInStore(draft, {
1651
1528
  payload: [{
1652
- serviceId: newService.id,
1653
- serviceUrl: newService.url,
1654
- serviceName: newService.name,
1655
- type: newService.type,
1529
+ serviceId: action.payload.id || generateServiceId(),
1530
+ serviceUrl: action.payload.url,
1531
+ serviceName: action.payload.name,
1532
+ type: action.payload.type,
1656
1533
  scope: 'user'
1657
1534
  }],
1658
1535
  type: timeSeriesActions.setServiceFilterChipsInStore.type
1659
1536
  });
1660
1537
  },
1661
1538
  removeService: function removeService(draft, action) {
1662
- if (draft.services) {
1663
- draft.services = draft.services.filter(function (el) {
1664
- return el.id !== action.payload.id;
1665
- });
1666
- timeSeriesReducer(draft, {
1667
- payload: action.payload,
1668
- type: timeSeriesActions.removeServiceFilterChipFromStore.type
1669
- });
1670
- }
1539
+ panelSlice.caseReducers.removeServiceFilterChipFromStore(draft, {
1540
+ payload: action.payload,
1541
+ type: timeSeriesActions.removeServiceFilterChipFromStore.type
1542
+ });
1671
1543
  },
1672
- closeServicePopup: function closeServicePopup(draft) {
1544
+ closeServicePopup: function closeServicePopup(draft, _action) {
1673
1545
  if (draft.timeseriesSelect) {
1674
1546
  draft.timeseriesSelect.servicePopup.isOpen = false;
1675
1547
  }
@@ -1708,8 +1580,316 @@ var slice = createSlice({
1708
1580
  }
1709
1581
  }
1710
1582
  });
1711
- var timeSeriesReducer = slice.reducer,
1712
- timeSeriesActions = slice.actions;
1583
+ var resetTimeSeriesPanels = createAction('timeseriesPanel/resetPanels');
1584
+ var timeSeriesActions = Object.assign({}, panelSlice.actions, {
1585
+ resetTimeSeriesPanels: resetTimeSeriesPanels
1586
+ });
1587
+ var resolvePanelId = function resolvePanelId(action) {
1588
+ var _action$payload3;
1589
+ return (_action$payload3 = action.payload) == null ? void 0 : _action$payload3.panelId;
1590
+ };
1591
+ var normalizeTimeSeriesState = function normalizeTimeSeriesState(state) {
1592
+ if ('byId' in state) {
1593
+ return state;
1594
+ }
1595
+ var legacyServices = state.services || [];
1596
+ state.services;
1597
+ var panelState = _objectWithoutPropertiesLoose(state, _excluded$3);
1598
+ return Object.assign({}, initialState, {
1599
+ services: legacyServices,
1600
+ byId: Object.assign({}, initialState.byId, {
1601
+ "default": panelState
1602
+ })
1603
+ });
1604
+ };
1605
+ var toServiceFilterChip = function toServiceFilterChip(service) {
1606
+ return {
1607
+ serviceId: service.id,
1608
+ serviceUrl: service.url,
1609
+ serviceName: service.name,
1610
+ type: service.type,
1611
+ scope: service.scope || 'system'
1612
+ };
1613
+ };
1614
+ var addServiceFilterChipsToPanel = function addServiceFilterChipsToPanel(panelState, servicesToAdd) {
1615
+ var _panelState$timeserie;
1616
+ if (!servicesToAdd.length) {
1617
+ return panelState;
1618
+ }
1619
+ var existingChips = ((_panelState$timeserie = panelState.timeseriesSelect) == null ? void 0 : _panelState$timeserie.filters.serviceFilterChips.entities) || {};
1620
+ var servicesMissingChips = servicesToAdd.filter(function (service) {
1621
+ return !existingChips[service.id];
1622
+ });
1623
+ if (!servicesMissingChips.length) {
1624
+ return panelState;
1625
+ }
1626
+ return panelSlice.reducer(panelState, timeSeriesActions.setServiceFilterChipsInStore(servicesMissingChips.map(toServiceFilterChip)));
1627
+ };
1628
+ var removeServiceFilterChipsFromPanel = function removeServiceFilterChipsFromPanel(panelState, serviceIdsToRemove) {
1629
+ if (!serviceIdsToRemove.length) {
1630
+ return panelState;
1631
+ }
1632
+ return serviceIdsToRemove.reduce(function (nextState, id) {
1633
+ return panelSlice.reducer(nextState, timeSeriesActions.removeServiceFilterChipFromStore({
1634
+ id: id
1635
+ }));
1636
+ }, panelState);
1637
+ };
1638
+ var timeSeriesReducer = function timeSeriesReducer(state, action) {
1639
+ var _Object$assign2, _Object$assign3;
1640
+ var normalizedState = normalizeTimeSeriesState(state != null ? state : initialState);
1641
+ var isTimeSeriesAction = typeof action.type === 'string' && action.type.startsWith(panelSlice.name + "/");
1642
+ if (action.type === resetTimeSeriesPanels.type) {
1643
+ return Object.assign({}, normalizedState, {
1644
+ byId: {}
1645
+ });
1646
+ }
1647
+ if (!isTimeSeriesAction) {
1648
+ return normalizedState;
1649
+ }
1650
+ var panelId = resolvePanelId(action);
1651
+ var serviceActionTypes = new Set([timeSeriesActions.loadUserAddedTimeSeriesServices.type, timeSeriesActions.addServices.type, timeSeriesActions.upsertService.type, timeSeriesActions.removeService.type, timeSeriesActions.registerTimeSeriesPreset.type]);
1652
+ var nextServices = normalizedState.services;
1653
+ if (action.type === timeSeriesActions.loadUserAddedTimeSeriesServices.type) {
1654
+ var payload = action.payload;
1655
+ var servicesPayload = Array.isArray(payload) ? payload : payload.timeSeriesServices;
1656
+ var newServices = [];
1657
+ servicesPayload.forEach(function (service) {
1658
+ var existingService = nextServices.find(function (el) {
1659
+ return el.url === service.url;
1660
+ });
1661
+ if (!existingService) {
1662
+ var _service$scope2;
1663
+ newServices.push(Object.assign({}, service, {
1664
+ id: service.scope === 'system' ? service.id : generateServiceId(),
1665
+ scope: (_service$scope2 = service.scope) != null ? _service$scope2 : 'user'
1666
+ }));
1667
+ }
1668
+ });
1669
+ if (newServices.length) {
1670
+ nextServices = [].concat(nextServices, newServices);
1671
+ }
1672
+ }
1673
+ if (action.type === timeSeriesActions.addServices.type) {
1674
+ var timeSeriesServices = action.payload.timeSeriesServices;
1675
+ var filteredServices = timeSeriesServices.reduce(function (acc, service) {
1676
+ if (!nextServices.some(function (existing) {
1677
+ return existing.url === service.url;
1678
+ })) {
1679
+ var hasDuplicateId = nextServices.some(function (existing) {
1680
+ return existing.id === service.id;
1681
+ });
1682
+ if (hasDuplicateId) {
1683
+ acc.push(Object.assign({}, service, {
1684
+ id: generateServiceId()
1685
+ }));
1686
+ } else {
1687
+ acc.push(service);
1688
+ }
1689
+ }
1690
+ return acc;
1691
+ }, []);
1692
+ if (filteredServices.length) {
1693
+ nextServices = [].concat(nextServices, filteredServices);
1694
+ }
1695
+ }
1696
+ if (action.type === timeSeriesActions.upsertService.type) {
1697
+ var _payload = action.payload;
1698
+ var newService = {
1699
+ id: _payload.id || generateServiceId(),
1700
+ description: _payload.description,
1701
+ url: _payload.url,
1702
+ name: _payload.name,
1703
+ type: _payload.type,
1704
+ scope: 'user'
1705
+ };
1706
+ if (_payload.isUpdate) {
1707
+ var index = nextServices.findIndex(function (el) {
1708
+ return el.id === _payload.id;
1709
+ });
1710
+ if (index >= 0) {
1711
+ nextServices = [].concat(nextServices.slice(0, index), [newService], nextServices.slice(index + 1));
1712
+ }
1713
+ } else {
1714
+ nextServices = [].concat(nextServices, [newService]);
1715
+ }
1716
+ }
1717
+ if (action.type === timeSeriesActions.removeService.type) {
1718
+ var id = action.payload.id;
1719
+ nextServices = nextServices.filter(function (service) {
1720
+ return service.id !== id;
1721
+ });
1722
+ }
1723
+ var previousServices = normalizedState.services;
1724
+ var addedServices = nextServices.filter(function (service) {
1725
+ return !previousServices.some(function (existing) {
1726
+ return existing.url === service.url;
1727
+ });
1728
+ });
1729
+ var updatedServices = nextServices.filter(function (service) {
1730
+ var previous = previousServices.find(function (existing) {
1731
+ return existing.id === service.id;
1732
+ });
1733
+ return previous && (previous.name !== service.name || previous.url !== service.url || previous.type !== service.type || previous.scope !== service.scope);
1734
+ });
1735
+ var removedServiceIds = previousServices.filter(function (service) {
1736
+ return !nextServices.some(function (existing) {
1737
+ return existing.id === service.id;
1738
+ });
1739
+ }).map(function (service) {
1740
+ return service.id;
1741
+ });
1742
+ var servicesToSync = [].concat(addedServices, updatedServices.filter(function (service) {
1743
+ return !addedServices.some(function (added) {
1744
+ return added.id === service.id;
1745
+ });
1746
+ }));
1747
+ var syncServiceChipsAcrossPanels = function syncServiceChipsAcrossPanels(byId, overrideServicesToSync, overrideRemovedServiceIds) {
1748
+ var servicesForSync = overrideServicesToSync != null ? overrideServicesToSync : servicesToSync;
1749
+ var removedIdsForSync = removedServiceIds;
1750
+ var shouldSync = servicesForSync.length > 0 || removedIdsForSync.length > 0;
1751
+ if (!shouldSync) {
1752
+ return byId;
1753
+ }
1754
+ var nextById = {};
1755
+ var didChange = false;
1756
+ Object.entries(byId).forEach(function (_ref) {
1757
+ var id = _ref[0],
1758
+ panelState = _ref[1];
1759
+ var nextPanelState = panelState;
1760
+ nextPanelState = addServiceFilterChipsToPanel(nextPanelState, servicesForSync);
1761
+ nextPanelState = removeServiceFilterChipsFromPanel(nextPanelState, removedIdsForSync);
1762
+ if (nextPanelState !== panelState) {
1763
+ didChange = true;
1764
+ }
1765
+ nextById[id] = nextPanelState;
1766
+ });
1767
+ return didChange ? nextById : byId;
1768
+ };
1769
+ if (action.type === timeSeriesActions.registerTimeSeriesPreset.type) {
1770
+ var _normalizedState$byId, _payload2$services, _Object$assign;
1771
+ var _payload2 = action.payload;
1772
+ if (!panelId) {
1773
+ return Object.assign({}, normalizedState, {
1774
+ services: nextServices,
1775
+ byId: syncServiceChipsAcrossPanels(normalizedState.byId)
1776
+ });
1777
+ }
1778
+ var _currentPanelState = (_normalizedState$byId = normalizedState.byId[panelId]) != null ? _normalizedState$byId : createPanelState();
1779
+ var newServicesAdded = [];
1780
+ var presetServices = (_payload2$services = _payload2.services) != null ? _payload2$services : [];
1781
+ var timeSeriesPresetWithParameterIds = produce(_payload2, function (draftPreset) {
1782
+ draftPreset.plotPreset.parameters.forEach(function (draftParameter) {
1783
+ draftParameter.id = generateParameterId();
1784
+ draftParameter.opacity = draftParameter.opacity || 70;
1785
+ var serviceFromStore = getServiceById(nextServices, draftParameter.serviceId);
1786
+ if (!serviceFromStore) {
1787
+ var serviceFromPreset = getServiceById(presetServices, draftParameter.serviceId);
1788
+ if (!serviceFromPreset) {
1789
+ console.error("A parameter from the preset has a service with id " + draftParameter.serviceId + " which is not in the store or in the preset");
1790
+ return;
1791
+ }
1792
+ var reUseAbleService = nextServices.find(function (storeService) {
1793
+ return storeService.url === serviceFromPreset.url;
1794
+ });
1795
+ if (!reUseAbleService) {
1796
+ nextServices = [].concat(nextServices, [Object.assign({}, serviceFromPreset, {
1797
+ scope: 'system'
1798
+ })]);
1799
+ newServicesAdded.push({
1800
+ serviceId: serviceFromPreset.id,
1801
+ serviceUrl: serviceFromPreset.url,
1802
+ serviceName: serviceFromPreset.name,
1803
+ type: serviceFromPreset.type,
1804
+ scope: 'system'
1805
+ });
1806
+ } else {
1807
+ draftParameter.serviceId = reUseAbleService.id;
1808
+ nextServices = nextServices.map(function (service) {
1809
+ return service.id === reUseAbleService.id ? Object.assign({}, service, {
1810
+ scope: 'system'
1811
+ }) : service;
1812
+ });
1813
+ }
1814
+ }
1815
+ });
1816
+ });
1817
+ presetServices.forEach(function (serviceFromPreset) {
1818
+ var serviceFromStore = nextServices.find(function (service) {
1819
+ return service.url === serviceFromPreset.url;
1820
+ });
1821
+ if (!serviceFromStore) {
1822
+ var uniqueServiceId = nextServices.some(function (service) {
1823
+ return service.id === serviceFromPreset.id;
1824
+ }) ? generateServiceId() : serviceFromPreset.id;
1825
+ nextServices = [].concat(nextServices, [Object.assign({}, serviceFromPreset, {
1826
+ id: uniqueServiceId,
1827
+ scope: 'system'
1828
+ })]);
1829
+ newServicesAdded.push({
1830
+ serviceId: uniqueServiceId,
1831
+ serviceUrl: serviceFromPreset.url,
1832
+ serviceName: serviceFromPreset.name,
1833
+ type: serviceFromPreset.type,
1834
+ scope: 'system'
1835
+ });
1836
+ } else {
1837
+ nextServices = nextServices.map(function (service) {
1838
+ return service.id === serviceFromStore.id ? Object.assign({}, service, {
1839
+ scope: 'system'
1840
+ }) : service;
1841
+ });
1842
+ }
1843
+ });
1844
+ var _nextPanelState = produce(_currentPanelState, function (draft) {
1845
+ draft.plotPreset = timeSeriesPresetWithParameterIds.plotPreset;
1846
+ panelSlice.caseReducers.setServiceFilterChipsInStore(draft, {
1847
+ payload: newServicesAdded,
1848
+ type: timeSeriesActions.setServiceFilterChipsInStore.type
1849
+ });
1850
+ });
1851
+ var updatedById = Object.assign({}, normalizedState.byId, (_Object$assign = {}, _Object$assign[panelId] = _nextPanelState, _Object$assign));
1852
+ var servicesToSyncFromPreset = Array.from(new Map([].concat(newServicesAdded.map(function (service) {
1853
+ return nextServices.find(function (nextService) {
1854
+ return nextService.id === service.serviceId;
1855
+ });
1856
+ }), presetServices.map(function (service) {
1857
+ return nextServices.find(function (nextService) {
1858
+ return nextService.url === service.url || nextService.id === service.id;
1859
+ });
1860
+ })).filter(function (service) {
1861
+ return !!service;
1862
+ }).map(function (service) {
1863
+ return [service.id, service];
1864
+ })).values());
1865
+ return Object.assign({}, normalizedState, {
1866
+ services: nextServices,
1867
+ byId: syncServiceChipsAcrossPanels(updatedById, servicesToSyncFromPreset)
1868
+ });
1869
+ }
1870
+ if (!panelId) {
1871
+ if (serviceActionTypes.has(action.type)) {
1872
+ return Object.assign({}, normalizedState, {
1873
+ services: nextServices,
1874
+ byId: syncServiceChipsAcrossPanels(normalizedState.byId)
1875
+ });
1876
+ }
1877
+ return normalizedState;
1878
+ }
1879
+ var currentPanelState = normalizedState.byId[panelId];
1880
+ var basePanelState = currentPanelState != null ? currentPanelState : createPanelState();
1881
+ if (normalizedState.services.length) {
1882
+ basePanelState = addServiceFilterChipsToPanel(basePanelState, normalizedState.services);
1883
+ }
1884
+ var nextPanelState = panelSlice.reducer(basePanelState, action);
1885
+ if (nextPanelState === currentPanelState && nextServices === normalizedState.services) {
1886
+ return normalizedState;
1887
+ }
1888
+ return Object.assign({}, normalizedState, {
1889
+ services: nextServices,
1890
+ byId: serviceActionTypes.has(action.type) ? syncServiceChipsAcrossPanels(Object.assign({}, normalizedState.byId, (_Object$assign2 = {}, _Object$assign2[panelId] = nextPanelState, _Object$assign2))) : Object.assign({}, normalizedState.byId, (_Object$assign3 = {}, _Object$assign3[panelId] = nextPanelState, _Object$assign3))
1891
+ });
1892
+ };
1713
1893
  var generateTimeSeriesId = function generateTimeSeriesId() {
1714
1894
  return "timeseriesid_" + v4();
1715
1895
  };
@@ -1737,20 +1917,36 @@ var generateServiceId = function generateServiceId() {
1737
1917
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
1738
1918
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1739
1919
  * */
1740
- var getPlotState = function getPlotState(state) {
1741
- var _state$timeSeries;
1742
- return (_state$timeSeries = state.timeSeries) == null ? void 0 : _state$timeSeries.plotPreset;
1920
+ var getPanelState = function getPanelState(state, panelId) {
1921
+ var timeSeriesState = state.timeSeries;
1922
+ if (!timeSeriesState) {
1923
+ return undefined;
1924
+ }
1925
+ if ('byId' in timeSeriesState) {
1926
+ var _timeSeriesState$byId;
1927
+ if (!panelId) {
1928
+ return undefined;
1929
+ }
1930
+ return (_timeSeriesState$byId = timeSeriesState.byId) == null ? void 0 : _timeSeriesState$byId[panelId];
1931
+ }
1932
+ return timeSeriesState;
1743
1933
  };
1744
- var getTimeSeriesState = function getTimeSeriesState(state) {
1745
- return state.timeSeries;
1934
+ var getPlotState = function getPlotState(state, panelId) {
1935
+ var _getPanelState;
1936
+ return (_getPanelState = getPanelState(state, panelId)) == null ? void 0 : _getPanelState.plotPreset;
1746
1937
  };
1747
- var getMapId = function getMapId(state) {
1748
- var _state$timeSeries2;
1749
- return (_state$timeSeries2 = state.timeSeries) == null || (_state$timeSeries2 = _state$timeSeries2.plotPreset) == null ? void 0 : _state$timeSeries2.mapId;
1938
+ var getTimeSeriesState = function getTimeSeriesState(state, panelId) {
1939
+ return getPanelState(state, panelId);
1750
1940
  };
1751
- var getPlotWithParameters = createSelector(getPlotState, function (_, selectPlotId) {
1941
+ var getMapId = function getMapId(state, panelId) {
1942
+ var _getPanelState2;
1943
+ return (_getPanelState2 = getPanelState(state, panelId)) == null || (_getPanelState2 = _getPanelState2.plotPreset) == null ? void 0 : _getPanelState2.mapId;
1944
+ };
1945
+ var getPlotWithParameters = createSelector([function (state, _selectPlotId, panelId) {
1946
+ return getPlotState(state, panelId);
1947
+ }, function (_, selectPlotId) {
1752
1948
  return selectPlotId;
1753
- }, function (plotPreset, selectPlotId) {
1949
+ }], function (plotPreset, selectPlotId) {
1754
1950
  if (!plotPreset || !selectPlotId) {
1755
1951
  return undefined;
1756
1952
  }
@@ -1767,13 +1963,26 @@ var getPlotWithParameters = createSelector(getPlotState, function (_, selectPlot
1767
1963
  parameters: parameters
1768
1964
  });
1769
1965
  });
1770
- var getService = createSelector(getTimeSeriesState, function (_, serviceId) {
1966
+ var getService = createSelector([function (state, _serviceId, _panelId) {
1967
+ return state.timeSeries;
1968
+ }, function (_, serviceId) {
1771
1969
  return serviceId;
1772
- }, function (timeSeriesState, serviceId) {
1773
- return timeSeriesState != null && timeSeriesState.services ? getServiceById(timeSeriesState.services, serviceId) : undefined;
1970
+ }], function (timeSeriesState, serviceId) {
1971
+ if (!timeSeriesState || !('byId' in timeSeriesState)) {
1972
+ return undefined;
1973
+ }
1974
+ return getServiceById(timeSeriesState.services || [], serviceId);
1774
1975
  });
1775
- var getServices = createSelector(getTimeSeriesState, function (timeSeriesState) {
1776
- return timeSeriesState == null ? void 0 : timeSeriesState.services;
1976
+ var getServices = createSelector([function (state, _panelId) {
1977
+ return state.timeSeries;
1978
+ }], function (timeSeriesState) {
1979
+ if (!timeSeriesState) {
1980
+ return [];
1981
+ }
1982
+ if ('byId' in timeSeriesState) {
1983
+ return timeSeriesState.services;
1984
+ }
1985
+ return [];
1777
1986
  }, selectorMemoizationOptions);
1778
1987
  /**
1779
1988
  * Returns search filter string
@@ -1805,18 +2014,31 @@ var getParametersInUse = createSelector(getTimeSeriesState, function (store) {
1805
2014
  * @returns {ActiveServiceObjectEntities} returnType: ActiveServiceObjectEntitiesobject of active services
1806
2015
  */
1807
2016
  // cast to usable type - selectEntities returns Dictionary<ActiveServiceObject> which is not usable inside of the code
1808
- var getServiceFilterChips = function getServiceFilterChips(store) {
1809
- return getServiceFilterChipsDictionary(store);
1810
- };
1811
- var _timeseriesSelectServ = timeseriesSelectServiceFilterChipsAdapter.getSelectors(function (store) {
1812
- var _store$timeSeries;
1813
- return (store == null || (_store$timeSeries = store.timeSeries) == null || (_store$timeSeries = _store$timeSeries.timeseriesSelect) == null || (_store$timeSeries = _store$timeSeries.filters) == null ? void 0 : _store$timeSeries.serviceFilterChips) || {
1814
- entities: {},
1815
- ids: []
1816
- };
1817
- }),
1818
- getServiceFilterChipsDictionary = _timeseriesSelectServ.selectEntities,
1819
- getServiceFilterChipsById = _timeseriesSelectServ.selectById;
2017
+ var getServiceFilterChipsState = function getServiceFilterChipsState(store, panelId) {
2018
+ var _getTimeSeriesState;
2019
+ return ((_getTimeSeriesState = getTimeSeriesState(store, panelId)) == null || (_getTimeSeriesState = _getTimeSeriesState.timeseriesSelect) == null || (_getTimeSeriesState = _getTimeSeriesState.filters) == null ? void 0 : _getTimeSeriesState.serviceFilterChips) || {
2020
+ entities: {},
2021
+ ids: []
2022
+ };
2023
+ };
2024
+ var makeServiceFilterChipsSelectors = function makeServiceFilterChipsSelectors(panelId) {
2025
+ return timeseriesSelectServiceFilterChipsAdapter.getSelectors(function (store) {
2026
+ return getServiceFilterChipsState(store, panelId);
2027
+ });
2028
+ };
2029
+ var getServiceFilterChips = function getServiceFilterChips(store, panelId) {
2030
+ return makeServiceFilterChipsSelectors(panelId).selectEntities(store);
2031
+ };
2032
+ var getServiceFilterChipsById = function getServiceFilterChipsById(store, id, panelId) {
2033
+ return makeServiceFilterChipsSelectors(panelId).selectById(store, id);
2034
+ };
2035
+ /**
2036
+ * Returns whether all service filter chips are enabled
2037
+ *
2038
+ * Example getAllFilterChipsEnabled(store);
2039
+ * @param {object} store store: object - store object
2040
+ * @returns {boolean} returnType: boolean
2041
+ */
1820
2042
  var getAllFilterChipsEnabled = createSelector(getTimeSeriesState, function (store) {
1821
2043
  var _store$timeseriesSele2;
1822
2044
  return (store == null || (_store$timeseriesSele2 = store.timeseriesSelect) == null || (_store$timeseriesSele2 = _store$timeseriesSele2.filters) == null ? void 0 : _store$timeseriesSele2.allServiceFilterChipsEnabled) || false;
@@ -1860,9 +2082,11 @@ var getParameterInfoParameter = createSelector(getTimeSeriesState, function (sto
1860
2082
  * @param {string} parameterId parameterId
1861
2083
  * @returns {Parameter} returnType: Parameter
1862
2084
  */
1863
- var getParameterById = createSelector(getTimeSeriesState, function (store, parameterId) {
1864
- return parameterId;
2085
+ var getParameterById = createSelector([function (store, _parameterId, panelId) {
2086
+ return getTimeSeriesState(store, panelId);
1865
2087
  }, function (store, parameterId) {
2088
+ return parameterId;
2089
+ }], function (store, parameterId) {
1866
2090
  if (store != null && store.plotPreset) {
1867
2091
  var _store$plotPreset$par2;
1868
2092
  return (_store$plotPreset$par2 = store.plotPreset.parameters) == null ? void 0 : _store$plotPreset$par2.find(function (parameter) {
@@ -1873,7 +2097,7 @@ var getParameterById = createSelector(getTimeSeriesState, function (store, param
1873
2097
  });
1874
2098
  var getServicePopupDetails = createSelector(getTimeSeriesState, function (store) {
1875
2099
  var _store$timeseriesSele6;
1876
- return (store == null || (_store$timeseriesSele6 = store.timeseriesSelect) == null ? void 0 : _store$timeseriesSele6.servicePopup) || initialState.timeseriesSelect.servicePopup;
2100
+ return (store == null || (_store$timeseriesSele6 = store.timeseriesSelect) == null ? void 0 : _store$timeseriesSele6.servicePopup) || initialPanelState.timeseriesSelect.servicePopup;
1877
2101
  });
1878
2102
  var getTimeSeriesPreset = createSelector(getPlotState, getServices, function (plotState, services) {
1879
2103
  if (!plotState || !services) {
@@ -1961,6 +2185,7 @@ var selectors = /*#__PURE__*/Object.freeze({
1961
2185
  getIsLegendVisible: getIsLegendVisible,
1962
2186
  getIsMapPinDisabled: getIsMapPinDisabled,
1963
2187
  getMapId: getMapId,
2188
+ getPanelState: getPanelState,
1964
2189
  getParameterById: getParameterById,
1965
2190
  getParameterInfoParameter: getParameterInfoParameter,
1966
2191
  getParametersInUse: getParametersInUse,
@@ -1970,7 +2195,6 @@ var selectors = /*#__PURE__*/Object.freeze({
1970
2195
  getService: getService,
1971
2196
  getServiceFilterChips: getServiceFilterChips,
1972
2197
  getServiceFilterChipsById: getServiceFilterChipsById,
1973
- getServiceFilterChipsDictionary: getServiceFilterChipsDictionary,
1974
2198
  getServicePopupDetails: getServicePopupDetails,
1975
2199
  getServices: getServices,
1976
2200
  getShouldHideLocationMarkers: getShouldHideLocationMarkers,
@@ -2008,47 +2232,50 @@ var types = /*#__PURE__*/Object.freeze({
2008
2232
 
2009
2233
  var ParameterInfoButtonConnect = function ParameterInfoButtonConnect(_ref) {
2010
2234
  var parameter = _ref.parameter,
2011
- _ref$source = _ref.source,
2012
- source = _ref$source === void 0 ? 'app' : _ref$source;
2235
+ panelId = _ref.panelId;
2013
2236
  var dispatch = useDispatch();
2237
+ var currentSourcePanelId = useSelector(function (store) {
2238
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesInfo);
2239
+ });
2014
2240
  var isOpenInStore = useSelector(function (store) {
2015
2241
  return uiSelectors.getisDialogOpen(store, uiTypes.DialogTypes.TimeSeriesInfo);
2016
2242
  });
2017
2243
  var currentParameterDisplayed = useSelector(function (store) {
2018
- return getParameterInfoParameter(store);
2244
+ return getParameterInfoParameter(store, panelId);
2019
2245
  });
2020
2246
  var isActive = parameter.id ? parameter.id === (currentParameterDisplayed == null ? void 0 : currentParameterDisplayed.id) : parameter.propertyName === (currentParameterDisplayed == null ? void 0 : currentParameterDisplayed.propertyName) && parameter.serviceId === (currentParameterDisplayed == null ? void 0 : currentParameterDisplayed.serviceId) && parameter.collectionId === (currentParameterDisplayed == null ? void 0 : currentParameterDisplayed.collectionId);
2021
2247
  var toggleInfoDialog = React.useCallback(function () {
2022
- dispatch(uiActions.setActiveMapIdForDialog({
2248
+ dispatch(uiActions.setToggleOpenDialog({
2023
2249
  type: uiTypes.DialogTypes.TimeSeriesInfo,
2024
- mapId: '',
2025
- setOpen: !isOpenInStore,
2026
- source: source
2250
+ setOpen: currentSourcePanelId !== panelId ? true : !isOpenInStore,
2251
+ sourcePanelId: panelId
2027
2252
  }));
2028
- }, [dispatch, isOpenInStore, source]);
2253
+ }, [dispatch, isOpenInStore, currentSourcePanelId, panelId]);
2029
2254
  var setCurrentParameterInfoDisplayed = React.useCallback(function () {
2030
2255
  dispatch(timeSeriesActions.setCurrentParameterInfoDisplayed({
2256
+ panelId: panelId,
2031
2257
  parameter: parameter.id || parameter
2032
2258
  }));
2033
2259
  dispatch(uiActions.orderDialog({
2034
2260
  type: uiTypes.DialogTypes.TimeSeriesInfo
2035
2261
  }));
2036
- }, [dispatch, parameter]);
2262
+ }, [dispatch, panelId, parameter]);
2263
+ var isOpenForPanel = isOpenInStore && currentSourcePanelId === panelId;
2037
2264
  var onClick = useCallback(function () {
2038
2265
  if (isActive) {
2039
2266
  toggleInfoDialog();
2040
2267
  }
2041
- if (!isActive && isOpenInStore) {
2268
+ if (!isActive && isOpenForPanel) {
2042
2269
  setCurrentParameterInfoDisplayed();
2043
2270
  }
2044
- if (!isActive && !isOpenInStore) {
2271
+ if (!isActive && !isOpenForPanel) {
2045
2272
  setCurrentParameterInfoDisplayed();
2046
2273
  toggleInfoDialog();
2047
2274
  }
2048
- }, [isActive, toggleInfoDialog, isOpenInStore, setCurrentParameterInfoDisplayed]);
2275
+ }, [isActive, toggleInfoDialog, isOpenForPanel, setCurrentParameterInfoDisplayed]);
2049
2276
  return jsx(ParameterInfoButton, {
2050
2277
  isActive: isActive,
2051
- isOpenInStore: isOpenInStore,
2278
+ isOpenInStore: isOpenForPanel,
2052
2279
  onClick: onClick
2053
2280
  });
2054
2281
  };
@@ -3027,7 +3254,7 @@ var useGetCollectionsAndInstanceDetails = function useGetCollectionsAndInstanceD
3027
3254
  }
3028
3255
  });
3029
3256
  };
3030
- var useGetPlotsWithData = function useGetPlotsWithData(plotsWithoutData, selectedLocation, services, splitGeoJsonByCollection, t) {
3257
+ var useGetPlotsWithData = function useGetPlotsWithData(plotsWithoutData, selectedLocation, services, splitGeoJsonByCollection, t, syncgroupTimeState) {
3031
3258
  var _useState = useState([]),
3032
3259
  plotsWithData = _useState[0],
3033
3260
  setPlotsWithData = _useState[1];
@@ -3060,7 +3287,7 @@ var useGetPlotsWithData = function useGetPlotsWithData(plotsWithoutData, selecte
3060
3287
  };
3061
3288
  // Construct timeinterval that needs to be fetched
3062
3289
  // Create here so if new data is advertised by the collection/instance a new request is made
3063
- var intervalParam = constructTimeInterval(collection, instanceInfo);
3290
+ var intervalParam = constructTimeInterval(collection, instanceInfo, syncgroupTimeState);
3064
3291
  return {
3065
3292
  queryKey: generateTimeSeriesQueryKeys(['get-parameter-data', parameter.propertyName, parameter.serviceId, parameter.collectionId, parameter.instanceId || 'undefined', ((_parameter$dimension = parameter.dimension) == null ? void 0 : _parameter$dimension.value) || 'undefined', intervalParam, selectedLocation.lat.toString() || 'undefined', selectedLocation.lon.toString() || 'undefined']),
3066
3293
  queryFn: function () {
@@ -3099,7 +3326,7 @@ var useGetPlotsWithData = function useGetPlotsWithData(plotsWithoutData, selecte
3099
3326
  retry: false
3100
3327
  };
3101
3328
  });
3102
- }, [collectionDetails, geojsonMap, plotsWithoutData.parameters, selectedLocation, collectionsList, isDetailsFetching]);
3329
+ }, [plotsWithoutData.parameters, collectionsList, collectionDetails, syncgroupTimeState, selectedLocation, isDetailsFetching, geojsonMap]);
3103
3330
  var results = useQueries({
3104
3331
  queries: queries,
3105
3332
  combine: function combine(results) {
@@ -3417,7 +3644,8 @@ var ParameterNameSelect = function ParameterNameSelect(_ref) {
3417
3644
  };
3418
3645
 
3419
3646
  var TimeSeriesManagerRowAccordion = function TimeSeriesManagerRowAccordion(_ref) {
3420
- var plotIsEnabled = _ref.plotIsEnabled,
3647
+ var panelId = _ref.panelId,
3648
+ plotIsEnabled = _ref.plotIsEnabled,
3421
3649
  rowIsEnabled = _ref.rowIsEnabled,
3422
3650
  parameter = _ref.parameter,
3423
3651
  styles = _ref.styles,
@@ -3540,6 +3768,7 @@ var TimeSeriesManagerRowAccordion = function TimeSeriesManagerRowAccordion(_ref)
3540
3768
  },
3541
3769
  children: [jsx(Grid, {
3542
3770
  children: jsx(ParameterInfoButtonConnect, {
3771
+ panelId: panelId,
3543
3772
  parameter: parameter
3544
3773
  })
3545
3774
  }), jsx(Grid, {
@@ -3624,7 +3853,8 @@ var RowLayout = function RowLayout(_ref) {
3624
3853
 
3625
3854
  var ParameterList = function ParameterList(_ref) {
3626
3855
  var _plot$parameters, _plot$parameters2;
3627
- var plot = _ref.plot,
3856
+ var panelId = _ref.panelId,
3857
+ plot = _ref.plot,
3628
3858
  plotIsEnabled = _ref.plotIsEnabled,
3629
3859
  deleteParameter = _ref.deleteParameter,
3630
3860
  toggleParameter = _ref.toggleParameter,
@@ -3666,6 +3896,7 @@ var ParameterList = function ParameterList(_ref) {
3666
3896
  children: [jsx(Box, {
3667
3897
  className: "medium-timeseriesmanager",
3668
3898
  children: jsx(TimeSeriesManagerRowAccordion, {
3899
+ panelId: panelId,
3669
3900
  addParameter: addParameter,
3670
3901
  deleteParameter: deleteParameter,
3671
3902
  parameter: parameter,
@@ -3681,6 +3912,7 @@ var ParameterList = function ParameterList(_ref) {
3681
3912
  container: true,
3682
3913
  justifyContent: "space-between",
3683
3914
  children: [jsx(ParameterInfoButtonConnect, {
3915
+ panelId: panelId,
3684
3916
  parameter: parameter
3685
3917
  }), ' ', jsx(CustomIconButton, {
3686
3918
  "data-testid": "duplicateButton",
@@ -3792,36 +4024,36 @@ var TimeSeriesSelectButtonConnect = function TimeSeriesSelectButtonConnect(_ref)
3792
4024
  onClick = _ref.onClick,
3793
4025
  t = _ref.t,
3794
4026
  plotId = _ref.plotId,
3795
- selectPlotId = _ref.selectPlotId;
4027
+ selectPlotId = _ref.selectPlotId,
4028
+ panelId = _ref.panelId;
3796
4029
  var dispatch = useDispatch();
3797
- var currentActiveMapId = useSelector(function (store) {
3798
- return uiSelectors.getDialogMapId(store, uiTypes.DialogTypes.TimeSeriesSelect);
4030
+ var currentSourcePanelId = useSelector(function (store) {
4031
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesSelect);
3799
4032
  });
3800
4033
  var isOpenInStore = useSelector(function (store) {
3801
4034
  return uiSelectors.getisDialogOpen(store, uiTypes.DialogTypes.TimeSeriesSelect);
3802
4035
  });
3803
- var mapId = useSelector(getMapId);
3804
4036
  var handleClick = function handleClick() {
3805
4037
  onClick();
3806
- var openDialogForDifferentMap = currentActiveMapId !== mapId;
3807
- var dialogIsNotOpenForCurrentMap = openDialogForDifferentMap || !isOpenInStore;
3808
- if (dialogIsNotOpenForCurrentMap) {
3809
- dispatch(uiActions.setActiveMapIdForDialog({
4038
+ var openDialogForDifferentPanel = currentSourcePanelId !== panelId;
4039
+ var dialogIsNotOpenForCurrentPanel = openDialogForDifferentPanel || !isOpenInStore;
4040
+ if (dialogIsNotOpenForCurrentPanel) {
4041
+ dispatch(uiActions.setToggleOpenDialog({
3810
4042
  type: uiTypes.DialogTypes.TimeSeriesSelect,
3811
- mapId: mapId,
3812
4043
  setOpen: true,
3813
- source: 'app'
4044
+ sourcePanelId: panelId
3814
4045
  }));
3815
4046
  }
3816
4047
  };
3817
4048
  var isSelectOpenForCurrentPlot = plotId === selectPlotId;
4049
+ var isOpenForPanel = isOpenInStore && currentSourcePanelId === panelId;
3818
4050
  return jsx(CustomTooltip, {
3819
4051
  title: t('timeseries-add-param-to-plot'),
3820
4052
  children: jsx(CustomToggleButton, {
3821
4053
  "data-testid": "timeSeriesSelectButton",
3822
4054
  disabled: !isEnabled,
3823
4055
  onClick: handleClick,
3824
- selected: !!isOpenInStore && isSelectOpenForCurrentPlot,
4056
+ selected: !!isOpenForPanel && isSelectOpenForCurrentPlot,
3825
4057
  sx: {
3826
4058
  marginLeft: '4px',
3827
4059
  height: '24px!important',
@@ -3838,7 +4070,8 @@ var TimeSeriesSelectButtonConnect = function TimeSeriesSelectButtonConnect(_ref)
3838
4070
  };
3839
4071
 
3840
4072
  var PlotRows = function PlotRows(_ref) {
3841
- var plot = _ref.plot,
4073
+ var panelId = _ref.panelId,
4074
+ plot = _ref.plot,
3842
4075
  rowIndex = _ref.rowIndex,
3843
4076
  showTooltip = _ref.showTooltip,
3844
4077
  deletePlot = _ref.deletePlot,
@@ -3903,6 +4136,7 @@ var PlotRows = function PlotRows(_ref) {
3903
4136
  onClick: function onClick() {
3904
4137
  return setSelectPlotId(plot.plotId);
3905
4138
  },
4139
+ panelId: panelId,
3906
4140
  plotId: plot.plotId,
3907
4141
  selectPlotId: selectPlotId,
3908
4142
  t: t
@@ -3982,6 +4216,7 @@ var PlotRows = function PlotRows(_ref) {
3982
4216
  timeout: "auto",
3983
4217
  unmountOnExit: true,
3984
4218
  children: jsx(ParameterList, {
4219
+ panelId: panelId,
3985
4220
  addParameter: addParameter,
3986
4221
  deleteParameter: deleteParameter,
3987
4222
  moveParameter: moveParameter,
@@ -4084,7 +4319,8 @@ var timeSeriesManagerStyle = {
4084
4319
  }
4085
4320
  };
4086
4321
  var TimeSeriesManager = function TimeSeriesManager(_ref) {
4087
- var onClose = _ref.onClose,
4322
+ var panelId = _ref.panelId,
4323
+ onClose = _ref.onClose,
4088
4324
  isOpen = _ref.isOpen,
4089
4325
  onMouseDown = _ref.onMouseDown,
4090
4326
  order = _ref.order,
@@ -4220,6 +4456,7 @@ var TimeSeriesManager = function TimeSeriesManager(_ref) {
4220
4456
  addParameter: addParameter,
4221
4457
  deleteParameter: deleteParameter,
4222
4458
  deletePlot: deletePlot,
4459
+ panelId: panelId,
4223
4460
  moveParameter: moveParameter,
4224
4461
  patchParameter: patchParameter,
4225
4462
  plot: plot,
@@ -4506,7 +4743,12 @@ var ParameterInfoList = function ParameterInfoList(_ref6) {
4506
4743
 
4507
4744
  var ParameterInfoDialogConnect = function ParameterInfoDialogConnect() {
4508
4745
  var _collection$dataQueri;
4509
- var currentParameterInfoDisplayed = useSelector(getParameterInfoParameter);
4746
+ var panelId = useSelector(function (store) {
4747
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesInfo);
4748
+ });
4749
+ var currentParameterInfoDisplayed = useSelector(function (store) {
4750
+ return getParameterInfoParameter(store, panelId);
4751
+ });
4510
4752
  var relatedService = useSelector(function (store) {
4511
4753
  return getService(store, (currentParameterInfoDisplayed == null ? void 0 : currentParameterInfoDisplayed.serviceId) || '');
4512
4754
  }) || {
@@ -4788,30 +5030,34 @@ var Rows = function Rows(_ref2) {
4788
5030
  });
4789
5031
  };
4790
5032
 
4791
- var ServiceOptionsButtonConnect = function ServiceOptionsButtonConnect() {
5033
+ var ServiceOptionsButtonConnect = function ServiceOptionsButtonConnect(_ref) {
5034
+ var panelId = _ref.panelId;
4792
5035
  var dispatch = useDispatch();
4793
5036
  var services = useSelector(function (store) {
4794
5037
  return getServices(store);
4795
5038
  });
4796
5039
  var parametersInUse = useSelector(function (store) {
4797
- return getParametersInUse(store);
5040
+ return getParametersInUse(store, panelId);
4798
5041
  });
4799
5042
  var openNewServicePopup = React.useCallback(function () {
4800
5043
  dispatch(timeSeriesActions.setServicePopup({
5044
+ panelId: panelId,
4801
5045
  isOpen: true,
4802
5046
  variant: 'add'
4803
5047
  }));
4804
- }, [dispatch]);
5048
+ }, [dispatch, panelId]);
4805
5049
  var openServicePopup = React.useCallback(function (variant, serviceId, url) {
4806
5050
  dispatch(timeSeriesActions.setServicePopup({
5051
+ panelId: panelId,
4807
5052
  isOpen: true,
4808
5053
  variant: variant,
4809
5054
  serviceId: serviceId,
4810
5055
  url: url
4811
5056
  }));
4812
- }, [dispatch]);
5057
+ }, [dispatch, panelId]);
4813
5058
  var removeService = React.useCallback(function (id, message) {
4814
5059
  dispatch(timeSeriesActions.removeService({
5060
+ panelId: panelId,
4815
5061
  id: id
4816
5062
  }));
4817
5063
  if (message) {
@@ -4820,7 +5066,7 @@ var ServiceOptionsButtonConnect = function ServiceOptionsButtonConnect() {
4820
5066
  message: message
4821
5067
  }));
4822
5068
  }
4823
- }, [dispatch]);
5069
+ }, [dispatch, panelId]);
4824
5070
  return jsx(ToggleMenu, {
4825
5071
  menuPosition: "bottom",
4826
5072
  children: jsx(ServiceOptionsDialog, {
@@ -5273,6 +5519,7 @@ var ServicePopup = function ServicePopup(props) {
5273
5519
  // when the dialog is open
5274
5520
  var ServicePopupDialogConnect = function ServicePopupDialogConnect(_ref) {
5275
5521
  var isOpen = _ref.isOpen,
5522
+ panelId = _ref.panelId,
5276
5523
  _ref$serviceId = _ref.serviceId,
5277
5524
  serviceId = _ref$serviceId === void 0 ? '' : _ref$serviceId,
5278
5525
  variant = _ref.variant,
@@ -5287,13 +5534,15 @@ var ServicePopupDialogConnect = function ServicePopupDialogConnect(_ref) {
5287
5534
  return getService(store, serviceId);
5288
5535
  });
5289
5536
  var popupState = useSelector(function (store) {
5290
- return getServicePopupDetails(store);
5537
+ return getServicePopupDetails(store, panelId);
5291
5538
  });
5292
5539
  var serviceSetService = React.useCallback(function (payload) {
5293
- dispatch(timeSeriesActions.upsertService(Object.assign({}, payload, {
5540
+ dispatch(timeSeriesActions.upsertService(Object.assign({
5541
+ panelId: panelId
5542
+ }, payload, {
5294
5543
  isUpdate: popupState.variant === 'edit'
5295
5544
  })));
5296
- }, [dispatch, popupState]);
5545
+ }, [dispatch, panelId, popupState]);
5297
5546
  var showSnackbar = React.useCallback(function (message) {
5298
5547
  dispatch(snackbarActions.openSnackbar({
5299
5548
  type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
@@ -5313,23 +5562,27 @@ var ServicePopupDialogConnect = function ServicePopupDialogConnect(_ref) {
5313
5562
  });
5314
5563
  };
5315
5564
 
5316
- var ServicePopupConnect = function ServicePopupConnect() {
5565
+ var ServicePopupConnect = function ServicePopupConnect(_ref) {
5566
+ var panelId = _ref.panelId;
5317
5567
  var dispatch = useDispatch();
5318
5568
  var _useSelector = useSelector(function (store) {
5319
- return getServicePopupDetails(store);
5569
+ return getServicePopupDetails(store, panelId);
5320
5570
  }),
5321
5571
  isOpen = _useSelector.isOpen,
5322
5572
  url = _useSelector.url,
5323
5573
  serviceId = _useSelector.serviceId,
5324
5574
  variant = _useSelector.variant;
5325
5575
  var setServicePopupClosed = React.useCallback(function () {
5326
- dispatch(timeSeriesActions.closeServicePopup());
5327
- }, [dispatch]);
5576
+ dispatch(timeSeriesActions.closeServicePopup({
5577
+ panelId: panelId
5578
+ }));
5579
+ }, [dispatch, panelId]);
5328
5580
  if (!isOpen) {
5329
5581
  return null;
5330
5582
  }
5331
5583
  return jsx(ServicePopupDialogConnect, {
5332
5584
  isOpen: isOpen,
5585
+ panelId: panelId,
5333
5586
  serviceId: serviceId,
5334
5587
  setServicePopupClosed: setServicePopupClosed,
5335
5588
  url: url,
@@ -5337,15 +5590,17 @@ var ServicePopupConnect = function ServicePopupConnect() {
5337
5590
  });
5338
5591
  };
5339
5592
 
5340
- var SearchFieldConnect = function SearchFieldConnect() {
5593
+ var SearchFieldConnect = function SearchFieldConnect(_ref) {
5594
+ var panelId = _ref.panelId;
5341
5595
  var dispatch = useDispatch();
5342
5596
  var _useTimeseriesTransla = useTimeseriesTranslation(),
5343
5597
  t = _useTimeseriesTransla.t;
5344
5598
  var searchFilter = useSelector(function (state) {
5345
- return getSearchFilter(state);
5599
+ return getSearchFilter(state, panelId);
5346
5600
  });
5347
5601
  var toggleServicePopup = function toggleServicePopup(url) {
5348
5602
  dispatch(timeSeriesActions.setServicePopup({
5603
+ panelId: panelId,
5349
5604
  isOpen: true,
5350
5605
  url: url,
5351
5606
  variant: 'save'
@@ -5353,7 +5608,8 @@ var SearchFieldConnect = function SearchFieldConnect() {
5353
5608
  };
5354
5609
  var setSearchFilter = function setSearchFilter(filterText) {
5355
5610
  dispatch(timeSeriesActions.setSearchFilter({
5356
- filterText: filterText
5611
+ filterText: filterText,
5612
+ panelId: panelId
5357
5613
  }));
5358
5614
  };
5359
5615
  return jsx(SearchField, {
@@ -5424,12 +5680,211 @@ var filterCollectionsParametersFromService = function filterCollectionsParameter
5424
5680
  }, []);
5425
5681
  };
5426
5682
 
5427
- var DEFAULT_DIALOG_HEIGHT = 500;
5428
- var DEFAULT_PADDING_TOP = 6;
5429
- var DEFAULT_RESULTS_HEIGHT = 22;
5430
- var DEFAULT_COLLECTION_ROW_HEIGHT = 48; // listItem height + 4px marginTop
5431
- var DEFAULT_PARAMETER_ROW_HEIGHT = 34; // listItem height
5432
- var DEFAULT_PARAMTER_LIST_PADDING_BOTTOM = 0;
5683
+ var RowComponent$1 = function RowComponent(_ref) {
5684
+ var index = _ref.index,
5685
+ style = _ref.style,
5686
+ filteredCollectionList = _ref.filteredCollectionList,
5687
+ collectionListItemDetails = _ref.collectionListItemDetails,
5688
+ setCollectionListItemDetails = _ref.setCollectionListItemDetails,
5689
+ handleAddOrRemoveClick = _ref.handleAddOrRemoveClick,
5690
+ searchFilter = _ref.searchFilter,
5691
+ panelId = _ref.panelId,
5692
+ selectPlot = _ref.selectPlot,
5693
+ t = _ref.t;
5694
+ var collectionListItem = filteredCollectionList[index];
5695
+ var collectionId = collectionListItem.collectionId;
5696
+ return jsxs(Box, {
5697
+ style: style,
5698
+ children: [jsx(ListItem, {
5699
+ sx: {
5700
+ backgroundColor: 'geowebColors.cards.cardContainer',
5701
+ height: '44px',
5702
+ marginTop: 0.5,
5703
+ borderWidth: '1px',
5704
+ borderStyle: 'solid',
5705
+ borderRadius: '3px',
5706
+ padding: 0,
5707
+ zIndex: 10,
5708
+ overflow: 'hidden',
5709
+ borderColor: 'geowebColors.cards.cardContainerBorder',
5710
+ '.MuiListItemText-primary': {
5711
+ fontSize: '12px',
5712
+ fontWeight: 500,
5713
+ textOverflow: 'ellipsis',
5714
+ overflow: 'hidden'
5715
+ }
5716
+ },
5717
+ children: jsxs(ListItemButton, {
5718
+ onClick: function onClick() {
5719
+ var _Object$assign;
5720
+ var currentState = collectionListItemDetails[collectionId];
5721
+ setCollectionListItemDetails(Object.assign({}, collectionListItemDetails, (_Object$assign = {}, _Object$assign[collectionId] = !currentState, _Object$assign)));
5722
+ },
5723
+ sx: {
5724
+ height: '100%',
5725
+ paddingLeft: '24px',
5726
+ paddingRight: '8px'
5727
+ },
5728
+ children: [jsxs(Grid, {
5729
+ container: true,
5730
+ size: "grow",
5731
+ sx: {
5732
+ justifyContent: 'space-between',
5733
+ alignItems: 'center'
5734
+ },
5735
+ children: [jsxs(Grid, {
5736
+ size: "grow",
5737
+ children: [jsx(Box, {
5738
+ sx: fontStyling(),
5739
+ children: jsx(SearchHighlight, {
5740
+ search: searchFilter,
5741
+ text: collectionListItem.collectionTitle || collectionListItem.collectionId
5742
+ })
5743
+ }), jsx(Box, {
5744
+ sx: fontStyling(false),
5745
+ children: jsx(SearchHighlight, {
5746
+ search: searchFilter,
5747
+ text: collectionListItem.serviceName
5748
+ })
5749
+ })]
5750
+ }), jsx(Grid, {
5751
+ children: jsx(ListItemText, {
5752
+ primary: collectionListItem.parameters.length + " " + t('timeseries-results'),
5753
+ sx: {
5754
+ paddingLeft: 1,
5755
+ paddingRight: 5,
5756
+ textAlign: 'right'
5757
+ }
5758
+ })
5759
+ })]
5760
+ }), collectionListItemDetails[collectionId] ? jsx(ChevronUp, {}) : jsx(ChevronDown, {})]
5761
+ })
5762
+ }), jsx(Collapse, {
5763
+ "in": collectionListItemDetails[collectionId],
5764
+ unmountOnExit: true,
5765
+ children: jsxs(List, {
5766
+ sx: {
5767
+ paddingBottom: DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + "px",
5768
+ paddingTop: 0,
5769
+ backgroundColor: 'geowebColors.cards.cardContainer',
5770
+ borderWidth: DEFAULT_PARAMTER_LIST_BORDER_BOTTOM + "px",
5771
+ borderStyle: 'none solid solid solid',
5772
+ borderColor: 'geowebColors.cards.cardContainerBorder',
5773
+ borderBottomLeftRadius: '3px',
5774
+ borderBottomRightRadius: '3px',
5775
+ boxShadow: 1,
5776
+ top: -5
5777
+ },
5778
+ children: [(collectionListItem == null ? void 0 : collectionListItem.parameters.length) < 1 && jsx(ListItem, {
5779
+ role: "listitem",
5780
+ sx: {
5781
+ height: DEFAULT_PARAMETER_ROW_HEIGHT + 4 + "px",
5782
+ minHeight: '36px',
5783
+ paddingLeft: '40px',
5784
+ paddingRight: '4px',
5785
+ paddingTop: '13px',
5786
+ ' .MuiListItemText-primary': {
5787
+ fontSize: '12px',
5788
+ fontWeight: 500,
5789
+ whiteSpace: 'nowrap',
5790
+ textOverflow: 'ellipsis',
5791
+ overflow: 'hidden'
5792
+ }
5793
+ },
5794
+ children: jsx(ListItemText, {
5795
+ secondary: t('timeseries-no-params'),
5796
+ sx: {
5797
+ paddingLeft: 1,
5798
+ paddingRight: 1
5799
+ }
5800
+ })
5801
+ }), collectionListItem.parameters.map(function (parameter) {
5802
+ var plotParameter = selectPlot.parameters.find(function (plotParameter) {
5803
+ return collectionListItem.serviceId === plotParameter.serviceId && collectionListItem.collectionId === plotParameter.collectionId && parameter.propertyName === plotParameter.propertyName;
5804
+ });
5805
+ var plotHasParameter = Boolean(plotParameter);
5806
+ var paramDisplayName = parameter.propertyLabel ? parameter.propertyLabel + " (" + parameter.propertyName + ")" : parameter.propertyName;
5807
+ return jsx(ListItem, {
5808
+ "aria-label": paramDisplayName,
5809
+ role: "listitem",
5810
+ sx: {
5811
+ paddingLeft: '40px',
5812
+ paddingRight: '4px',
5813
+ ':not(:first-of-type)': {
5814
+ borderTopColor: 'geowebColors.cards.cardContainerBorder',
5815
+ borderTopStyle: 'solid',
5816
+ borderTopWidth: '1px',
5817
+ height: DEFAULT_PARAMETER_ROW_HEIGHT + "px",
5818
+ minHeight: '32px'
5819
+ },
5820
+ ':first-of-type': {
5821
+ height: DEFAULT_PARAMETER_ROW_HEIGHT + 4 + "px",
5822
+ minHeight: '36px',
5823
+ paddingTop: '13px'
5824
+ },
5825
+ ':hover': {
5826
+ backgroundColor: 'geowebColors.cards.cardContainerMouseOver'
5827
+ }
5828
+ },
5829
+ children: jsxs(Grid, {
5830
+ container: true,
5831
+ size: "grow",
5832
+ sx: {
5833
+ justifyContent: 'space-between',
5834
+ alignItems: 'center'
5835
+ },
5836
+ children: [jsx(Grid, {
5837
+ size: "grow",
5838
+ children: jsx(Box, {
5839
+ sx: fontStyling(),
5840
+ children: jsx(SearchHighlight, {
5841
+ search: searchFilter,
5842
+ text: paramDisplayName
5843
+ })
5844
+ })
5845
+ }), jsx(Grid, {
5846
+ children: jsxs(Box, {
5847
+ sx: {
5848
+ marginRight: '8px'
5849
+ },
5850
+ children: [jsx(ParameterInfoButtonConnect, {
5851
+ panelId: panelId,
5852
+ parameter: plotParameter != null ? plotParameter : Object.assign({}, parameter, {
5853
+ plotId: selectPlot.plotId
5854
+ })
5855
+ }), jsx(CustomToggleButton, {
5856
+ fullWidth: true,
5857
+ onClick: function onClick() {
5858
+ var parameterWithPlotId = Object.assign({}, parameter, {
5859
+ plotId: selectPlot.plotId,
5860
+ id: plotParameter == null ? void 0 : plotParameter.id
5861
+ });
5862
+ handleAddOrRemoveClick(parameterWithPlotId, plotHasParameter);
5863
+ },
5864
+ selected: plotHasParameter,
5865
+ sx: {
5866
+ width: '60px',
5867
+ height: '24px !important',
5868
+ marginLeft: '4px'
5869
+ },
5870
+ variant: "tool",
5871
+ children: plotHasParameter ? 'Remove' : 'Add'
5872
+ })]
5873
+ })
5874
+ })]
5875
+ })
5876
+ }, parameter.propertyName);
5877
+ })]
5878
+ })
5879
+ })]
5880
+ });
5881
+ };
5882
+ var DEFAULT_DIALOG_HEIGHT = 500;
5883
+ var DEFAULT_PADDING_TOP = 6;
5884
+ var DEFAULT_RESULTS_HEIGHT = 22;
5885
+ var DEFAULT_COLLECTION_ROW_HEIGHT = 48; // listItem height + 4px marginTop
5886
+ var DEFAULT_PARAMETER_ROW_HEIGHT = 34; // listItem height
5887
+ var DEFAULT_PARAMTER_LIST_PADDING_BOTTOM = 0;
5433
5888
  var DEFAULT_PARAMTER_LIST_BORDER_BOTTOM = 1;
5434
5889
  var fontStyling = function fontStyling(primary) {
5435
5890
  if (primary === void 0) {
@@ -5445,35 +5900,34 @@ var fontStyling = function fontStyling(primary) {
5445
5900
  overflow: 'hidden'
5446
5901
  };
5447
5902
  };
5448
- var TimeSeriesSelectList = function TimeSeriesSelectList(_ref) {
5449
- var selectPlot = _ref.selectPlot,
5450
- collectionListItemDetails = _ref.collectionListItemDetails,
5451
- collectionList = _ref.collectionList,
5452
- handleAddOrRemoveClick = _ref.handleAddOrRemoveClick,
5453
- setCollectionListItemDetails = _ref.setCollectionListItemDetails,
5454
- searchFilter = _ref.searchFilter,
5455
- filterChipsServices = _ref.filterChipsServices,
5456
- allFilterChipsEnabled = _ref.allFilterChipsEnabled;
5457
- var listRef = React.useRef(null);
5903
+ var TimeSeriesSelectList = function TimeSeriesSelectList(_ref2) {
5904
+ var selectPlot = _ref2.selectPlot,
5905
+ panelId = _ref2.panelId,
5906
+ collectionListItemDetails = _ref2.collectionListItemDetails,
5907
+ collectionList = _ref2.collectionList,
5908
+ handleAddOrRemoveClick = _ref2.handleAddOrRemoveClick,
5909
+ setCollectionListItemDetails = _ref2.setCollectionListItemDetails,
5910
+ searchFilter = _ref2.searchFilter,
5911
+ filterChipsServices = _ref2.filterChipsServices,
5912
+ allFilterChipsEnabled = _ref2.allFilterChipsEnabled;
5458
5913
  var _React$useState = React.useState([]),
5459
5914
  filteredCollectionList = _React$useState[0],
5460
5915
  setFilteredCollectionList = _React$useState[1];
5461
5916
  var _useTimeseriesTransla = useTimeseriesTranslation(),
5462
5917
  t = _useTimeseriesTransla.t;
5463
5918
  React.useEffect(function () {
5464
- var _listRef$current;
5465
5919
  if (!collectionList) {
5466
5920
  return;
5467
5921
  }
5468
5922
  var filterResults = filterCollectionsParametersFromService(collectionList, searchFilter, filterChipsServices, allFilterChipsEnabled);
5469
5923
  setFilteredCollectionList(filterResults);
5470
- // Needed to recalculate the height of the list elements now that some collections/parameters have been filtered out
5471
- listRef == null || (_listRef$current = listRef.current) == null || _listRef$current.resetAfterIndex(0);
5472
5924
  }, [searchFilter, collectionList, filterChipsServices, allFilterChipsEnabled]);
5473
5925
  return jsxs(Box, {
5474
5926
  "data-testid": "timeseriesSelectList",
5475
5927
  sx: {
5476
- flex: 1
5928
+ flex: 1,
5929
+ minHeight: 0,
5930
+ overflow: 'hidden'
5477
5931
  },
5478
5932
  children: [jsxs(Box, {
5479
5933
  sx: {
@@ -5481,219 +5935,32 @@ var TimeSeriesSelectList = function TimeSeriesSelectList(_ref) {
5481
5935
  fontSize: '12px'
5482
5936
  },
5483
5937
  children: [filteredCollectionList.length, " ", t('timeseries-results')]
5484
- }), jsx(AutoSizer, {
5485
- children: function children(_ref2) {
5486
- var _ref2$height = _ref2.height,
5487
- height = _ref2$height === void 0 ? 0 : _ref2$height,
5488
- _ref2$width = _ref2.width,
5489
- width = _ref2$width === void 0 ? 0 : _ref2$width;
5490
- return jsx(VariableSizeList, {
5491
- height: height - DEFAULT_RESULTS_HEIGHT - DEFAULT_PADDING_TOP,
5492
- itemCount: filteredCollectionList.length,
5493
- itemSize: function itemSize(index) {
5494
- var collectionId = filteredCollectionList[index].collectionId;
5495
- if (!collectionListItemDetails[collectionId]) {
5496
- return DEFAULT_COLLECTION_ROW_HEIGHT;
5497
- }
5498
- if (filteredCollectionList[index].parameters.length < 1) {
5499
- return DEFAULT_PARAMETER_ROW_HEIGHT + DEFAULT_COLLECTION_ROW_HEIGHT + DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + DEFAULT_PARAMTER_LIST_BORDER_BOTTOM;
5500
- }
5501
- return filteredCollectionList[index].parameters.length * DEFAULT_PARAMETER_ROW_HEIGHT + DEFAULT_COLLECTION_ROW_HEIGHT + DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + DEFAULT_PARAMTER_LIST_BORDER_BOTTOM;
5502
- },
5503
- ref: listRef,
5504
- width: width,
5505
- children: function children(_ref3) {
5506
- var index = _ref3.index,
5507
- style = _ref3.style;
5508
- var collectionListItem = filteredCollectionList[index];
5509
- var collectionId = collectionListItem.collectionId;
5510
- return jsxs(Box, {
5511
- style: style,
5512
- children: [jsx(ListItem, {
5513
- sx: {
5514
- backgroundColor: 'geowebColors.cards.cardContainer',
5515
- height: '44px',
5516
- marginTop: 0.5,
5517
- borderWidth: '1px',
5518
- borderStyle: 'solid',
5519
- borderRadius: '3px',
5520
- padding: 0,
5521
- zIndex: 10,
5522
- overflow: 'hidden',
5523
- borderColor: 'geowebColors.cards.cardContainerBorder',
5524
- '.MuiListItemText-primary': {
5525
- fontSize: '12px',
5526
- fontWeight: 500,
5527
- textOverflow: 'ellipsis',
5528
- overflow: 'hidden'
5529
- }
5530
- },
5531
- children: jsxs(ListItemButton, {
5532
- onClick: function onClick() {
5533
- var _Object$assign, _listRef$current2;
5534
- var currentState = collectionListItemDetails[collectionId];
5535
- setCollectionListItemDetails(Object.assign({}, collectionListItemDetails, (_Object$assign = {}, _Object$assign[collectionId] = !currentState, _Object$assign)));
5536
- listRef == null || (_listRef$current2 = listRef.current) == null || _listRef$current2.resetAfterIndex(index);
5537
- },
5538
- sx: {
5539
- height: '100%',
5540
- paddingLeft: '24px',
5541
- paddingRight: '8px'
5542
- },
5543
- children: [jsxs(Grid, {
5544
- container: true,
5545
- size: "grow",
5546
- sx: {
5547
- justifyContent: 'space-between',
5548
- alignItems: 'center'
5549
- },
5550
- children: [jsxs(Grid, {
5551
- size: "grow",
5552
- children: [jsx(Box, {
5553
- sx: fontStyling(),
5554
- children: jsx(SearchHighlight, {
5555
- search: searchFilter,
5556
- text: collectionListItem.collectionTitle || collectionListItem.collectionId
5557
- })
5558
- }), jsx(Box, {
5559
- sx: fontStyling(false),
5560
- children: jsx(SearchHighlight, {
5561
- search: searchFilter,
5562
- text: collectionListItem.serviceName
5563
- })
5564
- })]
5565
- }), jsx(Grid, {
5566
- children: jsx(ListItemText, {
5567
- primary: collectionListItem.parameters.length + " " + t('timeseries-results'),
5568
- sx: {
5569
- paddingLeft: 1,
5570
- paddingRight: 5,
5571
- textAlign: 'right'
5572
- }
5573
- })
5574
- })]
5575
- }), collectionListItemDetails[collectionId] ? jsx(ChevronUp, {}) : jsx(ChevronDown, {})]
5576
- })
5577
- }), jsx(Collapse, {
5578
- "in": collectionListItemDetails[collectionId],
5579
- unmountOnExit: true,
5580
- children: jsxs(List, {
5581
- sx: {
5582
- paddingBottom: DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + "px",
5583
- paddingTop: 0,
5584
- backgroundColor: 'geowebColors.cards.cardContainer',
5585
- borderWidth: DEFAULT_PARAMTER_LIST_BORDER_BOTTOM + "px",
5586
- borderStyle: 'none solid solid solid',
5587
- borderColor: 'geowebColors.cards.cardContainerBorder',
5588
- borderBottomLeftRadius: '3px',
5589
- borderBottomRightRadius: '3px',
5590
- boxShadow: 1,
5591
- top: -5
5592
- },
5593
- children: [(collectionListItem == null ? void 0 : collectionListItem.parameters.length) < 1 && jsx(ListItem, {
5594
- role: "listitem",
5595
- sx: {
5596
- height: DEFAULT_PARAMETER_ROW_HEIGHT + 4 + "px",
5597
- minHeight: '36px',
5598
- paddingLeft: '40px',
5599
- paddingRight: '4px',
5600
- paddingTop: '13px',
5601
- ' .MuiListItemText-primary': {
5602
- fontSize: '12px',
5603
- fontWeight: 500,
5604
- whiteSpace: 'nowrap',
5605
- textOverflow: 'ellipsis',
5606
- overflow: 'hidden'
5607
- }
5608
- },
5609
- children: jsx(ListItemText, {
5610
- secondary: t('timeseries-no-params'),
5611
- sx: {
5612
- paddingLeft: 1,
5613
- paddingRight: 1
5614
- }
5615
- })
5616
- }), collectionListItem.parameters.map(function (parameter) {
5617
- var plotParameter = selectPlot.parameters.find(function (plotParameter) {
5618
- return collectionListItem.serviceId === plotParameter.serviceId && collectionListItem.collectionId === plotParameter.collectionId && parameter.propertyName === plotParameter.propertyName;
5619
- });
5620
- var plotHasParameter = Boolean(plotParameter);
5621
- var paramDisplayName = parameter.propertyLabel ? parameter.propertyLabel + " (" + parameter.propertyName + ")" : parameter.propertyName;
5622
- return jsx(ListItem, {
5623
- "aria-label": paramDisplayName,
5624
- role: "listitem",
5625
- sx: {
5626
- paddingLeft: '40px',
5627
- paddingRight: '4px',
5628
- ':not(:first-of-type)': {
5629
- borderTopColor: 'geowebColors.cards.cardContainerBorder',
5630
- borderTopStyle: 'solid',
5631
- borderTopWidth: '1px',
5632
- height: DEFAULT_PARAMETER_ROW_HEIGHT + "px",
5633
- minHeight: '32px'
5634
- },
5635
- ':first-of-type': {
5636
- height: DEFAULT_PARAMETER_ROW_HEIGHT + 4 + "px",
5637
- minHeight: '36px',
5638
- paddingTop: '13px'
5639
- },
5640
- ':hover': {
5641
- backgroundColor: 'geowebColors.cards.cardContainerMouseOver'
5642
- }
5643
- },
5644
- children: jsxs(Grid, {
5645
- container: true,
5646
- size: "grow",
5647
- sx: {
5648
- justifyContent: 'space-between',
5649
- alignItems: 'center'
5650
- },
5651
- children: [jsx(Grid, {
5652
- size: "grow",
5653
- children: jsx(Box, {
5654
- sx: fontStyling(),
5655
- children: jsx(SearchHighlight, {
5656
- search: searchFilter,
5657
- text: paramDisplayName
5658
- })
5659
- })
5660
- }), jsx(Grid, {
5661
- children: jsxs(Box, {
5662
- sx: {
5663
- marginRight: '8px'
5664
- },
5665
- children: [jsx(ParameterInfoButtonConnect, {
5666
- parameter: plotParameter != null ? plotParameter : Object.assign({}, parameter, {
5667
- plotId: selectPlot.plotId
5668
- })
5669
- }), jsx(CustomToggleButton, {
5670
- fullWidth: true,
5671
- onClick: function onClick() {
5672
- var parameterWithPlotId = Object.assign({}, parameter, {
5673
- plotId: selectPlot.plotId,
5674
- id: plotParameter == null ? void 0 : plotParameter.id
5675
- });
5676
- handleAddOrRemoveClick(parameterWithPlotId, plotHasParameter);
5677
- },
5678
- selected: plotHasParameter,
5679
- sx: {
5680
- width: '60px',
5681
- height: '24px !important',
5682
- marginLeft: '4px'
5683
- },
5684
- variant: "tool",
5685
- children: plotHasParameter ? 'Remove' : 'Add'
5686
- })]
5687
- })
5688
- })]
5689
- })
5690
- }, parameter.propertyName);
5691
- })]
5692
- })
5693
- })]
5694
- });
5695
- }
5696
- });
5938
+ }), jsx(List$1, {
5939
+ rowComponent: RowComponent$1,
5940
+ rowCount: filteredCollectionList.length,
5941
+ rowHeight: function rowHeight(index) {
5942
+ var collectionId = filteredCollectionList[index].collectionId;
5943
+ if (!collectionListItemDetails[collectionId]) {
5944
+ return DEFAULT_COLLECTION_ROW_HEIGHT;
5945
+ }
5946
+ if (filteredCollectionList[index].parameters.length < 1) {
5947
+ return DEFAULT_PARAMETER_ROW_HEIGHT + DEFAULT_COLLECTION_ROW_HEIGHT + DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + DEFAULT_PARAMTER_LIST_BORDER_BOTTOM;
5948
+ }
5949
+ return filteredCollectionList[index].parameters.length * DEFAULT_PARAMETER_ROW_HEIGHT + DEFAULT_COLLECTION_ROW_HEIGHT + DEFAULT_PARAMTER_LIST_PADDING_BOTTOM + DEFAULT_PARAMTER_LIST_BORDER_BOTTOM;
5950
+ },
5951
+ rowProps: {
5952
+ collectionListItemDetails: collectionListItemDetails,
5953
+ setCollectionListItemDetails: setCollectionListItemDetails,
5954
+ filteredCollectionList: filteredCollectionList,
5955
+ handleAddOrRemoveClick: handleAddOrRemoveClick,
5956
+ searchFilter: searchFilter,
5957
+ panelId: panelId,
5958
+ selectPlot: selectPlot,
5959
+ t: t
5960
+ },
5961
+ style: {
5962
+ width: '100%',
5963
+ height: "calc(100% - " + (DEFAULT_RESULTS_HEIGHT + DEFAULT_PADDING_TOP) + "px)"
5697
5964
  }
5698
5965
  })]
5699
5966
  });
@@ -5703,20 +5970,21 @@ var TimeSeriesSelectListConnect = /*#__PURE__*/memo(function (_ref) {
5703
5970
  var selectPlot = _ref.selectPlot,
5704
5971
  handleAddOrRemoveClick = _ref.handleAddOrRemoveClick,
5705
5972
  services = _ref.services,
5706
- isOpen = _ref.isOpen;
5973
+ isOpen = _ref.isOpen,
5974
+ panelId = _ref.panelId;
5707
5975
  var _useGetServiceCollect = useGetServiceCollectionDetails(services, isOpen),
5708
5976
  collectionList = _useGetServiceCollect.data;
5709
5977
  var _useState = useState({}),
5710
5978
  collectionListItemDetails = _useState[0],
5711
5979
  setCollectionListItemDetails = _useState[1];
5712
5980
  var filterChipsServices = useSelector(function (store) {
5713
- return getServiceFilterChips(store);
5981
+ return getServiceFilterChips(store, panelId);
5714
5982
  });
5715
5983
  var allFilterChipsEnabled = useSelector(function (store) {
5716
- return getAllFilterChipsEnabled(store);
5984
+ return getAllFilterChipsEnabled(store, panelId);
5717
5985
  });
5718
5986
  var searchFilter = useSelector(function (state) {
5719
- return getSearchFilter(state);
5987
+ return getSearchFilter(state, panelId);
5720
5988
  });
5721
5989
  return jsx(TimeSeriesSelectList, {
5722
5990
  allFilterChipsEnabled: allFilterChipsEnabled,
@@ -5724,6 +5992,7 @@ var TimeSeriesSelectListConnect = /*#__PURE__*/memo(function (_ref) {
5724
5992
  collectionListItemDetails: collectionListItemDetails,
5725
5993
  filterChipsServices: filterChipsServices,
5726
5994
  handleAddOrRemoveClick: handleAddOrRemoveClick,
5995
+ panelId: panelId,
5727
5996
  searchFilter: searchFilter,
5728
5997
  selectPlot: selectPlot,
5729
5998
  setCollectionListItemDetails: setCollectionListItemDetails
@@ -5770,24 +6039,28 @@ var ServiceChip = function ServiceChip(_ref) {
5770
6039
 
5771
6040
  var ServiceChipConnect = function ServiceChipConnect(_ref) {
5772
6041
  var service = _ref.service,
5773
- isAllSelected = _ref.isAllSelected;
6042
+ isAllSelected = _ref.isAllSelected,
6043
+ panelId = _ref.panelId;
5774
6044
  var dispatch = useDispatch();
5775
6045
  var serviceId = service.serviceId;
5776
6046
  var toggleChip = function toggleChip() {
5777
6047
  if (service.enabled) {
5778
6048
  if (isAllSelected) {
5779
6049
  dispatch(timeSeriesActions.setOnlyThisServiceFilterChipSelected({
5780
- serviceId: serviceId
6050
+ serviceId: serviceId,
6051
+ panelId: panelId
5781
6052
  }));
5782
6053
  return;
5783
6054
  }
5784
6055
  dispatch(timeSeriesActions.setServiceFilterChipUnselected({
5785
- serviceId: serviceId
6056
+ serviceId: serviceId,
6057
+ panelId: panelId
5786
6058
  }));
5787
6059
  return;
5788
6060
  }
5789
6061
  dispatch(timeSeriesActions.setServiceFilterChipSelected({
5790
- serviceId: serviceId
6062
+ serviceId: serviceId,
6063
+ panelId: panelId
5791
6064
  }));
5792
6065
  };
5793
6066
  return jsx(ServiceChip, {
@@ -5798,13 +6071,16 @@ var ServiceChipConnect = function ServiceChipConnect(_ref) {
5798
6071
  });
5799
6072
  };
5800
6073
  var AllChipConnect = function AllChipConnect(_ref2) {
5801
- var isAllSelected = _ref2.isAllSelected;
6074
+ var isAllSelected = _ref2.isAllSelected,
6075
+ panelId = _ref2.panelId;
5802
6076
  var dispatch = useDispatch();
5803
6077
  return jsx(ServiceChip, {
5804
6078
  isSelected: isAllSelected,
5805
6079
  toggleChip: function toggleChip() {
5806
6080
  if (!isAllSelected) {
5807
- dispatch(timeSeriesActions.setAllServiceFilterChipSelected());
6081
+ dispatch(timeSeriesActions.setAllServiceFilterChipSelected({
6082
+ panelId: panelId
6083
+ }));
5808
6084
  }
5809
6085
  }
5810
6086
  });
@@ -5812,7 +6088,8 @@ var AllChipConnect = function AllChipConnect(_ref2) {
5812
6088
 
5813
6089
  var TimeSeriesServiceList = function TimeSeriesServiceList(_ref) {
5814
6090
  var filterChipsServicesById = _ref.filterChipsServicesById,
5815
- isAllSelected = _ref.isAllSelected;
6091
+ isAllSelected = _ref.isAllSelected,
6092
+ panelId = _ref.panelId;
5816
6093
  var activeServices = Object.values(filterChipsServicesById);
5817
6094
  return jsx(Box, {
5818
6095
  "data-testid": "serviceList",
@@ -5831,10 +6108,12 @@ var TimeSeriesServiceList = function TimeSeriesServiceList(_ref) {
5831
6108
  fontSize: '0.875rem'
5832
6109
  },
5833
6110
  children: [activeServices.length ? jsx(AllChipConnect, {
5834
- isAllSelected: isAllSelected
6111
+ isAllSelected: isAllSelected,
6112
+ panelId: panelId
5835
6113
  }) : null, activeServices.map(function (service) {
5836
6114
  return jsx(ServiceChipConnect, {
5837
6115
  isAllSelected: isAllSelected,
6116
+ panelId: panelId,
5838
6117
  service: service
5839
6118
  }, service.serviceUrl);
5840
6119
  })]
@@ -5854,21 +6133,24 @@ var sortByService = function sortByService(serviceObj) {
5854
6133
  return Object.assign({}, result, (_Object$assign = {}, _Object$assign[key] = value, _Object$assign));
5855
6134
  }, {});
5856
6135
  };
5857
- var TimeSeriesServiceListConnect = function TimeSeriesServiceListConnect() {
6136
+ var TimeSeriesServiceListConnect = function TimeSeriesServiceListConnect(_ref4) {
6137
+ var panelId = _ref4.panelId;
5858
6138
  var filterChipsServices = useSelector(function (store) {
5859
- return getServiceFilterChips(store);
6139
+ return getServiceFilterChips(store, panelId);
5860
6140
  });
5861
6141
  var isAllFilterchipsEnabled = useSelector(function (store) {
5862
- return getAllFilterChipsEnabled(store);
6142
+ return getAllFilterChipsEnabled(store, panelId);
5863
6143
  });
5864
6144
  return jsx(TimeSeriesServiceList, {
5865
6145
  filterChipsServicesById: sortByService(filterChipsServices),
5866
- isAllSelected: isAllFilterchipsEnabled
6146
+ isAllSelected: isAllFilterchipsEnabled,
6147
+ panelId: panelId
5867
6148
  });
5868
6149
  };
5869
6150
 
5870
6151
  var TimeSeriesSelect = function TimeSeriesSelect(_ref) {
5871
- var onClose = _ref.onClose,
6152
+ var panelId = _ref.panelId,
6153
+ onClose = _ref.onClose,
5872
6154
  isOpen = _ref.isOpen,
5873
6155
  onMouseDown = _ref.onMouseDown,
5874
6156
  order = _ref.order,
@@ -5916,28 +6198,38 @@ var TimeSeriesSelect = function TimeSeriesSelect(_ref) {
5916
6198
  padding: '6px 8px',
5917
6199
  height: "calc(100% - " + (error ? 48 : 0) + "px)",
5918
6200
  display: 'flex',
5919
- flexDirection: 'column'
6201
+ flexDirection: 'column',
6202
+ minHeight: 0
5920
6203
  },
5921
- children: [jsx(SearchFieldConnect, {}), jsx(Box, {
6204
+ children: [jsx(SearchFieldConnect, {
6205
+ panelId: panelId
6206
+ }), jsx(Box, {
5922
6207
  sx: {
5923
6208
  position: 'absolute',
5924
6209
  margin: '64px 0 0 calc(100% - 40px)',
5925
6210
  zIndex: 2,
5926
6211
  "float": 'right'
5927
6212
  },
5928
- children: jsx(ServiceOptionsButtonConnect, {})
6213
+ children: jsx(ServiceOptionsButtonConnect, {
6214
+ panelId: panelId
6215
+ })
5929
6216
  }), jsx(Box, {
5930
6217
  sx: {
5931
6218
  paddingBottom: '6px',
5932
6219
  paddingRight: '32px'
5933
6220
  },
5934
- children: jsx(TimeSeriesServiceListConnect, {})
6221
+ children: jsx(TimeSeriesServiceListConnect, {
6222
+ panelId: panelId
6223
+ })
5935
6224
  }), jsx(TimeSeriesSelectListConnect, {
5936
6225
  handleAddOrRemoveClick: handleAddOrRemoveClick,
5937
6226
  isOpen: isOpen,
6227
+ panelId: panelId,
5938
6228
  selectPlot: selectPlot,
5939
6229
  services: services
5940
- }), jsx(ServicePopupConnect, {})]
6230
+ }), jsx(ServicePopupConnect, {
6231
+ panelId: panelId
6232
+ })]
5941
6233
  })]
5942
6234
  });
5943
6235
  };
@@ -5952,16 +6244,19 @@ var TimeSeriesSelectConnect = function TimeSeriesSelectConnect(_ref) {
5952
6244
  dialogOrder = _useSetupDialog.dialogOrder,
5953
6245
  isDialogOpen = _useSetupDialog.isDialogOpen,
5954
6246
  onCloseDialog = _useSetupDialog.onCloseDialog;
6247
+ var activePanelId = useSelector(function (state) {
6248
+ return uiSelectors.getSourcePanelId(state, DIALOG_TYPE);
6249
+ });
5955
6250
  var dispatch = useDispatch();
5956
6251
  var plot = useSelector(function (state) {
5957
- return getPlotWithParameters(state, selectPlotId);
6252
+ return getPlotWithParameters(state, selectPlotId, panelId);
5958
6253
  });
5959
6254
  // If select dialog for a plot is open but the plot is deleted, close the dialog
5960
6255
  React.useEffect(function () {
5961
- if (isDialogOpen && !plot) {
6256
+ if (isDialogOpen && activePanelId === panelId && !plot) {
5962
6257
  onCloseDialog();
5963
6258
  }
5964
- }, [plot, isDialogOpen, onCloseDialog]);
6259
+ }, [plot, isDialogOpen, onCloseDialog, activePanelId, panelId]);
5965
6260
  var handleAddOrRemoveClick = React.useCallback(function (parameter, plotHasParameter) {
5966
6261
  if (plotHasParameter) {
5967
6262
  dispatch(timeSeriesActions.deleteParameter({
@@ -5980,12 +6275,14 @@ var TimeSeriesSelectConnect = function TimeSeriesSelectConnect(_ref) {
5980
6275
  var services = useSelector(function (state) {
5981
6276
  return getServices(state);
5982
6277
  });
6278
+ var isDialogOpenForPanel = isDialogOpen && activePanelId === panelId;
5983
6279
  return plot && services && services.length > 0 ? jsx(TimeSeriesSelect, {
5984
6280
  handleAddOrRemoveClick: handleAddOrRemoveClick,
5985
- isOpen: isDialogOpen,
6281
+ isOpen: isDialogOpenForPanel,
5986
6282
  onClose: onCloseDialog,
5987
6283
  onMouseDown: setDialogOrder,
5988
6284
  order: dialogOrder,
6285
+ panelId: panelId,
5989
6286
  selectPlot: plot,
5990
6287
  services: services
5991
6288
  }) : null;
@@ -5996,7 +6293,7 @@ var origin = TimeSeriesActionOrigin.timeSeriesManager;
5996
6293
  var TimeSeriesManagerConnect = function TimeSeriesManagerConnect(_ref) {
5997
6294
  var preloadedTimeseriesServices = _ref.preloadedTimeseriesServices;
5998
6295
  var panelId = useSelector(function (store) {
5999
- return uiSelectors.getDialogMapId(store, uiTypes.DialogTypes.TimeSeriesManager);
6296
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesManager);
6000
6297
  });
6001
6298
  var _useSetupDialog = useSetupDialog(DIALOG_TYPE_MANAGER),
6002
6299
  setDialogOrder = _useSetupDialog.setDialogOrder,
@@ -6010,15 +6307,14 @@ var TimeSeriesManagerConnect = function TimeSeriesManagerConnect(_ref) {
6010
6307
  setSelectPlotId = _useState[1];
6011
6308
  var dispatch = useDispatch();
6012
6309
  var confirmDialog = useConfirmationDialog();
6013
- var plotState = useSelector(getPlotState);
6310
+ var plotState = useSelector(function (state) {
6311
+ return getPlotState(state, panelId);
6312
+ });
6014
6313
  React.useEffect(function () {
6015
- var addServices = function addServices(timeSeriesServices) {
6314
+ if (preloadedTimeseriesServices) {
6016
6315
  dispatch(timeSeriesActions.addServices({
6017
- timeSeriesServices: timeSeriesServices
6316
+ timeSeriesServices: preloadedTimeseriesServices
6018
6317
  }));
6019
- };
6020
- if (preloadedTimeseriesServices) {
6021
- addServices(preloadedTimeseriesServices);
6022
6318
  }
6023
6319
  }, [preloadedTimeseriesServices, dispatch]);
6024
6320
  var showSnackbar = React.useCallback(function (message) {
@@ -6126,6 +6422,7 @@ var TimeSeriesManagerConnect = function TimeSeriesManagerConnect(_ref) {
6126
6422
  onClose: onCloseDialog,
6127
6423
  onMouseDown: setDialogOrder,
6128
6424
  order: dialogOrder,
6425
+ panelId: panelId,
6129
6426
  patchParameter: patchParameter,
6130
6427
  plotState: plotState,
6131
6428
  selectPlotId: selectPlotId,
@@ -6270,7 +6567,7 @@ var LocationInfo = function LocationInfo(_ref) {
6270
6567
  return Math.abs(lat) + "\xB0 " + latHemisphere + ", " + Math.abs(lon) + "\xB0 " + lonHemisphere;
6271
6568
  };
6272
6569
  var formattedCoordinates = useMemo(function () {
6273
- if (location && location.geometry.type === 'Point') {
6570
+ if ((location == null ? void 0 : location.geometry.type) === 'Point') {
6274
6571
  var latitude = location.geometry.coordinates[1];
6275
6572
  var longitude = location.geometry.coordinates[0];
6276
6573
  return getFormattedCoordinates(latitude, longitude);
@@ -6455,10 +6752,12 @@ var ParameterInfoText = function ParameterInfoText(_ref6) {
6455
6752
  };
6456
6753
 
6457
6754
  var LocationInfoConnect = function LocationInfoConnect() {
6458
- var services = useSelector(getServices);
6459
6755
  var panelId = useSelector(function (store) {
6460
6756
  return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesLocationInfo);
6461
6757
  });
6758
+ var services = useSelector(function (state) {
6759
+ return getServices(state);
6760
+ });
6462
6761
  var selectedMapIds = useSelector(function (state) {
6463
6762
  return genericSelectors.getLinkedMaps(state, panelId);
6464
6763
  });
@@ -6524,11 +6823,14 @@ timeseriesListener.startListening({
6524
6823
  matcher: isAnyOf(timeSeriesActions.loadUserAddedTimeSeriesServices, timeSeriesActions.upsertService, timeSeriesActions.removeService, timeSeriesActions.registerTimeSeriesPreset),
6525
6824
  effect: function () {
6526
6825
  var _effect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(action, listenerApi) {
6826
+ var _listenerApi$getState;
6827
+ var services;
6527
6828
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6528
6829
  while (1) switch (_context.prev = _context.next) {
6529
6830
  case 0:
6530
- setUserAddedEDRServices(listenerApi.getState().timeSeries.services || []);
6531
- case 1:
6831
+ services = ((_listenerApi$getState = listenerApi.getState().timeSeries) == null ? void 0 : _listenerApi$getState.services) || [];
6832
+ setUserAddedEDRServices(services);
6833
+ case 2:
6532
6834
  case "end":
6533
6835
  return _context.stop();
6534
6836
  }
@@ -6629,13 +6931,17 @@ var LocationInfoButtonConnect = function LocationInfoButtonConnect(_ref) {
6629
6931
  var isOpenInStore = useSelector(function (store) {
6630
6932
  return uiSelectors.getisDialogOpen(store, uiTypes.DialogTypes.TimeSeriesLocationInfo);
6631
6933
  });
6934
+ var currentSourcePanelId = useSelector(function (store) {
6935
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeSeriesLocationInfo);
6936
+ });
6632
6937
  var handleClick = function handleClick() {
6633
6938
  dispatch(uiActions.setToggleOpenDialog({
6634
6939
  type: uiTypes.DialogTypes.TimeSeriesLocationInfo,
6635
- setOpen: !isOpenInStore,
6940
+ setOpen: currentSourcePanelId !== panelId ? true : !isOpenInStore,
6636
6941
  sourcePanelId: panelId
6637
6942
  }));
6638
6943
  };
6944
+ var isOpenForPanel = isOpenInStore && currentSourcePanelId === panelId;
6639
6945
  return jsx(CustomTooltip, {
6640
6946
  title: t('timeseries-location-info-title'),
6641
6947
  children: jsx("span", {
@@ -6644,7 +6950,7 @@ var LocationInfoButtonConnect = function LocationInfoButtonConnect(_ref) {
6644
6950
  icon: jsx(Info, {}),
6645
6951
  longText: t('timeseries-location-info-button'),
6646
6952
  onClick: handleClick,
6647
- selected: isOpenInStore,
6953
+ selected: isOpenForPanel,
6648
6954
  variant: "tool"
6649
6955
  })
6650
6956
  })
@@ -7360,6 +7666,34 @@ var useChartHeight = function useChartHeight(_ref) {
7360
7666
  updateHeight: updateHeight
7361
7667
  };
7362
7668
  };
7669
+ var applyDataZoomState = function applyDataZoomState(option, dataZoomState) {
7670
+ if (!dataZoomState || !(option != null && option.dataZoom) || !Array.isArray(option.dataZoom)) {
7671
+ return option;
7672
+ }
7673
+ return Object.assign({}, option, {
7674
+ dataZoom: option.dataZoom.map(function (dz) {
7675
+ return Object.assign({}, dz, {
7676
+ start: dataZoomState.start,
7677
+ end: dataZoomState.end
7678
+ });
7679
+ })
7680
+ });
7681
+ };
7682
+ var extractDataZoomState = function extractDataZoomState(params) {
7683
+ if (params.batch && params.batch.length > 0) {
7684
+ return {
7685
+ start: params.batch[0].start,
7686
+ end: params.batch[0].end
7687
+ };
7688
+ }
7689
+ if (params.start !== undefined && params.end !== undefined) {
7690
+ return {
7691
+ start: params.start,
7692
+ end: params.end
7693
+ };
7694
+ }
7695
+ return null;
7696
+ };
7363
7697
  var TimeSeriesChart = function TimeSeriesChart(_ref2) {
7364
7698
  var plotsWithData = _ref2.plotsWithData,
7365
7699
  _ref2$animation = _ref2.animation,
@@ -7370,14 +7704,18 @@ var TimeSeriesChart = function TimeSeriesChart(_ref2) {
7370
7704
  var _useThemeContext = useThemeContext(),
7371
7705
  namedTheme = _useThemeContext.namedTheme;
7372
7706
  var isDark = (namedTheme == null ? void 0 : namedTheme.theme.palette.mode) === 'dark';
7707
+ var dataZoomStateRef = React.useRef(null);
7373
7708
  var enabledPlots = plotsWithData.filter(function (plot) {
7374
7709
  return plot.enabled === undefined || plot.enabled;
7375
7710
  });
7376
7711
  var option = getOption(enabledPlots);
7712
+ var optionWithZoom = React.useMemo(function () {
7713
+ return applyDataZoomState(option, dataZoomStateRef.current);
7714
+ }, [option]);
7377
7715
  var _useChartHeight = useChartHeight({
7378
7716
  plotsWithData: enabledPlots,
7379
7717
  shouldShowLegend: shouldShowLegend,
7380
- option: option
7718
+ option: optionWithZoom
7381
7719
  }),
7382
7720
  chartHeight = _useChartHeight.chartHeight,
7383
7721
  chartRef = _useChartHeight.chartRef,
@@ -7390,6 +7728,12 @@ var TimeSeriesChart = function TimeSeriesChart(_ref2) {
7390
7728
  // noop, prevent flickering when toggling legend
7391
7729
  onEvents: {
7392
7730
  finished: function finished() {},
7731
+ datazoom: function datazoom(params) {
7732
+ var newState = extractDataZoomState(params);
7733
+ if (newState) {
7734
+ dataZoomStateRef.current = newState;
7735
+ }
7736
+ },
7393
7737
  legendselectchanged: function legendselectchanged(params) {
7394
7738
  if (!option.legend) {
7395
7739
  return;
@@ -7402,7 +7746,7 @@ var TimeSeriesChart = function TimeSeriesChart(_ref2) {
7402
7746
  }
7403
7747
  }
7404
7748
  },
7405
- option: Object.assign({}, option, {
7749
+ option: Object.assign({}, optionWithZoom, {
7406
7750
  animation: animation
7407
7751
  }),
7408
7752
  ref: chartRef,
@@ -7424,10 +7768,11 @@ var TimeSeriesView = /*#__PURE__*/React.memo(function (_ref) {
7424
7768
  isLoading = _ref.isLoading,
7425
7769
  _ref$shouldShowLegend = _ref.shouldShowLegend,
7426
7770
  shouldShowLegend = _ref$shouldShowLegend === void 0 ? true : _ref$shouldShowLegend,
7427
- onToggleLegendParam = _ref.onToggleLegendParam;
7771
+ onToggleLegendParam = _ref.onToggleLegendParam,
7772
+ syncgroupTimeState = _ref.syncgroupTimeState;
7428
7773
  var _useTimeseriesTransla = useTimeseriesTranslation(),
7429
7774
  t = _useTimeseriesTransla.t;
7430
- var _useGetPlotsWithData = useGetPlotsWithData(plotPreset, selectedLocation, services, splitGeoJsonByCollection, t),
7775
+ var _useGetPlotsWithData = useGetPlotsWithData(plotPreset, selectedLocation, services, splitGeoJsonByCollection, t, syncgroupTimeState),
7431
7776
  plotsWithData = _useGetPlotsWithData.data,
7432
7777
  isFetchingPlots = _useGetPlotsWithData.isFetching,
7433
7778
  error = _useGetPlotsWithData.error;
@@ -7454,36 +7799,35 @@ var TimeSeriesView = /*#__PURE__*/React.memo(function (_ref) {
7454
7799
  })]
7455
7800
  });
7456
7801
  }, function (previousProps, nextProps) {
7802
+ var _previousProps$syncgr, _nextProps$syncgroupT, _previousProps$syncgr2, _nextProps$syncgroupT2;
7457
7803
  var samePreset = previousProps.plotPreset === nextProps.plotPreset;
7458
7804
  var sameLocation = isEqual(previousProps.selectedLocation, nextProps.selectedLocation);
7459
7805
  var sameGeoJson = isEqual(previousProps.splitGeoJsonByCollection, nextProps.splitGeoJsonByCollection);
7460
7806
  var sameLegend = previousProps.shouldShowLegend === nextProps.shouldShowLegend;
7461
- return samePreset && sameLocation && sameGeoJson && sameLegend;
7807
+ var sameTime = ((_previousProps$syncgr = previousProps.syncgroupTimeState) == null ? void 0 : _previousProps$syncgr.start) === ((_nextProps$syncgroupT = nextProps.syncgroupTimeState) == null ? void 0 : _nextProps$syncgroupT.start) && ((_previousProps$syncgr2 = previousProps.syncgroupTimeState) == null ? void 0 : _previousProps$syncgr2.end) === ((_nextProps$syncgroupT2 = nextProps.syncgroupTimeState) == null ? void 0 : _nextProps$syncgroupT2.end);
7808
+ return samePreset && sameLocation && sameGeoJson && sameLegend && sameTime;
7462
7809
  });
7463
7810
 
7464
7811
  var TOOLTIP_TITLE = 'Timeseries Manager';
7465
7812
  var TimeSeriesManagerMapButtonConnect = function TimeSeriesManagerMapButtonConnect(_ref) {
7466
- var viewId = _ref.viewId,
7467
- _ref$source = _ref.source,
7468
- source = _ref$source === void 0 ? 'app' : _ref$source;
7813
+ var viewId = _ref.viewId;
7469
7814
  var dispatch = useDispatch();
7470
7815
  var _useTimeseriesTransla = useTimeseriesTranslation(),
7471
7816
  t = _useTimeseriesTransla.t;
7472
- var currentActiveMapId = useSelector(function (store) {
7473
- return uiSelectors.getDialogMapId(store, DIALOG_TYPE_MANAGER);
7817
+ var currentSourcePanelId = useSelector(function (store) {
7818
+ return uiSelectors.getSourcePanelId(store, DIALOG_TYPE_MANAGER);
7474
7819
  });
7475
7820
  var isOpenInStore = useSelector(function (store) {
7476
7821
  return uiSelectors.getisDialogOpen(store, DIALOG_TYPE_MANAGER);
7477
7822
  });
7478
7823
  var openTimeSeriesManagerDialog = React.useCallback(function () {
7479
- dispatch(uiActions.setActiveMapIdForDialog({
7824
+ dispatch(uiActions.setToggleOpenDialog({
7480
7825
  type: DIALOG_TYPE_MANAGER,
7481
- mapId: viewId,
7482
- setOpen: currentActiveMapId !== viewId ? true : !isOpenInStore,
7483
- source: source
7826
+ setOpen: currentSourcePanelId !== viewId ? true : !isOpenInStore,
7827
+ sourcePanelId: viewId
7484
7828
  }));
7485
- }, [currentActiveMapId, dispatch, isOpenInStore, viewId, source]);
7486
- var isOpen = currentActiveMapId === viewId && isOpenInStore;
7829
+ }, [currentSourcePanelId, dispatch, isOpenInStore, viewId]);
7830
+ var isOpen = currentSourcePanelId === viewId && isOpenInStore;
7487
7831
  return jsx(CustomTooltip, {
7488
7832
  title: TOOLTIP_TITLE,
7489
7833
  children: jsx("span", {
@@ -7505,29 +7849,43 @@ var LocationSelectButtonConnect = function LocationSelectButtonConnect(_ref) {
7505
7849
  var dispatch = useDispatch();
7506
7850
  var _useTimeseriesTransla = useTimeseriesTranslation(),
7507
7851
  t = _useTimeseriesTransla.t;
7508
- var timeSeriesLocation = useSelector(getCurrentLocation);
7852
+ var timeSeriesLocation = useSelector(function (state) {
7853
+ return getCurrentLocation(state, panelId);
7854
+ });
7855
+ var currentSourcePanelId = useSelector(function (store) {
7856
+ return uiSelectors.getSourcePanelId(store, uiTypes.DialogTypes.TimeseriesLocations);
7857
+ });
7509
7858
  var isLocationsDialogOpen = useSelector(function (store) {
7510
7859
  return uiSelectors.getisDialogOpen(store, uiTypes.DialogTypes.TimeseriesLocations);
7511
7860
  });
7512
- var isMapPinDisabled = useSelector(getIsMapPinDisabled);
7861
+ var isMapPinDisabled = useSelector(function (state) {
7862
+ return getIsMapPinDisabled(state, panelId);
7863
+ });
7864
+ var isLocationsDialogOpenRef = React.useRef(isLocationsDialogOpen);
7865
+ var currentSourcePanelIdRef = React.useRef(currentSourcePanelId);
7866
+ React.useEffect(function () {
7867
+ isLocationsDialogOpenRef.current = isLocationsDialogOpen;
7868
+ currentSourcePanelIdRef.current = currentSourcePanelId;
7869
+ }, [isLocationsDialogOpen, currentSourcePanelId]);
7513
7870
  var selectedLocationName = typeof (timeSeriesLocation == null || (_timeSeriesLocation$o = timeSeriesLocation.occurrences) == null || (_timeSeriesLocation$o = _timeSeriesLocation$o[0]) == null || (_timeSeriesLocation$o = _timeSeriesLocation$o.properties) == null ? void 0 : _timeSeriesLocation$o.name) === 'string' ? timeSeriesLocation.occurrences[0].properties.name : '';
7514
7871
  var toggleLocationsDialog = function toggleLocationsDialog() {
7515
7872
  dispatch(uiActions.setToggleOpenDialog({
7516
7873
  type: uiTypes.DialogTypes.TimeseriesLocations,
7517
- setOpen: !isLocationsDialogOpen,
7874
+ setOpen: currentSourcePanelId !== panelId ? true : !isLocationsDialogOpen,
7518
7875
  sourcePanelId: panelId
7519
7876
  }));
7520
7877
  };
7521
7878
  React.useEffect(function () {
7522
7879
  return function () {
7523
- if (isLocationsDialogOpen) {
7880
+ if (isLocationsDialogOpenRef.current && currentSourcePanelIdRef.current === panelId) {
7524
7881
  dispatch(uiActions.setToggleOpenDialog({
7525
7882
  setOpen: false,
7526
- type: uiTypes.DialogTypes.TimeseriesLocations
7883
+ type: uiTypes.DialogTypes.TimeseriesLocations,
7884
+ sourcePanelId: panelId
7527
7885
  }));
7528
7886
  }
7529
7887
  };
7530
- }, [dispatch, isLocationsDialogOpen]);
7888
+ }, [dispatch, panelId]);
7531
7889
  return jsx(CustomTooltip, {
7532
7890
  title: selectedLocationName || t('timeseries-select-location'),
7533
7891
  children: jsx("span", {
@@ -7544,7 +7902,7 @@ var LocationSelectButtonConnect = function LocationSelectButtonConnect(_ref) {
7544
7902
  }),
7545
7903
  longText: selectedLocationName || t('timeseries-location'),
7546
7904
  onClick: toggleLocationsDialog,
7547
- selected: isLocationsDialogOpen,
7905
+ selected: isLocationsDialogOpen ? currentSourcePanelId === panelId : null,
7548
7906
  shortText: selectedLocationName || t('timeseries-location')
7549
7907
  })
7550
7908
  })
@@ -7584,7 +7942,9 @@ var useMapPin = function useMapPin(_ref2) {
7584
7942
  var selectedMapIds = useSelector(function (state) {
7585
7943
  return genericSelectors.getLinkedMaps(state, panelId);
7586
7944
  });
7587
- var isMapPinDisabled = useSelector(getIsMapPinDisabled);
7945
+ var isMapPinDisabled = useSelector(function (state) {
7946
+ return getIsMapPinDisabled(state, panelId);
7947
+ });
7588
7948
  /* Make sure the mappin is visible when linking new maps */
7589
7949
  useEffect(function () {
7590
7950
  var toggleMapPinVisibility = function toggleMapPinVisibility(displayMapPin) {
@@ -7604,6 +7964,7 @@ var useMapPin = function useMapPin(_ref2) {
7604
7964
  var toggleDisableMapPin = function toggleDisableMapPin() {
7605
7965
  var newDisableMapPinState = !isMapPinDisabled;
7606
7966
  dispatch(timeSeriesActions.disableMapPin({
7967
+ panelId: panelId,
7607
7968
  isMapPinDisabled: newDisableMapPinState
7608
7969
  }));
7609
7970
  selectedMapIds.forEach(function (mapId) {
@@ -7619,23 +7980,38 @@ var useMapPin = function useMapPin(_ref2) {
7619
7980
  };
7620
7981
  };
7621
7982
  var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7622
- var _sharedGeoJSON$featur;
7983
+ var _linkedMapIds$, _sharedGeoJSON$featur;
7623
7984
  var panelId = _ref3.panelId;
7624
7985
  var dispatch = useDispatch();
7625
7986
  var _useTimeseriesTransla = useTimeseriesTranslation(),
7626
7987
  t = _useTimeseriesTransla.t;
7627
7988
  var geojsonLayerId = React.useRef(webmapUtils.generateLayerId()).current;
7628
- var shouldShowLegend = useSelector(getIsLegendVisible);
7629
- var services = useSelector(getServices);
7630
- var shouldHideLocationMarkers = useSelector(getShouldHideLocationMarkers);
7631
- var plotPresetState = useSelector(getPlotState);
7632
- var activeMapId = useSelector(function (store) {
7633
- return uiSelectors.getActiveWindowId(store);
7634
- });
7635
- var timeSeriesLocation = useSelector(getCurrentLocation);
7636
- var selectedFeature = useSelector(function (state) {
7989
+ var shouldShowLegend = useSelector(function (state) {
7990
+ return getIsLegendVisible(state, panelId);
7991
+ });
7992
+ var services = useSelector(function (state) {
7993
+ return getServices(state);
7994
+ });
7995
+ var shouldHideLocationMarkers = useSelector(function (state) {
7996
+ return getShouldHideLocationMarkers(state, panelId);
7997
+ });
7998
+ var plotPresetState = useSelector(function (state) {
7999
+ return getPlotState(state, panelId);
8000
+ });
8001
+ var linkedMapIds = useSelector(function (state) {
8002
+ return genericSelectors.getLinkedMaps(state, panelId);
8003
+ });
8004
+ var panelMapId = (_linkedMapIds$ = linkedMapIds == null ? void 0 : linkedMapIds[0]) != null ? _linkedMapIds$ : plotPresetState == null ? void 0 : plotPresetState.mapId;
8005
+ var timeSeriesLocation = useSelector(function (state) {
8006
+ return getCurrentLocation(state, panelId);
8007
+ });
8008
+ var selectedFeatureFromPanel = useSelector(function (state) {
7637
8009
  return genericSelectors.getSelectedFeature(state.syncGroups, panelId);
7638
8010
  });
8011
+ var selectedFeatureFromMap = useSelector(function (state) {
8012
+ return panelMapId ? genericSelectors.getSelectedFeature(state.syncGroups, panelMapId) : null;
8013
+ });
8014
+ var selectedFeature = selectedFeatureFromPanel != null ? selectedFeatureFromPanel : selectedFeatureFromMap;
7639
8015
  var allMaps = useSelector(function (store) {
7640
8016
  return mapSelectors.getAllMapsByIds(store);
7641
8017
  });
@@ -7659,9 +8035,10 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7659
8035
  }, [dispatch, panelId]);
7660
8036
  var setTimeSeriesLocation = useCallback(function (location) {
7661
8037
  dispatch(timeSeriesActions.setCurrentLocation({
8038
+ panelId: panelId,
7662
8039
  location: location
7663
8040
  }));
7664
- }, [dispatch]);
8041
+ }, [dispatch, panelId]);
7665
8042
  var memoizedSelectedFeature = React.useMemo(function () {
7666
8043
  if (!selectedFeature) {
7667
8044
  return null;
@@ -7675,9 +8052,9 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7675
8052
  // eslint-disable-next-line react-hooks/exhaustive-deps
7676
8053
  }, [selectedFeature == null ? void 0 : selectedFeature.lat, selectedFeature == null ? void 0 : selectedFeature.lon]);
7677
8054
  useEffect(function () {
7678
- if (!memoizedSelectedFeature && activeMapId) {
7679
- var _allMaps$activeMapId;
7680
- var activeMapCoordinates = (_allMaps$activeMapId = allMaps[activeMapId]) == null ? void 0 : _allMaps$activeMapId.mapPinLocation;
8055
+ if (!memoizedSelectedFeature && panelMapId) {
8056
+ var _allMaps$panelMapId;
8057
+ var activeMapCoordinates = (_allMaps$panelMapId = allMaps[panelMapId]) == null ? void 0 : _allMaps$panelMapId.mapPinLocation;
7681
8058
  if ((activeMapCoordinates == null ? void 0 : activeMapCoordinates.lat) !== undefined && (activeMapCoordinates == null ? void 0 : activeMapCoordinates.lon) !== undefined) {
7682
8059
  setTimeSeriesLocation(activeMapCoordinates);
7683
8060
  }
@@ -7692,7 +8069,7 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7692
8069
  };
7693
8070
  setTimeSeriesLocation(validLocation);
7694
8071
  }
7695
- }, [activeMapId, selectedFeature, setTimeSeriesLocation, memoizedSelectedFeature, allMaps]);
8072
+ }, [panelMapId, selectedFeature, setTimeSeriesLocation, memoizedSelectedFeature, allMaps]);
7696
8073
  useEffect(function () {
7697
8074
  return function () {
7698
8075
  if (panelId) {
@@ -7743,11 +8120,13 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7743
8120
  }, [dispatch, geojsonLayerId, shouldHideLocationMarkers, locationsData, memoizedSelectedFeature, panelId, stableServices, setTimeSeriesLocation]);
7744
8121
  var toggleLocationMarkers = function toggleLocationMarkers(shouldHide) {
7745
8122
  dispatch(timeSeriesActions.toggleLocationMarkers({
8123
+ panelId: panelId,
7746
8124
  shouldHideLocationMarkers: shouldHide
7747
8125
  }));
7748
8126
  };
7749
8127
  var toggleLegend = function toggleLegend() {
7750
8128
  dispatch(timeSeriesActions.toggleLegend({
8129
+ panelId: panelId,
7751
8130
  isLegendVisible: !shouldShowLegend
7752
8131
  }));
7753
8132
  };
@@ -7757,6 +8136,7 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7757
8136
  panelId: panelId
7758
8137
  }));
7759
8138
  };
8139
+ var syncgroupTimeState = useSyncgroupTimeState(panelId, 1000);
7760
8140
  return jsxs(Stack, {
7761
8141
  "data-testid": "TimeSeriesConnect",
7762
8142
  sx: {
@@ -7820,7 +8200,8 @@ var TimeSeriesConnect = function TimeSeriesConnect(_ref3) {
7820
8200
  selectedLocation: timeSeriesLocation,
7821
8201
  services: services,
7822
8202
  shouldShowLegend: shouldShowLegend,
7823
- splitGeoJsonByCollection: geoJSONWithService || []
8203
+ splitGeoJsonByCollection: geoJSONWithService || [],
8204
+ syncgroupTimeState: syncgroupTimeState
7824
8205
  })
7825
8206
  })]
7826
8207
  });
@@ -7837,17 +8218,20 @@ var TimeSeriesConnectWrapper = function TimeSeriesConnectWrapper(_ref) {
7837
8218
  React.useEffect(function () {
7838
8219
  var localStorageServices = getUserAddedEDRServices();
7839
8220
  dispatch(timeSeriesActions.loadUserAddedTimeSeriesServices(localStorageServices));
7840
- }, [dispatch, timeSeriesPreset, timeSeriesPresetRef]);
8221
+ }, [dispatch, panelId, timeSeriesPreset, timeSeriesPresetRef]);
7841
8222
  React.useEffect(function () {
7842
8223
  // Check if the preset has changed
7843
8224
  if (!isEqual(timeSeriesPreset, timeSeriesPresetRef.current)) {
7844
8225
  timeSeriesPresetRef.current = timeSeriesPreset;
7845
- timeSeriesPreset && dispatch(timeSeriesActions.registerTimeSeriesPreset(timeSeriesPreset));
8226
+ timeSeriesPreset && dispatch(timeSeriesActions.registerTimeSeriesPreset(Object.assign({}, timeSeriesPreset, {
8227
+ panelId: panelId
8228
+ })));
7846
8229
  hideLocationMarkers !== undefined && dispatch(timeSeriesActions.toggleLocationMarkers({
8230
+ panelId: panelId,
7847
8231
  shouldHideLocationMarkers: hideLocationMarkers
7848
8232
  }));
7849
8233
  }
7850
- }, [dispatch, timeSeriesPreset, timeSeriesPresetRef, hideLocationMarkers]);
8234
+ }, [dispatch, timeSeriesPreset, timeSeriesPresetRef, hideLocationMarkers, panelId]);
7851
8235
  return jsx(TimeSeriesConnect, {
7852
8236
  panelId: panelId
7853
8237
  });
@@ -8140,164 +8524,126 @@ var LocationListItem = function LocationListItem(_ref) {
8140
8524
  });
8141
8525
  };
8142
8526
 
8143
- var renderRow = function renderRow(features, handleChange, selectedLocation, isDisabled) {
8144
- if (isDisabled === void 0) {
8145
- isDisabled = false;
8146
- }
8147
- return function (props) {
8148
- var _feature$properties;
8149
- var index = props.index,
8150
- style = props.style;
8151
- var feature = features[index];
8152
- return jsx("div", {
8153
- style: Object.assign({}, style),
8154
- children: jsx(LocationListItem, {
8155
- handleChange: handleChange,
8156
- isDisabled: isDisabled,
8157
- location: (_feature$properties = feature.properties) == null ? void 0 : _feature$properties.name,
8158
- selectedLocation: selectedLocation
8159
- }, feature.id)
8160
- });
8161
- };
8527
+ var RowComponent = function RowComponent(_ref) {
8528
+ var _feature$properties;
8529
+ var index = _ref.index,
8530
+ style = _ref.style,
8531
+ handleChange = _ref.handleChange,
8532
+ selectedLocation = _ref.selectedLocation,
8533
+ features = _ref.features,
8534
+ _ref$isDisabled = _ref.isDisabled,
8535
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled;
8536
+ var feature = features[index];
8537
+ return jsx("div", {
8538
+ style: Object.assign({}, style),
8539
+ children: jsx(LocationListItem, {
8540
+ handleChange: handleChange,
8541
+ isDisabled: isDisabled,
8542
+ location: (_feature$properties = feature.properties) == null ? void 0 : _feature$properties.name,
8543
+ selectedLocation: selectedLocation
8544
+ }, feature.id)
8545
+ });
8162
8546
  };
8163
-
8164
- var FocusableListOuter = /*#__PURE__*/React.forwardRef(function (props, ref) {
8165
- // Track last interaction modality to conditionally show focus ring only for keyboard navigation.
8166
- var lastInteractionWasKeyboard = React.useRef(false);
8547
+ function useFocusVisible() {
8548
+ var lastWasKeyboard = React.useRef(false);
8549
+ var _React$useState = React.useState(false),
8550
+ focusVisible = _React$useState[0],
8551
+ setFocusVisible = _React$useState[1];
8167
8552
  React.useEffect(function () {
8168
- var handleKey = function handleKey(e) {
8169
- // Ignore modifier-only keys; any navigation key sets keyboard modality.
8170
- if (e.key) {
8171
- lastInteractionWasKeyboard.current = true;
8172
- }
8553
+ var onKey = function onKey() {
8554
+ lastWasKeyboard.current = true;
8173
8555
  };
8174
- var handlePointer = function handlePointer() {
8175
- lastInteractionWasKeyboard.current = false;
8556
+ var onPointer = function onPointer() {
8557
+ lastWasKeyboard.current = false;
8176
8558
  };
8177
- window.addEventListener('keydown', handleKey, {
8559
+ window.addEventListener('keydown', onKey, {
8178
8560
  capture: true
8179
8561
  });
8180
- window.addEventListener('mousedown', handlePointer, {
8562
+ window.addEventListener('pointerdown', onPointer, {
8181
8563
  capture: true
8182
8564
  });
8183
- window.addEventListener('pointerdown', handlePointer, {
8565
+ window.addEventListener('mousedown', onPointer, {
8184
8566
  capture: true
8185
8567
  });
8186
- window.addEventListener('touchstart', handlePointer, {
8568
+ window.addEventListener('touchstart', onPointer, {
8187
8569
  capture: true
8188
8570
  });
8189
- // Listen for custom selection event to remove focus styling after keyboard activation.
8190
- var handleSelection = function handleSelection() {
8191
- setIsFocusVisible(false);
8192
- };
8193
- window.addEventListener('location-list-selection', handleSelection);
8194
8571
  return function () {
8195
- window.removeEventListener('keydown', handleKey, {
8572
+ window.removeEventListener('keydown', onKey, {
8196
8573
  capture: true
8197
8574
  });
8198
- window.removeEventListener('mousedown', handlePointer, {
8575
+ window.removeEventListener('pointerdown', onPointer, {
8199
8576
  capture: true
8200
8577
  });
8201
- window.removeEventListener('pointerdown', handlePointer, {
8578
+ window.removeEventListener('mousedown', onPointer, {
8202
8579
  capture: true
8203
8580
  });
8204
- window.removeEventListener('touchstart', handlePointer, {
8581
+ window.removeEventListener('touchstart', onPointer, {
8205
8582
  capture: true
8206
8583
  });
8207
- window.removeEventListener('location-list-selection', handleSelection);
8208
8584
  };
8209
8585
  }, []);
8210
- var handleKeyDown = function handleKeyDown(e) {
8211
- var el = ref && typeof ref === 'object' && 'current' in ref ? ref.current : null;
8212
- if (!el) {
8213
- return;
8214
- }
8215
- var lineHeight = 40; // matches itemSize
8216
- var pageHeight = el.clientHeight;
8217
- switch (e.key) {
8218
- case 'ArrowDown':
8219
- e.preventDefault();
8220
- el.scrollTop += lineHeight;
8221
- break;
8222
- case 'ArrowUp':
8223
- e.preventDefault();
8224
- el.scrollTop -= lineHeight;
8225
- break;
8226
- case 'PageDown':
8227
- e.preventDefault();
8228
- el.scrollTop += pageHeight;
8229
- break;
8230
- case 'PageUp':
8231
- e.preventDefault();
8232
- el.scrollTop -= pageHeight;
8233
- break;
8234
- case 'Home':
8235
- e.preventDefault();
8236
- el.scrollTop = 0;
8237
- break;
8238
- case 'End':
8239
- e.preventDefault();
8240
- el.scrollTop = el.scrollHeight;
8241
- break;
8242
- }
8243
- };
8244
- // merge any existing style prop with our outline override
8245
- var mergedStyle = Object.assign({}, props.style, {
8246
- outline: 'none',
8247
- transition: 'box-shadow 120ms ease, background-color 120ms ease'
8248
- });
8249
- var _React$useState = React.useState(false),
8250
- isFocusVisible = _React$useState[0],
8251
- setIsFocusVisible = _React$useState[1];
8252
- var onFocus = function onFocus() {
8253
- if (lastInteractionWasKeyboard.current) {
8254
- setIsFocusVisible(true);
8586
+ return {
8587
+ focusVisible: focusVisible,
8588
+ onFocus: function onFocus() {
8589
+ if (lastWasKeyboard.current) {
8590
+ setFocusVisible(true);
8591
+ }
8592
+ },
8593
+ onBlur: function onBlur() {
8594
+ return setFocusVisible(false);
8595
+ },
8596
+ clear: function clear() {
8597
+ return setFocusVisible(false);
8255
8598
  }
8256
8599
  };
8257
- var onBlur = function onBlur() {
8258
- return setIsFocusVisible(false);
8259
- };
8260
- if (isFocusVisible) {
8261
- mergedStyle.boxShadow = '0 0 0 2px var(--focus-ring-color, #1976d2)';
8262
- mergedStyle.backgroundColor = 'rgba(25,118,210,0.06)';
8263
- }
8264
- return jsx("div", Object.assign({}, props, {
8265
- "aria-label": "Locations list",
8266
- onBlur: onBlur,
8267
- onFocus: onFocus,
8268
- onKeyDown: handleKeyDown,
8269
- // Remove focus styling immediately on mouse interaction
8270
- onMouseDown: function onMouseDown() {
8271
- setIsFocusVisible(false);
8272
- },
8273
- ref: ref,
8600
+ }
8601
+ var FocusableListWrapper = function FocusableListWrapper(_ref2) {
8602
+ var children = _ref2.children,
8603
+ onKeyDown = _ref2.onKeyDown,
8604
+ ariaLabel = _ref2['aria-label'];
8605
+ var fv = useFocusVisible();
8606
+ return jsx("div", {
8607
+ "aria-label": ariaLabel,
8608
+ onBlur: fv.onBlur,
8609
+ onFocus: fv.onFocus,
8610
+ onKeyDown: onKeyDown,
8611
+ onMouseDown: fv.clear,
8274
8612
  role: "listbox",
8275
- style: mergedStyle,
8276
- tabIndex: 0
8277
- }));
8278
- });
8279
- var LocationDropdown = function LocationDropdown(_ref) {
8613
+ style: Object.assign({
8614
+ outline: 'none',
8615
+ transition: 'box-shadow 120ms ease, background-color 120ms ease'
8616
+ }, fv.focusVisible ? {
8617
+ boxShadow: '0 0 0 2px var(--focus-ring-color, #1976d2)',
8618
+ backgroundColor: 'rgba(25,118,210,0.06)'
8619
+ } : null),
8620
+ tabIndex: 0,
8621
+ children: children
8622
+ });
8623
+ };
8624
+ var LocationDropdown = function LocationDropdown(_ref3) {
8280
8625
  var _combinedSelectedLoca;
8281
- var geoJson = _ref.geoJson,
8282
- splitGeoJson = _ref.splitGeoJson,
8283
- handleChange = _ref.handleChange,
8284
- selectedLocation = _ref.selectedLocation,
8285
- _ref$isDisabled = _ref.isDisabled,
8286
- isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
8287
- defaultExpanded = _ref.defaultExpanded;
8626
+ var geoJson = _ref3.geoJson,
8627
+ splitGeoJson = _ref3.splitGeoJson,
8628
+ handleChange = _ref3.handleChange,
8629
+ selectedLocation = _ref3.selectedLocation,
8630
+ _ref3$isDisabled = _ref3.isDisabled,
8631
+ isDisabled = _ref3$isDisabled === void 0 ? false : _ref3$isDisabled,
8632
+ defaultExpanded = _ref3.defaultExpanded;
8633
+ var listRef = useListRef(null);
8288
8634
  var _React$useState2 = React.useState(''),
8289
8635
  searchTerm = _React$useState2[0],
8290
8636
  setSearchTerm = _React$useState2[1];
8291
8637
  var combinedSelectedLocation = geoJson == null ? void 0 : geoJson.features.find(function (feature) {
8292
- var _feature$properties;
8293
- return selectedLocation === ((_feature$properties = feature.properties) == null ? void 0 : _feature$properties.name);
8638
+ var _feature$properties2;
8639
+ return selectedLocation === ((_feature$properties2 = feature.properties) == null ? void 0 : _feature$properties2.name);
8294
8640
  });
8295
8641
  var selectedLocationNames = combinedSelectedLocation ? Object.keys(combinedSelectedLocation == null || (_combinedSelectedLoca = combinedSelectedLocation.properties) == null ? void 0 : _combinedSelectedLoca.names) : [];
8296
8642
  var filteredResults = useMemo(function () {
8297
8643
  return splitGeoJson == null ? void 0 : splitGeoJson.map(function (dataset) {
8298
8644
  var filteredFeatures = dataset.geoJson.features.filter(function (feature) {
8299
- var _feature$properties2;
8300
- return (_feature$properties2 = feature.properties) == null ? void 0 : _feature$properties2.name.toLowerCase().includes(searchTerm.toLowerCase());
8645
+ var _feature$properties3;
8646
+ return (_feature$properties3 = feature.properties) == null ? void 0 : _feature$properties3.name.toLowerCase().includes(searchTerm.toLowerCase());
8301
8647
  });
8302
8648
  return Object.assign({}, dataset, {
8303
8649
  geoJson: Object.assign({}, dataset.geoJson, {
@@ -8308,6 +8654,40 @@ var LocationDropdown = function LocationDropdown(_ref) {
8308
8654
  }, [searchTerm, splitGeoJson]);
8309
8655
  var listContainerRef = React.useRef(null);
8310
8656
  var heightObserver = useResizeObserver(listContainerRef, filteredResults);
8657
+ var handleKeyDown = function handleKeyDown(e) {
8658
+ var _listContainerRef$cur, _listContainerRef$cur2;
8659
+ var lineHeight = 40;
8660
+ var page = 8 * lineHeight; // or compute from measured height if you want
8661
+ var next = (listContainerRef == null || (_listContainerRef$cur = listContainerRef.current) == null ? void 0 : _listContainerRef$cur.scrollTop) || 0;
8662
+ switch (e.key) {
8663
+ case 'ArrowDown':
8664
+ e.preventDefault();
8665
+ next += lineHeight;
8666
+ break;
8667
+ case 'ArrowUp':
8668
+ e.preventDefault();
8669
+ next -= lineHeight;
8670
+ break;
8671
+ case 'PageDown':
8672
+ e.preventDefault();
8673
+ next += page;
8674
+ break;
8675
+ case 'PageUp':
8676
+ e.preventDefault();
8677
+ next -= page;
8678
+ break;
8679
+ case 'Home':
8680
+ e.preventDefault();
8681
+ next = 0;
8682
+ break;
8683
+ default:
8684
+ return;
8685
+ }
8686
+ listContainerRef == null || (_listContainerRef$cur2 = listContainerRef.current) == null || _listContainerRef$cur2.scrollTo({
8687
+ top: Math.max(0, next),
8688
+ behavior: 'smooth'
8689
+ });
8690
+ };
8311
8691
  return jsx(Box, {
8312
8692
  "data-testid": "locationDropdownContainer",
8313
8693
  ref: listContainerRef,
@@ -8341,8 +8721,8 @@ var LocationDropdown = function LocationDropdown(_ref) {
8341
8721
  var collectionGeoJson = object.geoJson;
8342
8722
  // Find location from the collection that matches the selected location
8343
8723
  var collectionSelectedLocation = collectionGeoJson.features.find(function (feature) {
8344
- var _feature$properties3;
8345
- return selectedLocationNames.includes((_feature$properties3 = feature.properties) == null ? void 0 : _feature$properties3.name);
8724
+ var _feature$properties4;
8725
+ return selectedLocationNames.includes((_feature$properties4 = feature.properties) == null ? void 0 : _feature$properties4.name);
8346
8726
  });
8347
8727
  return jsx(Box, {
8348
8728
  "data-testid": "serviceDropdown",
@@ -8359,13 +8739,25 @@ var LocationDropdown = function LocationDropdown(_ref) {
8359
8739
  },
8360
8740
  title: collectionName,
8361
8741
  title2: serviceName,
8362
- children: jsx(FixedSizeList, {
8363
- height: heightObserver,
8364
- itemCount: collectionGeoJson.features.length,
8365
- itemSize: 40,
8366
- outerElementType: FocusableListOuter,
8367
- width: "100%",
8368
- children: renderRow(collectionGeoJson.features, handleChange, collectionSelectedLocation == null || (_collectionSelectedLo = collectionSelectedLocation.properties) == null ? void 0 : _collectionSelectedLo.name, isDisabled)
8742
+ children: jsx(FocusableListWrapper, {
8743
+ "aria-label": "Locations list",
8744
+ onKeyDown: handleKeyDown,
8745
+ children: jsx(List$1, {
8746
+ listRef: listRef,
8747
+ rowComponent: RowComponent,
8748
+ rowCount: collectionGeoJson.features.length,
8749
+ rowHeight: 40,
8750
+ rowProps: {
8751
+ handleChange: handleChange,
8752
+ selectedLocation: collectionSelectedLocation == null || (_collectionSelectedLo = collectionSelectedLocation.properties) == null ? void 0 : _collectionSelectedLo.name,
8753
+ features: collectionGeoJson.features,
8754
+ isDisabled: isDisabled
8755
+ },
8756
+ style: {
8757
+ height: heightObserver,
8758
+ width: '100%'
8759
+ }
8760
+ })
8369
8761
  })
8370
8762
  })
8371
8763
  }, collectionName + "-" + serviceName);
@@ -8375,6 +8767,7 @@ var LocationDropdown = function LocationDropdown(_ref) {
8375
8767
  };
8376
8768
 
8377
8769
  var _excluded = ["occurrences"];
8770
+ var emptyMapIdList = [];
8378
8771
  var LocationSelectDialogConnect = function LocationSelectDialogConnect() {
8379
8772
  var _timeSeriesLocation$o;
8380
8773
  var _useTimeseriesTransla = useTimeseriesTranslation(),
@@ -8389,16 +8782,20 @@ var LocationSelectDialogConnect = function LocationSelectDialogConnect() {
8389
8782
  dialogOrder = _useSetupDialog.dialogOrder,
8390
8783
  setDialogOrder = _useSetupDialog.setDialogOrder;
8391
8784
  var geoJSONWithService = useSelector(function (state) {
8392
- return getGeoJSONWithService(state, panelId);
8785
+ return panelId ? getGeoJSONWithService(state, panelId) : undefined;
8393
8786
  });
8394
8787
  var sharedGeoJSON = useSelector(function (state) {
8395
- return genericSelectors.selectSharedData(state, panelId);
8788
+ return panelId ? genericSelectors.selectSharedData(state, panelId) : undefined;
8396
8789
  });
8397
8790
  var selectedMapIds = useSelector(function (state) {
8398
- return genericSelectors.getLinkedMaps(state, panelId);
8791
+ return panelId ? genericSelectors.getLinkedMaps(state, panelId) : emptyMapIdList;
8792
+ });
8793
+ var isMapPinDisabled = useSelector(function (state) {
8794
+ return panelId ? getIsMapPinDisabled(state, panelId) : false;
8795
+ });
8796
+ var timeSeriesLocation = useSelector(function (state) {
8797
+ return panelId ? getCurrentLocation(state, panelId) : undefined;
8399
8798
  });
8400
- var isMapPinDisabled = useSelector(getIsMapPinDisabled);
8401
- var timeSeriesLocation = useSelector(getCurrentLocation);
8402
8799
  var setSelectedFeatureIndex = function setSelectedFeatureIndex(selectedFeatureIndex) {
8403
8800
  dispatch(layerActions.setSelectedFeature({
8404
8801
  layerId: geojsonLayerId,
@@ -8414,10 +8811,14 @@ var LocationSelectDialogConnect = function LocationSelectDialogConnect() {
8414
8811
  }));
8415
8812
  };
8416
8813
  var setTimeSeriesLocation = useCallback(function (location) {
8814
+ if (!panelId) {
8815
+ return;
8816
+ }
8417
8817
  dispatch(timeSeriesActions.setCurrentLocation({
8818
+ panelId: panelId,
8418
8819
  location: location
8419
8820
  }));
8420
- }, [dispatch]);
8821
+ }, [dispatch, panelId]);
8421
8822
  var setMapPinLocation = function setMapPinLocation(mapPinLocation) {
8422
8823
  selectedMapIds.forEach(function (mapId) {
8423
8824
  dispatch(mapActions.setMapPinLocation({
@@ -8432,6 +8833,9 @@ var LocationSelectDialogConnect = function LocationSelectDialogConnect() {
8432
8833
  var selectedLocationName = typeof (timeSeriesLocation == null || (_timeSeriesLocation$o = timeSeriesLocation.occurrences) == null || (_timeSeriesLocation$o = _timeSeriesLocation$o[0]) == null || (_timeSeriesLocation$o = _timeSeriesLocation$o.properties) == null ? void 0 : _timeSeriesLocation$o.name) === 'string' ? timeSeriesLocation.occurrences[0].properties.name : '';
8433
8834
  var onChangeLocation = function onChangeLocation(newSelectedLocation) {
8434
8835
  var _geojson$features, _feature$properties;
8836
+ if (!panelId) {
8837
+ return;
8838
+ }
8435
8839
  if (!(geojson != null && (_geojson$features = geojson.features) != null && _geojson$features.length)) {
8436
8840
  return;
8437
8841
  }
@@ -8467,6 +8871,9 @@ var LocationSelectDialogConnect = function LocationSelectDialogConnect() {
8467
8871
  var newMapPin = _objectWithoutPropertiesLoose(location, _excluded);
8468
8872
  setMapPinLocation(newMapPin);
8469
8873
  };
8874
+ if (!panelId) {
8875
+ return null;
8876
+ }
8470
8877
  return jsx(ToolContainerDraggable, {
8471
8878
  bounds: "parent",
8472
8879
  isOpen: isDialogOpen,