@opengeoweb/taf 4.0.0 → 4.2.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 +1 -1
- package/index.esm.js +299 -89
- package/index.umd.js +284 -81
- package/lib/TafDemo.stories.d.ts +18 -2
- package/lib/components/ComponentsLookUp/ComponentsLookUp.d.ts +3 -5
- package/lib/components/Providers/Providers.d.ts +4 -2
- package/lib/components/TafForm/TafForm.d.ts +1 -0
- package/lib/components/TafForm/utils.d.ts +5 -5
- package/lib/components/TafLayout/TacOverview/AdverseWeatherTacMessage.d.ts +8 -0
- package/lib/components/TafLayout/TacOverview/AdverseWeatherTacMessage.spec.d.ts +1 -0
- package/lib/components/TafLayout/TacOverview/AdverseWeatherTacMessage.stories.d.ts +25 -0
- package/lib/components/TafLayout/TacOverview/TacContainer.d.ts +1 -0
- package/lib/components/TafLayout/TacOverview/TacOverview.stories.d.ts +8 -0
- package/lib/components/TafLayout/TafLayout.d.ts +3 -1
- package/lib/components/TafLayout/TopTabs/TopTabs.d.ts +2 -0
- package/lib/components/TafLayout/utils.d.ts +3 -1
- package/lib/components/TafModule/TafModule.stories.d.ts +19 -2
- package/lib/components/TafModule/TafModuleProvider.d.ts +3 -3
- package/lib/types.d.ts +8 -0
- package/lib/utils/__mocks__/api.d.ts +6 -4
- package/lib/utils/api.d.ts +5 -5
- package/lib/utils/fakeApi.d.ts +0 -3
- package/lib/utils/mockdata/fakeTafList.d.ts +1 -0
- package/package.json +24 -10
package/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-sortablejs'), require('lodash'), require('@opengeoweb/authentication'), require('@opengeoweb/form-fields'), require('@opengeoweb/shared'), require('moment'), require('@opengeoweb/theme'), require('react-dom'), require('@opengeoweb/api'), require('@mui/material/LinearProgress'), require('@mui/material/Box')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-sortablejs', 'lodash', '@opengeoweb/authentication', '@opengeoweb/form-fields', '@opengeoweb/shared', 'moment', '@opengeoweb/theme', 'react-dom', '@opengeoweb/api', '@mui/material/LinearProgress', '@mui/material/Box'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactSortablejs, global.lodash, global.authentication, global.formFields, global.shared, global.moment, global.theme, global.ReactDOM, global.api, global.LinearProgress, global.Box));
|
|
5
|
-
})(this, (function (exports, React, material, reactHookForm, reactSortablejs, lodash, authentication, formFields, shared, moment, theme, ReactDOM, api, LinearProgress, Box) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('react-redux'), require('react-sortablejs'), require('lodash'), require('@opengeoweb/authentication'), require('@opengeoweb/form-fields'), require('@opengeoweb/shared'), require('@opengeoweb/core'), require('moment'), require('@opengeoweb/theme'), require('react-dom'), require('@opengeoweb/api'), require('@mui/material/LinearProgress'), require('@mui/material/Box')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'react-redux', 'react-sortablejs', 'lodash', '@opengeoweb/authentication', '@opengeoweb/form-fields', '@opengeoweb/shared', '@opengeoweb/core', 'moment', '@opengeoweb/theme', 'react-dom', '@opengeoweb/api', '@mui/material/LinearProgress', '@mui/material/Box'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Taf = {}, global.React, global.material, global.reactHookForm, global.reactRedux, global.reactSortablejs, global.lodash, global.authentication, global.formFields, global.shared, global.core, global.moment, global.theme, global.ReactDOM, global.api, global.LinearProgress, global.Box));
|
|
5
|
+
})(this, (function (exports, React, material, reactHookForm, reactRedux, reactSortablejs, lodash, authentication, formFields, shared, core, moment, theme, ReactDOM, api, LinearProgress, Box) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -2316,7 +2316,11 @@
|
|
|
2316
2316
|
var tacHasError = function tacHasError(tac) {
|
|
2317
2317
|
return tac === TAC_MISSING_DATA || tac === TAC_NOT_AVAILABLE || tac === TAC_RETRIEVING_DATA || tac === TAC_FAILED;
|
|
2318
2318
|
};
|
|
2319
|
-
var useTACGenerator = function useTACGenerator(taf, requestTAC) {
|
|
2319
|
+
var useTACGenerator = function useTACGenerator(taf, requestTAC, getJSON) {
|
|
2320
|
+
if (getJSON === void 0) {
|
|
2321
|
+
getJSON = false;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2320
2324
|
var _a = __read(React__default["default"].useState(!taf || taf.status === 'NEW' ? TAC_NOT_AVAILABLE : TAC_RETRIEVING_DATA), 2),
|
|
2321
2325
|
TAC = _a[0],
|
|
2322
2326
|
setTAC = _a[1];
|
|
@@ -2340,7 +2344,7 @@
|
|
|
2340
2344
|
|
|
2341
2345
|
controller.current = new AbortController();
|
|
2342
2346
|
setTAC(TAC_RETRIEVING_DATA);
|
|
2343
|
-
requestTAC(tafToPost, controller.current.signal).then(function (result) {
|
|
2347
|
+
requestTAC(tafToPost, getJSON, controller.current.signal).then(function (result) {
|
|
2344
2348
|
if (isMounted.current) {
|
|
2345
2349
|
setTAC(result.data);
|
|
2346
2350
|
}
|
|
@@ -2352,7 +2356,7 @@
|
|
|
2352
2356
|
} else {
|
|
2353
2357
|
setTAC(TAC_MISSING_DATA);
|
|
2354
2358
|
}
|
|
2355
|
-
}, [isMounted, requestTAC]);
|
|
2359
|
+
}, [isMounted, requestTAC, getJSON]);
|
|
2356
2360
|
React__default["default"].useEffect(function () {
|
|
2357
2361
|
if (taf && taf.status !== 'NEW') {
|
|
2358
2362
|
retrieveTAC(taf);
|
|
@@ -3960,6 +3964,9 @@
|
|
|
3960
3964
|
|
|
3961
3965
|
var noop = function noop() {};
|
|
3962
3966
|
|
|
3967
|
+
var getSnackbarMessage$2 = function getSnackbarMessage(isChecked, location) {
|
|
3968
|
+
return "You are now " + (isChecked ? '' : 'no longer ') + "the editor for TAF " + location;
|
|
3969
|
+
};
|
|
3963
3970
|
var TafForm = /*#__PURE__*/React__default["default"].memo(function (_a) {
|
|
3964
3971
|
var tafFromBackend = _a.tafFromBackend,
|
|
3965
3972
|
_b = _a.onFormAction,
|
|
@@ -3985,6 +3992,7 @@
|
|
|
3985
3992
|
var originalTaf = tafFromBackend.taf,
|
|
3986
3993
|
editor = tafFromBackend.editor;
|
|
3987
3994
|
var auth = authentication.useAuthenticationContext().auth;
|
|
3995
|
+
var dispatch = reactRedux.useDispatch();
|
|
3988
3996
|
var isEditor = editor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
|
|
3989
3997
|
var isDefaultDisabled = getIsFormDefaultDisabled(originalTaf.status);
|
|
3990
3998
|
var confirmDialog = shared.useConfirmationDialog();
|
|
@@ -4092,6 +4100,12 @@
|
|
|
4092
4100
|
setTafAction(action);
|
|
4093
4101
|
};
|
|
4094
4102
|
|
|
4103
|
+
var showSnackbar = React__default["default"].useCallback(function (message) {
|
|
4104
|
+
dispatch(core.snackbarActions.openSnackbar({
|
|
4105
|
+
message: message
|
|
4106
|
+
}));
|
|
4107
|
+
}, [dispatch]);
|
|
4108
|
+
|
|
4095
4109
|
var setIsEditor = function setIsEditor(checked) {
|
|
4096
4110
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
4097
4111
|
var editor, didSucceed;
|
|
@@ -4132,6 +4146,11 @@
|
|
|
4132
4146
|
|
|
4133
4147
|
case 3:
|
|
4134
4148
|
didSucceed = _a.sent();
|
|
4149
|
+
|
|
4150
|
+
if (didSucceed) {
|
|
4151
|
+
showSnackbar(getSnackbarMessage$2(checked, originalTaf.location));
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4135
4154
|
return [2
|
|
4136
4155
|
/*return*/
|
|
4137
4156
|
, didSucceed];
|
|
@@ -4435,8 +4454,8 @@
|
|
|
4435
4454
|
alignItems: 'center',
|
|
4436
4455
|
position: 'absolute',
|
|
4437
4456
|
top: {
|
|
4438
|
-
xs: '
|
|
4439
|
-
sm: '
|
|
4457
|
+
xs: '34px',
|
|
4458
|
+
sm: '-3px'
|
|
4440
4459
|
},
|
|
4441
4460
|
right: {
|
|
4442
4461
|
xs: 'calc(50% - 70px)',
|
|
@@ -4461,11 +4480,15 @@
|
|
|
4461
4480
|
sx: {
|
|
4462
4481
|
fontSize: '20px',
|
|
4463
4482
|
fontWeight: 500,
|
|
4464
|
-
height: '24px'
|
|
4483
|
+
height: '24px',
|
|
4484
|
+
display: 'flex',
|
|
4485
|
+
alignItems: 'center'
|
|
4465
4486
|
}
|
|
4466
4487
|
}, "TAC"), /*#__PURE__*/React__default["default"].createElement(material.Typography, {
|
|
4467
4488
|
sx: {
|
|
4468
|
-
fontSize: '
|
|
4489
|
+
fontSize: '12px',
|
|
4490
|
+
lineHeight: 1.67,
|
|
4491
|
+
letterSpacing: '0.21px',
|
|
4469
4492
|
margin: '8px 0px'
|
|
4470
4493
|
},
|
|
4471
4494
|
"data-testid": "form-tac-message"
|
|
@@ -4591,7 +4614,7 @@
|
|
|
4591
4614
|
sx: __assign({
|
|
4592
4615
|
textAlign: 'center',
|
|
4593
4616
|
fontWeight: 500,
|
|
4594
|
-
paddingTop: '
|
|
4617
|
+
paddingTop: '4px',
|
|
4595
4618
|
textTransform: 'capitalize'
|
|
4596
4619
|
}, sx)
|
|
4597
4620
|
}, title);
|
|
@@ -4657,17 +4680,32 @@
|
|
|
4657
4680
|
return locationSettings[location];
|
|
4658
4681
|
};
|
|
4659
4682
|
var sortTafsOnLocation = function sortTafsOnLocation(tafList, locationOrder) {
|
|
4683
|
+
if (tafList === void 0) {
|
|
4684
|
+
tafList = [];
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4660
4687
|
if (locationOrder === void 0) {
|
|
4661
4688
|
locationOrder = tafSettings.locationOrder;
|
|
4662
4689
|
}
|
|
4663
4690
|
|
|
4664
|
-
if (!tafList) return [];
|
|
4665
4691
|
return __spreadArray([], __read(tafList)).sort(function (_a, _b) {
|
|
4666
4692
|
var tafA = _a.taf;
|
|
4667
4693
|
var tafB = _b.taf;
|
|
4668
4694
|
return locationOrder.indexOf(tafA.location) < locationOrder.indexOf(tafB.location) ? -1 : 1;
|
|
4669
4695
|
});
|
|
4670
4696
|
};
|
|
4697
|
+
var sortTafsOnIssueDate = function sortTafsOnIssueDate(tafList) {
|
|
4698
|
+
if (tafList === void 0) {
|
|
4699
|
+
tafList = [];
|
|
4700
|
+
}
|
|
4701
|
+
|
|
4702
|
+
return __spreadArray([], __read(tafList)).sort(function (_a, _b) {
|
|
4703
|
+
var tafA = _a.taf;
|
|
4704
|
+
var tafB = _b.taf;
|
|
4705
|
+
if (tafA.issueDate < tafB.issueDate || tafA.issueDate && !tafB.issueDate) return -1;
|
|
4706
|
+
return 1;
|
|
4707
|
+
});
|
|
4708
|
+
};
|
|
4671
4709
|
var getBaseTime = function getBaseTime(baseTime, location) {
|
|
4672
4710
|
var currentBaseTime = moment__default["default"].utc(baseTime);
|
|
4673
4711
|
var activityPeriod = getLocationSetting(location).activity_period;
|
|
@@ -4695,7 +4733,8 @@
|
|
|
4695
4733
|
return 'UPCOMING';
|
|
4696
4734
|
};
|
|
4697
4735
|
var sortTafTimeSlots = function sortTafTimeSlots(tafList) {
|
|
4698
|
-
var
|
|
4736
|
+
var sortedListOnIssueDate = sortTafsOnIssueDate(tafList);
|
|
4737
|
+
var sortedListOnLocation = sortTafsOnLocation(sortedListOnIssueDate);
|
|
4699
4738
|
return sortedListOnLocation.reduce(function (sortedTafList, tafFromBackend) {
|
|
4700
4739
|
var taf = tafFromBackend.taf;
|
|
4701
4740
|
var timeSlot = getTafTimeSlot(taf.baseTime, taf.location, taf.status);
|
|
@@ -4735,6 +4774,29 @@
|
|
|
4735
4774
|
changeGroups: changeGroups
|
|
4736
4775
|
});
|
|
4737
4776
|
};
|
|
4777
|
+
var getNewTafLocationIndex = function getNewTafLocationIndex(tafLocations, previousTafLocationUUID) {
|
|
4778
|
+
var newActiveIndexForDraft = tafLocations.findIndex(function (location) {
|
|
4779
|
+
var _a;
|
|
4780
|
+
|
|
4781
|
+
return ((_a = location === null || location === void 0 ? void 0 : location.taf) === null || _a === void 0 ? void 0 : _a.previousId) === previousTafLocationUUID;
|
|
4782
|
+
});
|
|
4783
|
+
|
|
4784
|
+
if (newActiveIndexForDraft !== -1) {
|
|
4785
|
+
return newActiveIndexForDraft;
|
|
4786
|
+
}
|
|
4787
|
+
|
|
4788
|
+
var newActiveIndexForPublished = tafLocations.findIndex(function (location) {
|
|
4789
|
+
var _a;
|
|
4790
|
+
|
|
4791
|
+
return ((_a = location === null || location === void 0 ? void 0 : location.taf) === null || _a === void 0 ? void 0 : _a.uuid) === previousTafLocationUUID;
|
|
4792
|
+
});
|
|
4793
|
+
|
|
4794
|
+
if (newActiveIndexForPublished !== -1) {
|
|
4795
|
+
return newActiveIndexForPublished;
|
|
4796
|
+
}
|
|
4797
|
+
|
|
4798
|
+
return 0;
|
|
4799
|
+
};
|
|
4738
4800
|
|
|
4739
4801
|
/* *
|
|
4740
4802
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -4869,6 +4931,61 @@
|
|
|
4869
4931
|
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
4870
4932
|
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
4871
4933
|
* */
|
|
4934
|
+
var AdverseWeatherTACMessage = function AdverseWeatherTACMessage(_a) {
|
|
4935
|
+
var TAC = _a.TAC,
|
|
4936
|
+
isActive = _a.isActive;
|
|
4937
|
+
return /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
4938
|
+
"data-testid": "adverse-weather-tac",
|
|
4939
|
+
sx: {
|
|
4940
|
+
fontSize: '12px',
|
|
4941
|
+
lineHeight: '16px',
|
|
4942
|
+
letterSpacing: '0.4px',
|
|
4943
|
+
color: 'geowebColors.captions.captionStatus.rgba'
|
|
4944
|
+
}
|
|
4945
|
+
}, TAC.tac.map(function (line, index) {
|
|
4946
|
+
return /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
4947
|
+
key: line.toString() + index.toString(),
|
|
4948
|
+
component: "span",
|
|
4949
|
+
sx: {
|
|
4950
|
+
display: 'inline-block'
|
|
4951
|
+
}
|
|
4952
|
+
}, line.map(function (word, index) {
|
|
4953
|
+
return /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
4954
|
+
key: word.text + index.toString(),
|
|
4955
|
+
component: "span",
|
|
4956
|
+
sx: __assign(__assign({
|
|
4957
|
+
display: 'inline',
|
|
4958
|
+
boxDecorationBreak: 'clone',
|
|
4959
|
+
WebkitBoxDecorationBreak: 'clone'
|
|
4960
|
+
}, isActive && {
|
|
4961
|
+
backgroundColor: 'geowebColors.functional.warningHighlight.rgba'
|
|
4962
|
+
}), word.type === 'adverse' && {
|
|
4963
|
+
color: 'geowebColors.captions.captionError.rgba'
|
|
4964
|
+
})
|
|
4965
|
+
}, word.text === '=' ? "" + word.text : " " + word.text);
|
|
4966
|
+
}));
|
|
4967
|
+
}));
|
|
4968
|
+
};
|
|
4969
|
+
|
|
4970
|
+
/* *
|
|
4971
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4972
|
+
* you may not use this file except in compliance with the License.
|
|
4973
|
+
* You may obtain a copy of the License at
|
|
4974
|
+
*
|
|
4975
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4976
|
+
*
|
|
4977
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4978
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4979
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4980
|
+
* See the License for the specific language governing permissions and
|
|
4981
|
+
* limitations under the License.
|
|
4982
|
+
*
|
|
4983
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
4984
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
4985
|
+
* */
|
|
4986
|
+
var getSnackbarMessage$1 = function getSnackbarMessage(location, locationLabel) {
|
|
4987
|
+
return "TAF " + location + " " + locationLabel + " was imported successfully";
|
|
4988
|
+
};
|
|
4872
4989
|
|
|
4873
4990
|
var TacContainer = function TacContainer(_a) {
|
|
4874
4991
|
var taf = _a.taf,
|
|
@@ -4877,8 +4994,9 @@
|
|
|
4877
4994
|
_c = _a.isFormDisabled,
|
|
4878
4995
|
isFormDisabled = _c === void 0 ? false : _c;
|
|
4879
4996
|
var api$1 = api.useApiContext().api;
|
|
4997
|
+
var dispatch = reactRedux.useDispatch();
|
|
4880
4998
|
|
|
4881
|
-
var _d = __read(useTACGenerator(taf, api$1.getTAC), 2),
|
|
4999
|
+
var _d = __read(useTACGenerator(taf, api$1.getTAC, true), 2),
|
|
4882
5000
|
TAC = _d[0],
|
|
4883
5001
|
retrieveTAC = _d[1];
|
|
4884
5002
|
|
|
@@ -4894,6 +5012,11 @@
|
|
|
4894
5012
|
setValue = _e.setValue;
|
|
4895
5013
|
|
|
4896
5014
|
var updateTAC = useTafModuleContext().updateTAC;
|
|
5015
|
+
var showSnackbar = React__default["default"].useCallback(function (message) {
|
|
5016
|
+
dispatch(core.snackbarActions.openSnackbar({
|
|
5017
|
+
message: message
|
|
5018
|
+
}));
|
|
5019
|
+
}, [dispatch]);
|
|
4897
5020
|
|
|
4898
5021
|
var handleExport = function handleExport() {
|
|
4899
5022
|
var currentTaf = getValues();
|
|
@@ -4908,6 +5031,7 @@
|
|
|
4908
5031
|
trigger(); // trigger all fields validation
|
|
4909
5032
|
}, 0);
|
|
4910
5033
|
updateTAC(convertTafValuesToObject(newTaf));
|
|
5034
|
+
showSnackbar(getSnackbarMessage$1(location, locationLabel));
|
|
4911
5035
|
};
|
|
4912
5036
|
|
|
4913
5037
|
React__default["default"].useEffect(function () {
|
|
@@ -4977,23 +5101,18 @@
|
|
|
4977
5101
|
letterSpacing: '0.4px',
|
|
4978
5102
|
color: 'geowebColors.captions.captionStatus.rgba'
|
|
4979
5103
|
}
|
|
4980
|
-
}, TAC
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
WebkitBoxDecorationBreak: 'clone'
|
|
4993
|
-
}, isActive && {
|
|
4994
|
-
backgroundColor: 'geowebColors.functional.warningHighlight.rgba'
|
|
4995
|
-
})
|
|
4996
|
-
}, line));
|
|
5104
|
+
}, typeof TAC === 'string' ? /*#__PURE__*/React__default["default"].createElement(material.Box, {
|
|
5105
|
+
component: "span",
|
|
5106
|
+
sx: __assign({
|
|
5107
|
+
display: 'inline',
|
|
5108
|
+
boxDecorationBreak: 'clone',
|
|
5109
|
+
WebkitBoxDecorationBreak: 'clone'
|
|
5110
|
+
}, isActive && {
|
|
5111
|
+
backgroundColor: 'geowebColors.functional.warningHighlight.rgba'
|
|
5112
|
+
})
|
|
5113
|
+
}, TAC) : /*#__PURE__*/React__default["default"].createElement(AdverseWeatherTACMessage, {
|
|
5114
|
+
TAC: TAC,
|
|
5115
|
+
isActive: isActive
|
|
4997
5116
|
})));
|
|
4998
5117
|
};
|
|
4999
5118
|
|
|
@@ -5140,8 +5259,8 @@
|
|
|
5140
5259
|
sm: 'none'
|
|
5141
5260
|
},
|
|
5142
5261
|
position: 'absolute',
|
|
5143
|
-
right: '
|
|
5144
|
-
top: '
|
|
5262
|
+
right: '4px',
|
|
5263
|
+
top: '82px'
|
|
5145
5264
|
}
|
|
5146
5265
|
}, /*#__PURE__*/React__namespace.createElement(theme.ListItem, null)), /*#__PURE__*/React__namespace.createElement(material.Dialog, {
|
|
5147
5266
|
open: isOpen,
|
|
@@ -5592,7 +5711,10 @@
|
|
|
5592
5711
|
shouldClose: true
|
|
5593
5712
|
}), /*#__PURE__*/React__default["default"].createElement(material.Box, {
|
|
5594
5713
|
sx: {
|
|
5595
|
-
marginTop:
|
|
5714
|
+
marginTop: {
|
|
5715
|
+
xs: '44px',
|
|
5716
|
+
sm: '10px'
|
|
5717
|
+
},
|
|
5596
5718
|
padding: 1
|
|
5597
5719
|
}
|
|
5598
5720
|
}, /*#__PURE__*/React__default["default"].createElement(TafForm, {
|
|
@@ -5659,7 +5781,10 @@
|
|
|
5659
5781
|
"data-testid": "updateTafBtn",
|
|
5660
5782
|
onClick: onUpdateTaf,
|
|
5661
5783
|
sx: {
|
|
5662
|
-
marginRight:
|
|
5784
|
+
marginRight: {
|
|
5785
|
+
xs: 2,
|
|
5786
|
+
sm: 1
|
|
5787
|
+
},
|
|
5663
5788
|
marginLeft: 1
|
|
5664
5789
|
}
|
|
5665
5790
|
}, /*#__PURE__*/React__default["default"].createElement(theme.Cached, null))));
|
|
@@ -5670,6 +5795,51 @@
|
|
|
5670
5795
|
description: "It's not possible to autosave this TAF due to the presence of issue(s). Are you sure you want to close this TAF? Any changes made will be lost.",
|
|
5671
5796
|
confirmLabel: 'Exit without saving'
|
|
5672
5797
|
};
|
|
5798
|
+
var getTafMessagePrefix = function getTafMessagePrefix(_a, newStatus) {
|
|
5799
|
+
var location = _a.location,
|
|
5800
|
+
validDateStart = _a.validDateStart,
|
|
5801
|
+
messageType = _a.messageType;
|
|
5802
|
+
var formattedDate = formatBaseTime(moment__default["default"].utc(validDateStart));
|
|
5803
|
+
return "TAF " + location + " " + formattedDate + " " + messageType + " was " + newStatus + " successfully";
|
|
5804
|
+
};
|
|
5805
|
+
var getSnackbarMessage = function getSnackbarMessage(tafFromFrontEnd, isAutoSaved) {
|
|
5806
|
+
if (isAutoSaved === void 0) {
|
|
5807
|
+
isAutoSaved = false;
|
|
5808
|
+
}
|
|
5809
|
+
|
|
5810
|
+
var changeStatusTo = tafFromFrontEnd.changeStatusTo,
|
|
5811
|
+
taf = tafFromFrontEnd.taf;
|
|
5812
|
+
|
|
5813
|
+
if (isAutoSaved) {
|
|
5814
|
+
return 'All changes have been saved automatically';
|
|
5815
|
+
}
|
|
5816
|
+
|
|
5817
|
+
switch (changeStatusTo) {
|
|
5818
|
+
case 'DRAFT':
|
|
5819
|
+
return 'Saved as draft';
|
|
5820
|
+
|
|
5821
|
+
case 'DRAFT_AMENDED':
|
|
5822
|
+
return 'Saved as draft amended';
|
|
5823
|
+
|
|
5824
|
+
case 'DRAFT_CORRECTED':
|
|
5825
|
+
return 'Saved as draft correction';
|
|
5826
|
+
|
|
5827
|
+
case 'PUBLISHED':
|
|
5828
|
+
return getTafMessagePrefix(taf, 'published');
|
|
5829
|
+
|
|
5830
|
+
case 'CANCELLED':
|
|
5831
|
+
return getTafMessagePrefix(taf, 'cancelled');
|
|
5832
|
+
|
|
5833
|
+
case 'CORRECTED':
|
|
5834
|
+
return getTafMessagePrefix(taf, 'corrected');
|
|
5835
|
+
|
|
5836
|
+
case 'AMENDED':
|
|
5837
|
+
return getTafMessagePrefix(taf, 'amended');
|
|
5838
|
+
|
|
5839
|
+
default:
|
|
5840
|
+
return getTafMessagePrefix(taf, 'saved');
|
|
5841
|
+
}
|
|
5842
|
+
};
|
|
5673
5843
|
|
|
5674
5844
|
var TafLayout = function TafLayout(_a) {
|
|
5675
5845
|
var _b = _a.tafList,
|
|
@@ -5678,6 +5848,7 @@
|
|
|
5678
5848
|
onUpdateTaf = _c === void 0 ? function () {} : _c,
|
|
5679
5849
|
lastUpdateTime = _a.lastUpdateTime;
|
|
5680
5850
|
var api$1 = api.useApiContext().api;
|
|
5851
|
+
var dispatch = reactRedux.useDispatch();
|
|
5681
5852
|
var confirmDialog = shared.useConfirmationDialog();
|
|
5682
5853
|
|
|
5683
5854
|
var _d = useIssuesPane(),
|
|
@@ -5730,7 +5901,17 @@
|
|
|
5730
5901
|
error = _q[0],
|
|
5731
5902
|
setError = _q[1];
|
|
5732
5903
|
|
|
5733
|
-
var
|
|
5904
|
+
var showSnackbar = React__default["default"].useCallback(function (message) {
|
|
5905
|
+
dispatch(core.snackbarActions.openSnackbar({
|
|
5906
|
+
message: message
|
|
5907
|
+
}));
|
|
5908
|
+
}, [dispatch]);
|
|
5909
|
+
|
|
5910
|
+
var postTaf = function postTaf(data, isAutoSaved) {
|
|
5911
|
+
if (isAutoSaved === void 0) {
|
|
5912
|
+
isAutoSaved = false;
|
|
5913
|
+
}
|
|
5914
|
+
|
|
5734
5915
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
5735
5916
|
var error_1;
|
|
5736
5917
|
return __generator(this, function (_a) {
|
|
@@ -5744,8 +5925,9 @@
|
|
|
5744
5925
|
, postTafRequest(data)];
|
|
5745
5926
|
|
|
5746
5927
|
case 1:
|
|
5747
|
-
_a.sent();
|
|
5928
|
+
_a.sent();
|
|
5748
5929
|
|
|
5930
|
+
showSnackbar(getSnackbarMessage(data, isAutoSaved)); // callback
|
|
5749
5931
|
|
|
5750
5932
|
onUpdateTaf();
|
|
5751
5933
|
return [3
|
|
@@ -5831,7 +6013,7 @@
|
|
|
5831
6013
|
, postTaf({
|
|
5832
6014
|
taf: taf,
|
|
5833
6015
|
changeStatusTo: fromActionToStatus(tafActionToDraftAction(tafAction))
|
|
5834
|
-
})];
|
|
6016
|
+
}, true)];
|
|
5835
6017
|
|
|
5836
6018
|
case 3:
|
|
5837
6019
|
_a.sent();
|
|
@@ -5885,18 +6067,16 @@
|
|
|
5885
6067
|
};
|
|
5886
6068
|
|
|
5887
6069
|
React__default["default"].useEffect(function () {
|
|
6070
|
+
var _a, _b;
|
|
6071
|
+
|
|
5888
6072
|
var newSortedTafs = sortTafTimeSlots(tafList);
|
|
5889
6073
|
var updatedLocations = timeSlot === 'ACTIVE' ? newSortedTafs.current : newSortedTafs.upcoming;
|
|
5890
6074
|
updateSortedTafs(sortTafTimeSlots(tafList));
|
|
5891
6075
|
setLocations(updatedLocations); // update active index
|
|
5892
6076
|
|
|
5893
|
-
var
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
return ((_a = location === null || location === void 0 ? void 0 : location.taf) === null || _a === void 0 ? void 0 : _a.previousId) === ((_c = (_b = locations[activeTafIndex]) === null || _b === void 0 ? void 0 : _b.taf) === null || _c === void 0 ? void 0 : _c.uuid);
|
|
5897
|
-
});
|
|
5898
|
-
var newIndex = newActiveIndex !== -1 ? newActiveIndex : activeTafIndex;
|
|
5899
|
-
setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6077
|
+
var previousActiveLocationUUID = (_b = (_a = locations[activeTafIndex]) === null || _a === void 0 ? void 0 : _a.taf) === null || _b === void 0 ? void 0 : _b.uuid;
|
|
6078
|
+
var newTafLocationIndex = getNewTafLocationIndex(updatedLocations, previousActiveLocationUUID);
|
|
6079
|
+
setActiveTafIndex(newTafLocationIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5900
6080
|
}, [tafList, setLocations]);
|
|
5901
6081
|
React__default["default"].useEffect(function () {
|
|
5902
6082
|
setError(postError);
|
|
@@ -5913,7 +6093,7 @@
|
|
|
5913
6093
|
setError(patchError);
|
|
5914
6094
|
}, [patchError]);
|
|
5915
6095
|
|
|
5916
|
-
if (!tafList) {
|
|
6096
|
+
if (!tafList || !tafList.length) {
|
|
5917
6097
|
return null;
|
|
5918
6098
|
}
|
|
5919
6099
|
|
|
@@ -6170,10 +6350,14 @@
|
|
|
6170
6350
|
postTaf: function postTaf(formData) {
|
|
6171
6351
|
return axiosInstance.post('/taf', __assign({}, formData));
|
|
6172
6352
|
},
|
|
6173
|
-
getTAC: function getTAC(tafData, signal) {
|
|
6174
|
-
return axiosInstance.post
|
|
6353
|
+
getTAC: function getTAC(tafData, getJSON, signal) {
|
|
6354
|
+
return axiosInstance.post('/taf2tac', tafData, __assign(__assign({}, signal ? {
|
|
6175
6355
|
signal: signal
|
|
6176
|
-
}
|
|
6356
|
+
} : {}), {
|
|
6357
|
+
headers: {
|
|
6358
|
+
Accept: getJSON ? 'application/json' : 'text/plain'
|
|
6359
|
+
}
|
|
6360
|
+
}));
|
|
6177
6361
|
},
|
|
6178
6362
|
patchTaf: function patchTaf(formData) {
|
|
6179
6363
|
return axiosInstance.patch('/taf', __assign({}, formData));
|
|
@@ -6181,30 +6365,12 @@
|
|
|
6181
6365
|
};
|
|
6182
6366
|
};
|
|
6183
6367
|
|
|
6184
|
-
var createApi$1 = function createApi(
|
|
6185
|
-
var axiosInstance = api.createApiInstance(
|
|
6368
|
+
var createApi$1 = function createApi(props) {
|
|
6369
|
+
var axiosInstance = api.createApiInstance(props);
|
|
6186
6370
|
return getApiRoutes$1(axiosInstance);
|
|
6187
6371
|
};
|
|
6188
6372
|
|
|
6189
|
-
/* *
|
|
6190
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6191
|
-
* you may not use this file except in compliance with the License.
|
|
6192
|
-
* You may obtain a copy of the License at
|
|
6193
|
-
*
|
|
6194
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6195
|
-
*
|
|
6196
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
6197
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6198
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6199
|
-
* See the License for the specific language governing permissions and
|
|
6200
|
-
* limitations under the License.
|
|
6201
|
-
*
|
|
6202
|
-
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6203
|
-
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
6204
|
-
* */
|
|
6205
|
-
|
|
6206
6373
|
var MOCK_USERNAME = 'user.name';
|
|
6207
|
-
|
|
6208
6374
|
var currentDate = moment__default["default"].utc().format('YYYY-MM-DD');
|
|
6209
6375
|
var tomorrowDate = moment__default["default"].utc().add(1, 'day').format('YYYY-MM-DD');
|
|
6210
6376
|
var airportPeriod = 6;
|
|
@@ -7003,7 +7169,6 @@
|
|
|
7003
7169
|
taf: {
|
|
7004
7170
|
uuid: '954905487',
|
|
7005
7171
|
previousId: '5f9583fjdf45ff4330f337925',
|
|
7006
|
-
issueDate: currentDate + "T14:00:00Z",
|
|
7007
7172
|
baseTime: currentDate + "T12:00:00Z",
|
|
7008
7173
|
validDateStart: currentDate + "T14:00:00Z",
|
|
7009
7174
|
validDateEnd: tomorrowDate + "T18:00:00Z",
|
|
@@ -7063,7 +7228,6 @@
|
|
|
7063
7228
|
editor: null,
|
|
7064
7229
|
taf: __assign(__assign({}, fakeDraftAmendmentTaf.taf), {
|
|
7065
7230
|
location: 'EHRD',
|
|
7066
|
-
issueDate: "2022-01-06T14:00:00Z",
|
|
7067
7231
|
baseTime: "2022-01-06T12:00:00Z",
|
|
7068
7232
|
validDateStart: "2022-01-06T14:00:00Z",
|
|
7069
7233
|
validDateEnd: "2022-01-07T18:00:00Z",
|
|
@@ -7144,12 +7308,45 @@
|
|
|
7144
7308
|
});
|
|
7145
7309
|
|
|
7146
7310
|
var fakeTafTac = 'TAF EHAM 0812/0918 20020G35KT 0500 SN BKN040\nBECMG 0814/0816 0700 BKN001=';
|
|
7311
|
+
var fakeTafTacJson = {
|
|
7312
|
+
tac: [[{
|
|
7313
|
+
text: 'TAF'
|
|
7314
|
+
}, {
|
|
7315
|
+
text: 'EHAM'
|
|
7316
|
+
}, {
|
|
7317
|
+
text: '0812/0918'
|
|
7318
|
+
}, {
|
|
7319
|
+
text: '20020G35KT',
|
|
7320
|
+
type: 'adverse'
|
|
7321
|
+
}, {
|
|
7322
|
+
text: '0500',
|
|
7323
|
+
type: 'adverse'
|
|
7324
|
+
}, {
|
|
7325
|
+
text: 'SN',
|
|
7326
|
+
type: 'adverse'
|
|
7327
|
+
}, {
|
|
7328
|
+
text: 'BKN040'
|
|
7329
|
+
}], [{
|
|
7330
|
+
text: 'BECMG'
|
|
7331
|
+
}, {
|
|
7332
|
+
text: '0814/0816'
|
|
7333
|
+
}, {
|
|
7334
|
+
text: '0700',
|
|
7335
|
+
type: 'adverse'
|
|
7336
|
+
}, {
|
|
7337
|
+
text: 'BKN001',
|
|
7338
|
+
type: 'adverse'
|
|
7339
|
+
}, {
|
|
7340
|
+
text: '='
|
|
7341
|
+
}]]
|
|
7342
|
+
};
|
|
7147
7343
|
|
|
7148
7344
|
var fakeUpdatedTafList = __spreadArray([], __read(fakeTafList));
|
|
7149
7345
|
|
|
7150
7346
|
var setFakeUpdatedList = function setFakeUpdatedList(newList) {
|
|
7151
7347
|
fakeUpdatedTafList = newList;
|
|
7152
7348
|
};
|
|
7349
|
+
|
|
7153
7350
|
var getFakeUpdatedList = function getFakeUpdatedList() {
|
|
7154
7351
|
return fakeUpdatedTafList;
|
|
7155
7352
|
};
|
|
@@ -7172,12 +7369,16 @@
|
|
|
7172
7369
|
console.log('form has been posted with following values:', _postTaf.taf);
|
|
7173
7370
|
return axiosInstance.post('/taf', _postTaf);
|
|
7174
7371
|
},
|
|
7175
|
-
getTAC: function getTAC(taf, signal) {
|
|
7176
|
-
return axiosInstance.post
|
|
7372
|
+
getTAC: function getTAC(taf, getJSON, signal) {
|
|
7373
|
+
return axiosInstance.post('/taf2tac', taf, __assign(__assign({}, signal ? {
|
|
7177
7374
|
signal: signal
|
|
7178
|
-
}
|
|
7375
|
+
} : {}), {
|
|
7376
|
+
headers: {
|
|
7377
|
+
Accept: getJSON ? 'application/json' : 'text/plain'
|
|
7378
|
+
}
|
|
7379
|
+
})).then(function () {
|
|
7179
7380
|
return {
|
|
7180
|
-
data: fakeTafTac
|
|
7381
|
+
data: getJSON ? fakeTafTacJson : fakeTafTac
|
|
7181
7382
|
};
|
|
7182
7383
|
});
|
|
7183
7384
|
},
|
|
@@ -7242,13 +7443,15 @@
|
|
|
7242
7443
|
onSetAuth = _a.onSetAuth,
|
|
7243
7444
|
onPreventCloseView = _a.onPreventCloseView;
|
|
7244
7445
|
return config ? /*#__PURE__*/React__namespace.createElement(api.ApiProvider, {
|
|
7245
|
-
|
|
7246
|
-
|
|
7446
|
+
config: {
|
|
7447
|
+
baseURL: config.baseURL,
|
|
7448
|
+
appURL: config.baseURL,
|
|
7449
|
+
authTokenURL: config.authTokenURL,
|
|
7450
|
+
authClientId: config.authClientId
|
|
7451
|
+
},
|
|
7247
7452
|
auth: auth,
|
|
7248
7453
|
onSetAuth: onSetAuth,
|
|
7249
|
-
createApi: createApi$1
|
|
7250
|
-
authTokenUrl: config.authTokenUrl,
|
|
7251
|
-
authClientId: config.authClientId
|
|
7454
|
+
createApi: createApi$1
|
|
7252
7455
|
}, /*#__PURE__*/React__namespace.createElement(shared.ErrorBoundary, null, /*#__PURE__*/React__namespace.createElement(Wrapper, {
|
|
7253
7456
|
onPreventCloseView: onPreventCloseView
|
|
7254
7457
|
}))) : null;
|
package/lib/TafDemo.stories.d.ts
CHANGED
|
@@ -3,5 +3,21 @@ declare const _default: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
6
|
-
export declare const TafModuleLightTheme:
|
|
7
|
-
|
|
6
|
+
export declare const TafModuleLightTheme: {
|
|
7
|
+
(): React.ReactElement;
|
|
8
|
+
parameters: {
|
|
9
|
+
zeplinLink: {
|
|
10
|
+
name: string;
|
|
11
|
+
link: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const TafModuleDarkTheme: {
|
|
16
|
+
(): React.ReactElement;
|
|
17
|
+
parameters: {
|
|
18
|
+
zeplinLink: {
|
|
19
|
+
name: string;
|
|
20
|
+
link: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiModule, ApiUrls } from '@opengeoweb/api';
|
|
3
3
|
export declare const tafScreenPreset: {
|
|
4
4
|
id: string;
|
|
5
5
|
title: string;
|
|
@@ -23,12 +23,10 @@ export interface ComponentsLookUpPayload {
|
|
|
23
23
|
title?: string;
|
|
24
24
|
initialProps: Record<string, never>;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
interface ApiModuleProps extends ApiModule {
|
|
27
27
|
config: ApiUrls;
|
|
28
|
-
auth: Credentials;
|
|
29
|
-
onSetAuth: (credentias: Credentials) => void;
|
|
30
28
|
onPreventCloseView?: (shouldPreventClose: boolean) => void;
|
|
31
|
-
}
|
|
29
|
+
}
|
|
32
30
|
export declare const TafApiWrapper: React.FC<ApiModuleProps>;
|
|
33
31
|
export declare const componentsLookUp: (payload: ComponentsLookUpPayload, { config, auth, onSetAuth }: ApiModuleProps, ConnectedModuleWrapper?: any) => React.ReactElement;
|
|
34
32
|
export {};
|