@opengeoweb/warnings 9.34.0 → 9.35.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 +222 -153
- package/package.json +1 -1
- package/src/lib/aviation-api/hooks.d.ts +12 -3
- package/src/lib/components/ComponentsLookUp/ComponentsLookUp.d.ts +4 -1
- package/src/lib/components/FilterList/filter-hooks.d.ts +3 -2
- package/src/lib/components/PublicWarningList/PublicWarningList.d.ts +3 -1
- package/src/lib/components/PublicWarningList/PublicWarningListConnect.d.ts +4 -1
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useDispatch, useSelector } from 'react-redux';
|
|
3
3
|
import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Close, Options, ChevronDown, ChevronUp, Copy, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
|
|
4
|
-
import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog } from '@opengeoweb/store';
|
|
4
|
+
import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData } from '@opengeoweb/store';
|
|
5
5
|
import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, MapView, MapViewLayer, getFeatureExtent } from '@opengeoweb/webmap-react';
|
|
6
6
|
import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, FilterLabel, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
|
|
7
7
|
import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
|
|
@@ -18,10 +18,11 @@ import { VariableSizeList } from 'react-window';
|
|
|
18
18
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
19
19
|
import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, getHeaders, useAuthQuery, useAuthenticationContext, ProductStatus } from '@opengeoweb/api';
|
|
20
20
|
import { useFormContext } from 'react-hook-form';
|
|
21
|
-
import { isEqual, cloneDeep, clamp,
|
|
21
|
+
import { isEqual, cloneDeep, clamp, groupBy, pick } from 'lodash';
|
|
22
22
|
import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
|
|
23
23
|
import { SigmetForm, isInstanceOfCancelSigmet, AirmetForm, isInstanceOfCancelAirmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
|
|
24
24
|
import { produce } from 'immer';
|
|
25
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
25
26
|
import { isAxiosError } from 'axios';
|
|
26
27
|
|
|
27
28
|
var en = {
|
|
@@ -8607,7 +8608,7 @@ var Phenomenon$1 = function Phenomenon(_ref) {
|
|
|
8607
8608
|
isRequired = _useDraftFormHelpers.isRequired;
|
|
8608
8609
|
// These phenomena are sent to Public Warning Form
|
|
8609
8610
|
var warningFormPhenomena = warningPhenomena.filter(function (phenomenon) {
|
|
8610
|
-
return !phenomenon.isAviation;
|
|
8611
|
+
return !phenomenon.isAviation && phenomenon.key !== 'unspecified';
|
|
8611
8612
|
});
|
|
8612
8613
|
return jsx(ReactHookFormSelect, {
|
|
8613
8614
|
name: "phenomenon",
|
|
@@ -9111,17 +9112,51 @@ var getSigmetTAC = function getSigmetTAC(auth, product) {
|
|
|
9111
9112
|
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
9112
9113
|
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
9113
9114
|
* */
|
|
9114
|
-
var useAirmetList = function useAirmetList() {
|
|
9115
|
-
|
|
9115
|
+
var useAirmetList = function useAirmetList(disabled) {
|
|
9116
|
+
if (disabled === void 0) {
|
|
9117
|
+
disabled = false;
|
|
9118
|
+
}
|
|
9119
|
+
return useAuthQuery(['airmet-list'], getAirmetList, disabled);
|
|
9116
9120
|
};
|
|
9117
|
-
var useSigmetList = function useSigmetList() {
|
|
9118
|
-
|
|
9121
|
+
var useSigmetList = function useSigmetList(disabled) {
|
|
9122
|
+
if (disabled === void 0) {
|
|
9123
|
+
disabled = false;
|
|
9124
|
+
}
|
|
9125
|
+
return useAuthQuery(['sigmet-list'], getSigmetList, disabled);
|
|
9119
9126
|
};
|
|
9120
|
-
var useProductConfig = function useProductConfig(warningType) {
|
|
9121
|
-
|
|
9122
|
-
|
|
9127
|
+
var useProductConfig = function useProductConfig(warningType, disabled) {
|
|
9128
|
+
if (disabled === void 0) {
|
|
9129
|
+
disabled = false;
|
|
9130
|
+
}
|
|
9131
|
+
var airmetQuery = useAuthQuery(['airmet-config'], getAirmetConfig, disabled);
|
|
9132
|
+
var sigmetQuery = useAuthQuery(['sigmet-config'], getSigmetConfig, disabled);
|
|
9123
9133
|
return warningType === 'airmet' ? airmetQuery : sigmetQuery;
|
|
9124
9134
|
};
|
|
9135
|
+
var useTACApi = function useTACApi() {
|
|
9136
|
+
var _useAuthenticationCon = useAuthenticationContext(),
|
|
9137
|
+
auth = _useAuthenticationCon.auth;
|
|
9138
|
+
var queryClient = useQueryClient();
|
|
9139
|
+
var fetchSigmetTAC = function fetchSigmetTAC(product) {
|
|
9140
|
+
return queryClient.fetchQuery({
|
|
9141
|
+
queryKey: ['sigmet-tac', product],
|
|
9142
|
+
queryFn: function queryFn() {
|
|
9143
|
+
return getSigmetTAC(auth, product);
|
|
9144
|
+
}
|
|
9145
|
+
});
|
|
9146
|
+
};
|
|
9147
|
+
var fetchAirmetTAC = function fetchAirmetTAC(product) {
|
|
9148
|
+
return queryClient.fetchQuery({
|
|
9149
|
+
queryKey: ['airmet-tac', product],
|
|
9150
|
+
queryFn: function queryFn() {
|
|
9151
|
+
return getAirmetTAC(auth, product);
|
|
9152
|
+
}
|
|
9153
|
+
});
|
|
9154
|
+
};
|
|
9155
|
+
return {
|
|
9156
|
+
fetchSigmetTAC: fetchSigmetTAC,
|
|
9157
|
+
fetchAirmetTAC: fetchAirmetTAC
|
|
9158
|
+
};
|
|
9159
|
+
};
|
|
9125
9160
|
|
|
9126
9161
|
var _excluded$6 = ["IS_DRAFT", "object", "translation-select"];
|
|
9127
9162
|
var useScrollTopOnError = function useScrollTopOnError(error) {
|
|
@@ -9312,6 +9347,9 @@ var Form = function Form(_ref5) {
|
|
|
9312
9347
|
selectedAviationProduct = _ref5.selectedAviationProduct,
|
|
9313
9348
|
isSigmetWarning = _ref5.isSigmetWarning,
|
|
9314
9349
|
mode = _ref5.mode;
|
|
9350
|
+
var _useTACApi = useTACApi(),
|
|
9351
|
+
fetchSigmetTAC = _useTACApi.fetchSigmetTAC,
|
|
9352
|
+
fetchAirmetTAC = _useTACApi.fetchAirmetTAC;
|
|
9315
9353
|
var initialPublicWarningArea = publicWarningDetails && (publicWarningDetails == null ? void 0 : publicWarningDetails.areas) && (publicWarningDetails == null ? void 0 : publicWarningDetails.areas.length) && (publicWarningDetails == null || (_publicWarningDetails = publicWarningDetails.areas[0]) == null ? void 0 : _publicWarningDetails.geoJSON);
|
|
9316
9354
|
var _React$useState = React.useState(initialPublicWarningArea),
|
|
9317
9355
|
warningGeoJSONFeature = _React$useState[0],
|
|
@@ -9418,8 +9456,6 @@ var Form = function Form(_ref5) {
|
|
|
9418
9456
|
var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
|
|
9419
9457
|
var _useProductConfig = useProductConfig(warningType),
|
|
9420
9458
|
aviationConfig = _useProductConfig.data;
|
|
9421
|
-
var _useAuthenticationCon = useAuthenticationContext(),
|
|
9422
|
-
auth = _useAuthenticationCon.auth;
|
|
9423
9459
|
return jsxs(ContainerWrapper, {
|
|
9424
9460
|
children: [selectedAviationProduct ? jsx(ContainerFormWrapper, {
|
|
9425
9461
|
isReadOnly: isReadOnly,
|
|
@@ -9441,7 +9477,7 @@ var Form = function Form(_ref5) {
|
|
|
9441
9477
|
productConfig: aviationConfig,
|
|
9442
9478
|
product: selectedAviationProduct,
|
|
9443
9479
|
getTAC: function getTAC(product) {
|
|
9444
|
-
return
|
|
9480
|
+
return fetchSigmetTAC(product);
|
|
9445
9481
|
}
|
|
9446
9482
|
}) : jsx(AirmetForm, {
|
|
9447
9483
|
showMap: false,
|
|
@@ -9452,7 +9488,7 @@ var Form = function Form(_ref5) {
|
|
|
9452
9488
|
productConfig: aviationConfig,
|
|
9453
9489
|
product: selectedAviationProduct,
|
|
9454
9490
|
getTAC: function getTAC(product) {
|
|
9455
|
-
return
|
|
9491
|
+
return fetchAirmetTAC(product);
|
|
9456
9492
|
}
|
|
9457
9493
|
})
|
|
9458
9494
|
})
|
|
@@ -10823,9 +10859,9 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
10823
10859
|
return _ref5.apply(this, arguments);
|
|
10824
10860
|
};
|
|
10825
10861
|
}();
|
|
10826
|
-
var _useAirmetList = useAirmetList(),
|
|
10862
|
+
var _useAirmetList = useAirmetList(true),
|
|
10827
10863
|
airmetList = _useAirmetList.data;
|
|
10828
|
-
var _useSigmetList = useSigmetList(),
|
|
10864
|
+
var _useSigmetList = useSigmetList(true),
|
|
10829
10865
|
sigmetList = _useSigmetList.data;
|
|
10830
10866
|
var selectedSigmet = sigmetList == null ? void 0 : sigmetList.find(function (sigmet) {
|
|
10831
10867
|
return sigmet.uuid === selectedWarningId;
|
|
@@ -10835,9 +10871,9 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
|
|
|
10835
10871
|
});
|
|
10836
10872
|
var isSigmetWarning = Boolean(selectedSigmet);
|
|
10837
10873
|
var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
|
|
10838
|
-
var _useProductConfig = useProductConfig(warningType),
|
|
10874
|
+
var _useProductConfig = useProductConfig(warningType, !isDialogOpen),
|
|
10839
10875
|
aviationConfig = _useProductConfig.data;
|
|
10840
|
-
var selectedSigmetProduct = selectedSigmet ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : undefined;
|
|
10876
|
+
var selectedSigmetProduct = selectedSigmet && aviationConfig ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : undefined;
|
|
10841
10877
|
var selectedAirmetProduct = selectedAirmet ? transformAirmetToProductFormat(selectedAirmet, aviationConfig) : undefined;
|
|
10842
10878
|
var selectedAviationProduct = isSigmetWarning ? selectedSigmetProduct : selectedAirmetProduct;
|
|
10843
10879
|
var productCanBe = selectedAviationProduct !== null ? (selectedSigmet == null ? void 0 : selectedSigmet.canbe) || (selectedAirmet == null ? void 0 : selectedAirmet.canbe) : ['DRAFTED', 'DISCARDED', 'PUBLISHED'];
|
|
@@ -11966,115 +12002,6 @@ var WarningListItem = function WarningListItem(_ref) {
|
|
|
11966
12002
|
}), warning.id);
|
|
11967
12003
|
};
|
|
11968
12004
|
|
|
11969
|
-
/* *
|
|
11970
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11971
|
-
* you may not use this file except in compliance with the License.
|
|
11972
|
-
* You may obtain a copy of the License at
|
|
11973
|
-
*
|
|
11974
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11975
|
-
*
|
|
11976
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11977
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11978
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11979
|
-
* See the License for the specific language governing permissions and
|
|
11980
|
-
* limitations under the License.
|
|
11981
|
-
*
|
|
11982
|
-
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
11983
|
-
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
11984
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
11985
|
-
* */
|
|
11986
|
-
var useFilter = function useFilter(defaultFilter, pickedOptions) {
|
|
11987
|
-
var _useState = useState(defaultFilter),
|
|
11988
|
-
filter = _useState[0],
|
|
11989
|
-
setFilter = _useState[1];
|
|
11990
|
-
var pickedFilterOptions = pick(filter, ['unspecified'].concat(pickedOptions));
|
|
11991
|
-
var _useSelectedOptions = useSelectedOptions(pickedFilterOptions),
|
|
11992
|
-
allSelected = _useSelectedOptions.allSelected;
|
|
11993
|
-
return [pickedFilterOptions, setFilter, allSelected];
|
|
11994
|
-
};
|
|
11995
|
-
var useWarningFilters = function useWarningFilters(warnings) {
|
|
11996
|
-
var _useState2 = useState(defaultDomainFilter),
|
|
11997
|
-
domainFilter = _useState2[0],
|
|
11998
|
-
setDomainFilter = _useState2[1];
|
|
11999
|
-
var relevantLevels = Object.keys(domainFilter).flatMap(function (domain) {
|
|
12000
|
-
return domainFilter[domain] ? domainLevels[domain] : [];
|
|
12001
|
-
});
|
|
12002
|
-
var _useFilter = useFilter(defaultLevelFilter, relevantLevels),
|
|
12003
|
-
pickedLevelFilter = _useFilter[0],
|
|
12004
|
-
setLevelFilter = _useFilter[1],
|
|
12005
|
-
allLevelsSelected = _useFilter[2];
|
|
12006
|
-
var existingPhenomenon = Object.values(Phenomenon).filter(function (p) {
|
|
12007
|
-
return warnings.find(function (w) {
|
|
12008
|
-
return w.warningDetail.phenomenon === p;
|
|
12009
|
-
});
|
|
12010
|
-
});
|
|
12011
|
-
var _useFilter2 = useFilter(defaultPhenomenonFilter, existingPhenomenon),
|
|
12012
|
-
pickedPhenomenonFilter = _useFilter2[0],
|
|
12013
|
-
setPhenomenonFilter = _useFilter2[1],
|
|
12014
|
-
allPhenomenonSelected = _useFilter2[2];
|
|
12015
|
-
var _useSelectedOptions2 = useSelectedOptions(domainFilter),
|
|
12016
|
-
allDomainSelected = _useSelectedOptions2.allSelected;
|
|
12017
|
-
var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected;
|
|
12018
|
-
/**
|
|
12019
|
-
* @param filterKey - Name of the filter | "ALL" filters
|
|
12020
|
-
* @param optionKey - Name of the option | "ALL" options
|
|
12021
|
-
* @param value - The new value
|
|
12022
|
-
* @param only - Flag that decides if all other options should be disabled
|
|
12023
|
-
*/
|
|
12024
|
-
var updateFilter = function updateFilter(filterKey, optionKey, value, only) {
|
|
12025
|
-
if (filterKey === 'ALL') {
|
|
12026
|
-
setDomainFilter(function (state) {
|
|
12027
|
-
return updateState(state, 'ALL', value);
|
|
12028
|
-
});
|
|
12029
|
-
setLevelFilter(function (state) {
|
|
12030
|
-
return updateState(state, 'ALL', value);
|
|
12031
|
-
});
|
|
12032
|
-
setPhenomenonFilter(function (state) {
|
|
12033
|
-
return updateState(state, 'ALL', value);
|
|
12034
|
-
});
|
|
12035
|
-
} else if (filterKey === 'domain') {
|
|
12036
|
-
setDomainFilter(function (state) {
|
|
12037
|
-
return updateState(state, optionKey, value, only);
|
|
12038
|
-
});
|
|
12039
|
-
} else if (filterKey === 'level') {
|
|
12040
|
-
setLevelFilter(function (state) {
|
|
12041
|
-
return updateState(state, optionKey, value, only);
|
|
12042
|
-
});
|
|
12043
|
-
} else if (filterKey === 'phenomenon') {
|
|
12044
|
-
setPhenomenonFilter(function (state) {
|
|
12045
|
-
return updateState(state, optionKey, value, only);
|
|
12046
|
-
});
|
|
12047
|
-
}
|
|
12048
|
-
};
|
|
12049
|
-
var byFilterState = useCallback(function (warning) {
|
|
12050
|
-
var levelDomain = ['SIG', 'AIR'].find(function (d) {
|
|
12051
|
-
return d === warning.warningDetail.level;
|
|
12052
|
-
}) ? Domain.aviation : Domain["public"];
|
|
12053
|
-
if (!domainFilter[levelDomain]) {
|
|
12054
|
-
return false;
|
|
12055
|
-
}
|
|
12056
|
-
var level = getValue(Level, warning.warningDetail.level);
|
|
12057
|
-
if (!pickedLevelFilter[level]) {
|
|
12058
|
-
return false;
|
|
12059
|
-
}
|
|
12060
|
-
var phenomenon = getValue(Phenomenon, warning.warningDetail.phenomenon);
|
|
12061
|
-
if (!pickedPhenomenonFilter[phenomenon]) {
|
|
12062
|
-
return false;
|
|
12063
|
-
}
|
|
12064
|
-
return true;
|
|
12065
|
-
}, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter]);
|
|
12066
|
-
return {
|
|
12067
|
-
filterState: {
|
|
12068
|
-
domain: domainFilter,
|
|
12069
|
-
phenomenon: pickedPhenomenonFilter,
|
|
12070
|
-
level: pickedLevelFilter
|
|
12071
|
-
},
|
|
12072
|
-
allSelected: allSelected,
|
|
12073
|
-
updateFilter: updateFilter,
|
|
12074
|
-
byFilterState: byFilterState
|
|
12075
|
-
};
|
|
12076
|
-
};
|
|
12077
|
-
|
|
12078
12005
|
var BUTTON_AIRMET = 'AIRMET';
|
|
12079
12006
|
var BUTTON_SIGMET = 'SIGMET';
|
|
12080
12007
|
var NewWarningButton = function NewWarningButton(_ref) {
|
|
@@ -12269,6 +12196,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
|
|
|
12269
12196
|
var _ref$warnings = _ref.warnings,
|
|
12270
12197
|
warnings = _ref$warnings === void 0 ? [] : _ref$warnings,
|
|
12271
12198
|
filters = _ref.filters,
|
|
12199
|
+
filterHookState = _ref.filterHookState,
|
|
12272
12200
|
_ref$isLoading = _ref.isLoading,
|
|
12273
12201
|
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
12274
12202
|
error = _ref.error,
|
|
@@ -12295,13 +12223,11 @@ var PublicWarningList = function PublicWarningList(_ref) {
|
|
|
12295
12223
|
onClickAllChip = _ref$onClickAllChip === void 0 ? function () {} : _ref$onClickAllChip,
|
|
12296
12224
|
_ref$isAllChipSelecte = _ref.isAllChipSelected,
|
|
12297
12225
|
isAllChipSelected = _ref$isAllChipSelecte === void 0 ? true : _ref$isAllChipSelecte;
|
|
12226
|
+
var filterState = filterHookState.filterState,
|
|
12227
|
+
updateFilter = filterHookState.updateFilter,
|
|
12228
|
+
allSelected = filterHookState.allSelected;
|
|
12298
12229
|
var _useWarningsTranslati = useWarningsTranslation(),
|
|
12299
12230
|
t = _useWarningsTranslati.t;
|
|
12300
|
-
var _useWarningFilters = useWarningFilters(warnings),
|
|
12301
|
-
filterState = _useWarningFilters.filterState,
|
|
12302
|
-
allSelected = _useWarningFilters.allSelected,
|
|
12303
|
-
updateFilter = _useWarningFilters.updateFilter,
|
|
12304
|
-
byFilterState = _useWarningFilters.byFilterState;
|
|
12305
12231
|
var _React$useState = React__default.useState({
|
|
12306
12232
|
key: 'lastUpdatedTime',
|
|
12307
12233
|
direction: 'desc'
|
|
@@ -12313,8 +12239,8 @@ var PublicWarningList = function PublicWarningList(_ref) {
|
|
|
12313
12239
|
updateFilter('ALL', 'ALL', !isChecked);
|
|
12314
12240
|
};
|
|
12315
12241
|
var sortedWarnings = React__default.useMemo(function () {
|
|
12316
|
-
return groupWarningsOnStatus(warnings
|
|
12317
|
-
}, [warnings,
|
|
12242
|
+
return groupWarningsOnStatus(warnings, sortState);
|
|
12243
|
+
}, [warnings, sortState]);
|
|
12318
12244
|
var toggleSortDirection = function toggleSortDirection(key) {
|
|
12319
12245
|
setSortState(function (prevState) {
|
|
12320
12246
|
return {
|
|
@@ -12661,7 +12587,7 @@ var getSelectedFilterOptions = createSelector(selectAllFilters, function (filter
|
|
|
12661
12587
|
});
|
|
12662
12588
|
});
|
|
12663
12589
|
return selectedOptions;
|
|
12664
|
-
});
|
|
12590
|
+
}, selectorMemoizationOptions);
|
|
12665
12591
|
var getFilteredWarnings = createSelector(selectAllPublicWarnings, getIsAllSelected, getSelectedFilterOptions, selectAllFilterIds, function (warnings, isAllSelected, filters, filterIds) {
|
|
12666
12592
|
if (isAllSelected) {
|
|
12667
12593
|
return warnings;
|
|
@@ -12673,7 +12599,7 @@ var getFilteredWarnings = createSelector(selectAllPublicWarnings, getIsAllSelect
|
|
|
12673
12599
|
});
|
|
12674
12600
|
});
|
|
12675
12601
|
return result;
|
|
12676
|
-
});
|
|
12602
|
+
}, selectorMemoizationOptions);
|
|
12677
12603
|
|
|
12678
12604
|
var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
|
|
12679
12605
|
var _ref$onClose = _ref.onClose,
|
|
@@ -12753,7 +12679,117 @@ var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
|
|
|
12753
12679
|
}));
|
|
12754
12680
|
};
|
|
12755
12681
|
|
|
12756
|
-
|
|
12682
|
+
/* *
|
|
12683
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12684
|
+
* you may not use this file except in compliance with the License.
|
|
12685
|
+
* You may obtain a copy of the License at
|
|
12686
|
+
*
|
|
12687
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12688
|
+
*
|
|
12689
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12690
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12691
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12692
|
+
* See the License for the specific language governing permissions and
|
|
12693
|
+
* limitations under the License.
|
|
12694
|
+
*
|
|
12695
|
+
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
12696
|
+
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
12697
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
12698
|
+
* */
|
|
12699
|
+
var useFilter = function useFilter(defaultFilter, pickedOptions) {
|
|
12700
|
+
var _useState = useState(defaultFilter),
|
|
12701
|
+
filter = _useState[0],
|
|
12702
|
+
setFilter = _useState[1];
|
|
12703
|
+
var pickedFilterOptions = pick(filter, ['unspecified'].concat(pickedOptions));
|
|
12704
|
+
var _useSelectedOptions = useSelectedOptions(pickedFilterOptions),
|
|
12705
|
+
allSelected = _useSelectedOptions.allSelected;
|
|
12706
|
+
return [pickedFilterOptions, setFilter, allSelected];
|
|
12707
|
+
};
|
|
12708
|
+
var useWarningFilters = function useWarningFilters(warnings) {
|
|
12709
|
+
var _useState2 = useState(defaultDomainFilter),
|
|
12710
|
+
domainFilter = _useState2[0],
|
|
12711
|
+
setDomainFilter = _useState2[1];
|
|
12712
|
+
var relevantLevels = Object.keys(domainFilter).flatMap(function (domain) {
|
|
12713
|
+
return domainFilter[domain] ? domainLevels[domain] : [];
|
|
12714
|
+
});
|
|
12715
|
+
var _useFilter = useFilter(defaultLevelFilter, relevantLevels),
|
|
12716
|
+
pickedLevelFilter = _useFilter[0],
|
|
12717
|
+
setLevelFilter = _useFilter[1],
|
|
12718
|
+
allLevelsSelected = _useFilter[2];
|
|
12719
|
+
var existingPhenomenon = Object.values(Phenomenon).filter(function (p) {
|
|
12720
|
+
return warnings.find(function (w) {
|
|
12721
|
+
return w.warningDetail.phenomenon === p;
|
|
12722
|
+
});
|
|
12723
|
+
});
|
|
12724
|
+
var _useFilter2 = useFilter(defaultPhenomenonFilter, existingPhenomenon),
|
|
12725
|
+
pickedPhenomenonFilter = _useFilter2[0],
|
|
12726
|
+
setPhenomenonFilter = _useFilter2[1],
|
|
12727
|
+
allPhenomenonSelected = _useFilter2[2];
|
|
12728
|
+
var _useSelectedOptions2 = useSelectedOptions(domainFilter),
|
|
12729
|
+
allDomainSelected = _useSelectedOptions2.allSelected;
|
|
12730
|
+
var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected;
|
|
12731
|
+
/**
|
|
12732
|
+
* @param filterKey - Name of the filter | "ALL" filters
|
|
12733
|
+
* @param optionKey - Name of the option | "ALL" options
|
|
12734
|
+
* @param value - The new value
|
|
12735
|
+
* @param only - Flag that decides if all other options should be disabled
|
|
12736
|
+
*/
|
|
12737
|
+
var updateFilter = function updateFilter(filterKey, optionKey, value, only) {
|
|
12738
|
+
if (filterKey === 'ALL') {
|
|
12739
|
+
setDomainFilter(function (state) {
|
|
12740
|
+
return updateState(state, 'ALL', value);
|
|
12741
|
+
});
|
|
12742
|
+
setLevelFilter(function (state) {
|
|
12743
|
+
return updateState(state, 'ALL', value);
|
|
12744
|
+
});
|
|
12745
|
+
setPhenomenonFilter(function (state) {
|
|
12746
|
+
return updateState(state, 'ALL', value);
|
|
12747
|
+
});
|
|
12748
|
+
} else if (filterKey === 'domain') {
|
|
12749
|
+
setDomainFilter(function (state) {
|
|
12750
|
+
return updateState(state, optionKey, value, only);
|
|
12751
|
+
});
|
|
12752
|
+
} else if (filterKey === 'level') {
|
|
12753
|
+
setLevelFilter(function (state) {
|
|
12754
|
+
return updateState(state, optionKey, value, only);
|
|
12755
|
+
});
|
|
12756
|
+
} else if (filterKey === 'phenomenon') {
|
|
12757
|
+
setPhenomenonFilter(function (state) {
|
|
12758
|
+
return updateState(state, optionKey, value, only);
|
|
12759
|
+
});
|
|
12760
|
+
}
|
|
12761
|
+
};
|
|
12762
|
+
var byFilterState = useCallback(function (warning) {
|
|
12763
|
+
var levelDomain = ['SIG', 'AIR'].find(function (d) {
|
|
12764
|
+
return d === warning.warningDetail.level;
|
|
12765
|
+
}) ? Domain.aviation : Domain["public"];
|
|
12766
|
+
if (!domainFilter[levelDomain]) {
|
|
12767
|
+
return false;
|
|
12768
|
+
}
|
|
12769
|
+
var level = getValue(Level, warning.warningDetail.level);
|
|
12770
|
+
if (!pickedLevelFilter[level]) {
|
|
12771
|
+
return false;
|
|
12772
|
+
}
|
|
12773
|
+
var phenomenon = getValue(Phenomenon, warning.warningDetail.phenomenon);
|
|
12774
|
+
if (!pickedPhenomenonFilter[phenomenon]) {
|
|
12775
|
+
return false;
|
|
12776
|
+
}
|
|
12777
|
+
return true;
|
|
12778
|
+
}, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter]);
|
|
12779
|
+
return {
|
|
12780
|
+
filterState: {
|
|
12781
|
+
domain: domainFilter,
|
|
12782
|
+
phenomenon: pickedPhenomenonFilter,
|
|
12783
|
+
level: pickedLevelFilter
|
|
12784
|
+
},
|
|
12785
|
+
allSelected: allSelected,
|
|
12786
|
+
updateFilter: updateFilter,
|
|
12787
|
+
byFilterState: byFilterState
|
|
12788
|
+
};
|
|
12789
|
+
};
|
|
12790
|
+
|
|
12791
|
+
var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
|
|
12792
|
+
var panelId = _ref.panelId;
|
|
12757
12793
|
var _useWarningsTranslati = useWarningsTranslation(),
|
|
12758
12794
|
t = _useWarningsTranslati.t;
|
|
12759
12795
|
var dispatch = useDispatch();
|
|
@@ -12773,7 +12809,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12773
12809
|
setConfirmDialogOptions = _React$useState[1];
|
|
12774
12810
|
var filters = useSelector(selectAllFilters);
|
|
12775
12811
|
var isAllChipSelected = useSelector(getIsAllSelected);
|
|
12776
|
-
var
|
|
12812
|
+
var publicWarnings = useSelector(getFilteredWarnings);
|
|
12777
12813
|
var warnings = useSelector(selectAllPublicWarnings);
|
|
12778
12814
|
var selectedPublicWarningId = useSelector(getSelectedPublicWarningId);
|
|
12779
12815
|
var isLoading = useSelector(isPublicWarningsLoading || isFetchingAirmet || isFetchingSigmet);
|
|
@@ -12782,7 +12818,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12782
12818
|
var lastUpdatedTime = useSelector(getPublicWarningsLastUpdatedTime);
|
|
12783
12819
|
var warningsApi = getWarningsApi();
|
|
12784
12820
|
var openPublicWarningDialog = /*#__PURE__*/function () {
|
|
12785
|
-
var
|
|
12821
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formAction, publicWarning) {
|
|
12786
12822
|
var mayProceed;
|
|
12787
12823
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12788
12824
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -12817,7 +12853,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12817
12853
|
}, _callee);
|
|
12818
12854
|
}));
|
|
12819
12855
|
return function openPublicWarningDialog(_x, _x2) {
|
|
12820
|
-
return
|
|
12856
|
+
return _ref2.apply(this, arguments);
|
|
12821
12857
|
};
|
|
12822
12858
|
}();
|
|
12823
12859
|
var selectWarning = function selectWarning(publicWarning) {
|
|
@@ -12827,7 +12863,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12827
12863
|
void openPublicWarningDialog('');
|
|
12828
12864
|
};
|
|
12829
12865
|
var editWarning = /*#__PURE__*/function () {
|
|
12830
|
-
var
|
|
12866
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(publicWarning) {
|
|
12831
12867
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
12832
12868
|
while (1) switch (_context2.prev = _context2.next) {
|
|
12833
12869
|
case 0:
|
|
@@ -12858,11 +12894,11 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12858
12894
|
}, _callee2);
|
|
12859
12895
|
}));
|
|
12860
12896
|
return function editWarning(_x3) {
|
|
12861
|
-
return
|
|
12897
|
+
return _ref3.apply(this, arguments);
|
|
12862
12898
|
};
|
|
12863
12899
|
}();
|
|
12864
12900
|
var expireWarning = /*#__PURE__*/function () {
|
|
12865
|
-
var
|
|
12901
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(warning) {
|
|
12866
12902
|
var expiredWarning;
|
|
12867
12903
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
12868
12904
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -12888,11 +12924,11 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12888
12924
|
}, _callee3);
|
|
12889
12925
|
}));
|
|
12890
12926
|
return function expireWarning(_x4) {
|
|
12891
|
-
return
|
|
12927
|
+
return _ref4.apply(this, arguments);
|
|
12892
12928
|
};
|
|
12893
12929
|
}();
|
|
12894
12930
|
var withdrawWarning = /*#__PURE__*/function () {
|
|
12895
|
-
var
|
|
12931
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(warning) {
|
|
12896
12932
|
var withdrawWarning;
|
|
12897
12933
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
12898
12934
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -12918,7 +12954,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12918
12954
|
}, _callee4);
|
|
12919
12955
|
}));
|
|
12920
12956
|
return function withdrawWarning(_x5) {
|
|
12921
|
-
return
|
|
12957
|
+
return _ref5.apply(this, arguments);
|
|
12922
12958
|
};
|
|
12923
12959
|
}();
|
|
12924
12960
|
var openSnackbar = function openSnackbar(message) {
|
|
@@ -12993,12 +13029,38 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
12993
13029
|
newFilters: newFilters
|
|
12994
13030
|
}));
|
|
12995
13031
|
}, [dispatch, t, warnings]);
|
|
12996
|
-
var
|
|
12997
|
-
|
|
12998
|
-
|
|
13032
|
+
var combinedWarnings = React__default.useMemo(function () {
|
|
13033
|
+
var transformedSigmets = (sigmetList == null ? void 0 : sigmetList.map(transformSigmetToWarningFormat)) || [];
|
|
13034
|
+
var transformedAirmets = (airmetList == null ? void 0 : airmetList.map(transformAirmetToWarningFormat)) || [];
|
|
13035
|
+
return publicWarnings.concat(transformedSigmets).concat(transformedAirmets);
|
|
13036
|
+
}, [publicWarnings, sigmetList, airmetList]);
|
|
13037
|
+
var filterHookState = useWarningFilters(combinedWarnings);
|
|
13038
|
+
var filteredWarnings = React__default.useMemo(function () {
|
|
13039
|
+
return combinedWarnings.filter(filterHookState.byFilterState);
|
|
13040
|
+
}, [combinedWarnings, filterHookState.byFilterState]);
|
|
13041
|
+
var allFeatures = React__default.useMemo(function () {
|
|
13042
|
+
return filteredWarnings.reduce(function (acc, warning) {
|
|
13043
|
+
var _warning$warningDetai;
|
|
13044
|
+
var features = warning == null || (_warning$warningDetai = warning.warningDetail.areas) == null ? void 0 : _warning$warningDetai.map(function (a) {
|
|
13045
|
+
return {
|
|
13046
|
+
id: warning.id + a.objectName,
|
|
13047
|
+
geoJSON: a.geoJSON
|
|
13048
|
+
};
|
|
13049
|
+
}).filter(function (a) {
|
|
13050
|
+
return a.geoJSON;
|
|
13051
|
+
});
|
|
13052
|
+
if ((features == null ? void 0 : features.length) > 0) {
|
|
13053
|
+
return [].concat(acc, features);
|
|
13054
|
+
}
|
|
13055
|
+
return acc;
|
|
13056
|
+
}, []);
|
|
13057
|
+
}, [filteredWarnings]);
|
|
13058
|
+
useUpdateSharedData({
|
|
13059
|
+
features: allFeatures
|
|
13060
|
+
}, panelId);
|
|
12999
13061
|
return jsxs(Fragment, {
|
|
13000
13062
|
children: [jsx(PublicWarningList, {
|
|
13001
|
-
warnings:
|
|
13063
|
+
warnings: filteredWarnings,
|
|
13002
13064
|
isLoading: isLoading,
|
|
13003
13065
|
error: error,
|
|
13004
13066
|
onSelectWarning: selectWarning,
|
|
@@ -13012,6 +13074,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
|
|
|
13012
13074
|
lastUpdatedTime: lastUpdatedTime,
|
|
13013
13075
|
onRefetchWarnings: fetchWarnings,
|
|
13014
13076
|
filters: filters,
|
|
13077
|
+
filterHookState: filterHookState,
|
|
13015
13078
|
isAllChipSelected: isAllChipSelected,
|
|
13016
13079
|
onClickAllChip: onClickAllChip
|
|
13017
13080
|
}), confirmDialogOptions && jsx(ConfirmDeleteWarningDialog, {
|
|
@@ -13037,7 +13100,8 @@ var warningListViewPreset = {
|
|
|
13037
13100
|
var PublicWarningApiWrapper = function PublicWarningApiWrapper(_ref) {
|
|
13038
13101
|
var config = _ref.config,
|
|
13039
13102
|
auth = _ref.auth,
|
|
13040
|
-
onSetAuth = _ref.onSetAuth
|
|
13103
|
+
onSetAuth = _ref.onSetAuth,
|
|
13104
|
+
panelId = _ref.panelId;
|
|
13041
13105
|
return config ? jsx(ApiProvider, {
|
|
13042
13106
|
config: {
|
|
13043
13107
|
baseURL: config.baseURL,
|
|
@@ -13049,20 +13113,25 @@ var PublicWarningApiWrapper = function PublicWarningApiWrapper(_ref) {
|
|
|
13049
13113
|
onSetAuth: onSetAuth,
|
|
13050
13114
|
createApi: createApi$1,
|
|
13051
13115
|
children: jsx(ErrorBoundary, {
|
|
13052
|
-
children: jsx(PublicWarningListConnect, {
|
|
13116
|
+
children: jsx(PublicWarningListConnect, {
|
|
13117
|
+
panelId: panelId
|
|
13118
|
+
})
|
|
13053
13119
|
})
|
|
13054
13120
|
}) : null;
|
|
13055
13121
|
};
|
|
13056
13122
|
var componentsLookUp = function componentsLookUp(payload, apiProps) {
|
|
13057
|
-
var
|
|
13123
|
+
var id = payload.id,
|
|
13124
|
+
componentType = payload.componentType;
|
|
13058
13125
|
switch (componentType) {
|
|
13059
13126
|
case warningListViewPreset.componentType:
|
|
13060
13127
|
if (apiProps && apiProps.config) {
|
|
13061
13128
|
return jsx(PublicWarningApiWrapper, Object.assign({}, apiProps, {
|
|
13129
|
+
panelId: id,
|
|
13062
13130
|
"data-testid": "publicWarningModule"
|
|
13063
13131
|
}));
|
|
13064
13132
|
}
|
|
13065
13133
|
return jsx(PublicWarningListConnect, {
|
|
13134
|
+
panelId: id,
|
|
13066
13135
|
"data-testid": "publicWarningList"
|
|
13067
13136
|
});
|
|
13068
13137
|
default:
|
package/package.json
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { AirmetConfig, AirmetFromBackend, SigmetConfig, SigmetFromBackend } from '@opengeoweb/api';
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
3
|
+
import { AviationProduct } from '@opengeoweb/sigmet-airmet';
|
|
4
|
+
export declare const useAirmetList: (disabled?: boolean) => UseQueryResult<AirmetFromBackend[]>;
|
|
5
|
+
export declare const useSigmetList: (disabled?: boolean) => UseQueryResult<SigmetFromBackend[]>;
|
|
6
|
+
export declare const useProductConfig: (warningType: 'airmet' | 'sigmet', disabled?: boolean) => UseQueryResult<SigmetConfig | AirmetConfig>;
|
|
7
|
+
type FetchTACData = Promise<{
|
|
8
|
+
data: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const useTACApi: () => {
|
|
11
|
+
fetchSigmetTAC: (product: AviationProduct) => FetchTACData;
|
|
12
|
+
fetchAirmetTAC: (product: AviationProduct) => FetchTACData;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -10,6 +10,9 @@ export interface ComponentsLookUpPayload {
|
|
|
10
10
|
export interface ApiModuleProps extends ApiModule {
|
|
11
11
|
config: ApiUrls;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
interface Props extends ApiModuleProps {
|
|
14
|
+
panelId: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const PublicWarningApiWrapper: React.FC<Props>;
|
|
14
17
|
export declare const componentsLookUp: (payload: ComponentsLookUpPayload, apiProps?: ApiModuleProps) => React.ReactElement;
|
|
15
18
|
export {};
|
|
@@ -13,10 +13,11 @@ interface FilterState extends PickedFilterState {
|
|
|
13
13
|
export type FilterKeyType = keyof FilterState;
|
|
14
14
|
export type OptionKey<T extends FilterKeyType> = keyof FilterState[T];
|
|
15
15
|
export type UpdateFilter = <T extends FilterKeyType>(filterKey: T | 'ALL', optionKey: OptionKey<T> | 'ALL', value: boolean, only?: boolean) => void;
|
|
16
|
-
export
|
|
16
|
+
export interface FilterHookState {
|
|
17
17
|
filterState: PickedFilterState;
|
|
18
18
|
allSelected: boolean;
|
|
19
19
|
updateFilter: UpdateFilter;
|
|
20
20
|
byFilterState: (warning: PublicWarning) => boolean;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
|
+
export declare const useWarningFilters: (warnings: PublicWarning[]) => FilterHookState;
|
|
22
23
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PublicWarning } from '../../store/publicWarningForm/types';
|
|
3
3
|
import { WarningListFilter } from '../../store/publicWarnings/types';
|
|
4
|
+
import { FilterHookState } from '../FilterList/filter-hooks';
|
|
4
5
|
import { WarningListItemActions } from './WarningListItemMenu';
|
|
5
|
-
interface PublicWarningListProps extends WarningListItemActions {
|
|
6
|
+
export interface PublicWarningListProps extends WarningListItemActions {
|
|
6
7
|
warnings: PublicWarning[];
|
|
7
8
|
onSelectWarning?: (warning: PublicWarning) => void;
|
|
8
9
|
isLoading?: boolean;
|
|
@@ -12,6 +13,7 @@ interface PublicWarningListProps extends WarningListItemActions {
|
|
|
12
13
|
onCreateWarning?: () => void;
|
|
13
14
|
onRefetchWarnings?: () => void;
|
|
14
15
|
filters?: WarningListFilter[];
|
|
16
|
+
filterHookState: FilterHookState;
|
|
15
17
|
onClickAllChip?: (isChecked: boolean) => void;
|
|
16
18
|
isAllChipSelected?: boolean;
|
|
17
19
|
}
|