@opengeoweb/taf 2.14.0 → 2.15.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 +528 -81
- package/index.umd.js +563 -110
- package/lib/components/Providers/Providers.d.ts +1 -0
- package/lib/components/SwitchButton/SwitchButton.d.ts +4 -0
- package/lib/components/SwitchButton/SwitchButton.spec.d.ts +1 -0
- package/lib/components/SwitchButton/index.d.ts +1 -0
- package/lib/components/TafAvatar/TafAvatar.d.ts +8 -0
- package/lib/components/TafAvatar/index.d.ts +1 -0
- package/lib/components/TafForm/TafForm.d.ts +2 -1
- package/lib/components/TafLayout/LastUpdateTime/LastUpdateTime.d.ts +8 -0
- package/lib/components/TafLayout/LastUpdateTime/LastUpdateTime.spec.d.ts +1 -0
- package/lib/components/TafLayout/LastUpdateTime/LastUpdateTime.stories.d.ts +13 -0
- package/lib/components/TafLayout/LastUpdateTime/index.d.ts +1 -0
- package/lib/components/TafLayout/TafLayout.d.ts +2 -1
- package/lib/components/TafLayout/TafPanel/TafPanel.d.ts +2 -1
- package/lib/components/TafModule/TafModule.d.ts +1 -0
- package/lib/components/TafModule/TafModule.stories.d.ts +1 -0
- package/lib/types.d.ts +3 -1
- package/lib/utils/__mocks__/api.d.ts +1 -0
- package/lib/utils/fakeApi.d.ts +4 -0
- package/package.json +8 -5
package/index.esm.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { TextField, Grid, Box, Button, IconButton, Tooltip, Chip, Typography, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
|
|
3
|
+
import { TextField, Grid, Box, Button, IconButton, Tooltip, Chip, Typography, FormLabel, Switch, Card, Tabs, Tab, Dialog, MenuList, MenuItem, Backdrop, CircularProgress } from '@mui/material';
|
|
4
4
|
import { useFormContext, Controller, useFieldArray } from 'react-hook-form';
|
|
5
5
|
import { ReactSortable, Sortable } from 'react-sortablejs';
|
|
6
|
-
import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
|
|
7
|
-
import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, isAxiosError, getAxiosErrorMessage, AlertBanner, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
|
|
8
6
|
import { isEqual } from 'lodash';
|
|
7
|
+
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
8
|
+
import { getDeepProperty, ReactHookFormHiddenInput, ReactHookFormProvider } from '@opengeoweb/form-fields';
|
|
9
|
+
import { useIsMounted, ToggleMenu, useDraftFormHelpers, ToolContainerDraggable, Avatar, getInitials, useConfirmationDialog, usePreventBrowserClose, ToolButton, ToolHeader, AlertBanner, getErrorMessage as getErrorMessage$1, ConfirmationServiceProvider, usePoller, ErrorBoundary } from '@opengeoweb/shared';
|
|
9
10
|
import moment from 'moment';
|
|
10
|
-
import { Add, Delete, Close, DragHandle as DragHandle$1, ThumbsUp, Clock, Cancel, Edit, Success, Export, ListItem } from '@opengeoweb/theme';
|
|
11
|
+
import { Add, Delete, Close, DragHandle as DragHandle$1, ThumbsUp, Clock, Cancel, Edit, Success, Export, ListItem, Cached } from '@opengeoweb/theme';
|
|
11
12
|
import makeStyles from '@mui/styles/makeStyles';
|
|
12
13
|
import ReactDOM from 'react-dom';
|
|
13
|
-
import { useApiContext,
|
|
14
|
+
import { useApiContext, createApiInstance, ApiProvider } from '@opengeoweb/api';
|
|
14
15
|
import LinearProgress from '@mui/material/LinearProgress';
|
|
15
16
|
import Box$1 from '@mui/material/Box';
|
|
16
17
|
|
|
@@ -3832,7 +3833,12 @@ var IssuesPane = function IssuesPane(_ref3) {
|
|
|
3832
3833
|
fontSize: '4rem'
|
|
3833
3834
|
},
|
|
3834
3835
|
"data-testid": "zeroIssuesImage"
|
|
3835
|
-
}, /*#__PURE__*/React.createElement(ThumbsUp,
|
|
3836
|
+
}, /*#__PURE__*/React.createElement(ThumbsUp, {
|
|
3837
|
+
sx: {
|
|
3838
|
+
height: '69px',
|
|
3839
|
+
width: '58px'
|
|
3840
|
+
}
|
|
3841
|
+
})), errorList.length > 0 && errorList.map(function (error, index) {
|
|
3836
3842
|
return /*#__PURE__*/React.createElement(Typography // eslint-disable-next-line react/no-array-index-key
|
|
3837
3843
|
, {
|
|
3838
3844
|
// eslint-disable-next-line react/no-array-index-key
|
|
@@ -3922,9 +3928,75 @@ var TafModuleProvider = function TafModuleProvider(_ref2) {
|
|
|
3922
3928
|
}, children);
|
|
3923
3929
|
};
|
|
3924
3930
|
|
|
3931
|
+
/* *
|
|
3932
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3933
|
+
* you may not use this file except in compliance with the License.
|
|
3934
|
+
* You may obtain a copy of the License at
|
|
3935
|
+
*
|
|
3936
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3937
|
+
*
|
|
3938
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3939
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3940
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3941
|
+
* See the License for the specific language governing permissions and
|
|
3942
|
+
* limitations under the License.
|
|
3943
|
+
*
|
|
3944
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3945
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3946
|
+
* */
|
|
3947
|
+
var styles = {
|
|
3948
|
+
label: {
|
|
3949
|
+
color: 'geowebColors.buttons.tertiary.default.color',
|
|
3950
|
+
opacity: 1,
|
|
3951
|
+
fontSize: '12px',
|
|
3952
|
+
fontWeight: 500
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
|
|
3956
|
+
var SwitchButton = function SwitchButton(props) {
|
|
3957
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
3958
|
+
title: "Switch mode"
|
|
3959
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormLabel, {
|
|
3960
|
+
sx: styles.label
|
|
3961
|
+
}, "Viewer"), /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
3962
|
+
"data-testid": "switchMode"
|
|
3963
|
+
}, props)), /*#__PURE__*/React.createElement(FormLabel, {
|
|
3964
|
+
sx: styles.label
|
|
3965
|
+
}, "Editor")));
|
|
3966
|
+
};
|
|
3967
|
+
|
|
3968
|
+
/* *
|
|
3969
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3970
|
+
* you may not use this file except in compliance with the License.
|
|
3971
|
+
* You may obtain a copy of the License at
|
|
3972
|
+
*
|
|
3973
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3974
|
+
*
|
|
3975
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3976
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3977
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3978
|
+
* See the License for the specific language governing permissions and
|
|
3979
|
+
* limitations under the License.
|
|
3980
|
+
*
|
|
3981
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3982
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3983
|
+
* */
|
|
3984
|
+
|
|
3985
|
+
var TafAvatar = function TafAvatar(_ref) {
|
|
3986
|
+
var editor = _ref.editor,
|
|
3987
|
+
_ref$tooltipPlacement = _ref.tooltipPlacement,
|
|
3988
|
+
tooltipPlacement = _ref$tooltipPlacement === void 0 ? 'bottom' : _ref$tooltipPlacement;
|
|
3989
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
3990
|
+
title: "Editor: ".concat(editor),
|
|
3991
|
+
placement: tooltipPlacement
|
|
3992
|
+
}, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Avatar, {
|
|
3993
|
+
size: "small"
|
|
3994
|
+
}, getInitials(editor))));
|
|
3995
|
+
};
|
|
3996
|
+
|
|
3925
3997
|
var noop = function noop() {};
|
|
3926
3998
|
|
|
3927
|
-
var TafForm = function
|
|
3999
|
+
var TafForm = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
3928
4000
|
var tafFromBackend = _ref.tafFromBackend,
|
|
3929
4001
|
_ref$onFormAction = _ref.onFormAction,
|
|
3930
4002
|
onFormAction = _ref$onFormAction === void 0 ? function () {
|
|
@@ -3941,8 +4013,18 @@ var TafForm = function TafForm(_ref) {
|
|
|
3941
4013
|
_ref$setIsDisabled = _ref.setIsDisabled,
|
|
3942
4014
|
setIsDisabled = _ref$setIsDisabled === void 0 ? function () {
|
|
3943
4015
|
return null;
|
|
3944
|
-
} : _ref$setIsDisabled
|
|
3945
|
-
|
|
4016
|
+
} : _ref$setIsDisabled,
|
|
4017
|
+
_ref$onSwitchEditor = _ref.onSwitchEditor,
|
|
4018
|
+
onSwitchEditor = _ref$onSwitchEditor === void 0 ? function () {
|
|
4019
|
+
return null;
|
|
4020
|
+
} : _ref$onSwitchEditor;
|
|
4021
|
+
var originalTaf = tafFromBackend.taf,
|
|
4022
|
+
editor = tafFromBackend.editor;
|
|
4023
|
+
|
|
4024
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
4025
|
+
auth = _useAuthenticationCon.auth;
|
|
4026
|
+
|
|
4027
|
+
var isEditor = editor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
|
|
3946
4028
|
var isDefaultDisabled = getIsFormDefaultDisabled(tafFromBackend.taf.status);
|
|
3947
4029
|
var confirmDialog = useConfirmationDialog();
|
|
3948
4030
|
|
|
@@ -4047,6 +4129,93 @@ var TafForm = function TafForm(_ref) {
|
|
|
4047
4129
|
setTafAction(action);
|
|
4048
4130
|
};
|
|
4049
4131
|
|
|
4132
|
+
var setIsEditor = function setIsEditor(checked) {
|
|
4133
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
4134
|
+
var editor, didSucceed;
|
|
4135
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4136
|
+
while (1) {
|
|
4137
|
+
switch (_context.prev = _context.next) {
|
|
4138
|
+
case 0:
|
|
4139
|
+
editor = checked ? auth === null || auth === void 0 ? void 0 : auth.username : '';
|
|
4140
|
+
|
|
4141
|
+
if (!(editor === tafFromBackend.editor)) {
|
|
4142
|
+
_context.next = 3;
|
|
4143
|
+
break;
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
return _context.abrupt("return", true);
|
|
4147
|
+
|
|
4148
|
+
case 3:
|
|
4149
|
+
if (!(tafFromBackend.editor !== '' && tafFromBackend.editor !== null && tafFromBackend.editor !== (auth === null || auth === void 0 ? void 0 : auth.username))) {
|
|
4150
|
+
_context.next = 6;
|
|
4151
|
+
break;
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
_context.next = 6;
|
|
4155
|
+
return confirmDialog({
|
|
4156
|
+
title: 'Switch to editor mode',
|
|
4157
|
+
description: 'This TAF is already in edit mode and important information could get lost in the switching process.',
|
|
4158
|
+
confirmLabel: 'Edit mode'
|
|
4159
|
+
});
|
|
4160
|
+
|
|
4161
|
+
case 6:
|
|
4162
|
+
_context.next = 8;
|
|
4163
|
+
return onSwitchEditor(Object.assign(Object.assign({}, tafFromBackend), {
|
|
4164
|
+
editor: editor
|
|
4165
|
+
}));
|
|
4166
|
+
|
|
4167
|
+
case 8:
|
|
4168
|
+
didSucceed = _context.sent;
|
|
4169
|
+
return _context.abrupt("return", didSucceed);
|
|
4170
|
+
|
|
4171
|
+
case 10:
|
|
4172
|
+
case "end":
|
|
4173
|
+
return _context.stop();
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
}, _callee);
|
|
4177
|
+
}));
|
|
4178
|
+
};
|
|
4179
|
+
|
|
4180
|
+
var onSwitchMode = function onSwitchMode(event) {
|
|
4181
|
+
var checked = event.target.checked;
|
|
4182
|
+
|
|
4183
|
+
if (!checked && isFormDirty) {
|
|
4184
|
+
confirmDialog({
|
|
4185
|
+
title: 'Whoops',
|
|
4186
|
+
description: 'Are you sure you want to switch to viewer mode? Your unsaved changes will be lost.',
|
|
4187
|
+
confirmLabel: 'Switch mode'
|
|
4188
|
+
}).then(function () {
|
|
4189
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
4190
|
+
var didSucceed;
|
|
4191
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
4192
|
+
while (1) {
|
|
4193
|
+
switch (_context2.prev = _context2.next) {
|
|
4194
|
+
case 0:
|
|
4195
|
+
_context2.next = 2;
|
|
4196
|
+
return setIsEditor(checked);
|
|
4197
|
+
|
|
4198
|
+
case 2:
|
|
4199
|
+
didSucceed = _context2.sent;
|
|
4200
|
+
|
|
4201
|
+
if (didSucceed) {
|
|
4202
|
+
resetForm(undefined, isDefaultDisabled);
|
|
4203
|
+
resetTAC();
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
case 4:
|
|
4207
|
+
case "end":
|
|
4208
|
+
return _context2.stop();
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
}, _callee2);
|
|
4212
|
+
}));
|
|
4213
|
+
});
|
|
4214
|
+
} else {
|
|
4215
|
+
setIsEditor(checked);
|
|
4216
|
+
}
|
|
4217
|
+
};
|
|
4218
|
+
|
|
4050
4219
|
var onTafEditModeButtonPress = function onTafEditModeButtonPress(action) {
|
|
4051
4220
|
switch (action) {
|
|
4052
4221
|
case 'DRAFT':
|
|
@@ -4076,21 +4245,21 @@ var TafForm = function TafForm(_ref) {
|
|
|
4076
4245
|
case 'PUBLISH':
|
|
4077
4246
|
toggleIsDraft(false);
|
|
4078
4247
|
handleSubmit(function (data) {
|
|
4079
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function
|
|
4248
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
4080
4249
|
var didSucceed;
|
|
4081
|
-
return regeneratorRuntime.wrap(function
|
|
4250
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4082
4251
|
while (1) {
|
|
4083
|
-
switch (
|
|
4252
|
+
switch (_context3.prev = _context3.next) {
|
|
4084
4253
|
case 0:
|
|
4085
|
-
|
|
4254
|
+
_context3.next = 2;
|
|
4086
4255
|
return showConfirmDialog(action);
|
|
4087
4256
|
|
|
4088
4257
|
case 2:
|
|
4089
|
-
|
|
4258
|
+
_context3.next = 4;
|
|
4090
4259
|
return onFormAction(action, convertTafValuesToObject(data));
|
|
4091
4260
|
|
|
4092
4261
|
case 4:
|
|
4093
|
-
didSucceed =
|
|
4262
|
+
didSucceed = _context3.sent;
|
|
4094
4263
|
|
|
4095
4264
|
if (didSucceed) {
|
|
4096
4265
|
setIsDisabled(true);
|
|
@@ -4100,10 +4269,10 @@ var TafForm = function TafForm(_ref) {
|
|
|
4100
4269
|
|
|
4101
4270
|
case 6:
|
|
4102
4271
|
case "end":
|
|
4103
|
-
return
|
|
4272
|
+
return _context3.stop();
|
|
4104
4273
|
}
|
|
4105
4274
|
}
|
|
4106
|
-
},
|
|
4275
|
+
}, _callee3);
|
|
4107
4276
|
}));
|
|
4108
4277
|
})();
|
|
4109
4278
|
break;
|
|
@@ -4118,7 +4287,21 @@ var TafForm = function TafForm(_ref) {
|
|
|
4118
4287
|
switch (action) {
|
|
4119
4288
|
case 'CANCEL':
|
|
4120
4289
|
showConfirmDialog(action).then(function () {
|
|
4121
|
-
|
|
4290
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
4291
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
4292
|
+
while (1) {
|
|
4293
|
+
switch (_context4.prev = _context4.next) {
|
|
4294
|
+
case 0:
|
|
4295
|
+
_context4.next = 2;
|
|
4296
|
+
return onFormAction(action, convertTafValuesToObject(prepareTafValues(tafFromBackend.taf, action)));
|
|
4297
|
+
|
|
4298
|
+
case 2:
|
|
4299
|
+
case "end":
|
|
4300
|
+
return _context4.stop();
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
}, _callee4);
|
|
4304
|
+
}));
|
|
4122
4305
|
});
|
|
4123
4306
|
break;
|
|
4124
4307
|
|
|
@@ -4215,7 +4398,7 @@ var TafForm = function TafForm(_ref) {
|
|
|
4215
4398
|
setShouldValidate = _React$useState4[1];
|
|
4216
4399
|
|
|
4217
4400
|
React__default.useEffect(function () {
|
|
4218
|
-
setIsDisabled(isDefaultDisabled);
|
|
4401
|
+
setIsDisabled(!isEditor || isDefaultDisabled);
|
|
4219
4402
|
var defaultValues = prepareTafValues(tafFromBackend.taf, undefined, !isDefaultDisabled && !tafFromBackend.taf.changeGroups); // set initial form values
|
|
4220
4403
|
|
|
4221
4404
|
reset(defaultValues); // set validate flag to validate after the values have been set
|
|
@@ -4250,9 +4433,13 @@ var TafForm = function TafForm(_ref) {
|
|
|
4250
4433
|
|
|
4251
4434
|
reset(newValues); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4252
4435
|
}, [tafFromBackend]);
|
|
4436
|
+
React__default.useEffect(function () {
|
|
4437
|
+
// update disabled state when editor changed
|
|
4438
|
+
setIsDisabled(!isEditor || isDefaultDisabled); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4439
|
+
}, [editor]);
|
|
4253
4440
|
React__default.useEffect(function () {
|
|
4254
4441
|
if (shouldValidate && !isDisabled) {
|
|
4255
|
-
// trigger validation on all changegroup validity times after
|
|
4442
|
+
// trigger validation on all changegroup validity times after form is enabled since they could be outside the new validity period
|
|
4256
4443
|
var _tafFromBackend$taf$c = tafFromBackend.taf.changeGroups,
|
|
4257
4444
|
changeGroups = _tafFromBackend$taf$c === void 0 ? [] : _tafFromBackend$taf$c;
|
|
4258
4445
|
var validFields = changeGroups.map(function (_field, index) {
|
|
@@ -4261,8 +4448,33 @@ var TafForm = function TafForm(_ref) {
|
|
|
4261
4448
|
trigger(validFields);
|
|
4262
4449
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4263
4450
|
|
|
4264
|
-
}, [shouldValidate]);
|
|
4265
|
-
return /*#__PURE__*/React__default.createElement(
|
|
4451
|
+
}, [shouldValidate, isDisabled]);
|
|
4452
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
|
|
4453
|
+
sx: {
|
|
4454
|
+
display: 'flex',
|
|
4455
|
+
flexDirection: 'row',
|
|
4456
|
+
alignItems: 'center',
|
|
4457
|
+
position: 'absolute',
|
|
4458
|
+
top: {
|
|
4459
|
+
xs: '20px',
|
|
4460
|
+
sm: '0px'
|
|
4461
|
+
},
|
|
4462
|
+
right: {
|
|
4463
|
+
xs: 'calc(50% - 70px)',
|
|
4464
|
+
sm: '8px'
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
}, /*#__PURE__*/React__default.createElement(SwitchButton, {
|
|
4468
|
+
checked: isEditor,
|
|
4469
|
+
onChange: onSwitchMode
|
|
4470
|
+
}), /*#__PURE__*/React__default.createElement(Box, {
|
|
4471
|
+
sx: {
|
|
4472
|
+
width: '16px',
|
|
4473
|
+
marginLeft: 1
|
|
4474
|
+
}
|
|
4475
|
+
}, editor && /*#__PURE__*/React__default.createElement(TafAvatar, {
|
|
4476
|
+
editor: editor
|
|
4477
|
+
}))), /*#__PURE__*/React__default.createElement("form", {
|
|
4266
4478
|
"data-testid": "taf-form",
|
|
4267
4479
|
onSubmit: handleSubmit(onSubmit),
|
|
4268
4480
|
onBlur: onFormBlur
|
|
@@ -4328,7 +4540,7 @@ var TafForm = function TafForm(_ref) {
|
|
|
4328
4540
|
index: index
|
|
4329
4541
|
})
|
|
4330
4542
|
});
|
|
4331
|
-
})), !isDisabled && /*#__PURE__*/React__default.createElement(Grid, {
|
|
4543
|
+
})), !isDisabled && isEditor && /*#__PURE__*/React__default.createElement(Grid, {
|
|
4332
4544
|
container: true,
|
|
4333
4545
|
justifyContent: "space-between",
|
|
4334
4546
|
alignItems: "center",
|
|
@@ -4342,7 +4554,7 @@ var TafForm = function TafForm(_ref) {
|
|
|
4342
4554
|
errors: errors,
|
|
4343
4555
|
isIssuesPaneOpen: isIssuesPaneOpen,
|
|
4344
4556
|
setIsIssuesPaneOpen: setIsIssuesPaneOpen
|
|
4345
|
-
}))), /*#__PURE__*/React__default.createElement(TafFormButtons, {
|
|
4557
|
+
}))), isEditor && /*#__PURE__*/React__default.createElement(TafFormButtons, {
|
|
4346
4558
|
isFormDisabled: isDisabled,
|
|
4347
4559
|
tafAction: tafAction,
|
|
4348
4560
|
canBe: tafFromBackend.canbe,
|
|
@@ -4353,8 +4565,12 @@ var TafForm = function TafForm(_ref) {
|
|
|
4353
4565
|
name: field,
|
|
4354
4566
|
key: field
|
|
4355
4567
|
});
|
|
4356
|
-
}), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null));
|
|
4357
|
-
}
|
|
4568
|
+
}), /*#__PURE__*/React__default.createElement(DraftFieldHelper, null)));
|
|
4569
|
+
}, function (prevProps, nextProps) {
|
|
4570
|
+
// prevent re-render
|
|
4571
|
+
return !nextProps.isDisabled && prevProps.tafFromBackend !== nextProps.tafFromBackend && // if editor changed it should rerender
|
|
4572
|
+
prevProps.tafFromBackend.editor === nextProps.tafFromBackend.editor;
|
|
4573
|
+
});
|
|
4358
4574
|
|
|
4359
4575
|
/* *
|
|
4360
4576
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -4943,7 +5159,7 @@ var TacOverviewMobile = function TacOverviewMobile(_ref) {
|
|
|
4943
5159
|
},
|
|
4944
5160
|
position: 'absolute',
|
|
4945
5161
|
right: '8px',
|
|
4946
|
-
top: '
|
|
5162
|
+
top: '48px'
|
|
4947
5163
|
}
|
|
4948
5164
|
}, /*#__PURE__*/React.createElement(ListItem, null)), /*#__PURE__*/React.createElement(Dialog, {
|
|
4949
5165
|
open: isOpen,
|
|
@@ -5073,7 +5289,8 @@ var LocationTabs = function LocationTabs(_ref) {
|
|
|
5073
5289
|
paddingTop: '32px'
|
|
5074
5290
|
}
|
|
5075
5291
|
}, tafList.map(function (_ref2, index) {
|
|
5076
|
-
var taf = _ref2.taf
|
|
5292
|
+
var taf = _ref2.taf,
|
|
5293
|
+
editor = _ref2.editor;
|
|
5077
5294
|
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
5078
5295
|
key: taf.uuid,
|
|
5079
5296
|
selected: index === activeIndex,
|
|
@@ -5098,8 +5315,18 @@ var LocationTabs = function LocationTabs(_ref) {
|
|
|
5098
5315
|
onClick: function onClick() {
|
|
5099
5316
|
return onChangeTab(index);
|
|
5100
5317
|
}
|
|
5101
|
-
}, /*#__PURE__*/React.createElement(Box$1, {
|
|
5318
|
+
}, editor && /*#__PURE__*/React.createElement(Box$1, {
|
|
5319
|
+
sx: {
|
|
5320
|
+
position: 'absolute',
|
|
5321
|
+
top: '4px',
|
|
5322
|
+
left: '8px'
|
|
5323
|
+
}
|
|
5324
|
+
}, /*#__PURE__*/React.createElement(TafAvatar, {
|
|
5325
|
+
editor: editor,
|
|
5326
|
+
tooltipPlacement: "right"
|
|
5327
|
+
})), /*#__PURE__*/React.createElement(Box$1, {
|
|
5102
5328
|
component: "span",
|
|
5329
|
+
"data-testid": "taf-location",
|
|
5103
5330
|
sx: {
|
|
5104
5331
|
fontSize: '12px',
|
|
5105
5332
|
fontWeight: '500',
|
|
@@ -5175,13 +5402,15 @@ var fromActionToStatus = function fromActionToStatus(tafAction) {
|
|
|
5175
5402
|
};
|
|
5176
5403
|
|
|
5177
5404
|
var parseErrorMessage = function parseErrorMessage(error, params) {
|
|
5405
|
+
var message = getErrorMessage$1(error);
|
|
5178
5406
|
return params.changeStatusTo === 'CANCELLED' ? {
|
|
5179
5407
|
type: 'CANCELLED',
|
|
5180
|
-
title: 'Cancelling this TAF failed, please try again'
|
|
5408
|
+
title: 'Cancelling this TAF failed, please try again',
|
|
5409
|
+
message: message
|
|
5181
5410
|
} : {
|
|
5182
5411
|
type: 'SERVER',
|
|
5183
5412
|
title: 'An error has occurred while saving, please try again',
|
|
5184
|
-
message:
|
|
5413
|
+
message: message
|
|
5185
5414
|
};
|
|
5186
5415
|
};
|
|
5187
5416
|
|
|
@@ -5272,6 +5501,10 @@ var TafPanel = function TafPanel(_ref) {
|
|
|
5272
5501
|
postTaf = _ref$postTaf === void 0 ? function () {
|
|
5273
5502
|
return null;
|
|
5274
5503
|
} : _ref$postTaf,
|
|
5504
|
+
_ref$patchTaf = _ref.patchTaf,
|
|
5505
|
+
patchTaf = _ref$patchTaf === void 0 ? function () {
|
|
5506
|
+
return null;
|
|
5507
|
+
} : _ref$patchTaf,
|
|
5275
5508
|
_ref$isIssuesPaneOpen = _ref.isIssuesPaneOpen,
|
|
5276
5509
|
isIssuesPaneOpen = _ref$isIssuesPaneOpen === void 0 ? false : _ref$isIssuesPaneOpen,
|
|
5277
5510
|
_ref$setIsIssuesPaneO = _ref.setIsIssuesPaneOpen,
|
|
@@ -5358,7 +5591,8 @@ var TafPanel = function TafPanel(_ref) {
|
|
|
5358
5591
|
isIssuesPaneOpen: isIssuesPaneOpen,
|
|
5359
5592
|
setIsIssuesPaneOpen: setIsIssuesPaneOpen,
|
|
5360
5593
|
isDisabled: isFormDisabled,
|
|
5361
|
-
setIsDisabled: setIsFormDisabled
|
|
5594
|
+
setIsDisabled: setIsFormDisabled,
|
|
5595
|
+
onSwitchEditor: patchTaf
|
|
5362
5596
|
})));
|
|
5363
5597
|
};
|
|
5364
5598
|
|
|
@@ -5389,6 +5623,57 @@ var IssuesPaneWrapper = function IssuesPaneWrapper(props) {
|
|
|
5389
5623
|
}, props));
|
|
5390
5624
|
};
|
|
5391
5625
|
|
|
5626
|
+
/* *
|
|
5627
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5628
|
+
* you may not use this file except in compliance with the License.
|
|
5629
|
+
* You may obtain a copy of the License at
|
|
5630
|
+
*
|
|
5631
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5632
|
+
*
|
|
5633
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
5634
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5635
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5636
|
+
* See the License for the specific language governing permissions and
|
|
5637
|
+
* limitations under the License.
|
|
5638
|
+
*
|
|
5639
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5640
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
5641
|
+
* */
|
|
5642
|
+
var getLastUpdateTitle = function getLastUpdateTitle(time) {
|
|
5643
|
+
return "Last updated ".concat(time);
|
|
5644
|
+
};
|
|
5645
|
+
|
|
5646
|
+
var LastUpdateTime = function LastUpdateTime(_ref) {
|
|
5647
|
+
var _ref$onUpdateTaf = _ref.onUpdateTaf,
|
|
5648
|
+
onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
|
|
5649
|
+
lastUpdateTime = _ref.lastUpdateTime;
|
|
5650
|
+
return /*#__PURE__*/React__default.createElement(Box, {
|
|
5651
|
+
sx: {
|
|
5652
|
+
display: 'flex',
|
|
5653
|
+
alignItems: 'center',
|
|
5654
|
+
height: '100%',
|
|
5655
|
+
justifyContent: 'flex-end'
|
|
5656
|
+
}
|
|
5657
|
+
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
5658
|
+
sx: {
|
|
5659
|
+
color: 'geowebColors.captions.captionStatus.rgba',
|
|
5660
|
+
fontSize: '10px',
|
|
5661
|
+
lineHeight: '1.6',
|
|
5662
|
+
letterSpacing: '0.33px'
|
|
5663
|
+
},
|
|
5664
|
+
"data-testid": "lastupdated-time"
|
|
5665
|
+
}, getLastUpdateTitle(lastUpdateTime)), /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
5666
|
+
title: "Click to refresh"
|
|
5667
|
+
}, /*#__PURE__*/React__default.createElement(ToolButton, {
|
|
5668
|
+
"data-testid": "updateTafBtn",
|
|
5669
|
+
onClick: onUpdateTaf,
|
|
5670
|
+
sx: {
|
|
5671
|
+
marginRight: 1,
|
|
5672
|
+
marginLeft: 1
|
|
5673
|
+
}
|
|
5674
|
+
}, /*#__PURE__*/React__default.createElement(Cached, null))));
|
|
5675
|
+
};
|
|
5676
|
+
|
|
5392
5677
|
var CONFIRM_DIALOG_OPTIONS = {
|
|
5393
5678
|
title: 'Whoops',
|
|
5394
5679
|
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.",
|
|
@@ -5398,8 +5683,9 @@ var CONFIRM_DIALOG_OPTIONS = {
|
|
|
5398
5683
|
var TafLayout = function TafLayout(_ref) {
|
|
5399
5684
|
var _ref$tafList = _ref.tafList,
|
|
5400
5685
|
tafList = _ref$tafList === void 0 ? [] : _ref$tafList,
|
|
5401
|
-
_ref$
|
|
5402
|
-
|
|
5686
|
+
_ref$onUpdateTaf = _ref.onUpdateTaf,
|
|
5687
|
+
onUpdateTaf = _ref$onUpdateTaf === void 0 ? function () {} : _ref$onUpdateTaf,
|
|
5688
|
+
lastUpdateTime = _ref.lastUpdateTime;
|
|
5403
5689
|
|
|
5404
5690
|
var _useApiContext = useApiContext(),
|
|
5405
5691
|
api = _useApiContext.api;
|
|
@@ -5415,8 +5701,11 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5415
5701
|
var _usePostTafRequest = usePostTafRequest(api.postTaf),
|
|
5416
5702
|
isLoading = _usePostTafRequest.isLoading,
|
|
5417
5703
|
postTafRequest = _usePostTafRequest.doRequest,
|
|
5418
|
-
|
|
5419
|
-
|
|
5704
|
+
postError = _usePostTafRequest.error;
|
|
5705
|
+
|
|
5706
|
+
var _usePostTafRequest2 = usePostTafRequest(api.patchTaf),
|
|
5707
|
+
patchTafRequest = _usePostTafRequest2.doRequest,
|
|
5708
|
+
patchError = _usePostTafRequest2.error;
|
|
5420
5709
|
|
|
5421
5710
|
var _useTafModuleContext = useTafModuleContext(),
|
|
5422
5711
|
onValidateForm = _useTafModuleContext.onValidateForm,
|
|
@@ -5455,6 +5744,11 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5455
5744
|
isFormDisabled = _React$useState10[0],
|
|
5456
5745
|
setIsFormDisabled = _React$useState10[1];
|
|
5457
5746
|
|
|
5747
|
+
var _React$useState11 = React__default.useState(),
|
|
5748
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
5749
|
+
error = _React$useState12[0],
|
|
5750
|
+
setError = _React$useState12[1];
|
|
5751
|
+
|
|
5458
5752
|
var postTaf = function postTaf(data) {
|
|
5459
5753
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
5460
5754
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -5466,7 +5760,7 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5466
5760
|
|
|
5467
5761
|
case 2:
|
|
5468
5762
|
// callback
|
|
5469
|
-
|
|
5763
|
+
onUpdateTaf();
|
|
5470
5764
|
|
|
5471
5765
|
case 3:
|
|
5472
5766
|
case "end":
|
|
@@ -5477,25 +5771,54 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5477
5771
|
}));
|
|
5478
5772
|
};
|
|
5479
5773
|
|
|
5480
|
-
function
|
|
5481
|
-
return __awaiter(
|
|
5482
|
-
var taf;
|
|
5774
|
+
var patchTaf = function patchTaf(data) {
|
|
5775
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
5483
5776
|
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5484
5777
|
while (1) {
|
|
5485
5778
|
switch (_context2.prev = _context2.next) {
|
|
5779
|
+
case 0:
|
|
5780
|
+
_context2.prev = 0;
|
|
5781
|
+
_context2.next = 3;
|
|
5782
|
+
return patchTafRequest(data);
|
|
5783
|
+
|
|
5784
|
+
case 3:
|
|
5785
|
+
// callback
|
|
5786
|
+
onUpdateTaf();
|
|
5787
|
+
return _context2.abrupt("return", true);
|
|
5788
|
+
|
|
5789
|
+
case 7:
|
|
5790
|
+
_context2.prev = 7;
|
|
5791
|
+
_context2.t0 = _context2["catch"](0);
|
|
5792
|
+
return _context2.abrupt("return", false);
|
|
5793
|
+
|
|
5794
|
+
case 10:
|
|
5795
|
+
case "end":
|
|
5796
|
+
return _context2.stop();
|
|
5797
|
+
}
|
|
5798
|
+
}
|
|
5799
|
+
}, _callee2, null, [[0, 7]]);
|
|
5800
|
+
}));
|
|
5801
|
+
};
|
|
5802
|
+
|
|
5803
|
+
function onChangeTab(action, value) {
|
|
5804
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
5805
|
+
var taf;
|
|
5806
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
5807
|
+
while (1) {
|
|
5808
|
+
switch (_context3.prev = _context3.next) {
|
|
5486
5809
|
case 0:
|
|
5487
5810
|
if (!isFormDirty) {
|
|
5488
|
-
|
|
5811
|
+
_context3.next = 15;
|
|
5489
5812
|
break;
|
|
5490
5813
|
}
|
|
5491
5814
|
|
|
5492
|
-
|
|
5493
|
-
|
|
5815
|
+
_context3.prev = 1;
|
|
5816
|
+
_context3.next = 4;
|
|
5494
5817
|
return onValidateForm();
|
|
5495
5818
|
|
|
5496
5819
|
case 4:
|
|
5497
|
-
taf =
|
|
5498
|
-
|
|
5820
|
+
taf = _context3.sent;
|
|
5821
|
+
_context3.next = 7;
|
|
5499
5822
|
return postTaf({
|
|
5500
5823
|
taf: taf,
|
|
5501
5824
|
changeStatusTo: fromActionToStatus(tafActionToDraftAction(tafAction))
|
|
@@ -5503,19 +5826,19 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5503
5826
|
|
|
5504
5827
|
case 7:
|
|
5505
5828
|
action(value);
|
|
5506
|
-
|
|
5829
|
+
_context3.next = 13;
|
|
5507
5830
|
break;
|
|
5508
5831
|
|
|
5509
5832
|
case 10:
|
|
5510
|
-
|
|
5511
|
-
|
|
5833
|
+
_context3.prev = 10;
|
|
5834
|
+
_context3.t0 = _context3["catch"](1);
|
|
5512
5835
|
confirmDialog(CONFIRM_DIALOG_OPTIONS).then(function () {
|
|
5513
5836
|
action(value);
|
|
5514
5837
|
setError(null);
|
|
5515
5838
|
});
|
|
5516
5839
|
|
|
5517
5840
|
case 13:
|
|
5518
|
-
|
|
5841
|
+
_context3.next = 17;
|
|
5519
5842
|
break;
|
|
5520
5843
|
|
|
5521
5844
|
case 15:
|
|
@@ -5524,10 +5847,10 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5524
5847
|
|
|
5525
5848
|
case 17:
|
|
5526
5849
|
case "end":
|
|
5527
|
-
return
|
|
5850
|
+
return _context3.stop();
|
|
5528
5851
|
}
|
|
5529
5852
|
}
|
|
5530
|
-
},
|
|
5853
|
+
}, _callee3, null, [[1, 10]]);
|
|
5531
5854
|
}));
|
|
5532
5855
|
}
|
|
5533
5856
|
|
|
@@ -5560,7 +5883,8 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5560
5883
|
setActiveTafIndex(newIndex); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5561
5884
|
}, [tafList, setLocations]);
|
|
5562
5885
|
React__default.useEffect(function () {
|
|
5563
|
-
|
|
5886
|
+
setError(postError);
|
|
5887
|
+
var cancelErrorTimeout = postError && postError.type === 'CANCELLED' ? setTimeout(function () {
|
|
5564
5888
|
setError(null);
|
|
5565
5889
|
}, 10000) : null;
|
|
5566
5890
|
return function () {
|
|
@@ -5568,7 +5892,10 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5568
5892
|
clearTimeout(cancelErrorTimeout);
|
|
5569
5893
|
}
|
|
5570
5894
|
};
|
|
5571
|
-
}, [
|
|
5895
|
+
}, [postError]);
|
|
5896
|
+
React__default.useEffect(function () {
|
|
5897
|
+
setError(patchError);
|
|
5898
|
+
}, [patchError]);
|
|
5572
5899
|
|
|
5573
5900
|
if (!tafList) {
|
|
5574
5901
|
return null;
|
|
@@ -5614,6 +5941,13 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5614
5941
|
tafFromBackend: lastCurrentTaf,
|
|
5615
5942
|
timeSlot: timeSlot,
|
|
5616
5943
|
onChangeTimeSlot: onChangeTimeSlot
|
|
5944
|
+
})), /*#__PURE__*/React__default.createElement(Grid, {
|
|
5945
|
+
item: true,
|
|
5946
|
+
xs: 12,
|
|
5947
|
+
sm: 3
|
|
5948
|
+
}, lastUpdateTime && /*#__PURE__*/React__default.createElement(LastUpdateTime, {
|
|
5949
|
+
lastUpdateTime: lastUpdateTime,
|
|
5950
|
+
onUpdateTaf: onUpdateTaf
|
|
5617
5951
|
}))), /*#__PURE__*/React__default.createElement(Grid, {
|
|
5618
5952
|
container: true,
|
|
5619
5953
|
flexGrow: 1,
|
|
@@ -5663,6 +5997,7 @@ var TafLayout = function TafLayout(_ref) {
|
|
|
5663
5997
|
isFormDisabled: isFormDisabled,
|
|
5664
5998
|
setIsFormDisabled: setIsFormDisabled,
|
|
5665
5999
|
postTaf: postTaf,
|
|
6000
|
+
patchTaf: patchTaf,
|
|
5666
6001
|
isLoading: isLoading,
|
|
5667
6002
|
error: error
|
|
5668
6003
|
});
|
|
@@ -5704,41 +6039,78 @@ var TafWrapper = function TafWrapper(_a) {
|
|
|
5704
6039
|
}, children)));
|
|
5705
6040
|
};
|
|
5706
6041
|
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
* You may obtain a copy of the License at
|
|
5711
|
-
*
|
|
5712
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5713
|
-
*
|
|
5714
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5715
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5716
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5717
|
-
* See the License for the specific language governing permissions and
|
|
5718
|
-
* limitations under the License.
|
|
5719
|
-
*
|
|
5720
|
-
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5721
|
-
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
5722
|
-
* */
|
|
6042
|
+
var getCurrentDate = function getCurrentDate() {
|
|
6043
|
+
return moment.utc().format('HH:mm');
|
|
6044
|
+
};
|
|
5723
6045
|
|
|
5724
6046
|
var TafModule = function TafModule() {
|
|
5725
6047
|
var _useApiContext = useApiContext(),
|
|
5726
6048
|
api = _useApiContext.api;
|
|
5727
6049
|
|
|
5728
|
-
var
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
fetchNewTafList = _useApi.fetchApiData;
|
|
6050
|
+
var _React$useState = React.useState([]),
|
|
6051
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
6052
|
+
tafList = _React$useState2[0],
|
|
6053
|
+
setTafList = _React$useState2[1];
|
|
5733
6054
|
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
6055
|
+
var _React$useState3 = React.useState(true),
|
|
6056
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
6057
|
+
isLoading = _React$useState4[0],
|
|
6058
|
+
setIsLoading = _React$useState4[1];
|
|
6059
|
+
|
|
6060
|
+
var _React$useState5 = React.useState(null),
|
|
6061
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
6062
|
+
getTafListError = _React$useState6[0],
|
|
6063
|
+
setError = _React$useState6[1];
|
|
6064
|
+
|
|
6065
|
+
var _React$useState7 = React.useState(),
|
|
6066
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
6067
|
+
lastUpdateTime = _React$useState8[0],
|
|
6068
|
+
setLastUpdateTime = _React$useState8[1];
|
|
6069
|
+
|
|
6070
|
+
var fetchNewTafList = function fetchNewTafList() {
|
|
6071
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
6072
|
+
var result;
|
|
6073
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6074
|
+
while (1) {
|
|
6075
|
+
switch (_context.prev = _context.next) {
|
|
6076
|
+
case 0:
|
|
6077
|
+
setIsLoading(true);
|
|
6078
|
+
setError(null);
|
|
6079
|
+
_context.prev = 2;
|
|
6080
|
+
_context.next = 5;
|
|
6081
|
+
return api.getTafList();
|
|
6082
|
+
|
|
6083
|
+
case 5:
|
|
6084
|
+
result = _context.sent;
|
|
6085
|
+
setTafList(result.data);
|
|
6086
|
+
setIsLoading(false);
|
|
6087
|
+
setLastUpdateTime(getCurrentDate());
|
|
6088
|
+
_context.next = 15;
|
|
6089
|
+
break;
|
|
6090
|
+
|
|
6091
|
+
case 11:
|
|
6092
|
+
_context.prev = 11;
|
|
6093
|
+
_context.t0 = _context["catch"](2);
|
|
6094
|
+
setError(_context.t0);
|
|
6095
|
+
setIsLoading(false);
|
|
6096
|
+
|
|
6097
|
+
case 15:
|
|
6098
|
+
case "end":
|
|
6099
|
+
return _context.stop();
|
|
6100
|
+
}
|
|
6101
|
+
}
|
|
6102
|
+
}, _callee, null, [[2, 11]]);
|
|
6103
|
+
}));
|
|
6104
|
+
};
|
|
5737
6105
|
|
|
5738
|
-
var
|
|
5739
|
-
fetchNewTafList(
|
|
6106
|
+
var onUpdateTaf = function onUpdateTaf() {
|
|
6107
|
+
fetchNewTafList();
|
|
5740
6108
|
};
|
|
5741
6109
|
|
|
6110
|
+
React.useEffect(function () {
|
|
6111
|
+
fetchNewTafList(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6112
|
+
}, []);
|
|
6113
|
+
usePoller([tafList, getTafListError], fetchNewTafList);
|
|
5742
6114
|
var hasTafListError = getTafListError !== null;
|
|
5743
6115
|
return /*#__PURE__*/React.createElement(Box, {
|
|
5744
6116
|
component: "div",
|
|
@@ -5763,7 +6135,8 @@ var TafModule = function TafModule() {
|
|
|
5763
6135
|
}
|
|
5764
6136
|
}), /*#__PURE__*/React.createElement(TafLayout, {
|
|
5765
6137
|
tafList: tafList,
|
|
5766
|
-
|
|
6138
|
+
onUpdateTaf: onUpdateTaf,
|
|
6139
|
+
lastUpdateTime: lastUpdateTime
|
|
5767
6140
|
}));
|
|
5768
6141
|
};
|
|
5769
6142
|
|
|
@@ -5785,10 +6158,32 @@ var createApi$1 = function createApi(url, appUrl, auth, setAuth, authTokenUrl, a
|
|
|
5785
6158
|
return axiosInstance.post.apply(axiosInstance, ['/taf2tac'].concat([Object.assign({}, tafData)].concat(_toConsumableArray(signal ? [{
|
|
5786
6159
|
signal: signal
|
|
5787
6160
|
}] : []))));
|
|
6161
|
+
},
|
|
6162
|
+
patchTaf: function patchTaf(formData) {
|
|
6163
|
+
return axiosInstance.patch('/taf', Object.assign({}, formData));
|
|
5788
6164
|
}
|
|
5789
6165
|
};
|
|
5790
6166
|
};
|
|
5791
6167
|
|
|
6168
|
+
/* *
|
|
6169
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6170
|
+
* you may not use this file except in compliance with the License.
|
|
6171
|
+
* You may obtain a copy of the License at
|
|
6172
|
+
*
|
|
6173
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6174
|
+
*
|
|
6175
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6176
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6177
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6178
|
+
* See the License for the specific language governing permissions and
|
|
6179
|
+
* limitations under the License.
|
|
6180
|
+
*
|
|
6181
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6182
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
6183
|
+
* */
|
|
6184
|
+
|
|
6185
|
+
var MOCK_USERNAME = 'user.name';
|
|
6186
|
+
|
|
5792
6187
|
var currentDate = moment.utc().format('YYYY-MM-DD');
|
|
5793
6188
|
var tomorrowDate = moment.utc().add(1, 'day').format('YYYY-MM-DD');
|
|
5794
6189
|
var airportPeriod = 6;
|
|
@@ -5827,6 +6222,7 @@ var _validDateRange5 = validDateRange(moment.utc().add(-6, 'hours'), airportPeri
|
|
|
5827
6222
|
var fakeTafList = [{
|
|
5828
6223
|
creationDate: upcomingValidDateStart,
|
|
5829
6224
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6225
|
+
editor: MOCK_USERNAME,
|
|
5830
6226
|
taf: {
|
|
5831
6227
|
uuid: '5f9583fjdf0f337925',
|
|
5832
6228
|
baseTime: upcomingValidDateStart,
|
|
@@ -5846,6 +6242,7 @@ var fakeTafList = [{
|
|
|
5846
6242
|
}, {
|
|
5847
6243
|
creationDate: upcomingValidDateStart,
|
|
5848
6244
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6245
|
+
editor: null,
|
|
5849
6246
|
taf: {
|
|
5850
6247
|
uuid: '5f9583fjd111137925',
|
|
5851
6248
|
baseTime: upcomingValidDateStart,
|
|
@@ -5871,6 +6268,7 @@ var fakeTafList = [{
|
|
|
5871
6268
|
}, {
|
|
5872
6269
|
creationDate: upcomingValidDateStart,
|
|
5873
6270
|
canbe: ['CANCELLED', 'AMENDED', 'DISCARDED'],
|
|
6271
|
+
editor: null,
|
|
5874
6272
|
taf: {
|
|
5875
6273
|
uuid: '754905485',
|
|
5876
6274
|
baseTime: upcomingValidDateStart,
|
|
@@ -5928,6 +6326,7 @@ var fakeTafList = [{
|
|
|
5928
6326
|
}, {
|
|
5929
6327
|
creationDate: upcomingValidDateStart,
|
|
5930
6328
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6329
|
+
editor: MOCK_USERNAME,
|
|
5931
6330
|
taf: {
|
|
5932
6331
|
uuid: '43545345345',
|
|
5933
6332
|
issueDate: upcomingValidDateStart,
|
|
@@ -5998,6 +6397,7 @@ var fakeTafList = [{
|
|
|
5998
6397
|
}, {
|
|
5999
6398
|
creationDate: upcomingValidDateStart,
|
|
6000
6399
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6400
|
+
editor: null,
|
|
6001
6401
|
taf: {
|
|
6002
6402
|
uuid: '5f9583fjdf45ff4330f337925',
|
|
6003
6403
|
issueDate: upcomingValidDateStart,
|
|
@@ -6053,6 +6453,7 @@ var fakeTafList = [{
|
|
|
6053
6453
|
}, {
|
|
6054
6454
|
creationDate: upcomingValidDateStart,
|
|
6055
6455
|
canbe: ['AMENDED'],
|
|
6456
|
+
editor: null,
|
|
6056
6457
|
taf: {
|
|
6057
6458
|
uuid: '5464565464',
|
|
6058
6459
|
previousId: '5445fghrfg3546456',
|
|
@@ -6094,6 +6495,7 @@ var fakeTafList = [{
|
|
|
6094
6495
|
}, {
|
|
6095
6496
|
creationDate: upcomingValidDateStart,
|
|
6096
6497
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6498
|
+
editor: 'max.jansen',
|
|
6097
6499
|
taf: {
|
|
6098
6500
|
uuid: 'gh56734fghfgh',
|
|
6099
6501
|
previousId: '8574jnf93475',
|
|
@@ -6135,6 +6537,7 @@ var fakeTafList = [{
|
|
|
6135
6537
|
}, {
|
|
6136
6538
|
creationDate: currentValidDateStart,
|
|
6137
6539
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6540
|
+
editor: null,
|
|
6138
6541
|
taf: {
|
|
6139
6542
|
uuid: 'giskdj09845872039',
|
|
6140
6543
|
issueDate: currentValidDateStart,
|
|
@@ -6174,6 +6577,7 @@ var fakeTafList = [{
|
|
|
6174
6577
|
}, {
|
|
6175
6578
|
creationDate: currentValidDateStart,
|
|
6176
6579
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6580
|
+
editor: null,
|
|
6177
6581
|
taf: {
|
|
6178
6582
|
uuid: 'ghskdj09845872039',
|
|
6179
6583
|
baseTime: currentValidDateStart,
|
|
@@ -6193,6 +6597,7 @@ var fakeTafList = [{
|
|
|
6193
6597
|
}, {
|
|
6194
6598
|
creationDate: currentValidDateStart,
|
|
6195
6599
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6600
|
+
editor: null,
|
|
6196
6601
|
taf: {
|
|
6197
6602
|
uuid: 'ghskdj09845872040',
|
|
6198
6603
|
issueDate: currentValidDateStart,
|
|
@@ -6213,6 +6618,7 @@ var fakeTafList = [{
|
|
|
6213
6618
|
}, {
|
|
6214
6619
|
creationDate: "".concat(currentDate, "T06:00:00Z"),
|
|
6215
6620
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6621
|
+
editor: null,
|
|
6216
6622
|
taf: {
|
|
6217
6623
|
uuid: 'ghskdj09845872041',
|
|
6218
6624
|
issueDate: currentValidDateStart,
|
|
@@ -6233,6 +6639,7 @@ var fakeTafList = [{
|
|
|
6233
6639
|
}, {
|
|
6234
6640
|
creationDate: "".concat(currentDate, "T06:00:00Z"),
|
|
6235
6641
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6642
|
+
editor: null,
|
|
6236
6643
|
taf: {
|
|
6237
6644
|
uuid: 'ghskdj09845872042',
|
|
6238
6645
|
issueDate: currentValidDateStart,
|
|
@@ -6253,6 +6660,7 @@ var fakeTafList = [{
|
|
|
6253
6660
|
}, {
|
|
6254
6661
|
creationDate: "".concat(currentDate, "T06:00:00Z"),
|
|
6255
6662
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6663
|
+
editor: null,
|
|
6256
6664
|
taf: {
|
|
6257
6665
|
uuid: 'ghskdj09845872043',
|
|
6258
6666
|
issueDate: currentValidDateStart,
|
|
@@ -6273,6 +6681,7 @@ var fakeTafList = [{
|
|
|
6273
6681
|
}, {
|
|
6274
6682
|
creationDate: expiredValidDateStart,
|
|
6275
6683
|
canbe: [],
|
|
6684
|
+
editor: null,
|
|
6276
6685
|
taf: {
|
|
6277
6686
|
uuid: 'sdkjhsdf90845890',
|
|
6278
6687
|
issueDate: expiredValidDateStart,
|
|
@@ -6337,6 +6746,7 @@ var fakeTafList = [{
|
|
|
6337
6746
|
var fakeNewTaf = {
|
|
6338
6747
|
creationDate: "".concat(currentDate, "T12:00:00Z"),
|
|
6339
6748
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6749
|
+
editor: null,
|
|
6340
6750
|
taf: {
|
|
6341
6751
|
type: 'NORMAL',
|
|
6342
6752
|
messageType: 'ORG',
|
|
@@ -6357,6 +6767,7 @@ var fakeNewTaf = {
|
|
|
6357
6767
|
({
|
|
6358
6768
|
creationDate: "2022-01-06T12:00:00Z",
|
|
6359
6769
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6770
|
+
editor: MOCK_USERNAME,
|
|
6360
6771
|
taf: Object.assign(Object.assign({}, fakeNewTaf.taf), {
|
|
6361
6772
|
baseTime: "2022-01-06T12:00:00Z",
|
|
6362
6773
|
validDateStart: "2022-01-06T12:00:00Z",
|
|
@@ -6372,6 +6783,7 @@ var fakeNewTaf = {
|
|
|
6372
6783
|
var fakePublishedTaf = {
|
|
6373
6784
|
creationDate: "".concat(currentDate, "T12:00:00Z"),
|
|
6374
6785
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6786
|
+
editor: null,
|
|
6375
6787
|
taf: {
|
|
6376
6788
|
uuid: 'slsdkjg-023895',
|
|
6377
6789
|
issueDate: "".concat(currentDate, "T12:00:00Z"),
|
|
@@ -6447,7 +6859,9 @@ var fakePublishedTaf = {
|
|
|
6447
6859
|
({
|
|
6448
6860
|
creationDate: "2022-01-06T12:00:00Z",
|
|
6449
6861
|
canbe: ['CANCELLED', 'AMENDED', 'CORRECTED'],
|
|
6862
|
+
editor: MOCK_USERNAME,
|
|
6450
6863
|
taf: Object.assign(Object.assign({}, fakePublishedTaf.taf), {
|
|
6864
|
+
uuid: 'sowi3u4o-lsdjflsk',
|
|
6451
6865
|
location: 'EHGG',
|
|
6452
6866
|
baseTime: "2022-01-06T12:00:00Z",
|
|
6453
6867
|
issueDate: "2022-01-06T12:00:00Z",
|
|
@@ -6512,6 +6926,7 @@ var fakePublishedTaf = {
|
|
|
6512
6926
|
var fakeDraftTaf = {
|
|
6513
6927
|
creationDate: "".concat(currentDate, "T18:00:00Z"),
|
|
6514
6928
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6929
|
+
editor: null,
|
|
6515
6930
|
taf: {
|
|
6516
6931
|
uuid: '5f9583fjdf0f337925',
|
|
6517
6932
|
baseTime: "".concat(currentDate, "T18:00:00Z"),
|
|
@@ -6550,6 +6965,7 @@ var fakeDraftTaf = {
|
|
|
6550
6965
|
({
|
|
6551
6966
|
creationDate: "2022-01-06T18:00:00Z",
|
|
6552
6967
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6968
|
+
editor: MOCK_USERNAME,
|
|
6553
6969
|
taf: Object.assign(Object.assign({}, fakeDraftTaf.taf), {
|
|
6554
6970
|
baseTime: "2022-01-06T18:00:00Z",
|
|
6555
6971
|
validDateStart: "2022-01-06T18:00:00Z",
|
|
@@ -6565,6 +6981,7 @@ var fakeDraftTaf = {
|
|
|
6565
6981
|
var fakeDraftAmendmentTaf = {
|
|
6566
6982
|
creationDate: "".concat(currentDate, "T14:00:00Z"),
|
|
6567
6983
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
6984
|
+
editor: null,
|
|
6568
6985
|
taf: {
|
|
6569
6986
|
uuid: '954905487',
|
|
6570
6987
|
previousId: '5f9583fjdf45ff4330f337925',
|
|
@@ -6625,6 +7042,7 @@ var fakeDraftAmendmentTaf = {
|
|
|
6625
7042
|
({
|
|
6626
7043
|
creationDate: "2022-01-06T14:00:00Z",
|
|
6627
7044
|
canbe: ['DRAFTED', 'DISCARDED', 'PUBLISHED'],
|
|
7045
|
+
editor: null,
|
|
6628
7046
|
taf: Object.assign(Object.assign({}, fakeDraftAmendmentTaf.taf), {
|
|
6629
7047
|
location: 'EHRD',
|
|
6630
7048
|
issueDate: "2022-01-06T14:00:00Z",
|
|
@@ -6645,6 +7063,7 @@ var fakeDraftAmendmentTaf = {
|
|
|
6645
7063
|
var fakeAmendmentTaf = {
|
|
6646
7064
|
creationDate: "".concat(currentDate, "T14:00:00Z"),
|
|
6647
7065
|
canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
|
|
7066
|
+
editor: null,
|
|
6648
7067
|
taf: {
|
|
6649
7068
|
uuid: '754905486',
|
|
6650
7069
|
previousId: '5f9583fjdf45ff4330f337925',
|
|
@@ -6688,6 +7107,7 @@ var fakeAmendmentTaf = {
|
|
|
6688
7107
|
({
|
|
6689
7108
|
creationDate: "2022-01-06T14:00:00Z",
|
|
6690
7109
|
canbe: ['CANCELLED', 'CORRECTED', 'AMENDED'],
|
|
7110
|
+
editor: MOCK_USERNAME,
|
|
6691
7111
|
taf: Object.assign(Object.assign({}, fakeAmendmentTaf.taf), {
|
|
6692
7112
|
uuid: '7549058980',
|
|
6693
7113
|
issueDate: "2022-01-06T14:00:00Z",
|
|
@@ -6722,6 +7142,14 @@ var fakePromise = function fakePromise(withRandomError) {
|
|
|
6722
7142
|
});
|
|
6723
7143
|
};
|
|
6724
7144
|
|
|
7145
|
+
var fakeUpdatedTafList = _toConsumableArray(fakeTafList);
|
|
7146
|
+
|
|
7147
|
+
var setFakeUpdatedList = function setFakeUpdatedList(newList) {
|
|
7148
|
+
fakeUpdatedTafList = newList;
|
|
7149
|
+
};
|
|
7150
|
+
var getFakeUpdatedList = function getFakeUpdatedList() {
|
|
7151
|
+
return fakeUpdatedTafList;
|
|
7152
|
+
};
|
|
6725
7153
|
var fakeAxiosInstance = {
|
|
6726
7154
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
|
|
6727
7155
|
get: function get(_url, _params) {
|
|
@@ -6730,6 +7158,10 @@ var fakeAxiosInstance = {
|
|
|
6730
7158
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
|
|
6731
7159
|
post: function post(_url, _params, _signal) {
|
|
6732
7160
|
return fakePromise(false, _signal);
|
|
7161
|
+
},
|
|
7162
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types
|
|
7163
|
+
patch: function patch(_url, _params, _signal) {
|
|
7164
|
+
return fakePromise(false, _signal);
|
|
6733
7165
|
}
|
|
6734
7166
|
};
|
|
6735
7167
|
var createApi = function createApi() {
|
|
@@ -6739,7 +7171,7 @@ var createApi = function createApi() {
|
|
|
6739
7171
|
console.log('Retrieving new TAF list');
|
|
6740
7172
|
return fakeAxiosInstance.get('/taflist').then(function () {
|
|
6741
7173
|
return {
|
|
6742
|
-
data:
|
|
7174
|
+
data: getFakeUpdatedList()
|
|
6743
7175
|
};
|
|
6744
7176
|
});
|
|
6745
7177
|
},
|
|
@@ -6758,6 +7190,21 @@ var createApi = function createApi() {
|
|
|
6758
7190
|
data: fakeTafTac
|
|
6759
7191
|
};
|
|
6760
7192
|
});
|
|
7193
|
+
},
|
|
7194
|
+
patchTaf: function patchTaf(_patchTaf) {
|
|
7195
|
+
var updatedList = getFakeUpdatedList().map(function (tafFromBackend) {
|
|
7196
|
+
if (tafFromBackend.taf.uuid === _patchTaf.taf.uuid) {
|
|
7197
|
+
return Object.assign(Object.assign({}, tafFromBackend), {
|
|
7198
|
+
editor: _patchTaf.editor
|
|
7199
|
+
});
|
|
7200
|
+
}
|
|
7201
|
+
|
|
7202
|
+
return tafFromBackend;
|
|
7203
|
+
});
|
|
7204
|
+
setFakeUpdatedList(updatedList); // eslint-disable-next-line no-console
|
|
7205
|
+
|
|
7206
|
+
console.log("The new editor of the taf will be ".concat(_patchTaf.editor || 'empty'));
|
|
7207
|
+
return fakeAxiosInstance.patch('/taf', _patchTaf);
|
|
6761
7208
|
}
|
|
6762
7209
|
};
|
|
6763
7210
|
};
|