@opengeoweb/taf 14.5.2 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -103,7 +103,8 @@ var en = {
103
103
  autotaf: "Autotaf",
104
104
  "autotaf-no-data": "No autoTAFs available",
105
105
  "autotaf-no-location": "No data available for this location",
106
- "autotaf-no-config": "Missing config key: autoTAFlocations"
106
+ "autotaf-no-config": "Missing config key: autoTAFlocations",
107
+ "no-locations-message": "No locations available for this timeslot"
107
108
  };
108
109
  var fi = {
109
110
  "issues-button-title": "Näkymän yksityiskohdat",
@@ -355,7 +356,8 @@ var nl = {
355
356
  autotaf: "Autotaf",
356
357
  "autotaf-no-data": "Geen autoTAFs beschikbaar",
357
358
  "autotaf-no-location": "Geen data beschikbaar voor deze locatie",
358
- "autotaf-no-config": "Ontbrekende configuratie: autoTAFlocations"
359
+ "autotaf-no-config": "Ontbrekende configuratie: autoTAFlocations",
360
+ "no-locations-message": "Geen locaties beschikbaar voor dit tijdslot"
359
361
  };
360
362
  var tafTranslations = {
361
363
  en: en,
@@ -3076,6 +3078,32 @@ var getBaseTime = function getBaseTime(baseTime, location, tafConfig) {
3076
3078
  nextBaseTime: nextBaseTime
3077
3079
  };
3078
3080
  };
3081
+ /**
3082
+ * If we don't have a taf to get the baseTime from, we calculate it based on the current time and the activity_period from the config.
3083
+ * @param tafConfig
3084
+ * @returns
3085
+ */
3086
+ var calculateBaseTime = function calculateBaseTime(tafConfig) {
3087
+ var currentTime = dateUtils.utc();
3088
+ var currentHour = dateUtils.getHours(currentTime);
3089
+ // take the first location from config (via locationOrder)
3090
+ var firstLocation = tafConfig.locationOrder[0];
3091
+ var activityPeriod = getLocationSetting(firstLocation, tafConfig.locations).activity_period;
3092
+ var baseHour = Math.floor(currentHour / activityPeriod) * activityPeriod;
3093
+ var currentBaseTime = dateUtils.set(currentTime, {
3094
+ hours: baseHour,
3095
+ minutes: 0,
3096
+ seconds: 0,
3097
+ milliseconds: 0
3098
+ });
3099
+ var nextBaseTime = dateUtils.add(currentBaseTime, {
3100
+ hours: activityPeriod
3101
+ });
3102
+ return {
3103
+ currentBaseTime: currentBaseTime,
3104
+ nextBaseTime: nextBaseTime
3105
+ };
3106
+ };
3079
3107
  var getTafTimeSlot = function getTafTimeSlot(baseTime, location, status, tafConfig) {
3080
3108
  var now = dateUtils.utc();
3081
3109
  var _getBaseTime = getBaseTime(baseTime, location, tafConfig),
@@ -6533,28 +6561,19 @@ var TafPanel = function TafPanel(_ref) {
6533
6561
 
6534
6562
  var TopTabs = function TopTabs(_ref) {
6535
6563
  var timeSlot = _ref.timeSlot,
6564
+ tafFromBackend = _ref.tafFromBackend,
6536
6565
  _ref$onChangeTimeSlot = _ref.onChangeTimeSlot,
6537
- onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot,
6538
- _ref$tafFromBackend = _ref.tafFromBackend,
6539
- tafFromBackend = _ref$tafFromBackend === void 0 ? {
6540
- taf: {
6541
- baseTime: '2022-01-06T12:00:00Z',
6542
- location: 'EHAM'
6543
- }
6544
- } : _ref$tafFromBackend;
6566
+ onChangeTimeSlot = _ref$onChangeTimeSlot === void 0 ? function () {} : _ref$onChangeTimeSlot;
6545
6567
  var _useTafTranslation = useTafTranslation(),
6546
6568
  t = _useTafTranslation.t;
6547
6569
  var _useFormContext = useFormContext(),
6548
6570
  isDirty = _useFormContext.formState.isDirty;
6549
6571
  var _useTafConfigContext = useTafConfigContext(),
6550
6572
  tafConfig = _useTafConfigContext.tafConfig;
6551
- if (!tafFromBackend) {
6552
- return null;
6553
- }
6554
6573
  var activeTab = timeSlot === 'UPCOMING' ? 0 : 1;
6555
- var _getBaseTime = getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location, tafConfig),
6556
- currentBaseTime = _getBaseTime.currentBaseTime,
6557
- nextBaseTime = _getBaseTime.nextBaseTime;
6574
+ var _ref2 = tafFromBackend ? getBaseTime(tafFromBackend.taf.baseTime, tafFromBackend.taf.location, tafConfig) : calculateBaseTime(tafConfig),
6575
+ currentBaseTime = _ref2.currentBaseTime,
6576
+ nextBaseTime = _ref2.nextBaseTime;
6558
6577
  var tabs = [{
6559
6578
  title: t('top-tabs-upcoming') + " " + formatBaseTime(nextBaseTime),
6560
6579
  timeSlot: 'UPCOMING'
@@ -6650,8 +6669,7 @@ var TafLayout = function TafLayout(_ref) {
6650
6669
  current = _React$useState$.current,
6651
6670
  expired = _React$useState$.expired,
6652
6671
  updateSortedTafs = _React$useState[1];
6653
- var _current$slice = current.slice(-1),
6654
- lastCurrentTaf = _current$slice[0];
6672
+ var lastCurrentTaf = current.length > 0 ? current[current.length - 1] : undefined;
6655
6673
  var _React$useState2 = React.useState('UPCOMING'),
6656
6674
  timeSlot = _React$useState2[0],
6657
6675
  setTimeSlot = _React$useState2[1];
@@ -6889,94 +6907,93 @@ var TafLayout = function TafLayout(_ref) {
6889
6907
  onPressRefresh: onUpdateTaf
6890
6908
  }) : null
6891
6909
  })]
6892
- }), jsx(Grid, {
6910
+ }), jsxs(Grid, {
6893
6911
  container: true,
6912
+ spacing: 2,
6894
6913
  sx: {
6895
- flexGrow: 1,
6896
- overflow: 'hidden'
6914
+ height: '100%',
6915
+ paddingLeft: 1,
6916
+ paddingRight: 1,
6917
+ paddingTop: 2,
6918
+ overflow: 'auto'
6897
6919
  },
6898
- children: jsxs(Grid, {
6899
- container: true,
6900
- spacing: 2,
6901
- sx: {
6902
- height: '100%',
6903
- paddingLeft: 1,
6904
- paddingRight: 1,
6905
- paddingTop: 2,
6906
- overflow: 'auto'
6920
+ children: [jsx(Grid, {
6921
+ size: {
6922
+ xs: 3,
6923
+ sm: 1
6907
6924
  },
6908
- children: [jsx(Grid, {
6909
- size: {
6910
- xs: 3,
6911
- sm: 1
6912
- },
6913
- children: jsx(LocationTabs, {
6914
- activeIndex: activeTafIndex,
6915
- onChangeTab: onChangeLocationTab,
6916
- tafList: locations,
6917
- timeSlot: timeSlot
6918
- })
6919
- }), jsx(Grid, {
6920
- size: "grow",
6921
- children: jsxs(Card, {
6922
- sx: {
6923
- marginBottom: '12px',
6924
- position: 'relative',
6925
- minHeight: locations.length * 62 + 32
6926
- },
6927
- variant: "outlined",
6928
- children: [jsx(TacOverviewMobile, Object.assign({
6929
- activeTaf: activeTaf,
6930
- currentTafs: current,
6931
- expiredTafs: expired,
6932
- upcomingTafs: upcoming
6933
- }, isAutoTafEnabled && {
6934
- autoTafs: autoTafList
6935
- })), locations.map(function (tafFromBackend, index) {
6936
- return jsx(TafPanel, {
6937
- activeTafIndex: activeTafIndex,
6938
- error: error,
6939
- index: index,
6940
- isFormDisabled: isFormDisabled,
6941
- isIssuesPaneOpen: isIssuesPaneOpen,
6942
- isLoading: isPostTafPending,
6943
- patchTaf: patchTaf,
6944
- postTaf: postTaf,
6945
- previousTaf: getPreviousTaf(tafList, tafFromBackend),
6946
- setIsFormDisabled: setIsFormDisabled,
6947
- setIsIssuesPaneOpen: onToggleIssuesPane,
6948
- tafAction: tafAction,
6949
- tafFromBackend: tafFromBackend
6950
- }, tafFromBackend.taf.uuid);
6951
- })]
6952
- })
6953
- }), jsxs(Grid, {
6954
- size: {
6955
- xs: 0,
6956
- sm: 3
6925
+ children: jsx(LocationTabs, {
6926
+ activeIndex: activeTafIndex,
6927
+ onChangeTab: onChangeLocationTab,
6928
+ tafList: locations,
6929
+ timeSlot: timeSlot
6930
+ })
6931
+ }), jsx(Grid, {
6932
+ size: "grow",
6933
+ children: jsxs(Card, {
6934
+ sx: {
6935
+ marginBottom: '12px',
6936
+ position: 'relative',
6937
+ minHeight: locations.length * 62 + 32
6957
6938
  },
6958
- sx: Object.assign({
6959
- height: {
6960
- xs: 0,
6961
- sm: '100%'
6962
- }
6963
- }, isAutoTafEnabled && {
6964
- display: 'flex',
6965
- flexDirection: 'column'
6966
- }),
6967
- children: [jsx(TacOverview, {
6939
+ variant: "outlined",
6940
+ children: [jsx(TacOverviewMobile, Object.assign({
6968
6941
  activeTaf: activeTaf,
6969
6942
  currentTafs: current,
6970
6943
  expiredTafs: expired,
6971
- isFormDisabled: isFormDisabled,
6972
6944
  upcomingTafs: upcoming
6973
- }), isAutoTafEnabled ? jsx(AutoTaf, {
6974
- activeTaf: activeTaf,
6975
- isFormDisabled: isFormDisabled,
6976
- tafList: autoTafList
6977
- }) : null]
6978
- })]
6979
- })
6945
+ }, isAutoTafEnabled && {
6946
+ autoTafs: autoTafList
6947
+ })), locations.length > 0 ? locations.map(function (tafFromBackend, index) {
6948
+ return jsx(TafPanel, {
6949
+ activeTafIndex: activeTafIndex,
6950
+ error: error,
6951
+ index: index,
6952
+ isFormDisabled: isFormDisabled,
6953
+ isIssuesPaneOpen: isIssuesPaneOpen,
6954
+ isLoading: isPostTafPending,
6955
+ patchTaf: patchTaf,
6956
+ postTaf: postTaf,
6957
+ previousTaf: getPreviousTaf(tafList, tafFromBackend),
6958
+ setIsFormDisabled: setIsFormDisabled,
6959
+ setIsIssuesPaneOpen: onToggleIssuesPane,
6960
+ tafAction: tafAction,
6961
+ tafFromBackend: tafFromBackend
6962
+ }, tafFromBackend.taf.uuid);
6963
+ }) : jsx(Typography, {
6964
+ sx: {
6965
+ margin: 1
6966
+ },
6967
+ variant: "body1",
6968
+ children: t('no-locations-message')
6969
+ })]
6970
+ })
6971
+ }), jsxs(Grid, {
6972
+ size: {
6973
+ xs: 0,
6974
+ sm: 3
6975
+ },
6976
+ sx: Object.assign({
6977
+ height: {
6978
+ xs: 0,
6979
+ sm: '100%'
6980
+ }
6981
+ }, isAutoTafEnabled && {
6982
+ display: 'flex',
6983
+ flexDirection: 'column'
6984
+ }),
6985
+ children: [jsx(TacOverview, {
6986
+ activeTaf: activeTaf,
6987
+ currentTafs: current,
6988
+ expiredTafs: expired,
6989
+ isFormDisabled: isFormDisabled,
6990
+ upcomingTafs: upcoming
6991
+ }), isAutoTafEnabled ? jsx(AutoTaf, {
6992
+ activeTaf: activeTaf,
6993
+ isFormDisabled: isFormDisabled,
6994
+ tafList: autoTafList
6995
+ }) : null]
6996
+ })]
6980
6997
  })]
6981
6998
  })
6982
6999
  }), jsx(IssuesPaneWrapper, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/taf",
3
- "version": "14.5.2",
3
+ "version": "15.1.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": "14.5.2",
12
- "@opengeoweb/shared": "14.5.2",
11
+ "@opengeoweb/api": "15.1.0",
12
+ "@opengeoweb/shared": "15.1.0",
13
13
  "react-hook-form": "^7.50.1",
14
- "@opengeoweb/theme": "14.5.2",
15
- "@opengeoweb/form-fields": "14.5.2",
16
- "@opengeoweb/authentication": "14.5.2",
14
+ "@opengeoweb/theme": "15.1.0",
15
+ "@opengeoweb/form-fields": "15.1.0",
16
+ "@opengeoweb/authentication": "15.1.0",
17
17
  "@reduxjs/toolkit": "^2.6.1",
18
18
  "react-redux": "^9.2.0",
19
- "@opengeoweb/snackbar": "14.5.2",
19
+ "@opengeoweb/snackbar": "15.1.0",
20
20
  "react-sortablejs": "^6.1.4",
21
21
  "sortablejs": "^1.15.1",
22
22
  "@emotion/react": "^11.11.1",
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { TafFromBackend, TimeSlot } from '../../../types';
3
3
  interface TopTabsProps {
4
4
  timeSlot: TimeSlot;
5
- tafFromBackend: TafFromBackend;
5
+ tafFromBackend?: TafFromBackend;
6
6
  onChangeTimeSlot?: (timeSlot: TimeSlot, isFormDirty: boolean) => void;
7
7
  }
8
8
  declare const TopTabs: React.FC<TopTabsProps>;
@@ -8,6 +8,15 @@ export declare const getBaseTime: (baseTime: string, location: string, tafConfig
8
8
  currentBaseTime: Date;
9
9
  nextBaseTime: Date;
10
10
  };
11
+ /**
12
+ * If we don't have a taf to get the baseTime from, we calculate it based on the current time and the activity_period from the config.
13
+ * @param tafConfig
14
+ * @returns
15
+ */
16
+ export declare const calculateBaseTime: (tafConfig: TafConfig) => {
17
+ currentBaseTime: Date;
18
+ nextBaseTime: Date;
19
+ };
11
20
  export declare const getTafTimeSlot: (baseTime: string, location: string, status: TafStatus, tafConfig: TafConfig) => TimeSlot;
12
21
  interface TafTimeSlots {
13
22
  current: TafFromBackend[];