@opengeoweb/warnings 9.15.0 → 9.17.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 +1073 -891
- package/package.json +1 -2
- package/src/index.d.ts +2 -0
- package/src/lib/components/DrawingTool/DrawingTool.stories.d.ts +2 -2
- package/src/lib/components/ObjectManager/ObjectManager.stories.d.ts +7 -7
- package/src/lib/components/Providers/Providers.d.ts +0 -1
- package/src/lib/components/PublicWarningList/PublicWarningList.stories.d.ts +10 -2
- package/src/lib/components/PublicWarningsForm/ProbabilityField/ProbabilityField.d.ts +7 -0
- package/src/lib/components/PublicWarningsForm/ProbabilityField/index.d.ts +1 -0
- package/src/lib/components/PublicWarningsFormDialog/PublicWarningsFormDialog.stories.d.ts +18 -18
- package/src/lib/store/config.d.ts +0 -2
- package/src/lib/store/publicWarningForm/listener.d.ts +2 -0
- package/src/lib/store/publicWarnings/listener.d.ts +3 -0
- package/src/lib/utils/constants.d.ts +0 -1
- package/src/lib/utils/i18n.d.ts +11 -0
- package/src/lib/store/publicWarningForm/sagas.d.ts +0 -14
- package/src/lib/store/publicWarnings/sagas.d.ts +0 -6
- /package/src/lib/{store/publicWarningForm/sagas.spec.d.ts → components/PublicWarningList/PublicWarningListConnect.editorToggle.integration.spec.d.ts} +0 -0
- /package/src/lib/{store/publicWarnings/sagas.spec.d.ts → components/PublicWarningsForm/ProbabilityField/ProbabilityField.spec.d.ts} +0 -0
- /package/src/lib/{storyshots/Storyshots.spec.d.ts → store/publicWarnings/listener.spec.d.ts} +0 -0
package/index.esm.js
CHANGED
|
@@ -1,212 +1,26 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useState, useEffect } from 'react';
|
|
2
|
+
import React__default, { useState, useEffect, useRef } from 'react';
|
|
3
3
|
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
-
import { Polygons, Share, ExitDomain, Edit, Delete,
|
|
5
|
-
import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, mapStoreActions, drawtoolActions, layerActions, useSetupDialog
|
|
6
|
-
import { emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, MapView, MapViewLayer, defaultLayers, getFeatureExtent } from '@opengeoweb/webmap-react';
|
|
7
|
-
import { handleOutsideComponentTranslations, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage,
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
4
|
+
import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, Wind, Fog, Lightning, Snow, Rain, TemperatureHigh, TemperatureLow, CoastalEvent, breakpoints, Options, VisibilityOff, Success } from '@opengeoweb/theme';
|
|
5
|
+
import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, mapStoreActions, drawtoolActions, layerActions, useSetupDialog } from '@opengeoweb/store';
|
|
6
|
+
import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, MapView, MapViewLayer, defaultLayers, getFeatureExtent } from '@opengeoweb/webmap-react';
|
|
7
|
+
import { handleOutsideComponentTranslations, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, LastUpdateTime, StatusTag, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
|
|
8
|
+
import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
|
|
9
|
+
import 'i18next';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import { defaultBbox } from '@opengeoweb/core';
|
|
11
12
|
import { snackbarActions } from '@opengeoweb/snackbar';
|
|
12
13
|
import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, FormControl, Card, CardContent, ListItemIcon, CircularProgress, List } from '@mui/material';
|
|
13
14
|
import { VariableSizeList } from 'react-window';
|
|
14
15
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
15
|
-
import { DATE_FORMAT_FNS, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isValidDate, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
|
|
16
16
|
import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider } from '@opengeoweb/api';
|
|
17
|
-
import {
|
|
18
|
-
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
19
|
-
import { takeLatest, call as call$c, put, select, delay } from 'redux-saga/effects';
|
|
20
|
-
import { isAxiosError } from 'axios';
|
|
17
|
+
import { ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
|
|
21
18
|
import { useFormContext } from 'react-hook-form';
|
|
22
19
|
import { isEqual, cloneDeep, clamp } from 'lodash';
|
|
20
|
+
import { useAuthenticationContext } from '@opengeoweb/authentication';
|
|
23
21
|
import { produce } from 'immer';
|
|
24
22
|
import { generateMapId, LayerType, getWMJSMapById, WMBBOX } from '@opengeoweb/webmap';
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
/******************************************************************************
|
|
28
|
-
Copyright (c) Microsoft Corporation.
|
|
29
|
-
|
|
30
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
-
purpose with or without fee is hereby granted.
|
|
32
|
-
|
|
33
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
-
***************************************************************************** */
|
|
41
|
-
|
|
42
|
-
function __rest(s, e) {
|
|
43
|
-
var t = {};
|
|
44
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
45
|
-
t[p] = s[p];
|
|
46
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
47
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
48
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
49
|
-
t[p[i]] = s[p[i]];
|
|
50
|
-
}
|
|
51
|
-
return t;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
55
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
56
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
57
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
58
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
59
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
60
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
65
|
-
var e = new Error(message);
|
|
66
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/* *
|
|
70
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
71
|
-
* you may not use this file except in compliance with the License.
|
|
72
|
-
* You may obtain a copy of the License at
|
|
73
|
-
*
|
|
74
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
75
|
-
*
|
|
76
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
77
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
78
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
79
|
-
* See the License for the specific language governing permissions and
|
|
80
|
-
* limitations under the License.
|
|
81
|
-
*
|
|
82
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
83
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
84
|
-
* */
|
|
85
|
-
const objectDialogType = uiTypes.DialogTypes.ObjectManager;
|
|
86
|
-
const drawingDialogType = uiTypes.DialogTypes.DrawingTool;
|
|
87
|
-
|
|
88
|
-
/* *
|
|
89
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
90
|
-
* you may not use this file except in compliance with the License.
|
|
91
|
-
* You may obtain a copy of the License at
|
|
92
|
-
*
|
|
93
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
-
*
|
|
95
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
96
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
97
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
98
|
-
* See the License for the specific language governing permissions and
|
|
99
|
-
* limitations under the License.
|
|
100
|
-
*
|
|
101
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
102
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
103
|
-
* */
|
|
104
|
-
const drawAdapter = createEntityAdapter({
|
|
105
|
-
selectId: draw => draw.drawingInstanceId
|
|
106
|
-
});
|
|
107
|
-
const initialState$2 = drawAdapter.getInitialState();
|
|
108
|
-
const slice$2 = createSlice({
|
|
109
|
-
initialState: initialState$2,
|
|
110
|
-
name: 'drawingForm',
|
|
111
|
-
reducers: {
|
|
112
|
-
setDrawValues: (draft, action) => {
|
|
113
|
-
if (draft.entities[action.payload.drawingInstanceId]) {
|
|
114
|
-
drawAdapter.setOne(draft, action.payload);
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
// action caught in drawings/listener
|
|
118
|
-
submitDrawValues: (
|
|
119
|
-
// eslint-disable-next-line no-unused-vars
|
|
120
|
-
draft,
|
|
121
|
-
// eslint-disable-next-line no-unused-vars
|
|
122
|
-
action) => {},
|
|
123
|
-
setFormDirty: (draft, action) => {
|
|
124
|
-
const {
|
|
125
|
-
drawingInstanceId,
|
|
126
|
-
isFormDirty
|
|
127
|
-
} = action.payload;
|
|
128
|
-
if (draft.entities[drawingInstanceId]) {
|
|
129
|
-
drawAdapter.updateOne(draft, {
|
|
130
|
-
id: drawingInstanceId,
|
|
131
|
-
changes: {
|
|
132
|
-
isFormDirty
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
extraReducers: builder => {
|
|
139
|
-
builder
|
|
140
|
-
// register draw dialog
|
|
141
|
-
.addCase(uiActions.registerDialog, (draft, action) => {
|
|
142
|
-
const {
|
|
143
|
-
type
|
|
144
|
-
} = action.payload;
|
|
145
|
-
if (type === drawingDialogType) {
|
|
146
|
-
drawAdapter.addOne(draft, {
|
|
147
|
-
drawingInstanceId: type,
|
|
148
|
-
objectName: '',
|
|
149
|
-
id: ''
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
// unregister draw dialog
|
|
154
|
-
.addCase(uiActions.unregisterDialog, (draft, action) => {
|
|
155
|
-
const {
|
|
156
|
-
type
|
|
157
|
-
} = action.payload;
|
|
158
|
-
if (type === drawingDialogType) {
|
|
159
|
-
drawAdapter.removeOne(draft, type);
|
|
160
|
-
}
|
|
161
|
-
})
|
|
162
|
-
// reset draw dialog formDirty when dialog closes
|
|
163
|
-
.addCase(uiActions.setActiveMapIdForDialog, (draft, action) => {
|
|
164
|
-
const {
|
|
165
|
-
type,
|
|
166
|
-
setOpen
|
|
167
|
-
} = action.payload;
|
|
168
|
-
if (type === drawingDialogType && !setOpen) {
|
|
169
|
-
drawAdapter.updateOne(draft, {
|
|
170
|
-
id: type,
|
|
171
|
-
changes: {
|
|
172
|
-
isFormDirty: false
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
const {
|
|
180
|
-
reducer: reducer$2
|
|
181
|
-
} = slice$2;
|
|
182
|
-
const drawActions = slice$2.actions;
|
|
183
|
-
|
|
184
|
-
/* *
|
|
185
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
186
|
-
* you may not use this file except in compliance with the License.
|
|
187
|
-
* You may obtain a copy of the License at
|
|
188
|
-
*
|
|
189
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
190
|
-
*
|
|
191
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
192
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
193
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
194
|
-
* See the License for the specific language governing permissions and
|
|
195
|
-
* limitations under the License.
|
|
196
|
-
*
|
|
197
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
198
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
199
|
-
* */
|
|
200
|
-
const {
|
|
201
|
-
selectById: selectDrawByInstanceId
|
|
202
|
-
} = drawAdapter.getSelectors(state => {
|
|
203
|
-
var _a;
|
|
204
|
-
return (_a = state === null || state === void 0 ? void 0 : state.drawings) !== null && _a !== void 0 ? _a : {
|
|
205
|
-
entities: {},
|
|
206
|
-
ids: []
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
const getWarningFormDirty = createSelector(selectDrawByInstanceId, drawing => (drawing === null || drawing === void 0 ? void 0 : drawing.isFormDirty) || false);
|
|
23
|
+
import { isAxiosError } from 'axios';
|
|
210
24
|
|
|
211
25
|
var en = {
|
|
212
26
|
"drawing-tool-form-tools": "Tools",
|
|
@@ -273,6 +87,7 @@ var en = {
|
|
|
273
87
|
"warning-phenomenon-low-temp": "Low temperature",
|
|
274
88
|
"warning-phenomenon-funnel-cloud": "Funnel cloud",
|
|
275
89
|
"warning-phenomenon-coastal-event": "Coastal event",
|
|
90
|
+
"warning-probability-moderate-level-invalid": "Probability should be at least 30% when level is moderate",
|
|
276
91
|
"warning-valid-from": "Valid from",
|
|
277
92
|
"warning-valid-until": "Valid until",
|
|
278
93
|
"warning-valid-from-error-before-current": "Valid from time cannot be before current time",
|
|
@@ -309,6 +124,7 @@ var en = {
|
|
|
309
124
|
"warning-list-header-domain": "Domain",
|
|
310
125
|
"warning-list-header-phenomenon": "Phenomenon",
|
|
311
126
|
"warning-list-header-level": "Level",
|
|
127
|
+
"warning-list-header-status": "Status",
|
|
312
128
|
"warning-list-header-draft": "DRAFT"
|
|
313
129
|
};
|
|
314
130
|
var nl = {
|
|
@@ -376,6 +192,7 @@ var nl = {
|
|
|
376
192
|
"warning-phenomenon-low-temp": "Koude",
|
|
377
193
|
"warning-phenomenon-funnel-cloud": "Hozen",
|
|
378
194
|
"warning-phenomenon-coastal-event": "Kust incident",
|
|
195
|
+
"warning-probability-moderate-level-invalid": "Waarschijnlijkheid moet tenminste 30% zijn als Niveau Gematigd is",
|
|
379
196
|
"warning-valid-from": "Geldig vanaf",
|
|
380
197
|
"warning-valid-until": "Geldig tot",
|
|
381
198
|
"warning-valid-from-error-before-current": "Starttijd mag niet eerder zijn dan huidige tijd",
|
|
@@ -412,6 +229,7 @@ var nl = {
|
|
|
412
229
|
"warning-list-header-domain": "Domein",
|
|
413
230
|
"warning-list-header-phenomenon": "Fenomeen",
|
|
414
231
|
"warning-list-header-level": "Hoogte",
|
|
232
|
+
"warning-list-header-status": "Status",
|
|
415
233
|
"warning-list-header-draft": "CONCEPT"
|
|
416
234
|
};
|
|
417
235
|
var fi = {
|
|
@@ -479,6 +297,7 @@ var fi = {
|
|
|
479
297
|
"warning-phenomenon-low-temp": "ei käännetty",
|
|
480
298
|
"warning-phenomenon-funnel-cloud": "ei käännetty",
|
|
481
299
|
"warning-phenomenon-coastal-event": "ei käännetty",
|
|
300
|
+
"warning-probability-moderate-level-invalid": "ei käännetty",
|
|
482
301
|
"warning-valid-from": "ei käännetty",
|
|
483
302
|
"warning-valid-until": "ei käännetty",
|
|
484
303
|
"warning-valid-from-error-before-current": "ei käännetty",
|
|
@@ -515,110 +334,113 @@ var fi = {
|
|
|
515
334
|
"warning-list-header-domain": "ei käännetty",
|
|
516
335
|
"warning-list-header-phenomenon": "ei käännetty",
|
|
517
336
|
"warning-list-header-level": "ei käännetty",
|
|
337
|
+
"warning-list-header-status": "ei käännetty",
|
|
518
338
|
"warning-list-header-draft": "ei käännetty"
|
|
519
339
|
};
|
|
520
340
|
var no = {
|
|
521
|
-
"drawing-tool-form-tools": "
|
|
522
|
-
"drawing-tool-form-opacity": "
|
|
523
|
-
"drawing-tool-form-object-name": "
|
|
524
|
-
"drawing-tool-form-save": "
|
|
525
|
-
"drawing-tool-form-update": "
|
|
526
|
-
"drawing-tool-form-exit-draw-mode": "
|
|
527
|
-
"drawing-tool-form-drawing-required": "
|
|
528
|
-
"close-dialog-cancel": "
|
|
529
|
-
"close-dialog-confirm": "
|
|
530
|
-
"close-draw-dialog-title": "
|
|
531
|
-
"close-dialog-description": "
|
|
532
|
-
"drawing-tool-title": "
|
|
533
|
-
"object-manager-title": "
|
|
534
|
-
"object-manager-add": "
|
|
535
|
-
"delete-dialog-cancel": "
|
|
536
|
-
"delete-dialog-confirm": "
|
|
537
|
-
"delete-dialog-title": "
|
|
538
|
-
"delete-dialog-description": "
|
|
539
|
-
"delete-succes": "
|
|
540
|
-
"update-succes": "
|
|
541
|
-
"save-succes": "
|
|
542
|
-
"object-manager-no-objects": "
|
|
543
|
-
"object-manager-options-menu": "
|
|
544
|
-
"object-manager-button-edit": "
|
|
545
|
-
"object-manager-button-share": "
|
|
546
|
-
"object-manager-button-delete": "
|
|
547
|
-
"object-manager-button-view": "
|
|
548
|
-
"object-manager-no-object-selected": "
|
|
549
|
-
"object-manager-object-selected": "
|
|
550
|
-
"object-manager-share-menu": "
|
|
551
|
-
"public-warning-title": "
|
|
552
|
-
"close-warning-dialog-title": "
|
|
553
|
-
"warning-edit-mode-title": "
|
|
554
|
-
"warning-edit-mode-description": "
|
|
555
|
-
"warning-dialog-cancel": "
|
|
556
|
-
"warning-edit-mode-confirm": "
|
|
557
|
-
"warning-view-mode-title": "
|
|
558
|
-
"warning-view-mode-description": "
|
|
559
|
-
"warning-view-mode-confirm": "
|
|
560
|
-
"warning-probability": "
|
|
561
|
-
"warning-button-clear": "
|
|
562
|
-
"warning-button-save": "
|
|
563
|
-
"warning-button-saving": "
|
|
564
|
-
"warning-button-publish": "
|
|
565
|
-
"warning-button-publishing": "
|
|
566
|
-
"warning-area": "
|
|
567
|
-
"warning-button-add-object": "
|
|
568
|
-
"warning-description-original": "
|
|
569
|
-
"warning-description-translation": "
|
|
570
|
-
"warning-description-NL": "
|
|
571
|
-
"warning-level": "
|
|
572
|
-
"warning-level-moderate": "
|
|
573
|
-
"warning-level-severe": "
|
|
574
|
-
"warning-level-extreme": "
|
|
575
|
-
"warning-phenomenon": "
|
|
576
|
-
"warning-phenomenon-wind": "
|
|
577
|
-
"warning-phenomenon-fog": "
|
|
578
|
-
"warning-phenomenon-thunderstorm": "
|
|
579
|
-
"warning-phenomenon-snow-ice": "
|
|
580
|
-
"warning-phenomenon-rain": "
|
|
581
|
-
"warning-phenomenon-high-temp": "
|
|
582
|
-
"warning-phenomenon-low-temp": "
|
|
583
|
-
"warning-phenomenon-funnel-cloud": "
|
|
584
|
-
"warning-phenomenon-coastal-event": "
|
|
585
|
-
"warning-
|
|
586
|
-
"warning-valid-
|
|
587
|
-
"warning-valid-
|
|
588
|
-
"warning-valid-from-error-
|
|
589
|
-
"warning-valid-
|
|
590
|
-
"warning-valid-until-error-
|
|
591
|
-
"warning-valid-until-error-
|
|
592
|
-
"warning-
|
|
593
|
-
"warning-dialog-delete-
|
|
594
|
-
"warning-dialog-delete-
|
|
595
|
-
"warning-dialog-delete-
|
|
596
|
-
"warning-dialog-
|
|
597
|
-
"warning-dialog-ignore-
|
|
598
|
-
"warning-dialog-ignore-
|
|
599
|
-
"warning-dialog-ignore-
|
|
600
|
-
"warning-
|
|
601
|
-
"warning-
|
|
602
|
-
"warning-
|
|
603
|
-
"warning-editor-user-
|
|
604
|
-
"warning-editor-
|
|
605
|
-
"warning-editor-
|
|
606
|
-
"warning-
|
|
607
|
-
"warning-list-
|
|
608
|
-
"warning-list-button-
|
|
609
|
-
"warning-list-button-
|
|
610
|
-
"warning-list-
|
|
611
|
-
"warning-list-status-
|
|
612
|
-
"warning-list-status-
|
|
613
|
-
"warning-list-status-
|
|
614
|
-
"warning-list-
|
|
615
|
-
"warning-list-header-
|
|
616
|
-
"warning-list-header-
|
|
617
|
-
"warning-list-header-
|
|
618
|
-
"warning-list-header-
|
|
619
|
-
"warning-list-header-
|
|
620
|
-
"warning-list-header-
|
|
621
|
-
"warning-list-header-
|
|
341
|
+
"drawing-tool-form-tools": "Verktøy",
|
|
342
|
+
"drawing-tool-form-opacity": "Gjennomsiktighet",
|
|
343
|
+
"drawing-tool-form-object-name": "Objektnavn",
|
|
344
|
+
"drawing-tool-form-save": "Lagre nytt objekt",
|
|
345
|
+
"drawing-tool-form-update": "Oppdater objekt",
|
|
346
|
+
"drawing-tool-form-exit-draw-mode": "Trykk ESC for å avslutte tegnemodus",
|
|
347
|
+
"drawing-tool-form-drawing-required": "Objekttegning kreves",
|
|
348
|
+
"close-dialog-cancel": "Avbryt",
|
|
349
|
+
"close-dialog-confirm": "Lukk",
|
|
350
|
+
"close-draw-dialog-title": "Lukk tegneverktøy",
|
|
351
|
+
"close-dialog-description": "Du har gjort endringer, er du sikker på at du vil lukke?",
|
|
352
|
+
"drawing-tool-title": "Tegneverktøy",
|
|
353
|
+
"object-manager-title": "Objektmanager for",
|
|
354
|
+
"object-manager-add": "Legg til nytt objekt",
|
|
355
|
+
"delete-dialog-cancel": "Avbryt",
|
|
356
|
+
"delete-dialog-confirm": "Slett",
|
|
357
|
+
"delete-dialog-title": "Slett objekt",
|
|
358
|
+
"delete-dialog-description": "Er du sikker på at du vil slette?",
|
|
359
|
+
"delete-succes": "er slettet",
|
|
360
|
+
"update-succes": "er oppdatert",
|
|
361
|
+
"save-succes": "er lagret",
|
|
362
|
+
"object-manager-no-objects": "Fant ingen objekter",
|
|
363
|
+
"object-manager-options-menu": "Objektvalg",
|
|
364
|
+
"object-manager-button-edit": "Endre",
|
|
365
|
+
"object-manager-button-share": "Del",
|
|
366
|
+
"object-manager-button-delete": "Slett",
|
|
367
|
+
"object-manager-button-view": "Vis",
|
|
368
|
+
"object-manager-no-object-selected": "(ingen objekt er valgt)",
|
|
369
|
+
"object-manager-object-selected": "objekt er valgt",
|
|
370
|
+
"object-manager-share-menu": "Del objekt med",
|
|
371
|
+
"public-warning-title": "Farevarsel",
|
|
372
|
+
"close-warning-dialog-title": "Lukk farevarsel",
|
|
373
|
+
"warning-edit-mode-title": "Bytt til editeringsmodus",
|
|
374
|
+
"warning-edit-mode-description": "Dette varselet er allerede under endring av en annen bruker. Viktig informasjon kan gå tapt ved å bytte",
|
|
375
|
+
"warning-dialog-cancel": "Gå tilbake",
|
|
376
|
+
"warning-edit-mode-confirm": "Editeringsmodus",
|
|
377
|
+
"warning-view-mode-title": "Whoops",
|
|
378
|
+
"warning-view-mode-description": "Er du sikker på at du vil endre til visningsmodus? Ulagret endringer vil gå tapt.",
|
|
379
|
+
"warning-view-mode-confirm": "Bytt modus",
|
|
380
|
+
"warning-probability": "Sannsynlighet",
|
|
381
|
+
"warning-button-clear": "Slett",
|
|
382
|
+
"warning-button-save": "Lagre",
|
|
383
|
+
"warning-button-saving": "Lagrer",
|
|
384
|
+
"warning-button-publish": "Publiser",
|
|
385
|
+
"warning-button-publishing": "Publiserer",
|
|
386
|
+
"warning-area": "Område",
|
|
387
|
+
"warning-button-add-object": "Legg til objekt",
|
|
388
|
+
"warning-description-original": "Original beskrivelse",
|
|
389
|
+
"warning-description-translation": "Oversatt beskrivelse",
|
|
390
|
+
"warning-description-NL": "Nederlandsk (valgt)",
|
|
391
|
+
"warning-level": "Grad",
|
|
392
|
+
"warning-level-moderate": "Moderat",
|
|
393
|
+
"warning-level-severe": "Stor",
|
|
394
|
+
"warning-level-extreme": "Ekstrem",
|
|
395
|
+
"warning-phenomenon": "Fenomen",
|
|
396
|
+
"warning-phenomenon-wind": "Vind",
|
|
397
|
+
"warning-phenomenon-fog": "Tåke",
|
|
398
|
+
"warning-phenomenon-thunderstorm": "Tordenvær",
|
|
399
|
+
"warning-phenomenon-snow-ice": "Snø/is",
|
|
400
|
+
"warning-phenomenon-rain": "Regn",
|
|
401
|
+
"warning-phenomenon-high-temp": "Høy temperatur",
|
|
402
|
+
"warning-phenomenon-low-temp": "Lav temperatur",
|
|
403
|
+
"warning-phenomenon-funnel-cloud": "Tornado",
|
|
404
|
+
"warning-phenomenon-coastal-event": "Kysthendelse",
|
|
405
|
+
"warning-probability-moderate-level-invalid": "Sannsynlighet bør være minst 30% når level er moderat",
|
|
406
|
+
"warning-valid-from": "Gyldig fra",
|
|
407
|
+
"warning-valid-until": "Gyldig til",
|
|
408
|
+
"warning-valid-from-error-before-current": "Gyldig fra kan ikke være før nåtid",
|
|
409
|
+
"warning-valid-from-error-max-hours": "Gyldig fra kan ikke være mer enn {{MAX_HOURS}} timer etter nåtid",
|
|
410
|
+
"warning-valid-until-error-before-current": "Gyldig til kan ikke være før nåtid",
|
|
411
|
+
"warning-valid-until-error-max-hours": "Gyldig til kan ikke være mer enn {{MAX_HOURS}} timer etter nåtid",
|
|
412
|
+
"warning-valid-until-error-min-hours": "Gyldig til må være minst {{MIN_HOURS}} timer etter Gyldig fra",
|
|
413
|
+
"warning-dialog-delete-succes": "Varselet er slettet",
|
|
414
|
+
"warning-dialog-delete-title": "Slett varsel",
|
|
415
|
+
"warning-dialog-delete-confirm": "Slett",
|
|
416
|
+
"warning-dialog-delete-description": "Er du sikker på at du vil slette varselet?",
|
|
417
|
+
"warning-dialog-ignore-succes": "Varselet er blitt ignorert",
|
|
418
|
+
"warning-dialog-ignore-title": "Ignorer varselet",
|
|
419
|
+
"warning-dialog-ignore-confirm": "Ignorer",
|
|
420
|
+
"warning-dialog-ignore-description": "Er du sikker på at du vil ignorere dette varselet?",
|
|
421
|
+
"warning-save-succes": "Farevarselet er lagret!",
|
|
422
|
+
"warning-publish-succes": "Farevarselet er publisert!",
|
|
423
|
+
"warning-editor-user-viewer": "Visningsmodus",
|
|
424
|
+
"warning-editor-user-editor": "Editeringsmodus",
|
|
425
|
+
"warning-editor-add-editor": "Du editerer nå dette varselet",
|
|
426
|
+
"warning-editor-remove-editor": "Du editerer ikke lenger dette varselet",
|
|
427
|
+
"warning-list-button_create": "Lag et farevarsel",
|
|
428
|
+
"warning-list-button-use": "Bruk",
|
|
429
|
+
"warning-list-button-ignore": "Ignorer",
|
|
430
|
+
"warning-list-button-options": "Valg",
|
|
431
|
+
"warning-list-status-draft": "Utkast",
|
|
432
|
+
"warning-list-status-published": "Publisert",
|
|
433
|
+
"warning-list-status-todo": "Til sjekk",
|
|
434
|
+
"warning-list-status-expired": "Utgått (siste 24 timer)",
|
|
435
|
+
"warning-list-header-incident": "Hendelse",
|
|
436
|
+
"warning-list-header-last-update": "Sist oppdatert",
|
|
437
|
+
"warning-list-header-start-time": "Starttid",
|
|
438
|
+
"warning-list-header-end-time": "Sluttid",
|
|
439
|
+
"warning-list-header-domain": "Domene",
|
|
440
|
+
"warning-list-header-phenomenon": "Fenomen",
|
|
441
|
+
"warning-list-header-level": "Level",
|
|
442
|
+
"warning-list-header-status": "Status",
|
|
443
|
+
"warning-list-header-draft": "UTKAST"
|
|
622
444
|
};
|
|
623
445
|
var warningsTranslations = {
|
|
624
446
|
en: en,
|
|
@@ -627,6 +449,48 @@ var warningsTranslations = {
|
|
|
627
449
|
no: no
|
|
628
450
|
};
|
|
629
451
|
|
|
452
|
+
/******************************************************************************
|
|
453
|
+
Copyright (c) Microsoft Corporation.
|
|
454
|
+
|
|
455
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
456
|
+
purpose with or without fee is hereby granted.
|
|
457
|
+
|
|
458
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
459
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
460
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
461
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
462
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
463
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
464
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
465
|
+
***************************************************************************** */
|
|
466
|
+
|
|
467
|
+
function __rest(s, e) {
|
|
468
|
+
var t = {};
|
|
469
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
470
|
+
t[p] = s[p];
|
|
471
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
472
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
473
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
474
|
+
t[p[i]] = s[p[i]];
|
|
475
|
+
}
|
|
476
|
+
return t;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
480
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
481
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
482
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
483
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
484
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
485
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
490
|
+
var e = new Error(message);
|
|
491
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
492
|
+
};
|
|
493
|
+
|
|
630
494
|
/* *
|
|
631
495
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
632
496
|
* you may not use this file except in compliance with the License.
|
|
@@ -643,32 +507,8 @@ var warningsTranslations = {
|
|
|
643
507
|
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
644
508
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
645
509
|
* */
|
|
646
|
-
const
|
|
647
|
-
const
|
|
648
|
-
const initWarnI18n = () => {
|
|
649
|
-
i18n.use(initReactI18next).init({
|
|
650
|
-
lng: defaultLanguage,
|
|
651
|
-
ns: WARN_NAMESPACE,
|
|
652
|
-
interpolation: {
|
|
653
|
-
escapeValue: false
|
|
654
|
-
},
|
|
655
|
-
resources: {
|
|
656
|
-
en: {
|
|
657
|
-
[`${WARN_NAMESPACE}`]: warningsTranslations.en
|
|
658
|
-
},
|
|
659
|
-
nl: {
|
|
660
|
-
[`${WARN_NAMESPACE}`]: warningsTranslations.nl
|
|
661
|
-
},
|
|
662
|
-
fi: {
|
|
663
|
-
[`${WARN_NAMESPACE}`]: warningsTranslations.fi
|
|
664
|
-
},
|
|
665
|
-
no: {
|
|
666
|
-
[`${WARN_NAMESPACE}`]: warningsTranslations.no
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
};
|
|
671
|
-
const outsideComponentTranslations = handleOutsideComponentTranslations(warningsTranslations, WARN_NAMESPACE);
|
|
510
|
+
const objectDialogType = uiTypes.DialogTypes.ObjectManager;
|
|
511
|
+
const drawingDialogType = uiTypes.DialogTypes.DrawingTool;
|
|
672
512
|
|
|
673
513
|
/* *
|
|
674
514
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -686,22 +526,165 @@ const outsideComponentTranslations = handleOutsideComponentTranslations(warnings
|
|
|
686
526
|
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
687
527
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
688
528
|
* */
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
529
|
+
const drawAdapter = createEntityAdapter({
|
|
530
|
+
selectId: draw => draw.drawingInstanceId
|
|
531
|
+
});
|
|
532
|
+
const initialState$2 = drawAdapter.getInitialState();
|
|
533
|
+
const slice$2 = createSlice({
|
|
534
|
+
initialState: initialState$2,
|
|
535
|
+
name: 'drawingForm',
|
|
536
|
+
reducers: {
|
|
537
|
+
setDrawValues: (draft, action) => {
|
|
538
|
+
if (draft.entities[action.payload.drawingInstanceId]) {
|
|
539
|
+
drawAdapter.setOne(draft, action.payload);
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
// action caught in drawings/listener
|
|
543
|
+
submitDrawValues: (
|
|
544
|
+
// eslint-disable-next-line no-unused-vars
|
|
545
|
+
draft,
|
|
546
|
+
// eslint-disable-next-line no-unused-vars
|
|
547
|
+
action) => {},
|
|
548
|
+
setFormDirty: (draft, action) => {
|
|
549
|
+
const {
|
|
550
|
+
drawingInstanceId,
|
|
551
|
+
isFormDirty
|
|
552
|
+
} = action.payload;
|
|
553
|
+
if (draft.entities[drawingInstanceId]) {
|
|
554
|
+
drawAdapter.updateOne(draft, {
|
|
555
|
+
id: drawingInstanceId,
|
|
556
|
+
changes: {
|
|
557
|
+
isFormDirty
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
extraReducers: builder => {
|
|
564
|
+
builder
|
|
565
|
+
// register draw dialog
|
|
566
|
+
.addCase(uiActions.registerDialog, (draft, action) => {
|
|
567
|
+
const {
|
|
568
|
+
type
|
|
569
|
+
} = action.payload;
|
|
570
|
+
if (type === drawingDialogType) {
|
|
571
|
+
drawAdapter.addOne(draft, {
|
|
572
|
+
drawingInstanceId: type,
|
|
573
|
+
objectName: '',
|
|
574
|
+
id: ''
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
})
|
|
578
|
+
// unregister draw dialog
|
|
579
|
+
.addCase(uiActions.unregisterDialog, (draft, action) => {
|
|
580
|
+
const {
|
|
581
|
+
type
|
|
582
|
+
} = action.payload;
|
|
583
|
+
if (type === drawingDialogType) {
|
|
584
|
+
drawAdapter.removeOne(draft, type);
|
|
585
|
+
}
|
|
586
|
+
})
|
|
587
|
+
// reset draw dialog formDirty when dialog closes
|
|
588
|
+
.addCase(uiActions.setActiveMapIdForDialog, (draft, action) => {
|
|
589
|
+
const {
|
|
590
|
+
type,
|
|
591
|
+
setOpen
|
|
592
|
+
} = action.payload;
|
|
593
|
+
if (type === drawingDialogType && !setOpen) {
|
|
594
|
+
drawAdapter.updateOne(draft, {
|
|
595
|
+
id: type,
|
|
596
|
+
changes: {
|
|
597
|
+
isFormDirty: false
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
const {
|
|
605
|
+
reducer: reducer$2
|
|
606
|
+
} = slice$2;
|
|
607
|
+
const drawActions = slice$2.actions;
|
|
608
|
+
|
|
609
|
+
/* *
|
|
610
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
611
|
+
* you may not use this file except in compliance with the License.
|
|
612
|
+
* You may obtain a copy of the License at
|
|
613
|
+
*
|
|
614
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
615
|
+
*
|
|
616
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
617
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
618
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
619
|
+
* See the License for the specific language governing permissions and
|
|
620
|
+
* limitations under the License.
|
|
621
|
+
*
|
|
622
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
623
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
624
|
+
* */
|
|
625
|
+
const {
|
|
626
|
+
selectById: selectDrawByInstanceId
|
|
627
|
+
} = drawAdapter.getSelectors(state => {
|
|
628
|
+
var _a;
|
|
629
|
+
return (_a = state === null || state === void 0 ? void 0 : state.drawings) !== null && _a !== void 0 ? _a : {
|
|
630
|
+
entities: {},
|
|
631
|
+
ids: []
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
const getWarningFormDirty = createSelector(selectDrawByInstanceId, drawing => (drawing === null || drawing === void 0 ? void 0 : drawing.isFormDirty) || false);
|
|
635
|
+
|
|
636
|
+
/* *
|
|
637
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
638
|
+
* you may not use this file except in compliance with the License.
|
|
639
|
+
* You may obtain a copy of the License at
|
|
640
|
+
*
|
|
641
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
642
|
+
*
|
|
643
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
644
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
645
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
646
|
+
* See the License for the specific language governing permissions and
|
|
647
|
+
* limitations under the License.
|
|
648
|
+
*
|
|
649
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
650
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
651
|
+
* */
|
|
652
|
+
const WARN_NAMESPACE = 'warn';
|
|
653
|
+
const outsideComponentTranslations = handleOutsideComponentTranslations(warningsTranslations, WARN_NAMESPACE);
|
|
654
|
+
const useWarningsTranslation = () => useTranslation(WARN_NAMESPACE);
|
|
655
|
+
|
|
656
|
+
/* *
|
|
657
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
658
|
+
* you may not use this file except in compliance with the License.
|
|
659
|
+
* You may obtain a copy of the License at
|
|
660
|
+
*
|
|
661
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
662
|
+
*
|
|
663
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
664
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
665
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
666
|
+
* See the License for the specific language governing permissions and
|
|
667
|
+
* limitations under the License.
|
|
668
|
+
*
|
|
669
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
670
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
671
|
+
* */
|
|
672
|
+
const confirmationDialogOptions = t => {
|
|
673
|
+
return {
|
|
674
|
+
cancelLabel: t('close-dialog-cancel'),
|
|
675
|
+
title: t('close-draw-dialog-title'),
|
|
676
|
+
description: t('close-dialog-description'),
|
|
677
|
+
confirmLabel: t('close-dialog-confirm'),
|
|
678
|
+
catchOnCancel: true
|
|
679
|
+
};
|
|
680
|
+
};
|
|
698
681
|
const useCloseDrawDialog = ({
|
|
699
682
|
mapId,
|
|
700
683
|
source
|
|
701
684
|
}) => {
|
|
702
685
|
const {
|
|
703
686
|
t
|
|
704
|
-
} =
|
|
687
|
+
} = useWarningsTranslation();
|
|
705
688
|
const dispatch = useDispatch();
|
|
706
689
|
const drawLayerId = getSingularDrawtoolDrawLayerId(mapId);
|
|
707
690
|
const drawDialogActiveDrawModeId = useSelector(store => drawtoolSelectors.getActiveDrawModeId(store, drawingDialogType));
|
|
@@ -767,7 +750,7 @@ const useCloseObjectDialog = ({
|
|
|
767
750
|
}) => {
|
|
768
751
|
const dispatch = useDispatch();
|
|
769
752
|
const drawLayerId = getSingularDrawtoolDrawLayerId(mapId);
|
|
770
|
-
const
|
|
753
|
+
const featureLayerContainsGeoJSON = useSelector(store => layerSelectors.getHasFeatureLayerGeoJSON(store, drawLayerId));
|
|
771
754
|
const closeObjectDialog = (shouldReset = true) => {
|
|
772
755
|
// reset active object
|
|
773
756
|
if (shouldReset) {
|
|
@@ -784,7 +767,7 @@ const useCloseObjectDialog = ({
|
|
|
784
767
|
setOpen: false,
|
|
785
768
|
source
|
|
786
769
|
}));
|
|
787
|
-
if (
|
|
770
|
+
if (featureLayerContainsGeoJSON && shouldReset) {
|
|
788
771
|
dispatch(mapStoreActions.layerChangeGeojson({
|
|
789
772
|
layerId: drawLayerId,
|
|
790
773
|
geojson: emptyGeoJSON
|
|
@@ -801,11 +784,11 @@ const useDialogOptions = ({
|
|
|
801
784
|
const isDialogOpen = useSelector(store => uiSelectors.getisDialogOpen(store, dialogType));
|
|
802
785
|
const dialogMapId = useSelector(store => uiSelectors.getDialogMapId(store, dialogType));
|
|
803
786
|
const dialogLayerId = getSingularDrawtoolDrawLayerId(dialogMapId);
|
|
804
|
-
const
|
|
787
|
+
const hasGeoJSON = useSelector(store => layerSelectors.getHasFeatureLayerGeoJSON(store, dialogLayerId));
|
|
805
788
|
return {
|
|
806
789
|
isDialogOpen,
|
|
807
790
|
dialogMapId,
|
|
808
|
-
|
|
791
|
+
hasGeoJSON,
|
|
809
792
|
dialogLayerId
|
|
810
793
|
};
|
|
811
794
|
};
|
|
@@ -815,14 +798,14 @@ const useObjectDrawDialogAction = ({
|
|
|
815
798
|
}) => {
|
|
816
799
|
const {
|
|
817
800
|
t
|
|
818
|
-
} =
|
|
801
|
+
} = useWarningsTranslation();
|
|
819
802
|
const dispatch = useDispatch();
|
|
820
803
|
const confirmDialog = useConfirmationDialog();
|
|
821
804
|
const currentDrawLayerId = getSingularDrawtoolDrawLayerId(mapId);
|
|
822
805
|
// draw selectors
|
|
823
806
|
const {
|
|
824
807
|
isDialogOpen: isDrawDialogOpen,
|
|
825
|
-
|
|
808
|
+
hasGeoJSON: drawDialogLayerHasGeoJSON,
|
|
826
809
|
dialogLayerId: drawDialogLayerId
|
|
827
810
|
} = useDialogOptions({
|
|
828
811
|
dialogType: drawingDialogType
|
|
@@ -832,7 +815,7 @@ const useObjectDrawDialogAction = ({
|
|
|
832
815
|
// object selectors
|
|
833
816
|
const {
|
|
834
817
|
isDialogOpen: isObjectDialogOpen,
|
|
835
|
-
|
|
818
|
+
hasGeoJSON: objectDialogLayerHasGeoJSON,
|
|
836
819
|
dialogLayerId: objectDialogLayerId
|
|
837
820
|
} = useDialogOptions({
|
|
838
821
|
dialogType: objectDialogType
|
|
@@ -851,7 +834,7 @@ const useObjectDrawDialogAction = ({
|
|
|
851
834
|
return;
|
|
852
835
|
}
|
|
853
836
|
}
|
|
854
|
-
if (
|
|
837
|
+
if (drawDialogLayerHasGeoJSON) {
|
|
855
838
|
clearGeoJSON(drawDialogLayerId);
|
|
856
839
|
}
|
|
857
840
|
closeDrawDialog(true);
|
|
@@ -864,11 +847,11 @@ const useObjectDrawDialogAction = ({
|
|
|
864
847
|
source
|
|
865
848
|
}));
|
|
866
849
|
// move shape to screen
|
|
867
|
-
if (isObjectDialogOpen &&
|
|
850
|
+
if (isObjectDialogOpen && objectDialogLayerHasGeoJSON) {
|
|
868
851
|
// update new shape
|
|
869
|
-
dispatch(mapStoreActions.
|
|
852
|
+
dispatch(mapStoreActions.layerSetGeojsonFromLayer({
|
|
870
853
|
layerId: currentDrawLayerId,
|
|
871
|
-
|
|
854
|
+
sourceLayerId: objectDialogLayerId
|
|
872
855
|
}));
|
|
873
856
|
// remove current shape
|
|
874
857
|
clearGeoJSON(objectDialogLayerId);
|
|
@@ -876,7 +859,7 @@ const useObjectDrawDialogAction = ({
|
|
|
876
859
|
});
|
|
877
860
|
const openDrawDialog = newGeoJSON => {
|
|
878
861
|
if (isObjectDialogOpen) {
|
|
879
|
-
if (
|
|
862
|
+
if (objectDialogLayerHasGeoJSON) {
|
|
880
863
|
clearGeoJSON(objectDialogLayerId);
|
|
881
864
|
}
|
|
882
865
|
const shouldResetShape = newGeoJSON === undefined;
|
|
@@ -894,12 +877,19 @@ const useObjectDrawDialogAction = ({
|
|
|
894
877
|
drawToolId: drawingDialogType,
|
|
895
878
|
geoJSONLayerId: currentDrawLayerId
|
|
896
879
|
}));
|
|
880
|
+
// activate default draw mode
|
|
881
|
+
if (!drawDialogActiveDrawModeId && !isDrawDialogOpen) {
|
|
882
|
+
dispatch(drawtoolActions.changeDrawToolMode({
|
|
883
|
+
drawToolId: drawingDialogType,
|
|
884
|
+
drawModeId: defaultPolygon.drawModeId
|
|
885
|
+
}));
|
|
886
|
+
}
|
|
897
887
|
// move shape to screen
|
|
898
|
-
if (isDrawDialogOpen &&
|
|
888
|
+
if (isDrawDialogOpen && drawDialogLayerHasGeoJSON) {
|
|
899
889
|
// update new shape
|
|
900
|
-
dispatch(mapStoreActions.
|
|
890
|
+
dispatch(mapStoreActions.layerSetGeojsonFromLayer({
|
|
901
891
|
layerId: currentDrawLayerId,
|
|
902
|
-
|
|
892
|
+
sourceLayerId: drawDialogLayerId
|
|
903
893
|
}));
|
|
904
894
|
// remove current shape
|
|
905
895
|
clearGeoJSON(drawDialogLayerId);
|
|
@@ -2704,7 +2694,6 @@ $$5({ target: 'Array', proto: true, arity: 1, forced: FORCED$3 }, {
|
|
|
2704
2694
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
2705
2695
|
* */
|
|
2706
2696
|
const DATE_FORMAT_HEADER = 'EEEE, MMMM dd';
|
|
2707
|
-
const DATE_FORMAT_LASTUPDATEDTIME = 'HH:mm';
|
|
2708
2697
|
|
|
2709
2698
|
const DEFAULT_ADD_BUTTON_HEIGHT = 80;
|
|
2710
2699
|
const OBJECT_ITEM_SIZE = 50;
|
|
@@ -2782,7 +2771,7 @@ const Objects = ({
|
|
|
2782
2771
|
}) => {
|
|
2783
2772
|
const {
|
|
2784
2773
|
t
|
|
2785
|
-
} =
|
|
2774
|
+
} = useWarningsTranslation();
|
|
2786
2775
|
const listRef = React__default.useRef(null);
|
|
2787
2776
|
const {
|
|
2788
2777
|
listInclHeaders,
|
|
@@ -2949,7 +2938,7 @@ const Objects = ({
|
|
|
2949
2938
|
maxHeight: '32px',
|
|
2950
2939
|
overflow: 'hidden'
|
|
2951
2940
|
}
|
|
2952
|
-
}, object.scope === 'global' && 'Global: ', `${dateUtils.dateToString(dateUtils.utc(object.lastUpdatedTime),
|
|
2941
|
+
}, object.scope === 'global' && 'Global: ', `${dateUtils.dateToString(dateUtils.utc(object.lastUpdatedTime), dateUtils.DATE_FORMAT_DATEPICKER)} UTC`))))));
|
|
2953
2942
|
})))));
|
|
2954
2943
|
};
|
|
2955
2944
|
|
|
@@ -2989,7 +2978,7 @@ const ObjectManager = ({
|
|
|
2989
2978
|
}) => {
|
|
2990
2979
|
const {
|
|
2991
2980
|
t
|
|
2992
|
-
} =
|
|
2981
|
+
} = useWarningsTranslation();
|
|
2993
2982
|
const minSize = DEFAULT_OBJECT_MANAGER_MIN_SIZE;
|
|
2994
2983
|
const startSizeCalc = calculateStartSize(minSize, _size, _startPosition);
|
|
2995
2984
|
const [sizeInState, setSizeInState] = React.useState(startSizeCalc);
|
|
@@ -3147,7 +3136,7 @@ const ConfirmDeleteDialog = ({
|
|
|
3147
3136
|
}) => {
|
|
3148
3137
|
const {
|
|
3149
3138
|
t
|
|
3150
|
-
} =
|
|
3139
|
+
} = useWarningsTranslation();
|
|
3151
3140
|
const warningsApi = getWarningsApi();
|
|
3152
3141
|
const [isLoading, setIsLoading] = React__default.useState(false);
|
|
3153
3142
|
const [error, setError] = React__default.useState(undefined);
|
|
@@ -3426,7 +3415,7 @@ const ObjectManagerConnect = ({
|
|
|
3426
3415
|
}) => {
|
|
3427
3416
|
const {
|
|
3428
3417
|
t
|
|
3429
|
-
} =
|
|
3418
|
+
} = useWarningsTranslation();
|
|
3430
3419
|
const {
|
|
3431
3420
|
dialogOrder,
|
|
3432
3421
|
setDialogOrder,
|
|
@@ -5346,6 +5335,7 @@ var warningListJSON = [
|
|
|
5346
5335
|
status: "DRAFT",
|
|
5347
5336
|
editor: "user.name",
|
|
5348
5337
|
warningDetail: {
|
|
5338
|
+
id: "550c2b5e-937d-11ee-a1bf-0ab3cf8a98c1",
|
|
5349
5339
|
phenomenon: "fog",
|
|
5350
5340
|
geoJSON: {
|
|
5351
5341
|
type: "FeatureCollection",
|
|
@@ -5389,7 +5379,9 @@ var warningListJSON = [
|
|
|
5389
5379
|
validFrom: "2023-12-05T14:48:09Z",
|
|
5390
5380
|
validUntil: "2023-12-05T18:48:09Z",
|
|
5391
5381
|
level: "moderate",
|
|
5392
|
-
probability: 30
|
|
5382
|
+
probability: 30,
|
|
5383
|
+
descriptionOriginal: "This is the original description",
|
|
5384
|
+
descriptionTranslation: "This is the translation"
|
|
5393
5385
|
}
|
|
5394
5386
|
},
|
|
5395
5387
|
{
|
|
@@ -5679,419 +5671,89 @@ var warningListJSON = [
|
|
|
5679
5671
|
53.492000941975654
|
|
5680
5672
|
],
|
|
5681
5673
|
[
|
|
5682
|
-
4.280148780801422,
|
|
5683
|
-
52.46455621916433
|
|
5684
|
-
],
|
|
5685
|
-
[
|
|
5686
|
-
6.878229305858475,
|
|
5687
|
-
52.98133263853793
|
|
5688
|
-
],
|
|
5689
|
-
[
|
|
5690
|
-
5.0950448864466225,
|
|
5691
|
-
53.492000941975654
|
|
5692
|
-
]
|
|
5693
|
-
]
|
|
5694
|
-
]
|
|
5695
|
-
},
|
|
5696
|
-
properties: {
|
|
5697
|
-
fill: "#ff7800",
|
|
5698
|
-
stroke: "#ff7800",
|
|
5699
|
-
"fill-opacity": 0.2,
|
|
5700
|
-
"stroke-width": 2,
|
|
5701
|
-
selectionType: "poly",
|
|
5702
|
-
"stroke-opacity": 1
|
|
5703
|
-
}
|
|
5704
|
-
}
|
|
5705
|
-
]
|
|
5706
|
-
},
|
|
5707
|
-
validFrom: "2023-12-05T14:47:50Z",
|
|
5708
|
-
validUntil: "2023-12-05T20:47:50Z",
|
|
5709
|
-
level: "moderate",
|
|
5710
|
-
probability: 40
|
|
5711
|
-
}
|
|
5712
|
-
},
|
|
5713
|
-
{
|
|
5714
|
-
id: "3f756602-937d-11ee-a1bf-0ab3cf8a98c1",
|
|
5715
|
-
lastUpdatedTime: "2023-12-05T14:47:43Z",
|
|
5716
|
-
status: "EXPIRED",
|
|
5717
|
-
warningDetail: {
|
|
5718
|
-
phenomenon: "thunderstorm",
|
|
5719
|
-
geoJSON: {
|
|
5720
|
-
type: "FeatureCollection",
|
|
5721
|
-
features: [
|
|
5722
|
-
{
|
|
5723
|
-
type: "Feature",
|
|
5724
|
-
geometry: {
|
|
5725
|
-
type: "Polygon",
|
|
5726
|
-
coordinates: [
|
|
5727
|
-
[
|
|
5728
|
-
[
|
|
5729
|
-
5.0950448864466225,
|
|
5730
|
-
53.492000941975654
|
|
5731
|
-
],
|
|
5732
|
-
[
|
|
5733
|
-
4.280148780801422,
|
|
5734
|
-
52.46455621916433
|
|
5735
|
-
],
|
|
5736
|
-
[
|
|
5737
|
-
6.878229305858475,
|
|
5738
|
-
52.98133263853793
|
|
5739
|
-
],
|
|
5740
|
-
[
|
|
5741
|
-
5.0950448864466225,
|
|
5742
|
-
53.492000941975654
|
|
5743
|
-
]
|
|
5744
|
-
]
|
|
5745
|
-
]
|
|
5746
|
-
},
|
|
5747
|
-
properties: {
|
|
5748
|
-
fill: "#ff7800",
|
|
5749
|
-
stroke: "#ff7800",
|
|
5750
|
-
"fill-opacity": 0.2,
|
|
5751
|
-
"stroke-width": 2,
|
|
5752
|
-
selectionType: "poly",
|
|
5753
|
-
"stroke-opacity": 1
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
]
|
|
5757
|
-
},
|
|
5758
|
-
validFrom: "2023-12-05T14:47:34Z",
|
|
5759
|
-
validUntil: "2023-12-05T20:47:34Z",
|
|
5760
|
-
level: "extreme",
|
|
5761
|
-
probability: 40
|
|
5762
|
-
}
|
|
5763
|
-
}
|
|
5764
|
-
];
|
|
5765
|
-
|
|
5766
|
-
/* *
|
|
5767
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5768
|
-
* you may not use this file except in compliance with the License.
|
|
5769
|
-
* You may obtain a copy of the License at
|
|
5770
|
-
*
|
|
5771
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5772
|
-
*
|
|
5773
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5774
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5775
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5776
|
-
* See the License for the specific language governing permissions and
|
|
5777
|
-
* limitations under the License.
|
|
5778
|
-
*
|
|
5779
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5780
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
5781
|
-
* */
|
|
5782
|
-
const drawingList = drawingListJSON;
|
|
5783
|
-
const drawingsListFullContent = drawingsListFullContentJSON;
|
|
5784
|
-
const warningList = warningListJSON;
|
|
5785
|
-
|
|
5786
|
-
const ERROR_NOT_FOUND = 'Request failed with status code 400';
|
|
5787
|
-
const MOCK_USERNAME = 'user.name';
|
|
5788
|
-
const extractDrawingDetailsFromJSON = drawingId => {
|
|
5789
|
-
return drawingsListFullContent.find(element => element.id === drawingId);
|
|
5790
|
-
};
|
|
5791
|
-
const getApiRoutes = axiosInstance => ({
|
|
5792
|
-
// drawings
|
|
5793
|
-
getDrawings: () => {
|
|
5794
|
-
return axiosInstance.get('/drawings').then(() => {
|
|
5795
|
-
return {
|
|
5796
|
-
data: drawingList
|
|
5797
|
-
};
|
|
5798
|
-
});
|
|
5799
|
-
},
|
|
5800
|
-
getDrawingDetails: drawingId => {
|
|
5801
|
-
return axiosInstance.get(`/drawings/${drawingId}`).then(() => {
|
|
5802
|
-
if (!extractDrawingDetailsFromJSON(drawingId)) {
|
|
5803
|
-
throw new Error(ERROR_NOT_FOUND);
|
|
5804
|
-
}
|
|
5805
|
-
return {
|
|
5806
|
-
data: extractDrawingDetailsFromJSON(drawingId)
|
|
5807
|
-
};
|
|
5808
|
-
});
|
|
5809
|
-
},
|
|
5810
|
-
updateDrawing: (drawingId, data) => {
|
|
5811
|
-
// eslint-disable-next-line no-console
|
|
5812
|
-
console.log('api: save drawing', drawingId, data);
|
|
5813
|
-
return axiosInstance.post(`/drawings/${drawingId}/`, data);
|
|
5814
|
-
},
|
|
5815
|
-
saveDrawingAs: data => {
|
|
5816
|
-
// eslint-disable-next-line no-console
|
|
5817
|
-
console.log('api: save drawing as', data);
|
|
5818
|
-
return axiosInstance.post(`/drawings/`, data).then(() => 'new-drawing-id');
|
|
5819
|
-
},
|
|
5820
|
-
deleteDrawing: drawingId => {
|
|
5821
|
-
// eslint-disable-next-line no-console
|
|
5822
|
-
console.log('api: delete drawing', drawingId);
|
|
5823
|
-
drawingList.splice(drawingList.findIndex(drawing => drawing.id === drawingId), 1);
|
|
5824
|
-
return axiosInstance.post(`/drawings/${drawingId}?delete=true`);
|
|
5825
|
-
},
|
|
5826
|
-
// public warnings
|
|
5827
|
-
getWarnings: () => {
|
|
5828
|
-
return axiosInstance.get(`/warnings/`).then(() => ({
|
|
5829
|
-
data: warningList
|
|
5830
|
-
}));
|
|
5831
|
-
},
|
|
5832
|
-
saveWarningAs: data => {
|
|
5833
|
-
// eslint-disable-next-line no-console
|
|
5834
|
-
console.log('api: save warning as', data);
|
|
5835
|
-
return axiosInstance.post(`/warnings/`, data).then(() => 'new-warning-id');
|
|
5836
|
-
},
|
|
5837
|
-
updateWarning: (warningId, data) => {
|
|
5838
|
-
// eslint-disable-next-line no-console
|
|
5839
|
-
console.log(`api: update warning ${warningId}`, data);
|
|
5840
|
-
return axiosInstance.post(`/warnings/${warningId}/`, data);
|
|
5841
|
-
},
|
|
5842
|
-
deleteWarning: warningId => {
|
|
5843
|
-
// eslint-disable-next-line no-console
|
|
5844
|
-
console.log('api: delete warning', warningId);
|
|
5845
|
-
warningList.splice(warningList.findIndex(warning => warning.id === warningId), 1);
|
|
5846
|
-
return axiosInstance.post(`/warnings/${warningId}?delete=true`);
|
|
5847
|
-
},
|
|
5848
|
-
toggleEditorWarning: (warningId, isEditor) => {
|
|
5849
|
-
// eslint-disable-next-line no-console
|
|
5850
|
-
console.log('api: toggle editor warning', warningId, isEditor);
|
|
5851
|
-
const index = warningList.findIndex(warning => warning.id === warningId);
|
|
5852
|
-
warningList.splice(index, 1, Object.assign(Object.assign({}, warningList[index]), {
|
|
5853
|
-
editor: isEditor ? MOCK_USERNAME : null
|
|
5854
|
-
}));
|
|
5855
|
-
return axiosInstance.post(`/warnings/${warningId}?editor=${isEditor ? 'true' : 'false'}`);
|
|
5856
|
-
}
|
|
5857
|
-
});
|
|
5858
|
-
// used in storybook
|
|
5859
|
-
const createApi = () => {
|
|
5860
|
-
const instance = createFakeApiInstance();
|
|
5861
|
-
return getApiRoutes(instance);
|
|
5862
|
-
};
|
|
5863
|
-
|
|
5864
|
-
const getErrorMessage = error => isAxiosError(error) ? getAxiosErrorMessage(error) : error.message;
|
|
5865
|
-
function* saveOrUpdateWarning(publicWarning) {
|
|
5866
|
-
const warningsApi = yield call$c(getWarningsApi);
|
|
5867
|
-
if (publicWarning.warningDetail.id) {
|
|
5868
|
-
yield call$c(warningsApi.updateWarning, publicWarning.warningDetail.id, publicWarning);
|
|
5869
|
-
return publicWarning;
|
|
5870
|
-
}
|
|
5871
|
-
const newWarningId = yield call$c(warningsApi.saveWarningAs, publicWarning);
|
|
5872
|
-
return Object.assign(Object.assign({}, publicWarning), {
|
|
5873
|
-
warningDetail: Object.assign(Object.assign({}, publicWarning.warningDetail), {
|
|
5874
|
-
id: newWarningId
|
|
5875
|
-
})
|
|
5876
|
-
});
|
|
5877
|
-
}
|
|
5878
|
-
const getToggleEditorSuccessMessage = isEditor => outsideComponentTranslations[isEditor ? 'warning-editor-add-editor' : 'warning-editor-remove-editor'];
|
|
5879
|
-
function* toggleEditorWarningSaga({
|
|
5880
|
-
payload
|
|
5881
|
-
}) {
|
|
5882
|
-
try {
|
|
5883
|
-
const {
|
|
5884
|
-
warningId,
|
|
5885
|
-
isEditor,
|
|
5886
|
-
username
|
|
5887
|
-
} = payload;
|
|
5888
|
-
const warningsApi = yield call$c(getWarningsApi);
|
|
5889
|
-
yield call$c(warningsApi.toggleEditorWarning, warningId, isEditor);
|
|
5890
|
-
// update list to show correct avatar
|
|
5891
|
-
yield put(publicWarningActions.fetchWarnings());
|
|
5892
|
-
yield put(publicWarningFormActions.toggleEditorWarningSuccess({
|
|
5893
|
-
isEditor,
|
|
5894
|
-
username,
|
|
5895
|
-
message: getToggleEditorSuccessMessage(isEditor)
|
|
5896
|
-
}));
|
|
5897
|
-
} catch (error) {
|
|
5898
|
-
yield call$c(errorSaga, getErrorMessage(error));
|
|
5899
|
-
}
|
|
5900
|
-
}
|
|
5901
|
-
function* publishWarningSaga({
|
|
5902
|
-
payload
|
|
5903
|
-
}) {
|
|
5904
|
-
try {
|
|
5905
|
-
const {
|
|
5906
|
-
publicWarning
|
|
5907
|
-
} = payload;
|
|
5908
|
-
const publishedWarning = yield call$c(saveOrUpdateWarning, publicWarning);
|
|
5909
|
-
yield put(publicWarningFormActions.publishWarningSuccess({
|
|
5910
|
-
publicWarning: publishedWarning,
|
|
5911
|
-
message: outsideComponentTranslations['warning-publish-succes']
|
|
5912
|
-
}));
|
|
5913
|
-
yield put(uiActions.setToggleOpenDialog({
|
|
5914
|
-
type: publicWarningDialogType,
|
|
5915
|
-
setOpen: false
|
|
5916
|
-
}));
|
|
5917
|
-
} catch (error) {
|
|
5918
|
-
yield call$c(errorSaga, getErrorMessage(error));
|
|
5919
|
-
}
|
|
5920
|
-
}
|
|
5921
|
-
function* saveWarningSaga({
|
|
5922
|
-
payload
|
|
5923
|
-
}) {
|
|
5924
|
-
try {
|
|
5925
|
-
const {
|
|
5926
|
-
publicWarning
|
|
5927
|
-
} = payload;
|
|
5928
|
-
const savedWarning = yield call$c(saveOrUpdateWarning, publicWarning);
|
|
5929
|
-
yield put(publicWarningFormActions.saveWarningSuccess({
|
|
5930
|
-
publicWarning: savedWarning,
|
|
5931
|
-
message: outsideComponentTranslations['warning-save-succes']
|
|
5932
|
-
}));
|
|
5933
|
-
} catch (error) {
|
|
5934
|
-
yield call$c(errorSaga, getErrorMessage(error));
|
|
5935
|
-
}
|
|
5936
|
-
}
|
|
5937
|
-
function* successSaga({
|
|
5938
|
-
payload
|
|
5939
|
-
}) {
|
|
5940
|
-
const {
|
|
5941
|
-
message
|
|
5942
|
-
} = payload;
|
|
5943
|
-
yield put(snackbarActions.openSnackbar({
|
|
5944
|
-
message
|
|
5945
|
-
}));
|
|
5946
|
-
yield call$c(toggleDialogLoadingSaga, false);
|
|
5947
|
-
}
|
|
5948
|
-
function* errorSaga(message) {
|
|
5949
|
-
yield put(publicWarningFormActions.setFormError({
|
|
5950
|
-
message
|
|
5951
|
-
}));
|
|
5952
|
-
yield call$c(toggleDialogLoadingSaga, false);
|
|
5953
|
-
}
|
|
5954
|
-
function* toggleDialogLoadingSaga(isLoading) {
|
|
5955
|
-
const isDialogOpen = yield select(uiSelectors.getDialogDetailsByType, publicWarningDialogType);
|
|
5956
|
-
if (isDialogOpen) {
|
|
5957
|
-
yield put(uiActions.toggleIsLoadingDialog({
|
|
5958
|
-
isLoading,
|
|
5959
|
-
type: publicWarningDialogType
|
|
5960
|
-
}));
|
|
5961
|
-
}
|
|
5962
|
-
}
|
|
5963
|
-
function* openDialogSaga() {
|
|
5964
|
-
yield put(uiActions.setToggleOpenDialog({
|
|
5965
|
-
setOpen: true,
|
|
5966
|
-
type: publicWarningDialogType
|
|
5967
|
-
}));
|
|
5968
|
-
}
|
|
5969
|
-
function* publicWarningRootSaga() {
|
|
5970
|
-
// requests
|
|
5971
|
-
yield takeLatest(publicWarningFormActions.toggleEditorWarning, toggleEditorWarningSaga);
|
|
5972
|
-
yield takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
|
|
5973
|
-
yield takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
|
|
5974
|
-
// side effects ui/snackbar
|
|
5975
|
-
yield takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess, publicWarningFormActions.toggleEditorWarningSuccess], successSaga);
|
|
5976
|
-
yield takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
|
|
5977
|
-
yield takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
|
|
5978
|
-
}
|
|
5979
|
-
|
|
5980
|
-
/* *
|
|
5981
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5982
|
-
* you may not use this file except in compliance with the License.
|
|
5983
|
-
* You may obtain a copy of the License at
|
|
5984
|
-
*
|
|
5985
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5986
|
-
*
|
|
5987
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5988
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5989
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5990
|
-
* See the License for the specific language governing permissions and
|
|
5991
|
-
* limitations under the License.
|
|
5992
|
-
*
|
|
5993
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5994
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
5995
|
-
* */
|
|
5996
|
-
const getLastUpdatedTimeFormatted = () => dateUtils.dateToString(dateUtils.utc(), DATE_FORMAT_LASTUPDATEDTIME);
|
|
5997
|
-
function* fetchWarningsSaga() {
|
|
5998
|
-
try {
|
|
5999
|
-
const warningsApi = yield call$c(getWarningsApi);
|
|
6000
|
-
const {
|
|
6001
|
-
data: warnings
|
|
6002
|
-
} = yield call$c(warningsApi.getWarnings);
|
|
6003
|
-
const lastUpdatedTime = getLastUpdatedTimeFormatted();
|
|
6004
|
-
yield put(publicWarningActions.fetchWarningsSuccess({
|
|
6005
|
-
warnings,
|
|
6006
|
-
lastUpdatedTime
|
|
6007
|
-
}));
|
|
6008
|
-
yield delay(pollingIntervalTimeout);
|
|
6009
|
-
yield put(publicWarningActions.fetchWarnings());
|
|
6010
|
-
} catch (error) {
|
|
6011
|
-
yield put(publicWarningActions.fetchWarningsError({
|
|
6012
|
-
error: {
|
|
6013
|
-
name: error.name,
|
|
6014
|
-
message: error.message
|
|
6015
|
-
}
|
|
6016
|
-
}));
|
|
6017
|
-
}
|
|
6018
|
-
}
|
|
6019
|
-
function* refetchWarnings() {
|
|
6020
|
-
yield put(publicWarningActions.fetchWarnings());
|
|
6021
|
-
}
|
|
6022
|
-
function* publicWarnings() {
|
|
6023
|
-
yield takeLatest(publicWarningActions.fetchWarnings, fetchWarningsSaga);
|
|
6024
|
-
yield takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess], refetchWarnings);
|
|
6025
|
-
}
|
|
6026
|
-
|
|
6027
|
-
/* *
|
|
6028
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6029
|
-
* you may not use this file except in compliance with the License.
|
|
6030
|
-
* You may obtain a copy of the License at
|
|
6031
|
-
*
|
|
6032
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6033
|
-
*
|
|
6034
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
6035
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6036
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6037
|
-
* See the License for the specific language governing permissions and
|
|
6038
|
-
* limitations under the License.
|
|
6039
|
-
*
|
|
6040
|
-
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6041
|
-
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
6042
|
-
* */
|
|
6043
|
-
const getSnackbarMessage = (objectName, id) => id ? `Object "${objectName}" ${outsideComponentTranslations['update-succes']}!` : `Object "${objectName}" ${outsideComponentTranslations['save-succes']}!`;
|
|
6044
|
-
const drawingsListener = createListenerMiddleware();
|
|
6045
|
-
drawingsListener.startListening({
|
|
6046
|
-
actionCreator: drawActions.submitDrawValues,
|
|
6047
|
-
effect: ({
|
|
6048
|
-
payload
|
|
6049
|
-
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6050
|
-
listenerApi.cancelActiveListeners();
|
|
6051
|
-
const {
|
|
6052
|
-
id
|
|
6053
|
-
} = payload,
|
|
6054
|
-
formValues = __rest(payload, ["id"]);
|
|
6055
|
-
try {
|
|
6056
|
-
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
6057
|
-
isLoading: true,
|
|
6058
|
-
type: drawingDialogType
|
|
6059
|
-
}));
|
|
6060
|
-
const warningsApi = getWarningsApi();
|
|
6061
|
-
if (!id) {
|
|
6062
|
-
const newID = yield warningsApi.saveDrawingAs(formValues);
|
|
6063
|
-
listenerApi.dispatch(drawActions.setDrawValues({
|
|
6064
|
-
drawingInstanceId: drawingDialogType,
|
|
6065
|
-
id: newID,
|
|
6066
|
-
objectName: formValues.objectName
|
|
6067
|
-
}));
|
|
6068
|
-
} else {
|
|
6069
|
-
yield warningsApi.updateDrawing(id, formValues);
|
|
6070
|
-
}
|
|
6071
|
-
listenerApi.dispatch(uiActions.setErrorDialog({
|
|
6072
|
-
type: drawingDialogType,
|
|
6073
|
-
error: ''
|
|
6074
|
-
}));
|
|
6075
|
-
listenerApi.dispatch(snackbarActions.openSnackbar({
|
|
6076
|
-
message: getSnackbarMessage(formValues.objectName, id)
|
|
6077
|
-
}));
|
|
6078
|
-
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
6079
|
-
isLoading: false,
|
|
6080
|
-
type: drawingDialogType
|
|
6081
|
-
}));
|
|
6082
|
-
} catch (error) {
|
|
6083
|
-
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
6084
|
-
isLoading: false,
|
|
6085
|
-
type: drawingDialogType
|
|
6086
|
-
}));
|
|
6087
|
-
const errorMessage = isAxiosError$1(error) ? getAxiosErrorMessage(error) : error.message;
|
|
6088
|
-
listenerApi.dispatch(uiActions.setErrorDialog({
|
|
6089
|
-
type: drawingDialogType,
|
|
6090
|
-
error: errorMessage
|
|
6091
|
-
}));
|
|
6092
|
-
}
|
|
6093
|
-
})
|
|
6094
|
-
});
|
|
5674
|
+
4.280148780801422,
|
|
5675
|
+
52.46455621916433
|
|
5676
|
+
],
|
|
5677
|
+
[
|
|
5678
|
+
6.878229305858475,
|
|
5679
|
+
52.98133263853793
|
|
5680
|
+
],
|
|
5681
|
+
[
|
|
5682
|
+
5.0950448864466225,
|
|
5683
|
+
53.492000941975654
|
|
5684
|
+
]
|
|
5685
|
+
]
|
|
5686
|
+
]
|
|
5687
|
+
},
|
|
5688
|
+
properties: {
|
|
5689
|
+
fill: "#ff7800",
|
|
5690
|
+
stroke: "#ff7800",
|
|
5691
|
+
"fill-opacity": 0.2,
|
|
5692
|
+
"stroke-width": 2,
|
|
5693
|
+
selectionType: "poly",
|
|
5694
|
+
"stroke-opacity": 1
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
]
|
|
5698
|
+
},
|
|
5699
|
+
validFrom: "2023-12-05T14:47:50Z",
|
|
5700
|
+
validUntil: "2023-12-05T20:47:50Z",
|
|
5701
|
+
level: "moderate",
|
|
5702
|
+
probability: 40
|
|
5703
|
+
}
|
|
5704
|
+
},
|
|
5705
|
+
{
|
|
5706
|
+
id: "3f756602-937d-11ee-a1bf-0ab3cf8a98c1",
|
|
5707
|
+
lastUpdatedTime: "2023-12-05T14:47:43Z",
|
|
5708
|
+
status: "EXPIRED",
|
|
5709
|
+
warningDetail: {
|
|
5710
|
+
phenomenon: "thunderstorm",
|
|
5711
|
+
geoJSON: {
|
|
5712
|
+
type: "FeatureCollection",
|
|
5713
|
+
features: [
|
|
5714
|
+
{
|
|
5715
|
+
type: "Feature",
|
|
5716
|
+
geometry: {
|
|
5717
|
+
type: "Polygon",
|
|
5718
|
+
coordinates: [
|
|
5719
|
+
[
|
|
5720
|
+
[
|
|
5721
|
+
5.0950448864466225,
|
|
5722
|
+
53.492000941975654
|
|
5723
|
+
],
|
|
5724
|
+
[
|
|
5725
|
+
4.280148780801422,
|
|
5726
|
+
52.46455621916433
|
|
5727
|
+
],
|
|
5728
|
+
[
|
|
5729
|
+
6.878229305858475,
|
|
5730
|
+
52.98133263853793
|
|
5731
|
+
],
|
|
5732
|
+
[
|
|
5733
|
+
5.0950448864466225,
|
|
5734
|
+
53.492000941975654
|
|
5735
|
+
]
|
|
5736
|
+
]
|
|
5737
|
+
]
|
|
5738
|
+
},
|
|
5739
|
+
properties: {
|
|
5740
|
+
fill: "#ff7800",
|
|
5741
|
+
stroke: "#ff7800",
|
|
5742
|
+
"fill-opacity": 0.2,
|
|
5743
|
+
"stroke-width": 2,
|
|
5744
|
+
selectionType: "poly",
|
|
5745
|
+
"stroke-opacity": 1
|
|
5746
|
+
}
|
|
5747
|
+
}
|
|
5748
|
+
]
|
|
5749
|
+
},
|
|
5750
|
+
validFrom: "2023-12-05T14:47:34Z",
|
|
5751
|
+
validUntil: "2023-12-05T20:47:34Z",
|
|
5752
|
+
level: "extreme",
|
|
5753
|
+
probability: 40
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5756
|
+
];
|
|
6095
5757
|
|
|
6096
5758
|
/* *
|
|
6097
5759
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -6109,52 +5771,86 @@ drawingsListener.startListening({
|
|
|
6109
5771
|
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6110
5772
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
6111
5773
|
* */
|
|
6112
|
-
const
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
drawings: reducer$2,
|
|
6116
|
-
publicWarningForm: reducer,
|
|
6117
|
-
publicWarnings: reducer$1
|
|
6118
|
-
},
|
|
6119
|
-
sagas: [publicWarningRootSaga, publicWarnings],
|
|
6120
|
-
middlewares: [drawingsListener.middleware]
|
|
6121
|
-
};
|
|
5774
|
+
const drawingList = drawingListJSON;
|
|
5775
|
+
const drawingsListFullContent = drawingsListFullContentJSON;
|
|
5776
|
+
const warningList = warningListJSON;
|
|
6122
5777
|
|
|
6123
|
-
|
|
6124
|
-
const
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
}) => {
|
|
6128
|
-
return /*#__PURE__*/React.createElement(WarningsI18nProvider, null, /*#__PURE__*/React.createElement(ThemeWrapper, {
|
|
6129
|
-
theme: _theme
|
|
6130
|
-
}, children));
|
|
5778
|
+
const ERROR_NOT_FOUND = 'Request failed with status code 400';
|
|
5779
|
+
const MOCK_USERNAME = 'user.name';
|
|
5780
|
+
const extractDrawingDetailsFromJSON = drawingId => {
|
|
5781
|
+
return drawingsListFullContent.find(element => element.id === drawingId);
|
|
6131
5782
|
};
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
5783
|
+
const getApiRoutes = axiosInstance => ({
|
|
5784
|
+
// drawings
|
|
5785
|
+
getDrawings: () => {
|
|
5786
|
+
return axiosInstance.get('/drawings').then(() => {
|
|
5787
|
+
return {
|
|
5788
|
+
data: drawingList
|
|
5789
|
+
};
|
|
5790
|
+
});
|
|
5791
|
+
},
|
|
5792
|
+
getDrawingDetails: drawingId => {
|
|
5793
|
+
return axiosInstance.get(`/drawings/${drawingId}`).then(() => {
|
|
5794
|
+
if (!extractDrawingDetailsFromJSON(drawingId)) {
|
|
5795
|
+
throw new Error(ERROR_NOT_FOUND);
|
|
5796
|
+
}
|
|
5797
|
+
return {
|
|
5798
|
+
data: extractDrawingDetailsFromJSON(drawingId)
|
|
5799
|
+
};
|
|
5800
|
+
});
|
|
5801
|
+
},
|
|
5802
|
+
updateDrawing: (drawingId, data) => {
|
|
5803
|
+
// eslint-disable-next-line no-console
|
|
5804
|
+
console.log('api: save drawing', drawingId, data);
|
|
5805
|
+
return axiosInstance.post(`/drawings/${drawingId}/`, data);
|
|
5806
|
+
},
|
|
5807
|
+
saveDrawingAs: data => {
|
|
5808
|
+
// eslint-disable-next-line no-console
|
|
5809
|
+
console.log('api: save drawing as', data);
|
|
5810
|
+
return axiosInstance.post(`/drawings/`, data).then(() => 'new-drawing-id');
|
|
5811
|
+
},
|
|
5812
|
+
deleteDrawing: drawingId => {
|
|
5813
|
+
// eslint-disable-next-line no-console
|
|
5814
|
+
console.log('api: delete drawing', drawingId);
|
|
5815
|
+
drawingList.splice(drawingList.findIndex(drawing => drawing.id === drawingId), 1);
|
|
5816
|
+
return axiosInstance.post(`/drawings/${drawingId}?delete=true`);
|
|
5817
|
+
},
|
|
5818
|
+
// public warnings
|
|
5819
|
+
getWarnings: () => {
|
|
5820
|
+
return axiosInstance.get(`/warnings/`).then(() => ({
|
|
5821
|
+
data: warningList
|
|
5822
|
+
}));
|
|
5823
|
+
},
|
|
5824
|
+
saveWarningAs: data => {
|
|
5825
|
+
// eslint-disable-next-line no-console
|
|
5826
|
+
console.log('api: save warning as', data);
|
|
5827
|
+
return axiosInstance.post(`/warnings/`, data).then(() => 'new-warning-id');
|
|
5828
|
+
},
|
|
5829
|
+
updateWarning: (warningId, data) => {
|
|
5830
|
+
// eslint-disable-next-line no-console
|
|
5831
|
+
console.log(`api: update warning ${warningId}`, data);
|
|
5832
|
+
return axiosInstance.post(`/warnings/${warningId}/`, data);
|
|
5833
|
+
},
|
|
5834
|
+
deleteWarning: warningId => {
|
|
5835
|
+
// eslint-disable-next-line no-console
|
|
5836
|
+
console.log('api: delete warning', warningId);
|
|
5837
|
+
warningList.splice(warningList.findIndex(warning => warning.id === warningId), 1);
|
|
5838
|
+
return axiosInstance.post(`/warnings/${warningId}?delete=true`);
|
|
5839
|
+
},
|
|
5840
|
+
toggleEditorWarning: (warningId, isEditor) => {
|
|
5841
|
+
// eslint-disable-next-line no-console
|
|
5842
|
+
console.log('api: toggle editor warning', warningId, isEditor);
|
|
5843
|
+
const index = warningList.findIndex(warning => warning.id === warningId);
|
|
5844
|
+
warningList.splice(index, 1, Object.assign(Object.assign({}, warningList[index]), {
|
|
5845
|
+
editor: isEditor ? MOCK_USERNAME : null
|
|
5846
|
+
}));
|
|
5847
|
+
return axiosInstance.post(`/warnings/${warningId}?editor=${isEditor ? 'true' : 'false'}`);
|
|
5848
|
+
}
|
|
6138
5849
|
});
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
i18n
|
|
6144
|
-
} = useTranslation();
|
|
6145
|
-
React.useEffect(() => {
|
|
6146
|
-
i18n.addResourceBundle('en', WARN_NAMESPACE, warningsTranslations.en);
|
|
6147
|
-
i18n.addResourceBundle('nl', WARN_NAMESPACE, warningsTranslations.nl);
|
|
6148
|
-
}, [i18n]);
|
|
6149
|
-
return children;
|
|
6150
|
-
};
|
|
6151
|
-
const WarningsI18nProvider = ({
|
|
6152
|
-
children
|
|
6153
|
-
}) => {
|
|
6154
|
-
initWarnI18n();
|
|
6155
|
-
return /*#__PURE__*/React.createElement(I18nextProvider, {
|
|
6156
|
-
i18n: i18n
|
|
6157
|
-
}, children);
|
|
5850
|
+
// used in storybook
|
|
5851
|
+
const createApi = () => {
|
|
5852
|
+
const instance = createFakeApiInstance();
|
|
5853
|
+
return getApiRoutes(instance);
|
|
6158
5854
|
};
|
|
6159
5855
|
|
|
6160
5856
|
/* *
|
|
@@ -6179,13 +5875,13 @@ const WarningsModuleProvider = ({
|
|
|
6179
5875
|
onSetAuth,
|
|
6180
5876
|
children
|
|
6181
5877
|
}) => {
|
|
6182
|
-
return /*#__PURE__*/React.createElement(
|
|
5878
|
+
return /*#__PURE__*/React.createElement(ApiProvider, {
|
|
6183
5879
|
config: config,
|
|
6184
5880
|
auth: auth,
|
|
6185
5881
|
onSetAuth: onSetAuth,
|
|
6186
5882
|
createApi: config !== undefined ? createApi$1 : createApi,
|
|
6187
5883
|
name: API_NAME
|
|
6188
|
-
}, children)
|
|
5884
|
+
}, children);
|
|
6189
5885
|
};
|
|
6190
5886
|
|
|
6191
5887
|
/* *
|
|
@@ -6210,7 +5906,7 @@ const DrawingToolMapButtonConnect = ({
|
|
|
6210
5906
|
}) => {
|
|
6211
5907
|
const {
|
|
6212
5908
|
t
|
|
6213
|
-
} =
|
|
5909
|
+
} = useWarningsTranslation();
|
|
6214
5910
|
// const drawingDialogType = isMultiMap
|
|
6215
5911
|
// ? `${uiTypes.DialogTypes.DrawingTool}-${mapId}`
|
|
6216
5912
|
// : uiTypes.DialogTypes.DrawingTool;
|
|
@@ -6265,7 +5961,7 @@ const DrawingTool = ({
|
|
|
6265
5961
|
}) => {
|
|
6266
5962
|
const {
|
|
6267
5963
|
t
|
|
6268
|
-
} =
|
|
5964
|
+
} = useWarningsTranslation();
|
|
6269
5965
|
const minSize = DEFAULT_DRAW_TOOL_MIN_SIZE;
|
|
6270
5966
|
const startSizeCalc = calculateStartSize(minSize, _size, _startPosition);
|
|
6271
5967
|
const [sizeInState, setSizeInState] = React.useState(startSizeCalc);
|
|
@@ -6466,7 +6162,7 @@ const DrawingToolFormContentsNoMemo = ({
|
|
|
6466
6162
|
}) => {
|
|
6467
6163
|
const {
|
|
6468
6164
|
t
|
|
6469
|
-
} =
|
|
6165
|
+
} = useWarningsTranslation();
|
|
6470
6166
|
const hasErrors = Object.keys(errors).length > 0;
|
|
6471
6167
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Box, {
|
|
6472
6168
|
sx: {
|
|
@@ -6588,7 +6284,7 @@ const DrawingToolFormContentsNoMemo = ({
|
|
|
6588
6284
|
};
|
|
6589
6285
|
const DrawingToolFormContents = /*#__PURE__*/React__default.memo(DrawingToolFormContentsNoMemo, isEqual);
|
|
6590
6286
|
|
|
6591
|
-
const getObjectName$1 = objectName => objectName || `${dateUtils.dateToString(new Date(),
|
|
6287
|
+
const getObjectName$1 = objectName => objectName || `${dateUtils.dateToString(new Date(), dateUtils.DATE_FORMAT_DATEPICKER, true)} UTC`;
|
|
6592
6288
|
const DrawingToolForm = ({
|
|
6593
6289
|
onSubmitForm,
|
|
6594
6290
|
isLoading: _isLoading = false,
|
|
@@ -6628,7 +6324,7 @@ const DrawingToolForm = ({
|
|
|
6628
6324
|
}
|
|
6629
6325
|
});
|
|
6630
6326
|
React.useEffect(() => {
|
|
6631
|
-
if (_activeDrawModeId) {
|
|
6327
|
+
if (_activeDrawModeId || _activeDrawModeId === '') {
|
|
6632
6328
|
setValue('geoJSON', geoJSON, {
|
|
6633
6329
|
shouldDirty: true
|
|
6634
6330
|
});
|
|
@@ -6840,7 +6536,7 @@ const DrawingToolConnect = ({
|
|
|
6840
6536
|
}) => {
|
|
6841
6537
|
const {
|
|
6842
6538
|
t
|
|
6843
|
-
} =
|
|
6539
|
+
} = useWarningsTranslation();
|
|
6844
6540
|
const dialogType = getDialogType(initialMapId, _isMultiMap);
|
|
6845
6541
|
const activeMapId = useSelector(store => uiSelectors.getDialogMapId(store, dialogType));
|
|
6846
6542
|
// In case of a multimap, use the map id that is passed
|
|
@@ -6920,7 +6616,7 @@ const DEFAULT_WARNING_DIALOG_POSITION = {
|
|
|
6920
6616
|
left: 60
|
|
6921
6617
|
};
|
|
6922
6618
|
const DEFAULT_WARNING_DIALOG_MIN_SIZE = {
|
|
6923
|
-
width:
|
|
6619
|
+
width: 264,
|
|
6924
6620
|
height: 300
|
|
6925
6621
|
};
|
|
6926
6622
|
const PublicWarningsFormDialog = ({
|
|
@@ -6944,15 +6640,32 @@ const PublicWarningsFormDialog = ({
|
|
|
6944
6640
|
}) => {
|
|
6945
6641
|
const {
|
|
6946
6642
|
t
|
|
6947
|
-
} =
|
|
6643
|
+
} = useWarningsTranslation();
|
|
6948
6644
|
const minSize = DEFAULT_WARNING_DIALOG_MIN_SIZE;
|
|
6949
6645
|
const startSizeCalc = calculateStartSize(minSize, _size, _startPosition);
|
|
6950
6646
|
const [sizeInState, setSizeInState] = React.useState(startSizeCalc);
|
|
6951
6647
|
const onChangeMode = () => {
|
|
6952
6648
|
_onChangeFormMode(!_isReadOnly);
|
|
6953
6649
|
};
|
|
6650
|
+
const fullTitle = title || t('public-warning-title');
|
|
6954
6651
|
return /*#__PURE__*/React.createElement(ToolContainerDraggable, Object.assign({
|
|
6955
|
-
title:
|
|
6652
|
+
title: _shouldHideFormMode ? fullTitle : undefined
|
|
6653
|
+
}, !_shouldHideFormMode && {
|
|
6654
|
+
leftHeaderComponent: ( /*#__PURE__*/React.createElement(Box, {
|
|
6655
|
+
className: "header-title"
|
|
6656
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
6657
|
+
variant: "h2",
|
|
6658
|
+
noWrap: true,
|
|
6659
|
+
sx: {
|
|
6660
|
+
fontSize: 12,
|
|
6661
|
+
fontWeight: 500,
|
|
6662
|
+
lineHeight: '22px',
|
|
6663
|
+
marginTop: '-1px',
|
|
6664
|
+
paddingLeft: 1
|
|
6665
|
+
},
|
|
6666
|
+
role: "heading"
|
|
6667
|
+
}, fullTitle)))
|
|
6668
|
+
}, {
|
|
6956
6669
|
startSize: sizeInState,
|
|
6957
6670
|
minWidth: minSize.width,
|
|
6958
6671
|
minHeight: minSize.height,
|
|
@@ -7664,7 +7377,7 @@ const tabStyle = {
|
|
|
7664
7377
|
const CustomTabPanel = props => {
|
|
7665
7378
|
const {
|
|
7666
7379
|
t
|
|
7667
|
-
} =
|
|
7380
|
+
} = useWarningsTranslation();
|
|
7668
7381
|
const {
|
|
7669
7382
|
children,
|
|
7670
7383
|
value,
|
|
@@ -7707,7 +7420,7 @@ const CustomTabPanel = props => {
|
|
|
7707
7420
|
disabled: isDisabled
|
|
7708
7421
|
}, /*#__PURE__*/React__default.createElement(MenuItem, {
|
|
7709
7422
|
value: "NL"
|
|
7710
|
-
}, t('warning-description-NL'))))),
|
|
7423
|
+
}, t('warning-description-NL'))))), children);
|
|
7711
7424
|
};
|
|
7712
7425
|
const DescriptionField = ({
|
|
7713
7426
|
isDisabled: _isDisabled = false,
|
|
@@ -7715,13 +7428,32 @@ const DescriptionField = ({
|
|
|
7715
7428
|
}) => {
|
|
7716
7429
|
const {
|
|
7717
7430
|
t
|
|
7718
|
-
} =
|
|
7719
|
-
const
|
|
7431
|
+
} = useWarningsTranslation();
|
|
7432
|
+
const {
|
|
7433
|
+
isRequired
|
|
7434
|
+
} = useDraftFormHelpers();
|
|
7435
|
+
const {
|
|
7436
|
+
formState
|
|
7437
|
+
} = useFormContext();
|
|
7438
|
+
const [activeTab, setActiveTab] = React__default.useState(0);
|
|
7720
7439
|
const handleChange = (event, newValue) => {
|
|
7721
|
-
|
|
7440
|
+
setActiveTab(newValue);
|
|
7722
7441
|
};
|
|
7442
|
+
const lastSubmitCount = useRef(0);
|
|
7443
|
+
// next code shows the tab for the textarea which is in the invalid state
|
|
7444
|
+
useEffect(() => {
|
|
7445
|
+
if (formState.submitCount === lastSubmitCount.current) {
|
|
7446
|
+
return;
|
|
7447
|
+
}
|
|
7448
|
+
lastSubmitCount.current = formState.submitCount;
|
|
7449
|
+
if ('descriptionOriginal' in formState.errors) {
|
|
7450
|
+
setActiveTab(0);
|
|
7451
|
+
} else if ('descriptionTranslation' in formState.errors) {
|
|
7452
|
+
setActiveTab(1);
|
|
7453
|
+
}
|
|
7454
|
+
}, [formState.errors, formState.submitCount]);
|
|
7723
7455
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Tabs, Object.assign({
|
|
7724
|
-
value:
|
|
7456
|
+
value: activeTab,
|
|
7725
7457
|
onChange: handleChange,
|
|
7726
7458
|
"aria-label": "description tabs"
|
|
7727
7459
|
}, _isDisabled && {
|
|
@@ -7740,33 +7472,43 @@ const DescriptionField = ({
|
|
|
7740
7472
|
label: t('warning-description-translation'),
|
|
7741
7473
|
disabled: _isDisabled
|
|
7742
7474
|
}, a11yProps(1)))), /*#__PURE__*/React__default.createElement(CustomTabPanel, {
|
|
7743
|
-
value:
|
|
7475
|
+
value: activeTab,
|
|
7744
7476
|
index: 0,
|
|
7745
7477
|
isDisabled: _isDisabled,
|
|
7746
7478
|
isReadOnly: _isReadOnly
|
|
7747
7479
|
}, /*#__PURE__*/React__default.createElement(ReactHookFormTextField, {
|
|
7748
|
-
rules: {
|
|
7480
|
+
rules: {
|
|
7481
|
+
validate: {
|
|
7482
|
+
isRequired
|
|
7483
|
+
}
|
|
7484
|
+
},
|
|
7749
7485
|
minRows: 4,
|
|
7750
7486
|
name: "descriptionOriginal",
|
|
7751
7487
|
multiline: true,
|
|
7752
7488
|
disabled: _isDisabled,
|
|
7753
|
-
isReadOnly: _isReadOnly
|
|
7489
|
+
isReadOnly: _isReadOnly,
|
|
7490
|
+
onKeyDown: event => event.stopPropagation()
|
|
7754
7491
|
})), /*#__PURE__*/React__default.createElement(CustomTabPanel, {
|
|
7755
|
-
value:
|
|
7492
|
+
value: activeTab,
|
|
7756
7493
|
index: 1,
|
|
7757
7494
|
isDisabled: _isDisabled,
|
|
7758
7495
|
isReadOnly: _isReadOnly
|
|
7759
7496
|
}, /*#__PURE__*/React__default.createElement(ReactHookFormTextField, {
|
|
7760
|
-
rules: {
|
|
7497
|
+
rules: {
|
|
7498
|
+
validate: {
|
|
7499
|
+
isRequired
|
|
7500
|
+
}
|
|
7501
|
+
},
|
|
7761
7502
|
minRows: 4,
|
|
7762
7503
|
name: "descriptionTranslation",
|
|
7763
7504
|
multiline: true,
|
|
7764
7505
|
disabled: _isDisabled,
|
|
7765
|
-
isReadOnly: _isReadOnly
|
|
7506
|
+
isReadOnly: _isReadOnly,
|
|
7507
|
+
onKeyDown: event => event.stopPropagation()
|
|
7766
7508
|
})));
|
|
7767
7509
|
};
|
|
7768
7510
|
|
|
7769
|
-
const formatDate = lastUpdatedTime => dateUtils.dateToString(dateUtils.isoStringToDate(lastUpdatedTime), `${
|
|
7511
|
+
const formatDate = lastUpdatedTime => dateUtils.dateToString(dateUtils.isoStringToDate(lastUpdatedTime, false), `${dateUtils.DATE_FORMAT_DATEPICKER} 'UTC'`);
|
|
7770
7512
|
const getObjectName = (geoJSON, objectName, t) => {
|
|
7771
7513
|
if (geoJSON) {
|
|
7772
7514
|
return objectName || t('object-manager-object-selected');
|
|
@@ -7782,7 +7524,7 @@ const AreaField = ({
|
|
|
7782
7524
|
}) => {
|
|
7783
7525
|
const {
|
|
7784
7526
|
t
|
|
7785
|
-
} =
|
|
7527
|
+
} = useWarningsTranslation();
|
|
7786
7528
|
const {
|
|
7787
7529
|
getValues,
|
|
7788
7530
|
formState: {
|
|
@@ -7940,7 +7682,7 @@ const Phenomenon = ({
|
|
|
7940
7682
|
}) => {
|
|
7941
7683
|
const {
|
|
7942
7684
|
t
|
|
7943
|
-
} =
|
|
7685
|
+
} = useWarningsTranslation();
|
|
7944
7686
|
const {
|
|
7945
7687
|
isRequired
|
|
7946
7688
|
} = useDraftFormHelpers();
|
|
@@ -8005,15 +7747,19 @@ const LevelField = ({
|
|
|
8005
7747
|
}) => {
|
|
8006
7748
|
const {
|
|
8007
7749
|
t
|
|
8008
|
-
} =
|
|
7750
|
+
} = useWarningsTranslation();
|
|
8009
7751
|
const {
|
|
8010
7752
|
isRequired
|
|
8011
7753
|
} = useDraftFormHelpers();
|
|
8012
7754
|
const {
|
|
8013
|
-
watch
|
|
7755
|
+
watch,
|
|
7756
|
+
trigger
|
|
8014
7757
|
} = useFormContext();
|
|
8015
7758
|
const selectedLevel = watch('level');
|
|
8016
7759
|
const levelDetails = levelOptions(t).find(level => level.key === selectedLevel);
|
|
7760
|
+
const onChangeLevel = () => {
|
|
7761
|
+
trigger(['level', 'probability']);
|
|
7762
|
+
};
|
|
8017
7763
|
return /*#__PURE__*/React.createElement(ReactHookFormSelect, {
|
|
8018
7764
|
name: "level",
|
|
8019
7765
|
label: t('warning-level'),
|
|
@@ -8030,7 +7776,8 @@ const LevelField = ({
|
|
|
8030
7776
|
}
|
|
8031
7777
|
},
|
|
8032
7778
|
disabled: _isDisabled || _isReadOnly,
|
|
8033
|
-
isReadOnly: _isReadOnly
|
|
7779
|
+
isReadOnly: _isReadOnly,
|
|
7780
|
+
onChange: onChangeLevel
|
|
8034
7781
|
}, levelOptions(t).map(level => ( /*#__PURE__*/React.createElement(MenuItem, {
|
|
8035
7782
|
value: level.key,
|
|
8036
7783
|
key: level.key,
|
|
@@ -8073,7 +7820,9 @@ const LevelField = ({
|
|
|
8073
7820
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
8074
7821
|
* */
|
|
8075
7822
|
const VALID_FROM_MAX_HOURS_AFTER_CURRENT = 168;
|
|
8076
|
-
const isValueBeforeCurrentTime$1 = (value, t) =>
|
|
7823
|
+
const isValueBeforeCurrentTime$1 = (value, t) => {
|
|
7824
|
+
return isXHoursBefore(value, dateUtils.getCurrentTimeAsString(), 0) || t('warning-valid-from-error-before-current');
|
|
7825
|
+
};
|
|
8077
7826
|
const isMaxHoursAfterCurrentTime$1 = (value, t) => isXHoursAfter(value, dateUtils.getCurrentTimeAsString(), VALID_FROM_MAX_HOURS_AFTER_CURRENT) || t('warning-valid-from-error-max-hours', {
|
|
8078
7827
|
ns: WARN_NAMESPACE,
|
|
8079
7828
|
MAX_HOURS: VALID_FROM_MAX_HOURS_AFTER_CURRENT
|
|
@@ -8084,20 +7833,22 @@ const ValidFrom = ({
|
|
|
8084
7833
|
}) => {
|
|
8085
7834
|
const {
|
|
8086
7835
|
t
|
|
8087
|
-
} =
|
|
7836
|
+
} = useWarningsTranslation();
|
|
8088
7837
|
const {
|
|
8089
7838
|
isRequired
|
|
8090
7839
|
} = useDraftFormHelpers();
|
|
8091
7840
|
const {
|
|
8092
7841
|
trigger
|
|
8093
7842
|
} = useFormContext();
|
|
8094
|
-
const onChangeValidFrom = () =>
|
|
7843
|
+
const onChangeValidFrom = () => {
|
|
7844
|
+
trigger(['validFrom', 'validUntil']);
|
|
7845
|
+
};
|
|
8095
7846
|
return /*#__PURE__*/React.createElement(ReactHookFormDateTime, {
|
|
8096
7847
|
name: "validFrom",
|
|
8097
7848
|
rules: {
|
|
8098
7849
|
validate: {
|
|
8099
7850
|
isRequired,
|
|
8100
|
-
isValidDate,
|
|
7851
|
+
isValidDate: dateUtils.isValidIsoDateString,
|
|
8101
7852
|
// The valid from time cannot be before the current time
|
|
8102
7853
|
isValueBeforeCurrentTime: value => isValueBeforeCurrentTime$1(value, t),
|
|
8103
7854
|
// Valid from can be no more than X hours after current time
|
|
@@ -8136,7 +7887,7 @@ const isMaxHoursAfterCurrentTime = (value, t) => isXHoursAfter(value, dateUtils.
|
|
|
8136
7887
|
MAX_HOURS: VALID_UNTIL_MAX_HOURS_AFTER_CURRENT
|
|
8137
7888
|
});
|
|
8138
7889
|
const isMinHoursAfterValidFrom = (value, validFromValue, t) => {
|
|
8139
|
-
if (isEmpty(value) || isEmpty(validFromValue) || !
|
|
7890
|
+
if (isEmpty(value) || isEmpty(validFromValue) || !dateUtils.isValidIsoDateString(validFromValue)) {
|
|
8140
7891
|
return true;
|
|
8141
7892
|
}
|
|
8142
7893
|
const duration = dateUtils.differenceInHours(new Date(value), new Date(validFromValue));
|
|
@@ -8151,19 +7902,23 @@ const ValidUntil = ({
|
|
|
8151
7902
|
}) => {
|
|
8152
7903
|
const {
|
|
8153
7904
|
t
|
|
8154
|
-
} =
|
|
7905
|
+
} = useWarningsTranslation();
|
|
8155
7906
|
const {
|
|
8156
7907
|
isRequired
|
|
8157
7908
|
} = useDraftFormHelpers();
|
|
8158
7909
|
const {
|
|
8159
|
-
getValues
|
|
7910
|
+
getValues,
|
|
7911
|
+
trigger
|
|
8160
7912
|
} = useFormContext();
|
|
7913
|
+
const onChangeValidUntil = () => {
|
|
7914
|
+
trigger(['validFrom', 'validUntil']);
|
|
7915
|
+
};
|
|
8161
7916
|
return /*#__PURE__*/React.createElement(ReactHookFormDateTime, {
|
|
8162
7917
|
name: "validUntil",
|
|
8163
7918
|
rules: {
|
|
8164
7919
|
validate: {
|
|
8165
7920
|
isRequired,
|
|
8166
|
-
isValidDate,
|
|
7921
|
+
isValidDate: dateUtils.isValidIsoDateString,
|
|
8167
7922
|
// The valid until time cannot be before the current time
|
|
8168
7923
|
isValueBeforeCurrentTime: value => isValueBeforeCurrentTime(value, t),
|
|
8169
7924
|
// Valid until time can be no more than X hours after current time
|
|
@@ -8175,7 +7930,8 @@ const ValidUntil = ({
|
|
|
8175
7930
|
label: t('warning-valid-until'),
|
|
8176
7931
|
disablePast: true,
|
|
8177
7932
|
disabled: isDisabled || isReadOnly,
|
|
8178
|
-
isReadOnly: isReadOnly
|
|
7933
|
+
isReadOnly: isReadOnly,
|
|
7934
|
+
onChange: onChangeValidUntil
|
|
8179
7935
|
});
|
|
8180
7936
|
};
|
|
8181
7937
|
|
|
@@ -8244,6 +8000,70 @@ const WarningsMapView = ({
|
|
|
8244
8000
|
}))));
|
|
8245
8001
|
};
|
|
8246
8002
|
|
|
8003
|
+
/* *
|
|
8004
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8005
|
+
* you may not use this file except in compliance with the License.
|
|
8006
|
+
* You may obtain a copy of the License at
|
|
8007
|
+
*
|
|
8008
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8009
|
+
*
|
|
8010
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
8011
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
8012
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
8013
|
+
* See the License for the specific language governing permissions and
|
|
8014
|
+
* limitations under the License.
|
|
8015
|
+
*
|
|
8016
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
8017
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
8018
|
+
* */
|
|
8019
|
+
const probablityOptions = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10];
|
|
8020
|
+
const defaultProbability = 30;
|
|
8021
|
+
const ProbabilityField = ({
|
|
8022
|
+
isDisabled,
|
|
8023
|
+
isReadOnly
|
|
8024
|
+
}) => {
|
|
8025
|
+
const {
|
|
8026
|
+
t
|
|
8027
|
+
} = useWarningsTranslation();
|
|
8028
|
+
const {
|
|
8029
|
+
trigger,
|
|
8030
|
+
getValues
|
|
8031
|
+
} = useFormContext();
|
|
8032
|
+
const {
|
|
8033
|
+
isRequired
|
|
8034
|
+
} = useDraftFormHelpers();
|
|
8035
|
+
const isValidProbabilityForLevel = (value, fieldValues) => {
|
|
8036
|
+
if (fieldValues['level'] === 'moderate' && value < 30) {
|
|
8037
|
+
return t('warning-probability-moderate-level-invalid');
|
|
8038
|
+
}
|
|
8039
|
+
return true;
|
|
8040
|
+
};
|
|
8041
|
+
const onChangeProbability = () => {
|
|
8042
|
+
trigger('probability');
|
|
8043
|
+
// We don't want to trigger the missing value validation
|
|
8044
|
+
if (!isEmpty(getValues('level'))) {
|
|
8045
|
+
trigger('level');
|
|
8046
|
+
}
|
|
8047
|
+
};
|
|
8048
|
+
return /*#__PURE__*/React.createElement(ReactHookFormSelect, {
|
|
8049
|
+
name: "probability",
|
|
8050
|
+
label: t('warning-probability'),
|
|
8051
|
+
rules: {
|
|
8052
|
+
validate: {
|
|
8053
|
+
isRequired,
|
|
8054
|
+
isValidProbabilityForLevel
|
|
8055
|
+
}
|
|
8056
|
+
},
|
|
8057
|
+
disabled: isDisabled || isReadOnly,
|
|
8058
|
+
isReadOnly: isReadOnly,
|
|
8059
|
+
defaultValue: defaultProbability,
|
|
8060
|
+
onChange: onChangeProbability
|
|
8061
|
+
}, probablityOptions.map(probability => ( /*#__PURE__*/React.createElement(MenuItem, {
|
|
8062
|
+
value: probability,
|
|
8063
|
+
key: probability
|
|
8064
|
+
}, probability, " %"))));
|
|
8065
|
+
};
|
|
8066
|
+
|
|
8247
8067
|
const getEmptyPublicWarning = () => {
|
|
8248
8068
|
const currentTime = new Date();
|
|
8249
8069
|
const validFromTime = dateUtils.add(currentTime, {
|
|
@@ -8294,7 +8114,6 @@ const spinnerSx = {
|
|
|
8294
8114
|
margin: 'auto',
|
|
8295
8115
|
marginLeft: 1
|
|
8296
8116
|
};
|
|
8297
|
-
const probablityOptions = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0];
|
|
8298
8117
|
const ContainerWrapper = styled('div')(() => ({
|
|
8299
8118
|
containerType: 'size',
|
|
8300
8119
|
height: '100%'
|
|
@@ -8381,7 +8200,7 @@ const Form = ({
|
|
|
8381
8200
|
}) => {
|
|
8382
8201
|
const {
|
|
8383
8202
|
t
|
|
8384
|
-
} =
|
|
8203
|
+
} = useWarningsTranslation();
|
|
8385
8204
|
const {
|
|
8386
8205
|
handleSubmit,
|
|
8387
8206
|
reset,
|
|
@@ -8522,16 +8341,10 @@ const Form = ({
|
|
|
8522
8341
|
item: true,
|
|
8523
8342
|
xs: 12,
|
|
8524
8343
|
sm: 6
|
|
8525
|
-
}, /*#__PURE__*/React.createElement(
|
|
8526
|
-
|
|
8527
|
-
label: t('warning-probability'),
|
|
8528
|
-
rules: {},
|
|
8529
|
-
disabled: areFieldsDisabled || _isReadOnly2,
|
|
8344
|
+
}, /*#__PURE__*/React.createElement(ProbabilityField, {
|
|
8345
|
+
isDisabled: areFieldsDisabled,
|
|
8530
8346
|
isReadOnly: _isReadOnly2
|
|
8531
|
-
},
|
|
8532
|
-
value: probability,
|
|
8533
|
-
key: probability
|
|
8534
|
-
}, probability, " %")))))), /*#__PURE__*/React.createElement(Grid, {
|
|
8347
|
+
}))), /*#__PURE__*/React.createElement(Grid, {
|
|
8535
8348
|
item: true,
|
|
8536
8349
|
xs: 12,
|
|
8537
8350
|
container: true,
|
|
@@ -8618,6 +8431,7 @@ const PublicWarningsForm = props => {
|
|
|
8618
8431
|
const defaultValues = getFormData(publicWarningDetails, object);
|
|
8619
8432
|
return /*#__PURE__*/React.createElement(ReactHookFormProvider, {
|
|
8620
8433
|
options: Object.assign(Object.assign({}, defaultFormOptions), {
|
|
8434
|
+
mode: 'onSubmit',
|
|
8621
8435
|
defaultValues
|
|
8622
8436
|
})
|
|
8623
8437
|
}, /*#__PURE__*/React.createElement(Form, Object.assign({}, props)));
|
|
@@ -8764,7 +8578,7 @@ const PublicWarningsFormDialogConnect = ({
|
|
|
8764
8578
|
} = useSetupDialog(publicWarningDialogType, _source);
|
|
8765
8579
|
const {
|
|
8766
8580
|
t
|
|
8767
|
-
} =
|
|
8581
|
+
} = useWarningsTranslation();
|
|
8768
8582
|
const dispatch = useDispatch();
|
|
8769
8583
|
const confirmDialog = useConfirmationDialog();
|
|
8770
8584
|
const formAction = useSelector(store => getPublicWarningFormState(store));
|
|
@@ -8912,6 +8726,30 @@ const getWarningWithoutId = warning => {
|
|
|
8912
8726
|
warningDetail: cleanWarningDetail
|
|
8913
8727
|
});
|
|
8914
8728
|
};
|
|
8729
|
+
const WarningListHeaderContent = _a => {
|
|
8730
|
+
var {
|
|
8731
|
+
title,
|
|
8732
|
+
width = 76
|
|
8733
|
+
} = _a,
|
|
8734
|
+
props = __rest(_a, ["title", "width"]);
|
|
8735
|
+
return /*#__PURE__*/React__default.createElement(Grid, Object.assign({
|
|
8736
|
+
item: true
|
|
8737
|
+
}, props, {
|
|
8738
|
+
sx: Object.assign(Object.assign({}, props.sx), {
|
|
8739
|
+
width
|
|
8740
|
+
})
|
|
8741
|
+
}), /*#__PURE__*/React__default.createElement(Box, {
|
|
8742
|
+
sx: {
|
|
8743
|
+
overflow: 'hidden',
|
|
8744
|
+
fontWeight: 'normal',
|
|
8745
|
+
textOverflow: 'ellipsis',
|
|
8746
|
+
fontSize: 12,
|
|
8747
|
+
lineHeight: 1.33,
|
|
8748
|
+
height: 16,
|
|
8749
|
+
color: 'geowebColors.captions.captionStatus.rgba'
|
|
8750
|
+
}
|
|
8751
|
+
}, title));
|
|
8752
|
+
};
|
|
8915
8753
|
const WarningListColumnContent = _a => {
|
|
8916
8754
|
var {
|
|
8917
8755
|
title,
|
|
@@ -8934,7 +8772,11 @@ const WarningListColumnContent = _a => {
|
|
|
8934
8772
|
fontSize: 10,
|
|
8935
8773
|
lineHeight: 1.6,
|
|
8936
8774
|
height: 12,
|
|
8937
|
-
color: status === 'EXPIRED' ? 'geowebColors.typographyAndIcons.inactiveText' : 'geowebColors.captions.captionStatus.rgba'
|
|
8775
|
+
color: status === 'EXPIRED' ? 'geowebColors.typographyAndIcons.inactiveText' : 'geowebColors.captions.captionStatus.rgba',
|
|
8776
|
+
display: 'block',
|
|
8777
|
+
[`@container publicWarningList (min-width: ${breakpoints.desktop}px)`]: {
|
|
8778
|
+
display: 'none'
|
|
8779
|
+
}
|
|
8938
8780
|
}
|
|
8939
8781
|
}, title)), /*#__PURE__*/React__default.createElement(Box, {
|
|
8940
8782
|
sx: {
|
|
@@ -8956,7 +8798,7 @@ const WarningsOnStatus = ({
|
|
|
8956
8798
|
}) => {
|
|
8957
8799
|
const {
|
|
8958
8800
|
t
|
|
8959
|
-
} =
|
|
8801
|
+
} = useWarningsTranslation();
|
|
8960
8802
|
const headerText = `${warnings.length} ${getStatus(status)}`;
|
|
8961
8803
|
const onClickWarning = warning => () => _onSelectWarning(warning);
|
|
8962
8804
|
const onClickEditWarning = warning => () => _onEditWarning(warning);
|
|
@@ -9008,15 +8850,14 @@ const WarningsOnStatus = ({
|
|
|
9008
8850
|
return /*#__PURE__*/React__default.createElement(ListItem, {
|
|
9009
8851
|
key: warning.id,
|
|
9010
8852
|
sx: {
|
|
9011
|
-
marginBottom: 0.
|
|
8853
|
+
marginBottom: 0.25,
|
|
8854
|
+
minHeight: '32px',
|
|
9012
8855
|
padding: '0 0',
|
|
9013
|
-
minHeight: '48px',
|
|
9014
8856
|
backgroundColor: status === 'EXPIRED' ? 'geowebColors.cards.cardContainerDisabled' : 'geowebColors.cards.cardContainer',
|
|
9015
8857
|
borderColor: status === 'EXPIRED' ? 'geowebColors.cards.cardContainerDisabledBorder' : 'geowebColors.cards.cardContainerBorder',
|
|
9016
8858
|
borderRadius: 1,
|
|
9017
8859
|
borderWidth: activeWarningId === warning.id ? '1px' : '1px',
|
|
9018
|
-
borderStyle: 'solid'
|
|
9019
|
-
containerType: 'inline-size'
|
|
8860
|
+
borderStyle: 'solid'
|
|
9020
8861
|
},
|
|
9021
8862
|
secondaryAction: status !== 'EXPIRED' ? ( /*#__PURE__*/React__default.createElement(ToggleMenu, {
|
|
9022
8863
|
menuTitle: t('warning-list-button-options'),
|
|
@@ -9033,12 +8874,11 @@ const WarningsOnStatus = ({
|
|
|
9033
8874
|
}, /*#__PURE__*/React__default.createElement(ListItemButton, {
|
|
9034
8875
|
sx: {
|
|
9035
8876
|
height: '100%',
|
|
9036
|
-
minHeight: '48px',
|
|
9037
8877
|
padding: 1,
|
|
9038
8878
|
'.warning-list': {
|
|
9039
8879
|
justifyContent: 'left'
|
|
9040
8880
|
},
|
|
9041
|
-
[`@container (min-width: ${breakpoints.desktop}px)`]: {
|
|
8881
|
+
[`@container publicWarningList (min-width: ${breakpoints.desktop}px)`]: {
|
|
9042
8882
|
'.warning-list': {
|
|
9043
8883
|
justifyContent: 'space-between'
|
|
9044
8884
|
}
|
|
@@ -9060,18 +8900,18 @@ const WarningsOnStatus = ({
|
|
|
9060
8900
|
status: status,
|
|
9061
8901
|
width: 142
|
|
9062
8902
|
}), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
9063
|
-
title: t('warning-list-header-last-update')
|
|
8903
|
+
title: `${t('warning-list-header-last-update')} UTC`,
|
|
9064
8904
|
status: status,
|
|
9065
8905
|
width: 142
|
|
9066
|
-
}, warning.lastUpdatedTime &&
|
|
9067
|
-
title: t('warning-list-header-start-time')
|
|
8906
|
+
}, warning.lastUpdatedTime && dateUtils.dateToString(dateUtils.utc(warning.lastUpdatedTime), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH)), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
8907
|
+
title: `${t('warning-list-header-start-time')} UTC`,
|
|
9068
8908
|
status: status,
|
|
9069
8909
|
width: 142
|
|
9070
|
-
}, warning.warningDetail.validFrom &&
|
|
9071
|
-
title: t('warning-list-header-end-time')
|
|
8910
|
+
}, warning.warningDetail.validFrom && dateUtils.dateToString(dateUtils.utc(warning.warningDetail.validFrom), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH)), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
8911
|
+
title: `${t('warning-list-header-end-time')} UTC`,
|
|
9072
8912
|
status: status,
|
|
9073
8913
|
width: 142
|
|
9074
|
-
}, warning.warningDetail.validUntil &&
|
|
8914
|
+
}, warning.warningDetail.validUntil && dateUtils.dateToString(dateUtils.utc(warning.warningDetail.validUntil), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH)), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
9075
8915
|
title: t('warning-list-header-domain'),
|
|
9076
8916
|
status: status
|
|
9077
8917
|
}, warning.warningDetail.domain), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
@@ -9101,7 +8941,9 @@ const WarningsOnStatus = ({
|
|
|
9101
8941
|
marginLeft: -0.5
|
|
9102
8942
|
}
|
|
9103
8943
|
}, ((_a = warning.warningDetail) === null || _a === void 0 ? void 0 : _a.level) && (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.title) || '-')), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
|
|
9104
|
-
|
|
8944
|
+
title: t('warning-list-header-status'),
|
|
8945
|
+
status: status,
|
|
8946
|
+
width: 96
|
|
9105
8947
|
}, status === 'DRAFT' ? ( /*#__PURE__*/React__default.createElement(Box, {
|
|
9106
8948
|
sx: {
|
|
9107
8949
|
position: 'relative',
|
|
@@ -9118,7 +8960,7 @@ const WarningsOnStatus = ({
|
|
|
9118
8960
|
editor: warning.editor
|
|
9119
8961
|
}))), /*#__PURE__*/React__default.createElement(Button, {
|
|
9120
8962
|
sx: {
|
|
9121
|
-
height: '
|
|
8963
|
+
height: '16px',
|
|
9122
8964
|
padding: '0px',
|
|
9123
8965
|
'& .MuiSvgIcon-root': {
|
|
9124
8966
|
marginRight: '-2px'
|
|
@@ -9130,7 +8972,8 @@ const WarningsOnStatus = ({
|
|
|
9130
8972
|
content: status.toLowerCase(),
|
|
9131
8973
|
color: status === 'EXPIRED' ? 'grey' : 'green',
|
|
9132
8974
|
sx: {
|
|
9133
|
-
width: 66
|
|
8975
|
+
width: 66,
|
|
8976
|
+
height: '16px'
|
|
9134
8977
|
}
|
|
9135
8978
|
}))))));
|
|
9136
8979
|
}))));
|
|
@@ -9150,13 +8993,15 @@ const PublicWarningList = ({
|
|
|
9150
8993
|
}) => {
|
|
9151
8994
|
const {
|
|
9152
8995
|
t
|
|
9153
|
-
} =
|
|
8996
|
+
} = useWarningsTranslation();
|
|
9154
8997
|
const sortedWarnings = warnings ? sortWarningsOnStatus(warnings) : null;
|
|
9155
8998
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
9156
8999
|
sx: {
|
|
9157
9000
|
padding: 3,
|
|
9158
9001
|
height: '100%',
|
|
9159
|
-
overflowY: 'auto'
|
|
9002
|
+
overflowY: 'auto',
|
|
9003
|
+
containerName: 'publicWarningList',
|
|
9004
|
+
containerType: 'inline-size'
|
|
9160
9005
|
},
|
|
9161
9006
|
"data-testid": "publicWarningList"
|
|
9162
9007
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
@@ -9174,10 +9019,55 @@ const PublicWarningList = ({
|
|
|
9174
9019
|
}, t('warning-list-button_create'))), error && /*#__PURE__*/React__default.createElement(AlertBanner, {
|
|
9175
9020
|
title: error.message,
|
|
9176
9021
|
shouldClose: true
|
|
9177
|
-
}), _isLoading
|
|
9022
|
+
}), _isLoading ? ( /*#__PURE__*/React__default.createElement(LinearProgress, {
|
|
9178
9023
|
"data-testid": "loading-bar",
|
|
9179
9024
|
color: "secondary"
|
|
9180
|
-
}))
|
|
9025
|
+
})) : ( /*#__PURE__*/React__default.createElement(Box, {
|
|
9026
|
+
sx: {
|
|
9027
|
+
height: '4px'
|
|
9028
|
+
}
|
|
9029
|
+
})), !error && ( /*#__PURE__*/React__default.createElement(Grid, {
|
|
9030
|
+
container: true,
|
|
9031
|
+
rowSpacing: 0,
|
|
9032
|
+
columnSpacing: 2,
|
|
9033
|
+
alignItems: "center",
|
|
9034
|
+
justifyContent: "space-between",
|
|
9035
|
+
sx: {
|
|
9036
|
+
maxWidth: '100%',
|
|
9037
|
+
display: 'none',
|
|
9038
|
+
[`@container publicWarningList (min-width: ${breakpoints.desktop}px)`]: {
|
|
9039
|
+
display: 'flex'
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
}, /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9043
|
+
title: t('warning-list-header-incident'),
|
|
9044
|
+
width: 142,
|
|
9045
|
+
sx: {
|
|
9046
|
+
marginLeft: 1
|
|
9047
|
+
}
|
|
9048
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9049
|
+
title: `${t('warning-list-header-last-update')} UTC`,
|
|
9050
|
+
width: 142
|
|
9051
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9052
|
+
title: `${t('warning-list-header-start-time')} UTC`,
|
|
9053
|
+
width: 142
|
|
9054
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9055
|
+
title: `${t('warning-list-header-end-time')} UTC`,
|
|
9056
|
+
width: 142
|
|
9057
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9058
|
+
title: t('warning-list-header-domain')
|
|
9059
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9060
|
+
title: t('warning-list-header-phenomenon'),
|
|
9061
|
+
width: 140
|
|
9062
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9063
|
+
title: t('warning-list-header-level')
|
|
9064
|
+
}), /*#__PURE__*/React__default.createElement(WarningListHeaderContent, {
|
|
9065
|
+
title: t('warning-list-header-status'),
|
|
9066
|
+
width: 96,
|
|
9067
|
+
sx: {
|
|
9068
|
+
marginRight: '48px'
|
|
9069
|
+
}
|
|
9070
|
+
}))), lastUpdatedTime && ( /*#__PURE__*/React__default.createElement(Box, {
|
|
9181
9071
|
sx: {
|
|
9182
9072
|
marginBottom: -3.25,
|
|
9183
9073
|
button: {
|
|
@@ -9333,7 +9223,7 @@ const ConfirmDeleteWarningDialog = ({
|
|
|
9333
9223
|
}) => {
|
|
9334
9224
|
const {
|
|
9335
9225
|
t
|
|
9336
|
-
} =
|
|
9226
|
+
} = useWarningsTranslation();
|
|
9337
9227
|
const [isLoading, setIsLoading] = React__default.useState(false);
|
|
9338
9228
|
const [error, setError] = React__default.useState(undefined);
|
|
9339
9229
|
const onSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -9378,7 +9268,7 @@ const ConfirmDeleteWarningDialog = ({
|
|
|
9378
9268
|
const PublicWarningListConnect = () => {
|
|
9379
9269
|
const {
|
|
9380
9270
|
t
|
|
9381
|
-
} =
|
|
9271
|
+
} = useWarningsTranslation();
|
|
9382
9272
|
const dispatch = useDispatch();
|
|
9383
9273
|
const confirmDialog = useConfirmationDialog();
|
|
9384
9274
|
const [confirmDialogOptions, setConfirmDialogOptions] = React__default.useState(undefined);
|
|
@@ -9509,16 +9399,308 @@ const componentsLookUp = (payload, apiProps) => {
|
|
|
9509
9399
|
switch (componentType) {
|
|
9510
9400
|
case warningListViewPreset.componentType:
|
|
9511
9401
|
if (apiProps && apiProps.config) {
|
|
9512
|
-
return /*#__PURE__*/React.createElement(
|
|
9402
|
+
return /*#__PURE__*/React.createElement(PublicWarningApiWrapper, Object.assign({}, apiProps, {
|
|
9513
9403
|
"data-testid": "publicWarningModule"
|
|
9514
|
-
}))
|
|
9404
|
+
}));
|
|
9515
9405
|
}
|
|
9516
|
-
return /*#__PURE__*/React.createElement(
|
|
9406
|
+
return /*#__PURE__*/React.createElement(PublicWarningListConnect, {
|
|
9517
9407
|
"data-testid": "publicWarningList"
|
|
9518
|
-
})
|
|
9408
|
+
});
|
|
9519
9409
|
default:
|
|
9520
9410
|
return null;
|
|
9521
9411
|
}
|
|
9522
9412
|
};
|
|
9523
9413
|
|
|
9524
|
-
|
|
9414
|
+
const getErrorMessage = error => isAxiosError(error) ? getAxiosErrorMessage(error) : error.message;
|
|
9415
|
+
const getToggleEditorSuccessMessage = isEditor => outsideComponentTranslations[isEditor ? 'warning-editor-add-editor' : 'warning-editor-remove-editor'];
|
|
9416
|
+
const publicWarningFormListener = createListenerMiddleware();
|
|
9417
|
+
publicWarningFormListener.startListening({
|
|
9418
|
+
actionCreator: publicWarningFormActions.toggleEditorWarning,
|
|
9419
|
+
effect: ({
|
|
9420
|
+
payload
|
|
9421
|
+
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9422
|
+
listenerApi.cancelActiveListeners();
|
|
9423
|
+
try {
|
|
9424
|
+
const {
|
|
9425
|
+
warningId,
|
|
9426
|
+
isEditor,
|
|
9427
|
+
username
|
|
9428
|
+
} = payload;
|
|
9429
|
+
const warningsApi = getWarningsApi();
|
|
9430
|
+
yield warningsApi.toggleEditorWarning(warningId, isEditor);
|
|
9431
|
+
// update list to show correct avatar
|
|
9432
|
+
listenerApi.dispatch(publicWarningActions.fetchWarnings());
|
|
9433
|
+
listenerApi.dispatch(publicWarningFormActions.toggleEditorWarningSuccess({
|
|
9434
|
+
isEditor,
|
|
9435
|
+
username,
|
|
9436
|
+
message: getToggleEditorSuccessMessage(isEditor)
|
|
9437
|
+
}));
|
|
9438
|
+
} catch (error) {
|
|
9439
|
+
const isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
|
|
9440
|
+
errorEffect(listenerApi.dispatch, getErrorMessage(error), isDialogOpen);
|
|
9441
|
+
}
|
|
9442
|
+
})
|
|
9443
|
+
});
|
|
9444
|
+
publicWarningFormListener.startListening({
|
|
9445
|
+
actionCreator: publicWarningFormActions.publishWarning,
|
|
9446
|
+
effect: ({
|
|
9447
|
+
payload
|
|
9448
|
+
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9449
|
+
listenerApi.cancelActiveListeners();
|
|
9450
|
+
try {
|
|
9451
|
+
const {
|
|
9452
|
+
publicWarning
|
|
9453
|
+
} = payload;
|
|
9454
|
+
const publishedWarning = yield saveOrUpdateWarning(publicWarning);
|
|
9455
|
+
listenerApi.dispatch(publicWarningFormActions.publishWarningSuccess({
|
|
9456
|
+
publicWarning: publishedWarning,
|
|
9457
|
+
message: outsideComponentTranslations['warning-publish-succes']
|
|
9458
|
+
}));
|
|
9459
|
+
listenerApi.dispatch(uiActions.setToggleOpenDialog({
|
|
9460
|
+
type: publicWarningDialogType,
|
|
9461
|
+
setOpen: false
|
|
9462
|
+
}));
|
|
9463
|
+
} catch (error) {
|
|
9464
|
+
const isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
|
|
9465
|
+
errorEffect(listenerApi.dispatch, getErrorMessage(error), isDialogOpen);
|
|
9466
|
+
}
|
|
9467
|
+
})
|
|
9468
|
+
});
|
|
9469
|
+
publicWarningFormListener.startListening({
|
|
9470
|
+
actionCreator: publicWarningFormActions.saveWarning,
|
|
9471
|
+
effect: ({
|
|
9472
|
+
payload
|
|
9473
|
+
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9474
|
+
listenerApi.cancelActiveListeners();
|
|
9475
|
+
try {
|
|
9476
|
+
const {
|
|
9477
|
+
publicWarning
|
|
9478
|
+
} = payload;
|
|
9479
|
+
const savedWarning = yield saveOrUpdateWarning(publicWarning);
|
|
9480
|
+
listenerApi.dispatch(publicWarningFormActions.saveWarningSuccess({
|
|
9481
|
+
publicWarning: savedWarning,
|
|
9482
|
+
message: outsideComponentTranslations['warning-save-succes']
|
|
9483
|
+
}));
|
|
9484
|
+
} catch (error) {
|
|
9485
|
+
const isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
|
|
9486
|
+
errorEffect(listenerApi.dispatch, getErrorMessage(error), isDialogOpen);
|
|
9487
|
+
}
|
|
9488
|
+
})
|
|
9489
|
+
});
|
|
9490
|
+
// Side effects/snackbar listeners
|
|
9491
|
+
publicWarningFormListener.startListening({
|
|
9492
|
+
matcher: isAnyOf(publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess, publicWarningFormActions.toggleEditorWarningSuccess),
|
|
9493
|
+
effect: ({
|
|
9494
|
+
payload
|
|
9495
|
+
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9496
|
+
listenerApi.cancelActiveListeners();
|
|
9497
|
+
const {
|
|
9498
|
+
message
|
|
9499
|
+
} = payload;
|
|
9500
|
+
listenerApi.dispatch(snackbarActions.openSnackbar({
|
|
9501
|
+
message
|
|
9502
|
+
}));
|
|
9503
|
+
const isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
|
|
9504
|
+
toggleDialogLoadingEffect(listenerApi.dispatch, isDialogOpen, false);
|
|
9505
|
+
})
|
|
9506
|
+
});
|
|
9507
|
+
publicWarningFormListener.startListening({
|
|
9508
|
+
matcher: isAnyOf(publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning),
|
|
9509
|
+
effect: (_, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9510
|
+
listenerApi.cancelActiveListeners();
|
|
9511
|
+
const isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
|
|
9512
|
+
toggleDialogLoadingEffect(listenerApi.dispatch, isDialogOpen, true);
|
|
9513
|
+
})
|
|
9514
|
+
});
|
|
9515
|
+
publicWarningFormListener.startListening({
|
|
9516
|
+
actionCreator: publicWarningFormActions.openPublicWarningFormDialog,
|
|
9517
|
+
effect: (_, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9518
|
+
listenerApi.cancelActiveListeners();
|
|
9519
|
+
listenerApi.dispatch(uiActions.setToggleOpenDialog({
|
|
9520
|
+
setOpen: true,
|
|
9521
|
+
type: publicWarningDialogType
|
|
9522
|
+
}));
|
|
9523
|
+
})
|
|
9524
|
+
});
|
|
9525
|
+
const saveOrUpdateWarning = publicWarning => __awaiter(void 0, void 0, void 0, function* () {
|
|
9526
|
+
const warningsApi = getWarningsApi();
|
|
9527
|
+
if (publicWarning.warningDetail.id) {
|
|
9528
|
+
yield warningsApi.updateWarning(publicWarning.warningDetail.id, publicWarning);
|
|
9529
|
+
return publicWarning;
|
|
9530
|
+
}
|
|
9531
|
+
const newWarningId = yield warningsApi.saveWarningAs(publicWarning);
|
|
9532
|
+
return Object.assign(Object.assign({}, publicWarning), {
|
|
9533
|
+
warningDetail: Object.assign(Object.assign({}, publicWarning.warningDetail), {
|
|
9534
|
+
id: newWarningId
|
|
9535
|
+
})
|
|
9536
|
+
});
|
|
9537
|
+
});
|
|
9538
|
+
const toggleDialogLoadingEffect = (dispatch, isDialogOpen, isLoading) => {
|
|
9539
|
+
if (isDialogOpen) {
|
|
9540
|
+
dispatch(uiActions.toggleIsLoadingDialog({
|
|
9541
|
+
isLoading,
|
|
9542
|
+
type: publicWarningDialogType
|
|
9543
|
+
}));
|
|
9544
|
+
}
|
|
9545
|
+
};
|
|
9546
|
+
const errorEffect = (dispatch, message, isDialogOpen) => {
|
|
9547
|
+
dispatch(publicWarningFormActions.setFormError({
|
|
9548
|
+
message
|
|
9549
|
+
}));
|
|
9550
|
+
toggleDialogLoadingEffect(dispatch, isDialogOpen, false);
|
|
9551
|
+
};
|
|
9552
|
+
|
|
9553
|
+
/* *
|
|
9554
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9555
|
+
* you may not use this file except in compliance with the License.
|
|
9556
|
+
* You may obtain a copy of the License at
|
|
9557
|
+
*
|
|
9558
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9559
|
+
*
|
|
9560
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9561
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9562
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9563
|
+
* See the License for the specific language governing permissions and
|
|
9564
|
+
* limitations under the License.
|
|
9565
|
+
*
|
|
9566
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
9567
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
9568
|
+
* */
|
|
9569
|
+
const getLastUpdatedTimeFormatted = () => dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_HOURS);
|
|
9570
|
+
const publicWarningsListener = createListenerMiddleware();
|
|
9571
|
+
publicWarningsListener.startListening({
|
|
9572
|
+
actionCreator: publicWarningActions.fetchWarnings,
|
|
9573
|
+
effect: (_, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9574
|
+
listenerApi.cancelActiveListeners();
|
|
9575
|
+
try {
|
|
9576
|
+
const warningsApi = getWarningsApi();
|
|
9577
|
+
const {
|
|
9578
|
+
data: warnings
|
|
9579
|
+
} = yield warningsApi.getWarnings();
|
|
9580
|
+
const lastUpdatedTime = getLastUpdatedTimeFormatted();
|
|
9581
|
+
listenerApi.dispatch(publicWarningActions.fetchWarningsSuccess({
|
|
9582
|
+
warnings,
|
|
9583
|
+
lastUpdatedTime
|
|
9584
|
+
}));
|
|
9585
|
+
yield listenerApi.delay(pollingIntervalTimeout);
|
|
9586
|
+
listenerApi.dispatch(publicWarningActions.fetchWarnings());
|
|
9587
|
+
} catch (error) {
|
|
9588
|
+
// Don't set an error if the cancelActiveListeners was invoked (which throws a TaskAbortError)
|
|
9589
|
+
if ((error === null || error === void 0 ? void 0 : error.code) !== 'listener-cancelled') {
|
|
9590
|
+
listenerApi.dispatch(publicWarningActions.fetchWarningsError({
|
|
9591
|
+
error: {
|
|
9592
|
+
name: error.name,
|
|
9593
|
+
message: error.message
|
|
9594
|
+
}
|
|
9595
|
+
}));
|
|
9596
|
+
}
|
|
9597
|
+
}
|
|
9598
|
+
})
|
|
9599
|
+
});
|
|
9600
|
+
publicWarningsListener.startListening({
|
|
9601
|
+
matcher: isAnyOf(publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess),
|
|
9602
|
+
effect: (_, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9603
|
+
listenerApi.cancelActiveListeners();
|
|
9604
|
+
listenerApi.dispatch(publicWarningActions.fetchWarnings());
|
|
9605
|
+
})
|
|
9606
|
+
});
|
|
9607
|
+
|
|
9608
|
+
/* *
|
|
9609
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9610
|
+
* you may not use this file except in compliance with the License.
|
|
9611
|
+
* You may obtain a copy of the License at
|
|
9612
|
+
*
|
|
9613
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9614
|
+
*
|
|
9615
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9616
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9617
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9618
|
+
* See the License for the specific language governing permissions and
|
|
9619
|
+
* limitations under the License.
|
|
9620
|
+
*
|
|
9621
|
+
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
9622
|
+
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
9623
|
+
* */
|
|
9624
|
+
const getSnackbarMessage = (objectName, id) => id ? `Object "${objectName}" ${outsideComponentTranslations['update-succes']}!` : `Object "${objectName}" ${outsideComponentTranslations['save-succes']}!`;
|
|
9625
|
+
const drawingsListener = createListenerMiddleware();
|
|
9626
|
+
drawingsListener.startListening({
|
|
9627
|
+
actionCreator: drawActions.submitDrawValues,
|
|
9628
|
+
effect: ({
|
|
9629
|
+
payload
|
|
9630
|
+
}, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9631
|
+
listenerApi.cancelActiveListeners();
|
|
9632
|
+
const {
|
|
9633
|
+
id
|
|
9634
|
+
} = payload,
|
|
9635
|
+
formValues = __rest(payload, ["id"]);
|
|
9636
|
+
try {
|
|
9637
|
+
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
9638
|
+
isLoading: true,
|
|
9639
|
+
type: drawingDialogType
|
|
9640
|
+
}));
|
|
9641
|
+
const warningsApi = getWarningsApi();
|
|
9642
|
+
if (!id) {
|
|
9643
|
+
const newID = yield warningsApi.saveDrawingAs(formValues);
|
|
9644
|
+
listenerApi.dispatch(drawActions.setDrawValues({
|
|
9645
|
+
drawingInstanceId: drawingDialogType,
|
|
9646
|
+
id: newID,
|
|
9647
|
+
objectName: formValues.objectName
|
|
9648
|
+
}));
|
|
9649
|
+
} else {
|
|
9650
|
+
yield warningsApi.updateDrawing(id, formValues);
|
|
9651
|
+
}
|
|
9652
|
+
listenerApi.dispatch(uiActions.setErrorDialog({
|
|
9653
|
+
type: drawingDialogType,
|
|
9654
|
+
error: ''
|
|
9655
|
+
}));
|
|
9656
|
+
listenerApi.dispatch(snackbarActions.openSnackbar({
|
|
9657
|
+
message: getSnackbarMessage(formValues.objectName, id)
|
|
9658
|
+
}));
|
|
9659
|
+
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
9660
|
+
isLoading: false,
|
|
9661
|
+
type: drawingDialogType
|
|
9662
|
+
}));
|
|
9663
|
+
} catch (error) {
|
|
9664
|
+
// Don't do anything if the cancelActiveListeners was invoked (which throws a TaskAbortError)
|
|
9665
|
+
if (error.code !== 'listener-cancelled') {
|
|
9666
|
+
listenerApi.dispatch(uiActions.toggleIsLoadingDialog({
|
|
9667
|
+
isLoading: false,
|
|
9668
|
+
type: drawingDialogType
|
|
9669
|
+
}));
|
|
9670
|
+
const errorMessage = isAxiosError$1(error) ? getAxiosErrorMessage(error) : error.message;
|
|
9671
|
+
listenerApi.dispatch(uiActions.setErrorDialog({
|
|
9672
|
+
type: drawingDialogType,
|
|
9673
|
+
error: errorMessage
|
|
9674
|
+
}));
|
|
9675
|
+
}
|
|
9676
|
+
}
|
|
9677
|
+
})
|
|
9678
|
+
});
|
|
9679
|
+
|
|
9680
|
+
/* *
|
|
9681
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9682
|
+
* you may not use this file except in compliance with the License.
|
|
9683
|
+
* You may obtain a copy of the License at
|
|
9684
|
+
*
|
|
9685
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9686
|
+
*
|
|
9687
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9688
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
9689
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9690
|
+
* See the License for the specific language governing permissions and
|
|
9691
|
+
* limitations under the License.
|
|
9692
|
+
*
|
|
9693
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
9694
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
9695
|
+
* */
|
|
9696
|
+
const drawingModuleConfig = {
|
|
9697
|
+
id: 'drawing-module',
|
|
9698
|
+
reducersMap: {
|
|
9699
|
+
drawings: reducer$2,
|
|
9700
|
+
publicWarningForm: reducer,
|
|
9701
|
+
publicWarnings: reducer$1
|
|
9702
|
+
},
|
|
9703
|
+
middlewares: [drawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware]
|
|
9704
|
+
};
|
|
9705
|
+
|
|
9706
|
+
export { DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, isAlreadyEdited, useObjectDrawDialogAction, warningFormConfirmationOptions, warningsTranslations };
|