@opengeoweb/taf 13.1.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,7 +45,7 @@ const Component = () => {
45
45
 
46
46
  ## Configuration
47
47
 
48
- The TAF configuration is currently coming from the frontend and is located in `libs/taf/src/lib/utils/tafConfig.json`
48
+ The TAF configuration is fetched from the [TAF backend](https://gitlab.com/opengeoweb/backend-services/aviation-taf-backend) via the `/taf-config` endpoint.
49
49
 
50
50
  ## AutoTaf
51
51
 
package/index.esm.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default from 'react';
4
- import { Grid, Button, Chip, Box, Typography, TextField, Card, Tabs, Tab, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
4
+ import { Grid, Button, Chip, Box, Typography, TextField, LinearProgress, Card, Tabs, Tab, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
5
5
  import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
6
6
  import { useDispatch } from 'react-redux';
7
7
  import { ReactSortable } from 'react-sortablejs';
8
8
  import Sortable from 'sortablejs';
9
9
  import { useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
10
10
  import { HIDDEN_INPUT_HELPER_IS_DRAFT, getDeepProperty, useDraftFormHelpers, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
11
- import { SHARED_NAMESPACE, dateUtils, sessionStorageProvider, getErrorMessage as getErrorMessage$1, getWarningMessage, CustomIconButton, CustomTooltip, ToolContainerDraggable, Avatar, getInitials, ToggleMenu, useConfirmationDialog, usePreventBrowserClose, SwitchButton, CustomDialog, ToolHeader, AlertBanner, LastUpdateTime, ErrorBoundary } from '@opengeoweb/shared';
11
+ import { SHARED_NAMESPACE, dateUtils, sessionStorageProvider, getErrorMessage as getErrorMessage$1, getWarningMessage, CustomIconButton, CustomTooltip, ToolContainerDraggable, Avatar, getInitials, ToggleMenu, useConfirmationDialog, usePreventBrowserClose, SwitchButton, AlertBanner, CustomDialog, ToolHeader, LastUpdateTime, ErrorBoundary } from '@opengeoweb/shared';
12
12
  import { snackbarActions, snackbarTypes } from '@opengeoweb/snackbar';
13
13
  import 'i18next';
14
14
  import { useTranslation } from 'react-i18next';
@@ -18,7 +18,7 @@ import { getHeaders, handleResponse, useAuthQuery, useAuthenticationContext } fr
18
18
  import { DragHandle as DragHandle$1, ThumbsUp, Add, Delete, Close, Clock, Cancel, Success, Edit, Export, ListItem } from '@opengeoweb/theme';
19
19
  import ReactDOM from 'react-dom';
20
20
  import { useTheme } from '@emotion/react';
21
- import LinearProgress from '@mui/material/LinearProgress';
21
+ import LinearProgress$1 from '@mui/material/LinearProgress';
22
22
  import Box$1 from '@mui/material/Box';
23
23
  import { http, HttpResponse, delay } from 'msw';
24
24
 
@@ -48,6 +48,8 @@ var en = {
48
48
  "error-auth-message": "Please log in to proceed.",
49
49
  "error-list": "An error has occurred while retrieving the list",
50
50
  "error-title-retry": "Try again",
51
+ "error-config": "An error has occurred while retrieving the TAF configuration",
52
+ "error-config-message": "Failed to get TAF configuration from backend",
51
53
  "editor-on": "You are now the editor for TAF {{location}}",
52
54
  "editor-off": "You are now no longer the editor for TAF {{location}}",
53
55
  "taf-import-message": "TAF {{location}} {{locationLabel}} was imported successfully",
@@ -130,6 +132,8 @@ var fi = {
130
132
  "error-auth-message": "Kirjaudu sisään jatkaaksesi",
131
133
  "error-list": "Listaa haettaessa on tapahtunut virhe",
132
134
  "error-title-retry": "Yritä uudelleen",
135
+ "error-config": "🚧 ei käännetty",
136
+ "error-config-message": "🚧 ei käännetty",
133
137
  "editor-on": "Olet nyt TAF:n {{location}} editoija",
134
138
  "editor-off": "Et ole enää TAF:n {{location}} editoija",
135
139
  "taf-import-message": "TAF {{location}} {{locationLabel}} tuotu onnistuneesti",
@@ -212,6 +216,8 @@ var no = {
212
216
  "error-auth-message": "Vennligst logg inn.",
213
217
  "error-list": "En feil har oppstått ved henting av liste",
214
218
  "error-title-retry": "Prøv igjen",
219
+ "error-config": "ikke oversatt",
220
+ "error-config-message": "ikke oversatt",
215
221
  "editor-on": "Du er no redaktøren for TAF {{location}}",
216
222
  "editor-off": "Du er ikke lenger redaktøren for TAF {{location}}",
217
223
  "taf-import-message": "TAF {{location}} {{locationLabel}} ble importert",
@@ -294,6 +300,8 @@ var nl = {
294
300
  "error-auth-message": "Log in om door te gaan.",
295
301
  "error-list": "Er is een fout opgetreden bij het laden van de lijst",
296
302
  "error-title-retry": "Probeer opnieuw",
303
+ "error-config": "Er is een fout opgetreden bij het laden van de TAF configuratie",
304
+ "error-config-message": "De TAF configuratie kon niet worden opgehaald",
297
305
  "editor-on": "Je bent nu de editor van TAF {{location}}",
298
306
  "editor-off": "Je bent nu niet langer de editor van TAF {{location}}",
299
307
  "taf-import-message": "TAF {{location}} {{locationLabel}} is succesvol geïmporteerd",
@@ -2599,60 +2607,10 @@ var getTAC = function getTAC(auth, data) {
2599
2607
  body: JSON.stringify(data)
2600
2608
  }).then(handleResponse);
2601
2609
  };
2602
-
2603
- var location_indicator_mwo = "EHDB";
2604
- var locations = {
2605
- EHAM: {
2606
- validity_duration: 30,
2607
- activity_period: 6,
2608
- label: "Schiphol"
2609
- },
2610
- EHRD: {
2611
- validity_duration: 30,
2612
- activity_period: 6,
2613
- label: "Rotterdam"
2614
- },
2615
- EHGG: {
2616
- validity_duration: 30,
2617
- activity_period: 6,
2618
- label: "Eelde"
2619
- },
2620
- EHBK: {
2621
- validity_duration: 30,
2622
- activity_period: 6,
2623
- label: "Maastricht"
2624
- },
2625
- EHLE: {
2626
- validity_duration: 30,
2627
- activity_period: 6,
2628
- label: "Lelystad"
2629
- },
2630
- TNCB: {
2631
- validity_duration: 30,
2632
- activity_period: 6,
2633
- label: "Bonaire"
2634
- }
2635
- };
2636
- var locationOrder = [
2637
- "EHAM",
2638
- "EHRD",
2639
- "EHLE",
2640
- "EHGG",
2641
- "EHBK",
2642
- "TNCB"
2643
- ];
2644
- var autoTAFlocations = [
2645
- "EHAM",
2646
- "EHRD",
2647
- "EHLE",
2648
- "EHGG",
2649
- "EHBK"
2650
- ];
2651
- var tafConfig = {
2652
- location_indicator_mwo: location_indicator_mwo,
2653
- locations: locations,
2654
- locationOrder: locationOrder,
2655
- autoTAFlocations: autoTAFlocations
2610
+ var getTafConfig = function getTafConfig(auth) {
2611
+ return fetch(tafBaseUrl + "/taf-config", {
2612
+ headers: getHeaders(auth)
2613
+ }).then(handleResponse);
2656
2614
  };
2657
2615
 
2658
2616
  /* *
@@ -2672,15 +2630,7 @@ var tafConfig = {
2672
2630
  * Copyright 2022 - Finnish Meteorological Institute (FMI)
2673
2631
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
2674
2632
  * */
2675
- // TODO: should be validated
2676
- var getTafSettings = function getTafSettings() {
2677
- return tafConfig;
2678
- };
2679
- var tafSettings = getTafSettings();
2680
2633
  var getLocationSetting = function getLocationSetting(location, locationSettings) {
2681
- if (locationSettings === void 0) {
2682
- locationSettings = tafSettings.locations;
2683
- }
2684
2634
  return locationSettings[location];
2685
2635
  };
2686
2636
  var sortTafsOnLocation = function sortTafsOnLocation(tafList, locationOrder) {
@@ -2688,7 +2638,7 @@ var sortTafsOnLocation = function sortTafsOnLocation(tafList, locationOrder) {
2688
2638
  tafList = [];
2689
2639
  }
2690
2640
  if (locationOrder === void 0) {
2691
- locationOrder = tafSettings.locationOrder;
2641
+ locationOrder = [];
2692
2642
  }
2693
2643
  return [].concat(tafList).sort(function (_ref, _ref2) {
2694
2644
  var tafA = _ref.taf;
@@ -2709,9 +2659,9 @@ var sortTafsOnIssueDate = function sortTafsOnIssueDate(tafList) {
2709
2659
  return -1;
2710
2660
  });
2711
2661
  };
2712
- var getBaseTime = function getBaseTime(baseTime, location) {
2662
+ var getBaseTime = function getBaseTime(baseTime, location, tafConfig) {
2713
2663
  var currentBaseTime = dateUtils.utc(baseTime);
2714
- var activityPeriod = getLocationSetting(location).activity_period;
2664
+ var activityPeriod = getLocationSetting(location, tafConfig.locations).activity_period;
2715
2665
  var nextBaseTime = dateUtils.add(dateUtils.utc(baseTime), {
2716
2666
  hours: activityPeriod
2717
2667
  });
@@ -2720,9 +2670,9 @@ var getBaseTime = function getBaseTime(baseTime, location) {
2720
2670
  nextBaseTime: nextBaseTime
2721
2671
  };
2722
2672
  };
2723
- var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status) {
2673
+ var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status, tafConfig) {
2724
2674
  var now = dateUtils.utc();
2725
- var _getBaseTime = getBaseTime(baseTime, location),
2675
+ var _getBaseTime = getBaseTime(baseTime, location, tafConfig),
2726
2676
  currentBaseTime = _getBaseTime.currentBaseTime,
2727
2677
  nextBaseTime = _getBaseTime.nextBaseTime;
2728
2678
  if (status === 'EXPIRED') {
@@ -2733,12 +2683,12 @@ var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status) {
2733
2683
  }
2734
2684
  return 'UPCOMING';
2735
2685
  };
2736
- var sortTafTimeSlots = function sortTafTimeSlots(tafList) {
2686
+ var sortTafTimeSlots = function sortTafTimeSlots(tafList, tafConfig) {
2737
2687
  var sortedListOnIssueDate = sortTafsOnIssueDate(tafList);
2738
- var sortedListOnLocation = sortTafsOnLocation(sortedListOnIssueDate);
2688
+ var sortedListOnLocation = sortTafsOnLocation(sortedListOnIssueDate, tafConfig.locationOrder);
2739
2689
  return sortedListOnLocation.reduce(function (sortedTafList, tafFromBackend) {
2740
2690
  var taf = tafFromBackend.taf;
2741
- var timeSlot = getTafTimeSlot(taf.baseTime, taf.location, taf.status);
2691
+ var timeSlot = getTafTimeSlot(taf.baseTime, taf.location, taf.status, tafConfig);
2742
2692
  if (timeSlot === 'EXPIRED') {
2743
2693
  sortedTafList.expired.push(tafFromBackend);
2744
2694
  } else if (timeSlot === 'ACTIVE') {
@@ -2787,9 +2737,6 @@ var getPreviousTaf = function getPreviousTaf(tafList, currentTaf) {
2787
2737
  return previousTaf ? previousTaf.taf : null;
2788
2738
  };
2789
2739
  var getAutoTafLocations = function getAutoTafLocations(autoTAFlocations) {
2790
- if (autoTAFlocations === void 0) {
2791
- autoTAFlocations = tafSettings.autoTAFlocations;
2792
- }
2793
2740
  return autoTAFlocations || null;
2794
2741
  };
2795
2742
  var scrollToPosition = function scrollToPosition(scrollRef, activeLocation) {
@@ -2872,6 +2819,12 @@ var useTafList = function useTafList(disabled) {
2872
2819
  }
2873
2820
  return useAuthQuery(['taf-list'], getTafList, disabled, 1000 * 60 * 5);
2874
2821
  };
2822
+ var useTafConfig = function useTafConfig(disabled) {
2823
+ if (disabled === void 0) {
2824
+ disabled = false;
2825
+ }
2826
+ return useAuthQuery(['taf-config'], getTafConfig, disabled, false);
2827
+ };
2875
2828
  var usePostTaf = function usePostTaf() {
2876
2829
  var queryClient = useQueryClient();
2877
2830
  var _useAuthenticationCon = useAuthenticationContext(),
@@ -4198,10 +4151,12 @@ var TafFormTextField = function TafFormTextField(_ref3) {
4198
4151
  onBlur: function onBlur(event) {
4199
4152
  return onBlurField(event, field.onBlur);
4200
4153
  },
4201
- inputProps: {
4202
- maxLength: maxLength,
4203
- className: 'inputText',
4204
- 'aria-label': name
4154
+ slotProps: {
4155
+ htmlInput: {
4156
+ maxLength: maxLength,
4157
+ className: 'inputText',
4158
+ 'aria-label': name
4159
+ }
4205
4160
  },
4206
4161
  autoFocus: autoFocus,
4207
4162
  shouldPreventUppercase: shouldPreventUppercase
@@ -5445,7 +5400,7 @@ var AdverseWeatherTACMessage = function AdverseWeatherTACMessage(_ref) {
5445
5400
  color: 'geowebColors.captions.captionError.rgba',
5446
5401
  fontWeight: 'bold'
5447
5402
  }),
5448
- children: word.text === '=' ? "" + word.text : " " + word.text
5403
+ children: word.text === '=' ? word.text : " " + word.text
5449
5404
  }, word.text + index.toString());
5450
5405
  })
5451
5406
  }, line.toString() + index.toString());
@@ -5453,6 +5408,94 @@ var AdverseWeatherTACMessage = function AdverseWeatherTACMessage(_ref) {
5453
5408
  });
5454
5409
  };
5455
5410
 
5411
+ var TafConfigContext = /*#__PURE__*/React__default.createContext({
5412
+ tafConfig: null
5413
+ });
5414
+ var useTafConfigContext = function useTafConfigContext() {
5415
+ return React__default.useContext(TafConfigContext);
5416
+ };
5417
+ var TafConfigWrapper = function TafConfigWrapper(_ref) {
5418
+ var children = _ref.children;
5419
+ var _useTafTranslation = useTafTranslation(),
5420
+ t = _useTafTranslation.t;
5421
+ var _React$useState = React__default.useState(null),
5422
+ errorMessage = _React$useState[0],
5423
+ setErrorMessage = _React$useState[1];
5424
+ var ERROR_CONFIG = t('error-config');
5425
+ var ERROR_CONFIG_MESSAGE = t('error-config-message');
5426
+ var _useAuthenticationCon = useAuthenticationContext$1(),
5427
+ isLoggedIn = _useAuthenticationCon.isLoggedIn;
5428
+ var ERROR_AUTH = t('error-auth');
5429
+ var ERROR_AUTH_MESSAGE = t('error-auth-message');
5430
+ var _useTafConfig = useTafConfig(),
5431
+ isFetching = _useTafConfig.isFetching,
5432
+ tafConfigError = _useTafConfig.error,
5433
+ tafConfig = _useTafConfig.data,
5434
+ fetchConfig = _useTafConfig.refetch;
5435
+ var onFetchConfig = /*#__PURE__*/function () {
5436
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5437
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5438
+ while (1) switch (_context.prev = _context.next) {
5439
+ case 0:
5440
+ _context.next = 2;
5441
+ return fetchConfig();
5442
+ case 2:
5443
+ case "end":
5444
+ return _context.stop();
5445
+ }
5446
+ }, _callee);
5447
+ }));
5448
+ return function onFetchConfig() {
5449
+ return _ref2.apply(this, arguments);
5450
+ };
5451
+ }();
5452
+ React__default.useEffect(function () {
5453
+ if (!isLoggedIn) {
5454
+ setErrorMessage({
5455
+ title: ERROR_AUTH,
5456
+ info: ERROR_AUTH_MESSAGE
5457
+ });
5458
+ } else if (tafConfigError) {
5459
+ setErrorMessage({
5460
+ title: ERROR_CONFIG,
5461
+ info: tafConfigError.message
5462
+ });
5463
+ } else {
5464
+ setErrorMessage(null);
5465
+ }
5466
+ }, [t, isLoggedIn, tafConfigError, ERROR_CONFIG, ERROR_AUTH, ERROR_AUTH_MESSAGE]);
5467
+ var contextValue = React__default.useMemo(function () {
5468
+ return {
5469
+ tafConfig: tafConfig
5470
+ };
5471
+ }, [tafConfig]);
5472
+ if (isLoggedIn && isFetching) {
5473
+ return jsx(LinearProgress, {
5474
+ "data-testid": "tafconfig-loading-bar",
5475
+ color: "secondary",
5476
+ sx: {
5477
+ marginBottom: '-4px'
5478
+ }
5479
+ });
5480
+ }
5481
+ if (errorMessage || !tafConfig) {
5482
+ return jsx(AlertBanner, {
5483
+ severity: "error",
5484
+ title: errorMessage ? errorMessage.title : ERROR_CONFIG,
5485
+ info: errorMessage ? errorMessage.info : ERROR_CONFIG_MESSAGE,
5486
+ "data-testid": "error-message",
5487
+ actionButtonProps: !errorMessage || errorMessage.title !== ERROR_AUTH ? {
5488
+ title: t('error-title-retry'),
5489
+ onClick: onFetchConfig
5490
+ } : undefined
5491
+ });
5492
+ }
5493
+ return jsx(TafConfigContext.Provider, {
5494
+ value: contextValue,
5495
+ children: children
5496
+ });
5497
+ };
5498
+
5456
5499
  var TacHighLight = function TacHighLight(_ref) {
5457
5500
  var isActive = _ref.isActive,
5458
5501
  children = _ref.children;
@@ -5483,8 +5526,10 @@ var TacContainer = function TacContainer(_ref2) {
5483
5526
  var status = taf.status,
5484
5527
  location = taf.location,
5485
5528
  baseTime = taf.baseTime;
5486
- var locationLabel = getLocationSetting(location).label;
5487
- var timeSlot = getTafTimeSlot(baseTime, location, status);
5529
+ var _useTafConfigContext = useTafConfigContext(),
5530
+ tafConfig = _useTafConfigContext.tafConfig;
5531
+ var locationLabel = getLocationSetting(location, tafConfig.locations).label;
5532
+ var timeSlot = getTafTimeSlot(baseTime, location, status, tafConfig);
5488
5533
  var _useFormContext = useFormContext(),
5489
5534
  getValues = _useFormContext.getValues,
5490
5535
  trigger = _useFormContext.trigger,
@@ -5727,7 +5772,9 @@ var TacContainerLayout = function TacContainerLayout(_ref) {
5727
5772
  exportBtnSlot = _ref.exportBtnSlot,
5728
5773
  statusSlot = _ref.statusSlot,
5729
5774
  children = _ref.children;
5730
- var locationLabel = getLocationSetting(location).label;
5775
+ var _useTafConfigContext = useTafConfigContext(),
5776
+ tafConfig = _useTafConfigContext.tafConfig;
5777
+ var locationLabel = getLocationSetting(location, tafConfig.locations).label;
5731
5778
  return jsxs(Box, {
5732
5779
  sx: {
5733
5780
  marginBottom: '20px'
@@ -5819,13 +5866,15 @@ var AutoTaf = function AutoTaf(_ref2) {
5819
5866
  var _useTafTranslation = useTafTranslation(),
5820
5867
  t = _useTafTranslation.t;
5821
5868
  var scrollRef = React__default.useRef(null);
5869
+ var _useTafConfigContext = useTafConfigContext(),
5870
+ tafConfig = _useTafConfigContext.tafConfig;
5822
5871
  React__default.useEffect(function () {
5823
5872
  if (activeTaf) {
5824
5873
  scrollToPosition(scrollRef, activeTaf.taf.location);
5825
5874
  }
5826
5875
  }, [activeTaf]);
5827
5876
  var renderAutoTaf = function renderAutoTaf(tafList) {
5828
- var autoTafLocations = getAutoTafLocations();
5877
+ var autoTafLocations = getAutoTafLocations(tafConfig == null ? void 0 : tafConfig.autoTAFlocations);
5829
5878
  if (!autoTafLocations) {
5830
5879
  return jsx(Message, {
5831
5880
  text: t('autotaf-no-config')
@@ -5969,11 +6018,13 @@ var TopTabs = function TopTabs(_ref) {
5969
6018
  t = _useTafTranslation.t;
5970
6019
  var _useFormContext = useFormContext(),
5971
6020
  isDirty = _useFormContext.formState.isDirty;
6021
+ var _useTafConfigContext = useTafConfigContext(),
6022
+ tafConfig = _useTafConfigContext.tafConfig;
5972
6023
  if (!tafFromBackend) {
5973
6024
  return null;
5974
6025
  }
5975
6026
  var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
5976
- var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location),
6027
+ var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location, tafConfig),
5977
6028
  currentBaseTime = _getBaseTime.currentBaseTime,
5978
6029
  nextBaseTime = _getBaseTime.nextBaseTime;
5979
6030
  var tabs = [{
@@ -6276,7 +6327,9 @@ var TafLayout = function TafLayout(_ref) {
6276
6327
  var _useTafModuleContext = useTafModuleContext(),
6277
6328
  onValidateForm = _useTafModuleContext.onValidateForm,
6278
6329
  tafAction = _useTafModuleContext.tafAction;
6279
- var _React$useState = React__default.useState(sortTafTimeSlots(tafList)),
6330
+ var _useTafConfigContext = useTafConfigContext(),
6331
+ tafConfig = _useTafConfigContext.tafConfig;
6332
+ var _React$useState = React__default.useState(sortTafTimeSlots(tafList, tafConfig)),
6280
6333
  _React$useState$ = _React$useState[0],
6281
6334
  upcoming = _React$useState$.upcoming,
6282
6335
  current = _React$useState$.current,
@@ -6445,9 +6498,9 @@ var TafLayout = function TafLayout(_ref) {
6445
6498
  };
6446
6499
  React__default.useEffect(function () {
6447
6500
  var _locations$activeTafI;
6448
- var newSortedTafs = sortTafTimeSlots(tafList);
6501
+ var newSortedTafs = sortTafTimeSlots(tafList, tafConfig);
6449
6502
  var updatedLocations = timeSlot === 'ACTIVE' ? newSortedTafs.current : newSortedTafs.upcoming;
6450
- updateSortedTafs(sortTafTimeSlots(tafList));
6503
+ updateSortedTafs(sortTafTimeSlots(tafList, tafConfig));
6451
6504
  setLocations(updatedLocations);
6452
6505
  // update active index
6453
6506
  var previousActiveLocationUUID = (_locations$activeTafI = locations[activeTafIndex]) == null || (_locations$activeTafI = _locations$activeTafI.taf) == null ? void 0 : _locations$activeTafI.uuid;
@@ -6660,10 +6713,6 @@ var TafModule = function TafModule(_ref) {
6660
6713
  var _React$useState = React.useState(null),
6661
6714
  errorMessage = _React$useState[0],
6662
6715
  setErrorMessage = _React$useState[1];
6663
- var _useAuthenticationCon = useAuthenticationContext$1(),
6664
- isLoggedIn = _useAuthenticationCon.isLoggedIn;
6665
- var ERROR_AUTH = t('error-auth');
6666
- var ERROR_AUTH_MESSAGE = t('error-auth-message');
6667
6716
  var _useTafList = useTafList(),
6668
6717
  isFetching = _useTafList.isFetching,
6669
6718
  tafListError = _useTafList.error,
@@ -6689,12 +6738,7 @@ var TafModule = function TafModule(_ref) {
6689
6738
  };
6690
6739
  }();
6691
6740
  React.useEffect(function () {
6692
- if (!isLoggedIn) {
6693
- setErrorMessage({
6694
- title: ERROR_AUTH,
6695
- info: ERROR_AUTH_MESSAGE
6696
- });
6697
- } else if (tafListError) {
6741
+ if (tafListError) {
6698
6742
  setErrorMessage({
6699
6743
  title: t('error-list'),
6700
6744
  info: tafListError.message
@@ -6702,7 +6746,7 @@ var TafModule = function TafModule(_ref) {
6702
6746
  } else {
6703
6747
  setErrorMessage(null);
6704
6748
  }
6705
- }, [t, tafListError, isLoggedIn, ERROR_AUTH, ERROR_AUTH_MESSAGE]);
6749
+ }, [t, tafListError]);
6706
6750
  return jsx(ResponsiveWrapper, {
6707
6751
  children: jsxs(Box, {
6708
6752
  component: "div",
@@ -6711,7 +6755,7 @@ var TafModule = function TafModule(_ref) {
6711
6755
  sx: {
6712
6756
  height: '100%'
6713
6757
  },
6714
- children: [isLoggedIn && isFetching && jsx(LinearProgress, {
6758
+ children: [isFetching && jsx(LinearProgress$1, {
6715
6759
  "data-testid": "loading-bar",
6716
6760
  color: "secondary",
6717
6761
  sx: {
@@ -6722,10 +6766,10 @@ var TafModule = function TafModule(_ref) {
6722
6766
  title: errorMessage.title,
6723
6767
  info: errorMessage.info,
6724
6768
  "data-testid": "error-message",
6725
- actionButtonProps: errorMessage.title !== ERROR_AUTH ? {
6769
+ actionButtonProps: {
6726
6770
  title: t('error-title-retry'),
6727
6771
  onClick: onUpdateTaf
6728
- } : undefined
6772
+ }
6729
6773
  }) : null, jsx(TafLayout, {
6730
6774
  tafList: tafList || [],
6731
6775
  onUpdateTaf: onUpdateTaf,
@@ -6740,8 +6784,10 @@ var Wrapper = function Wrapper(_ref3) {
6740
6784
  isAutoTafEnabled = _ref3$isAutoTafEnable === void 0 ? false : _ref3$isAutoTafEnable,
6741
6785
  props = _objectWithoutPropertiesLoose(_ref3, _excluded);
6742
6786
  return jsx(TafWrapper, Object.assign({}, props, {
6743
- children: jsx(TafModule, {
6744
- isAutoTafEnabled: isAutoTafEnabled
6787
+ children: jsx(TafConfigWrapper, {
6788
+ children: jsx(TafModule, {
6789
+ isAutoTafEnabled: isAutoTafEnabled
6790
+ })
6745
6791
  })
6746
6792
  }));
6747
6793
  };
@@ -6775,7 +6821,6 @@ var TafApiWrapper = function TafApiWrapper(_ref) {
6775
6821
  };
6776
6822
  var componentsLookUp = function componentsLookUp(payload, _ref2,
6777
6823
  // TODO: find a good way to type this module without the apps complaining
6778
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
6779
6824
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6780
6825
  ConnectedModuleWrapper) {
6781
6826
  var config = _ref2.config,
@@ -7997,6 +8042,43 @@ var fakeTafTacJson = {
7997
8042
  text: '='
7998
8043
  }]]
7999
8044
  };
8045
+ var fakeTafConfig = {
8046
+ location_indicator_mwo: 'EHDB',
8047
+ locations: {
8048
+ EHAM: {
8049
+ validity_duration: 30,
8050
+ activity_period: 6,
8051
+ label: 'Schiphol'
8052
+ },
8053
+ EHRD: {
8054
+ validity_duration: 30,
8055
+ activity_period: 6,
8056
+ label: 'Rotterdam'
8057
+ },
8058
+ EHGG: {
8059
+ validity_duration: 30,
8060
+ activity_period: 6,
8061
+ label: 'Eelde'
8062
+ },
8063
+ EHBK: {
8064
+ validity_duration: 30,
8065
+ activity_period: 6,
8066
+ label: 'Maastricht'
8067
+ },
8068
+ EHLE: {
8069
+ validity_duration: 30,
8070
+ activity_period: 6,
8071
+ label: 'Lelystad'
8072
+ },
8073
+ TNCB: {
8074
+ validity_duration: 30,
8075
+ activity_period: 6,
8076
+ label: 'Bonaire'
8077
+ }
8078
+ },
8079
+ locationOrder: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK', 'TNCB'],
8080
+ autoTAFlocations: ['EHAM', 'EHRD', 'EHLE', 'EHGG', 'EHBK']
8081
+ };
8000
8082
  var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8001
8083
  return HttpResponse.json(getFakeUpdatedList());
8002
8084
  }), http.post(/^.*\/taf$/, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -8058,6 +8140,8 @@ var tafEndPoints = [http.get(/^.*\/taflist$/, function () {
8058
8140
  return _context3.stop();
8059
8141
  }
8060
8142
  }, _callee3);
8061
- })))];
8143
+ }))), http.get(/^.*\/taf-config$/, function () {
8144
+ return HttpResponse.json(fakeTafConfig);
8145
+ })];
8062
8146
 
8063
8147
  export { TAF_NAMESPACE, TafApiWrapper, TafForm, Wrapper as TafModule, componentsLookUp, tafEndPoints, tafScreenPreset, tafTranslations };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/taf",
3
- "version": "13.1.1",
3
+ "version": "14.0.0",
4
4
  "description": "GeoWeb TAF library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,15 +8,15 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "13.1.1",
12
- "@opengeoweb/shared": "13.1.1",
11
+ "@opengeoweb/api": "14.0.0",
12
+ "@opengeoweb/shared": "14.0.0",
13
13
  "react-hook-form": "^7.50.1",
14
- "@opengeoweb/theme": "13.1.1",
15
- "@opengeoweb/form-fields": "13.1.1",
16
- "@opengeoweb/authentication": "13.1.1",
14
+ "@opengeoweb/theme": "14.0.0",
15
+ "@opengeoweb/form-fields": "14.0.0",
16
+ "@opengeoweb/authentication": "14.0.0",
17
17
  "@reduxjs/toolkit": "^2.6.1",
18
18
  "react-redux": "^9.2.0",
19
- "@opengeoweb/snackbar": "13.1.1",
19
+ "@opengeoweb/snackbar": "14.0.0",
20
20
  "react-sortablejs": "^6.1.4",
21
21
  "sortablejs": "^1.15.1",
22
22
  "@emotion/react": "^11.11.1",
@@ -1,27 +1,27 @@
1
1
  import { TFunction } from 'i18next';
2
2
  import { AxiosError } from 'axios';
3
- import { AutoTAFlocations, Taf, TafConfigLocation, TafConfigLocations, TafFromBackend, TafFromFrontEnd, TafStatus, TimeSlot } from '../../types';
4
- export declare const getLocationSetting: (location: string, locationSettings?: TafConfigLocations) => TafConfigLocation;
3
+ import { AutoTAFlocations, Taf, TafConfig, TafConfigLocation, TafConfigLocations, TafFromBackend, TafFromFrontEnd, TafStatus, TimeSlot } from '../../types';
4
+ export declare const getLocationSetting: (location: string, locationSettings: TafConfigLocations) => TafConfigLocation;
5
5
  export declare const sortTafsOnLocation: (tafList?: TafFromBackend[], locationOrder?: string[]) => TafFromBackend[];
6
6
  export declare const sortTafsOnIssueDate: (tafList?: TafFromBackend[]) => TafFromBackend[];
7
- export declare const getBaseTime: (baseTime: string, location: string) => {
7
+ export declare const getBaseTime: (baseTime: string, location: string, tafConfig: TafConfig) => {
8
8
  currentBaseTime: Date;
9
9
  nextBaseTime: Date;
10
10
  };
11
- export declare const getTafTimeSlot: (baseTime: string, location: string, status: TafStatus) => TimeSlot;
11
+ export declare const getTafTimeSlot: (baseTime: string, location: string, status: TafStatus, tafConfig: TafConfig) => TimeSlot;
12
12
  interface TafTimeSlots {
13
13
  current: TafFromBackend[];
14
14
  upcoming: TafFromBackend[];
15
15
  expired: TafFromBackend[];
16
16
  }
17
- export declare const sortTafTimeSlots: (tafList: TafFromBackend[]) => TafTimeSlots;
17
+ export declare const sortTafTimeSlots: (tafList: TafFromBackend[], tafConfig: TafConfig) => TafTimeSlots;
18
18
  export declare const muiTabA11yProps: (index: number) => {
19
19
  id: string;
20
20
  "aria-controls": string;
21
21
  };
22
22
  export declare const getNewTafLocationIndex: (tafLocations: TafFromBackend[], previousTafLocationUUID: string) => number;
23
23
  export declare const getPreviousTaf: (tafList: TafFromBackend[], currentTaf: TafFromBackend) => Taf;
24
- export declare const getAutoTafLocations: (autoTAFlocations?: AutoTAFlocations | undefined) => AutoTAFlocations | null;
24
+ export declare const getAutoTafLocations: (autoTAFlocations: AutoTAFlocations | undefined) => AutoTAFlocations | null;
25
25
  export declare const scrollToPosition: (scrollRef: React.RefObject<HTMLElement>, activeLocation: string) => void;
26
26
  export declare const formatBaseTime: (time: Date) => string;
27
27
  export declare const getSnackbarMessage: (tafFromFrontEnd: TafFromFrontEnd, isAutoSaved: boolean, t: TFunction) => string;
@@ -30,6 +30,15 @@ export declare const TafModuleLightThemeWithErrorOnLoadingList: {
30
30
  };
31
31
  };
32
32
  };
33
+ export declare const TafModuleLightThemeWithErrorOnLoadingConfig: {
34
+ parameters: {
35
+ msw: {
36
+ handlers: {
37
+ taf: import("msw").HttpHandler[];
38
+ };
39
+ };
40
+ };
41
+ };
33
42
  export declare const TafModuleWithNewData: {
34
43
  parameters: {
35
44
  msw: {
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { TafConfig } from '../../types';
3
+ interface TafConfigWrapperContext {
4
+ tafConfig?: TafConfig;
5
+ }
6
+ export declare const TafConfigContext: React.Context<TafConfigWrapperContext>;
7
+ export declare const useTafConfigContext: () => Partial<TafConfigWrapperContext>;
8
+ interface TafConfigWrapperProps {
9
+ children?: React.ReactNode;
10
+ }
11
+ declare const TafConfigWrapper: React.FC<TafConfigWrapperProps>;
12
+ export default TafConfigWrapper;
@@ -1,6 +1,7 @@
1
1
  import { Credentials } from '@opengeoweb/authentication';
2
- import { TAC, Taf, TafFromBackend, TafFromFrontEnd } from '../../types';
2
+ import { TAC, Taf, TafConfig, TafFromBackend, TafFromFrontEnd } from '../../types';
3
3
  export declare const getTafList: (auth: Credentials) => Promise<TafFromBackend[]>;
4
4
  export declare const postTaf: (auth: Credentials, data: TafFromFrontEnd) => Promise<Response>;
5
5
  export declare const patchTaf: (auth: Credentials, data: TafFromFrontEnd, force?: boolean) => Promise<Response>;
6
6
  export declare const getTAC: (auth: Credentials, data: Taf) => Promise<TAC>;
7
+ export declare const getTafConfig: (auth: Credentials) => Promise<TafConfig>;
@@ -1,5 +1,6 @@
1
- import { AdverseWeatherTAC, TafFromBackend } from '../../types';
1
+ import { AdverseWeatherTAC, TafFromBackend, TafConfig } from '../../types';
2
2
  export declare const getFakeUpdatedList: () => TafFromBackend[];
3
3
  export declare const fakeTafTac = "TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040 BECMG 0814/0816 0700 BKN001=";
4
4
  export declare const fakeTafTacJson: AdverseWeatherTAC;
5
+ export declare const fakeTafConfig: TafConfig;
5
6
  export declare const tafEndPoints: import("msw").HttpHandler[];
@@ -1,7 +1,8 @@
1
1
  import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
2
- import { TAC, Taf, TafFromBackend, TafFromFrontEnd } from '../../types';
2
+ import { TAC, Taf, TafFromBackend, TafFromFrontEnd, TafConfig } from '../../types';
3
3
  import { TafError } from '../../components/TafLayout/utils';
4
4
  export declare const useTafList: (disabled?: boolean) => UseQueryResult<TafFromBackend[]>;
5
+ export declare const useTafConfig: (disabled?: boolean) => UseQueryResult<TafConfig>;
5
6
  type PostReturnType<T> = UseMutationResult<Response | null, Error, T>;
6
7
  interface PostTafProps {
7
8
  tafData: TafFromFrontEnd;