@opengeoweb/sigmet-airmet 9.1.0 → 9.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/index.esm.js +72 -32
- package/package.json +1 -1
- package/src/lib/components/MetInfoWrapper/DownloadSigmetAirmetConfigWrapper.d.ts +1 -0
- package/src/lib/components/MetInfoWrapper/utils.d.ts +1 -0
- package/src/lib/components/ProductForms/SigmetForm/SigmetForm.d.ts +1 -0
- package/src/lib/components/ProductForms/utils.d.ts +7 -1
package/index.esm.js
CHANGED
|
@@ -14,6 +14,7 @@ import 'react-dom';
|
|
|
14
14
|
import { mapSelectors, syncGroupsActions, mapStoreActions, defaultLayers, syncConstants } from '@opengeoweb/store';
|
|
15
15
|
import { LayerManagerMapButtonConnect, LegendMapButtonConnect, MultiDimensionSelectMapButtonsConnect, MapViewConnect, LegendConnect, LayerManagerConnect } from '@opengeoweb/core';
|
|
16
16
|
import { TimeSliderConnect } from '@opengeoweb/timeslider';
|
|
17
|
+
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
17
18
|
import { jsx } from 'react/jsx-runtime';
|
|
18
19
|
|
|
19
20
|
function _iterableToArrayLimit(r, l) {
|
|
@@ -1046,7 +1047,11 @@ var getProductFormMode = function getProductFormMode(canBeOptions, productListIt
|
|
|
1046
1047
|
var buttonStyle = {
|
|
1047
1048
|
minWidth: 96
|
|
1048
1049
|
};
|
|
1049
|
-
var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(
|
|
1050
|
+
var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(_ref) {
|
|
1051
|
+
var canBe = _ref.canBe,
|
|
1052
|
+
onButtonPress = _ref.onButtonPress,
|
|
1053
|
+
_ref$areActionsDisabl = _ref.areActionsDisabled,
|
|
1054
|
+
areActionsDisabled = _ref$areActionsDisabl === void 0 ? false : _ref$areActionsDisabl;
|
|
1050
1055
|
var hasDiscardButton = canBe.includes('DISCARDED');
|
|
1051
1056
|
var onDiscard = function onDiscard() {
|
|
1052
1057
|
return onButtonPress('DISCARDED');
|
|
@@ -1068,13 +1073,15 @@ var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(can
|
|
|
1068
1073
|
action: onDiscard
|
|
1069
1074
|
}] : []), _toConsumableArray(hasSaveButton ? [{
|
|
1070
1075
|
text: 'Save',
|
|
1071
|
-
action: onSave
|
|
1076
|
+
action: onSave,
|
|
1077
|
+
isDisabled: areActionsDisabled
|
|
1072
1078
|
}] : []), _toConsumableArray(hasCancelButton ? [{
|
|
1073
1079
|
text: 'Cancel',
|
|
1074
1080
|
action: onCancel
|
|
1075
1081
|
}] : []), _toConsumableArray(hasPublishButton ? [{
|
|
1076
1082
|
text: 'Publish',
|
|
1077
|
-
action: onPublish
|
|
1083
|
+
action: onPublish,
|
|
1084
|
+
isDisabled: areActionsDisabled
|
|
1078
1085
|
}] : []));
|
|
1079
1086
|
return /*#__PURE__*/React.createElement(Box$2, {
|
|
1080
1087
|
sx: {
|
|
@@ -1098,7 +1105,8 @@ var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(can
|
|
|
1098
1105
|
variant: "tertiary",
|
|
1099
1106
|
onClick: onSave,
|
|
1100
1107
|
sx: buttonStyle,
|
|
1101
|
-
"data-testid": "productform-dialog-draft"
|
|
1108
|
+
"data-testid": "productform-dialog-draft",
|
|
1109
|
+
disabled: areActionsDisabled
|
|
1102
1110
|
}, "Save"), hasCancelButton && /*#__PURE__*/React.createElement(Button, {
|
|
1103
1111
|
variant: "tertiary",
|
|
1104
1112
|
onClick: onCancel,
|
|
@@ -1108,7 +1116,8 @@ var getProductFormLifecycleButtons = function getProductFormLifecycleButtons(can
|
|
|
1108
1116
|
variant: "primary",
|
|
1109
1117
|
onClick: onPublish,
|
|
1110
1118
|
sx: buttonStyle,
|
|
1111
|
-
"data-testid": "productform-dialog-publish"
|
|
1119
|
+
"data-testid": "productform-dialog-publish",
|
|
1120
|
+
disabled: areActionsDisabled
|
|
1112
1121
|
}, "Publish")), /*#__PURE__*/React.createElement(Box$2, {
|
|
1113
1122
|
display: {
|
|
1114
1123
|
lg: 'none'
|
|
@@ -2557,6 +2566,7 @@ var Type = function Type(_ref) {
|
|
|
2557
2566
|
isReadOnly: isReadOnly,
|
|
2558
2567
|
size: "small",
|
|
2559
2568
|
"data-testid": "type",
|
|
2569
|
+
defaultValue: "NORMAL",
|
|
2560
2570
|
onChange: function onChange() {
|
|
2561
2571
|
triggerValidations(['validDateStart', 'validDateEnd'], getValues, trigger);
|
|
2562
2572
|
_onChange();
|
|
@@ -8239,7 +8249,8 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
8239
8249
|
_ref$showMap = _ref.showMap,
|
|
8240
8250
|
showMap = _ref$showMap === void 0 ? true : _ref$showMap,
|
|
8241
8251
|
_ref$productConfig = _ref.productConfig,
|
|
8242
|
-
productConfig = _ref$productConfig === void 0 ? sigmetConfig : _ref$productConfig
|
|
8252
|
+
productConfig = _ref$productConfig === void 0 ? sigmetConfig : _ref$productConfig,
|
|
8253
|
+
setDialogActionsDisabled = _ref.setDialogActionsDisabled;
|
|
8243
8254
|
var _useApiContext = useApiContext(),
|
|
8244
8255
|
api = _useApiContext.api;
|
|
8245
8256
|
var _useMapDrawTool = useMapDrawTool({
|
|
@@ -8351,10 +8362,11 @@ var SigmetForm = function SigmetForm(_ref) {
|
|
|
8351
8362
|
};
|
|
8352
8363
|
React__default.useEffect(function () {
|
|
8353
8364
|
var isInDrawMode = activeStartTool !== '' || activeEndTool !== '';
|
|
8365
|
+
setDialogActionsDisabled && setDialogActionsDisabled(isInDrawMode);
|
|
8354
8366
|
if (!isReadOnly && isInDrawMode !== isDisabled) {
|
|
8355
8367
|
setIsDisabled(isInDrawMode);
|
|
8356
8368
|
}
|
|
8357
|
-
}, [activeStartTool, activeEndTool, isReadOnly, isDisabled]);
|
|
8369
|
+
}, [activeStartTool, activeEndTool, isReadOnly, isDisabled, setDialogActionsDisabled]);
|
|
8358
8370
|
var _useConditionalFields = useConditionalFields$1(productConfig),
|
|
8359
8371
|
hasVolcanicAshes = _useConditionalFields.hasVolcanicAshes,
|
|
8360
8372
|
omitChange = _useConditionalFields.omitChange;
|
|
@@ -9138,6 +9150,7 @@ var ProductListRow = function ProductListRow(_ref2) {
|
|
|
9138
9150
|
|
|
9139
9151
|
var ERROR_CONFIG = 'An error has occurred while loading the config';
|
|
9140
9152
|
var ERROR_BACKEND = 'An error has occurred while retrieving the list, please try again';
|
|
9153
|
+
var ERROR_AUTH$1 = 'This feature is protected by authentication.';
|
|
9141
9154
|
var validateConfig = function validateConfig(productType, productConfig) {
|
|
9142
9155
|
var validatedConfig = productType === 'sigmet' ? validateSigmet(productConfig) : validateAirmet(productConfig);
|
|
9143
9156
|
if (validatedConfig !== true && Array.isArray(validatedConfig)) {
|
|
@@ -9163,54 +9176,72 @@ var useProductApi = function useProductApi(productType, productConfig) {
|
|
|
9163
9176
|
var _useApiContext = useApiContext(),
|
|
9164
9177
|
api = _useApiContext.api;
|
|
9165
9178
|
var requestList = productType === 'sigmet' ? api.getSigmetList : api.getAirmetList;
|
|
9179
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
9180
|
+
isLoggedIn = _useAuthenticationCon.isLoggedIn;
|
|
9166
9181
|
var updateState = function updateState(newState) {
|
|
9167
9182
|
if (isMounted.current) {
|
|
9168
|
-
setState(
|
|
9183
|
+
setState(function (currentState) {
|
|
9184
|
+
return Object.assign(Object.assign({}, currentState), newState);
|
|
9185
|
+
});
|
|
9169
9186
|
}
|
|
9170
9187
|
};
|
|
9171
9188
|
var fetchNewData = function fetchNewData() {
|
|
9172
9189
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
9173
|
-
var _a, _yield$requestList, data,
|
|
9190
|
+
var _a, newError, _yield$requestList, data, _newError;
|
|
9174
9191
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9175
9192
|
while (1) switch (_context.prev = _context.next) {
|
|
9176
9193
|
case 0:
|
|
9194
|
+
if (!(!isLoggedIn && Array.isArray(isLoggedIn))) {
|
|
9195
|
+
_context.next = 4;
|
|
9196
|
+
break;
|
|
9197
|
+
}
|
|
9198
|
+
newError = {
|
|
9199
|
+
name: ERROR_AUTH$1,
|
|
9200
|
+
message: createReadableErrorMessage(isLoggedIn)
|
|
9201
|
+
};
|
|
9202
|
+
updateState(Object.assign(Object.assign({}, state), {
|
|
9203
|
+
error: newError,
|
|
9204
|
+
isLoading: false
|
|
9205
|
+
}));
|
|
9206
|
+
return _context.abrupt("return");
|
|
9207
|
+
case 4:
|
|
9177
9208
|
if (!(((_a = state.error) === null || _a === void 0 ? void 0 : _a.name) === ERROR_CONFIG || state.isLoading)) {
|
|
9178
|
-
_context.next =
|
|
9209
|
+
_context.next = 6;
|
|
9179
9210
|
break;
|
|
9180
9211
|
}
|
|
9181
9212
|
return _context.abrupt("return");
|
|
9182
|
-
case
|
|
9213
|
+
case 6:
|
|
9183
9214
|
updateState(Object.assign(Object.assign({}, state), {
|
|
9184
9215
|
isLoading: true,
|
|
9185
9216
|
error: undefined
|
|
9186
9217
|
}));
|
|
9187
|
-
_context.prev =
|
|
9188
|
-
_context.next =
|
|
9218
|
+
_context.prev = 7;
|
|
9219
|
+
_context.next = 10;
|
|
9189
9220
|
return requestList();
|
|
9190
|
-
case
|
|
9221
|
+
case 10:
|
|
9191
9222
|
_yield$requestList = _context.sent;
|
|
9192
9223
|
data = _yield$requestList.data;
|
|
9193
9224
|
updateState(Object.assign(Object.assign({}, state), {
|
|
9194
9225
|
result: data,
|
|
9195
9226
|
isLoading: false
|
|
9196
9227
|
}));
|
|
9197
|
-
_context.next =
|
|
9228
|
+
_context.next = 19;
|
|
9198
9229
|
break;
|
|
9199
|
-
case
|
|
9200
|
-
_context.prev =
|
|
9201
|
-
_context.t0 = _context["catch"](
|
|
9202
|
-
|
|
9230
|
+
case 15:
|
|
9231
|
+
_context.prev = 15;
|
|
9232
|
+
_context.t0 = _context["catch"](7);
|
|
9233
|
+
_newError = Object.assign(Object.assign({}, _context.t0), {
|
|
9203
9234
|
name: ERROR_BACKEND
|
|
9204
9235
|
});
|
|
9205
9236
|
updateState(Object.assign(Object.assign({}, state), {
|
|
9206
|
-
error:
|
|
9237
|
+
error: _newError,
|
|
9207
9238
|
isLoading: false
|
|
9208
9239
|
}));
|
|
9209
|
-
case
|
|
9240
|
+
case 19:
|
|
9210
9241
|
case "end":
|
|
9211
9242
|
return _context.stop();
|
|
9212
9243
|
}
|
|
9213
|
-
}, _callee, null, [[
|
|
9244
|
+
}, _callee, null, [[7, 15]]);
|
|
9214
9245
|
}));
|
|
9215
9246
|
};
|
|
9216
9247
|
React__default.useEffect(function () {
|
|
@@ -9252,7 +9283,7 @@ var ProductList = function ProductList(_ref) {
|
|
|
9252
9283
|
error = _ref.error,
|
|
9253
9284
|
onClickProductRow = _ref.onClickProductRow,
|
|
9254
9285
|
onClickNewProduct = _ref.onClickNewProduct;
|
|
9255
|
-
var shouldHideCreateNew = error && error.name === ERROR_CONFIG;
|
|
9286
|
+
var shouldHideCreateNew = error && (error.name === ERROR_AUTH$1 || error.name === ERROR_CONFIG);
|
|
9256
9287
|
return /*#__PURE__*/React__default.createElement(Grid, {
|
|
9257
9288
|
container: true,
|
|
9258
9289
|
direction: "column",
|
|
@@ -9286,7 +9317,7 @@ var ProductList = function ProductList(_ref) {
|
|
|
9286
9317
|
}
|
|
9287
9318
|
}), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
9288
9319
|
severity: "error",
|
|
9289
|
-
title: error.name
|
|
9320
|
+
title: error.name,
|
|
9290
9321
|
info: error.message ? error.message : '',
|
|
9291
9322
|
dataTestId: "productList-alert"
|
|
9292
9323
|
}), productList && /*#__PURE__*/React__default.createElement(List, {
|
|
@@ -14059,6 +14090,10 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
14059
14090
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
14060
14091
|
errorStoreMessageText = _React$useState6[0],
|
|
14061
14092
|
setErrorStoreMessageText = _React$useState6[1];
|
|
14093
|
+
var _React$useState7 = React.useState(false),
|
|
14094
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
14095
|
+
dialogActionsDisabled = _React$useState8[0],
|
|
14096
|
+
setDialogActionsDisabled = _React$useState8[1];
|
|
14062
14097
|
var postProduct = function postProduct(productToPost, newStatus) {
|
|
14063
14098
|
var uuid = product !== null && product.uuid ? product.uuid : null;
|
|
14064
14099
|
var postProductParam = productType === 'sigmet' ? createSigmetPostParameter(productToPost, newStatus, uuid) : createAirmetPostParameter(productToPost, newStatus, uuid);
|
|
@@ -14169,7 +14204,11 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
14169
14204
|
title: "An error has occurred while saving, please try again",
|
|
14170
14205
|
info: errorStoreMessageText
|
|
14171
14206
|
}) : null,
|
|
14172
|
-
options: getProductFormLifecycleButtons(
|
|
14207
|
+
options: getProductFormLifecycleButtons({
|
|
14208
|
+
canBe: productCanBe,
|
|
14209
|
+
onButtonPress: onProductButtonPress,
|
|
14210
|
+
areActionsDisabled: dialogActionsDisabled
|
|
14211
|
+
}),
|
|
14173
14212
|
style: {
|
|
14174
14213
|
zIndex: 1000
|
|
14175
14214
|
},
|
|
@@ -14183,7 +14222,8 @@ var ProductFormDialogContent = function ProductFormDialogContent(_ref) {
|
|
|
14183
14222
|
isCancelSigmet: product !== null && isInstanceOfCancelSigmet(product),
|
|
14184
14223
|
initialSigmet: product !== null && !isInstanceOfCancelSigmet(product) ? product : null,
|
|
14185
14224
|
initialCancelSigmet: product !== null && isInstanceOfCancelSigmet(product) ? product : null,
|
|
14186
|
-
productConfig: productConfig
|
|
14225
|
+
productConfig: productConfig,
|
|
14226
|
+
setDialogActionsDisabled: setDialogActionsDisabled
|
|
14187
14227
|
}) : /*#__PURE__*/React.createElement(AirmetForm, {
|
|
14188
14228
|
mode: mode,
|
|
14189
14229
|
isCancelAirmet: product !== null && isInstanceOfCancelAirmet(product),
|
|
@@ -14288,10 +14328,7 @@ var MetInfoWrapper = function MetInfoWrapper(_ref) {
|
|
|
14288
14328
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
14289
14329
|
selectedProduct = _React$useState4[0],
|
|
14290
14330
|
setSelectedProduct = _React$useState4[1];
|
|
14291
|
-
|
|
14292
|
-
fetchNewProductList();
|
|
14293
|
-
};
|
|
14294
|
-
usePoller([productList, errorList], getNewProductList, 60000);
|
|
14331
|
+
usePoller([productList, errorList], fetchNewProductList, 60000);
|
|
14295
14332
|
React__default.useEffect(function () {
|
|
14296
14333
|
if (selectedProduct) {
|
|
14297
14334
|
toggleDialogOpen();
|
|
@@ -14302,7 +14339,7 @@ var MetInfoWrapper = function MetInfoWrapper(_ref) {
|
|
|
14302
14339
|
var shouldRefreshList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
14303
14340
|
// Refresh list on closing dialog
|
|
14304
14341
|
if (isFormDialogOpen === true && shouldRefreshList) {
|
|
14305
|
-
|
|
14342
|
+
fetchNewProductList();
|
|
14306
14343
|
}
|
|
14307
14344
|
setIsFormDialogOpen(!isFormDialogOpen);
|
|
14308
14345
|
};
|
|
@@ -14358,11 +14395,14 @@ var MetInfoWrapper = function MetInfoWrapper(_ref) {
|
|
|
14358
14395
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
14359
14396
|
* */
|
|
14360
14397
|
var ERROR_TITLE = 'Something went wrong with loading the configuration file';
|
|
14398
|
+
var ERROR_AUTH = 'This feature is protected by authentication. Please log in to proceed';
|
|
14361
14399
|
var DownloadSigmetAirmetConfigWrapper = function DownloadSigmetAirmetConfigWrapper(_ref) {
|
|
14362
14400
|
var productType = _ref.productType,
|
|
14363
14401
|
productConfigKey = _ref.productConfigKey;
|
|
14364
14402
|
var _useApiContext = useApiContext(),
|
|
14365
14403
|
api = _useApiContext.api;
|
|
14404
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
14405
|
+
isLoggedIn = _useAuthenticationCon.isLoggedIn;
|
|
14366
14406
|
var getConfigurationRequest = api[productType === 'sigmet' ? 'getSigmetConfiguration' : 'getAirmetConfiguration'];
|
|
14367
14407
|
var _useApi = useApi(getConfigurationRequest, productConfigKey),
|
|
14368
14408
|
productConfig = _useApi.result,
|
|
@@ -14382,7 +14422,7 @@ var DownloadSigmetAirmetConfigWrapper = function DownloadSigmetAirmetConfigWrapp
|
|
|
14382
14422
|
if (error) {
|
|
14383
14423
|
return /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
14384
14424
|
title: ERROR_TITLE,
|
|
14385
|
-
info: error.message
|
|
14425
|
+
info: !isLoggedIn ? ERROR_AUTH : error.message
|
|
14386
14426
|
});
|
|
14387
14427
|
}
|
|
14388
14428
|
return /*#__PURE__*/React__default.createElement(MetInfoWrapper, {
|
package/package.json
CHANGED
|
@@ -5,5 +5,6 @@ interface ModuleWrapperProps {
|
|
|
5
5
|
productConfigKey?: string;
|
|
6
6
|
}
|
|
7
7
|
export declare const ERROR_TITLE = "Something went wrong with loading the configuration file";
|
|
8
|
+
export declare const ERROR_AUTH = "This feature is protected by authentication. Please log in to proceed";
|
|
8
9
|
declare const DownloadSigmetAirmetConfigWrapper: React.FC<ModuleWrapperProps>;
|
|
9
10
|
export default DownloadSigmetAirmetConfigWrapper;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AirmetFromBackend, ProductConfig, ProductType, SigmetFromBackend } from '../../types';
|
|
2
2
|
export declare const ERROR_CONFIG = "An error has occurred while loading the config";
|
|
3
3
|
export declare const ERROR_BACKEND = "An error has occurred while retrieving the list, please try again";
|
|
4
|
+
export declare const ERROR_AUTH = "This feature is protected by authentication.";
|
|
4
5
|
export declare const validateConfig: (productType: ProductType, productConfig: ProductConfig) => true | Error;
|
|
5
6
|
type State = {
|
|
6
7
|
isLoading: boolean;
|
|
@@ -7,6 +7,7 @@ export interface SigmetFormProps {
|
|
|
7
7
|
initialCancelSigmet?: CancelSigmet;
|
|
8
8
|
showMap?: boolean;
|
|
9
9
|
productConfig?: ProductConfig;
|
|
10
|
+
setDialogActionsDisabled?: (disabled: boolean) => void;
|
|
10
11
|
}
|
|
11
12
|
declare const SigmetForm: React.FC<SigmetFormProps>;
|
|
12
13
|
export default SigmetForm;
|
|
@@ -32,7 +32,12 @@ export declare const getLevelInFeet: (level: number, unit: string) => number;
|
|
|
32
32
|
export declare const isLevelLower: (ownValue: number | string, ownUnit: LevelUnits, otherValue: number, otherUnit: LevelUnits) => boolean;
|
|
33
33
|
export declare const getDialogtitle: (product: AviationProduct, productType: ProductType) => string;
|
|
34
34
|
export declare const getProductFormMode: (canBeOptions: ProductCanbe[], productListItem: SigmetFromBackend | AirmetFromBackend) => string;
|
|
35
|
-
|
|
35
|
+
interface ProductFormLifecycleButtonsProps {
|
|
36
|
+
canBe: string[];
|
|
37
|
+
onButtonPress: (newStatus: ProductStatus | 'DISCARDED') => void;
|
|
38
|
+
areActionsDisabled?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare const getProductFormLifecycleButtons: React.FC<ProductFormLifecycleButtonsProps>;
|
|
36
41
|
export declare const hasValue: (value: number | string) => boolean;
|
|
37
42
|
export declare const prepareFormValues: <T extends AviationProduct>(product: T) => T;
|
|
38
43
|
export declare const createSigmetPostParameter: (sigmetToPost: Sigmet | CancelSigmet, newStatus: ProductStatus, previousUuid: string) => SigmetFromFrontend;
|
|
@@ -66,3 +71,4 @@ export declare const firID = "drawtools-fir";
|
|
|
66
71
|
export declare const getDrawTools: (type: StartOrEndDrawing, firShape: GeoJSON.FeatureCollection) => DrawMode[];
|
|
67
72
|
export declare const updateDrawToolsWithFir: (drawTools: DrawMode[], newFirShape: GeoJSON.FeatureCollection) => DrawMode[];
|
|
68
73
|
export declare const getToolIcon: (id: string) => React.ReactElement;
|
|
74
|
+
export {};
|