@opengeoweb/cap 12.1.2 → 12.3.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 +303 -965
- package/package.json +15 -15
- package/src/lib/CapDemo.stories.d.ts +2 -1
- package/src/lib/components/ComponentsLookUp/componentsLookUp.d.ts +1 -3
- package/src/lib/components/GanttChart/GanttModule.stories.d.ts +1 -0
- package/src/lib/components/MapViewCap/MapViewCapConnect.d.ts +1 -1
- package/src/lib/components/MapViewCap/MapViewCapConnectWrapper.d.ts +1 -1
- package/src/lib/components/Providers/Providers.d.ts +6 -6
- package/src/lib/components/WarningListCap/WarningListCap.d.ts +4 -2
- package/src/lib/components/WarningListCap/WarningListRowCap/WarningListRowCapConnect.d.ts +2 -1
- package/src/lib/components/types.d.ts +0 -3
- package/src/lib/store/index.d.ts +0 -4
- package/src/lib/store/store.d.ts +2 -11
- package/src/lib/store/types.d.ts +0 -27
- package/src/lib/utils/addFeedAddressToCustomGeoJsonFeature.d.ts +1 -1
- package/src/lib/utils/cap-api/api.d.ts +12 -0
- package/src/lib/utils/cap-api/fakeApi.d.ts +2 -0
- package/src/lib/utils/cap-api/hooks.d.ts +10 -0
- package/src/lib/utils/highlightGeoJson.d.ts +1 -1
- package/src/lib/utils/i18n.d.ts +1 -0
- package/src/lib/utils/mockAlert.d.ts +0 -17
- package/src/lib/utils/mockCapData.d.ts +1 -4
- package/src/lib/utils/mockGeoJson.d.ts +0 -2
- package/src/lib/store/mockStore.d.ts +0 -21
- package/src/lib/store/reducer.d.ts +0 -12
- package/src/lib/store/reducer.spec.d.ts +0 -1
- package/src/lib/store/selector.spec.d.ts +0 -1
- package/src/lib/store/selectors.d.ts +0 -15
- package/src/lib/utils/api.d.ts +0 -20
- package/src/lib/utils/api.spec.d.ts +0 -1
- package/src/lib/utils/fakeApi.d.ts +0 -2
- package/src/lib/utils/fakeApi.spec.d.ts +0 -1
package/index.esm.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import { Grid2, Typography, Box, Card, CircularProgress } from '@mui/material';
|
|
2
|
+
import { Grid, Typography, Box, LinearProgress, Card, CircularProgress } from '@mui/material';
|
|
4
3
|
import { Box as Box$1 } from '@mui/system';
|
|
5
|
-
import { dateUtils, AlertBanner } from '@opengeoweb/shared';
|
|
6
|
-
import { useSelector, useDispatch } from 'react-redux';
|
|
7
|
-
import { createEntityAdapter, createSlice, createSelector, combineReducers, configureStore } from '@reduxjs/toolkit';
|
|
4
|
+
import { dateUtils, AlertBanner, sessionStorageProvider, usePrevious } from '@opengeoweb/shared';
|
|
8
5
|
import React, { useMemo } from 'react';
|
|
9
6
|
import i18n from 'i18next';
|
|
10
7
|
import { useTranslation } from 'react-i18next';
|
|
11
8
|
import { ConfigurableMapConnect } from '@opengeoweb/core';
|
|
12
9
|
import '@opengeoweb/timeslider';
|
|
13
10
|
import { isOpenLayersEnabled, OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapViewLayer, MapWarningProperties } from '@opengeoweb/webmap-react';
|
|
11
|
+
import { useQuery, useQueries } from '@tanstack/react-query';
|
|
12
|
+
import { handleResponse } from '@opengeoweb/api';
|
|
14
13
|
import { GeoJSON } from 'ol/format';
|
|
15
|
-
import {
|
|
14
|
+
import { useSelector } from 'react-redux';
|
|
15
|
+
import { mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer } from '@opengeoweb/store';
|
|
16
16
|
import { webmapUtils } from '@opengeoweb/webmap';
|
|
17
|
+
import { combineReducers, configureStore } from '@reduxjs/toolkit';
|
|
17
18
|
|
|
18
19
|
var en = {
|
|
19
20
|
"map-view-cap-error-title": "Something went wrong with loading the configuration file",
|
|
@@ -58,117 +59,6 @@ var capTrans = {
|
|
|
58
59
|
nl: nl
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
/* *
|
|
62
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
63
|
-
* you may not use this file except in compliance with the License.
|
|
64
|
-
* You may obtain a copy of the License at
|
|
65
|
-
*
|
|
66
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
67
|
-
*
|
|
68
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
69
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
70
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
71
|
-
* See the License for the specific language governing permissions and
|
|
72
|
-
* limitations under the License.
|
|
73
|
-
*
|
|
74
|
-
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
75
|
-
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
76
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
77
|
-
* */
|
|
78
|
-
var feedAdapter = createEntityAdapter();
|
|
79
|
-
var feedInitialState = feedAdapter.getInitialState();
|
|
80
|
-
var alertAdapter = createEntityAdapter({
|
|
81
|
-
// we use identifier as id
|
|
82
|
-
selectId: function selectId(capAlert) {
|
|
83
|
-
return capAlert.identifier;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
var alertInitialState = alertAdapter.getInitialState();
|
|
87
|
-
var initialState = {
|
|
88
|
-
feeds: feedInitialState,
|
|
89
|
-
alerts: alertInitialState
|
|
90
|
-
};
|
|
91
|
-
var slice = createSlice({
|
|
92
|
-
initialState: initialState,
|
|
93
|
-
name: 'capReducer',
|
|
94
|
-
reducers: {
|
|
95
|
-
addManyAlerts: function addManyAlerts(draft, action) {
|
|
96
|
-
alertAdapter.upsertMany(draft.alerts, action.payload);
|
|
97
|
-
},
|
|
98
|
-
addManyAlertsToFeed: function addManyAlertsToFeed(draft, action) {
|
|
99
|
-
feedAdapter.upsertOne(draft.feeds, {
|
|
100
|
-
id: action.payload.feedId,
|
|
101
|
-
lastUpdated: Date.now(),
|
|
102
|
-
alertIds: action.payload.alertIds
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
setFeedLastUpdatedTimes: function setFeedLastUpdatedTimes(draft, action) {
|
|
106
|
-
feedAdapter.updateMany(draft.feeds, action.payload);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
var capReducer = slice.reducer,
|
|
111
|
-
capActions = slice.actions;
|
|
112
|
-
|
|
113
|
-
/* *
|
|
114
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
115
|
-
* you may not use this file except in compliance with the License.
|
|
116
|
-
* You may obtain a copy of the License at
|
|
117
|
-
*
|
|
118
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
119
|
-
*
|
|
120
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
121
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
122
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
123
|
-
* See the License for the specific language governing permissions and
|
|
124
|
-
* limitations under the License.
|
|
125
|
-
*
|
|
126
|
-
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
127
|
-
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
128
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
129
|
-
* */
|
|
130
|
-
var getCapStore = function getCapStore(store) {
|
|
131
|
-
if (store && store.cap) {
|
|
132
|
-
return store.cap;
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
};
|
|
136
|
-
var _feedAdapter$getSelec = feedAdapter.getSelectors(function (state) {
|
|
137
|
-
return state.cap.feeds;
|
|
138
|
-
}),
|
|
139
|
-
getCapFeedById = _feedAdapter$getSelec.selectById,
|
|
140
|
-
getCapFeeds = _feedAdapter$getSelec.selectAll;
|
|
141
|
-
var _alertAdapter$getSele = alertAdapter.getSelectors(function (state) {
|
|
142
|
-
return state.cap.alerts;
|
|
143
|
-
}),
|
|
144
|
-
getAlertById = _alertAdapter$getSele.selectById,
|
|
145
|
-
getAlerts = _alertAdapter$getSele.selectAll,
|
|
146
|
-
getAlertIds = _alertAdapter$getSele.selectIds;
|
|
147
|
-
var getAlertsInEffect = createSelector(getAlerts, function (_state, selectedTime) {
|
|
148
|
-
return selectedTime;
|
|
149
|
-
}, function (alerts, selectedTime) {
|
|
150
|
-
return alerts.filter(function (alert) {
|
|
151
|
-
return dateUtils.isBetween(dateUtils.createDate(selectedTime), dateUtils.createDate(alert.onset), dateUtils.createDate(alert.expires), '[)');
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
var getLastUpdatedTimes = createSelector(getCapFeeds, function (feeds) {
|
|
155
|
-
return feeds.map(function (feed) {
|
|
156
|
-
return feed.lastUpdated;
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
var selectors = /*#__PURE__*/Object.freeze({
|
|
161
|
-
__proto__: null,
|
|
162
|
-
getAlertById: getAlertById,
|
|
163
|
-
getAlertIds: getAlertIds,
|
|
164
|
-
getAlerts: getAlerts,
|
|
165
|
-
getAlertsInEffect: getAlertsInEffect,
|
|
166
|
-
getCapFeedById: getCapFeedById,
|
|
167
|
-
getCapFeeds: getCapFeeds,
|
|
168
|
-
getCapStore: getCapStore,
|
|
169
|
-
getLastUpdatedTimes: getLastUpdatedTimes
|
|
170
|
-
});
|
|
171
|
-
|
|
172
62
|
function _arrayLikeToArray(r, a) {
|
|
173
63
|
(null == a || a > r.length) && (a = r.length);
|
|
174
64
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -177,38 +67,10 @@ function _arrayLikeToArray(r, a) {
|
|
|
177
67
|
function _arrayWithHoles(r) {
|
|
178
68
|
if (Array.isArray(r)) return r;
|
|
179
69
|
}
|
|
180
|
-
function _arrayWithoutHoles(r) {
|
|
181
|
-
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
182
|
-
}
|
|
183
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
184
|
-
try {
|
|
185
|
-
var i = n[a](c),
|
|
186
|
-
u = i.value;
|
|
187
|
-
} catch (n) {
|
|
188
|
-
return void e(n);
|
|
189
|
-
}
|
|
190
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
191
|
-
}
|
|
192
|
-
function _asyncToGenerator(n) {
|
|
193
|
-
return function () {
|
|
194
|
-
var t = this,
|
|
195
|
-
e = arguments;
|
|
196
|
-
return new Promise(function (r, o) {
|
|
197
|
-
var a = n.apply(t, e);
|
|
198
|
-
function _next(n) {
|
|
199
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
200
|
-
}
|
|
201
|
-
function _throw(n) {
|
|
202
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
203
|
-
}
|
|
204
|
-
_next(void 0);
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
70
|
function _createForOfIteratorHelper(r, e) {
|
|
209
71
|
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
210
72
|
if (!t) {
|
|
211
|
-
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e
|
|
73
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
212
74
|
t && (r = t);
|
|
213
75
|
var n = 0,
|
|
214
76
|
F = function () {};
|
|
@@ -216,9 +78,9 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
216
78
|
s: F,
|
|
217
79
|
n: function () {
|
|
218
80
|
return n >= r.length ? {
|
|
219
|
-
done:
|
|
81
|
+
done: true
|
|
220
82
|
} : {
|
|
221
|
-
done:
|
|
83
|
+
done: false,
|
|
222
84
|
value: r[n++]
|
|
223
85
|
};
|
|
224
86
|
},
|
|
@@ -231,8 +93,8 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
231
93
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
232
94
|
}
|
|
233
95
|
var o,
|
|
234
|
-
a =
|
|
235
|
-
u =
|
|
96
|
+
a = true,
|
|
97
|
+
u = false;
|
|
236
98
|
return {
|
|
237
99
|
s: function () {
|
|
238
100
|
t = t.call(r);
|
|
@@ -242,7 +104,7 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
242
104
|
return a = r.done, r;
|
|
243
105
|
},
|
|
244
106
|
e: function (r) {
|
|
245
|
-
u =
|
|
107
|
+
u = true, o = r;
|
|
246
108
|
},
|
|
247
109
|
f: function () {
|
|
248
110
|
try {
|
|
@@ -256,14 +118,11 @@ function _createForOfIteratorHelper(r, e) {
|
|
|
256
118
|
function _defineProperty(e, r, t) {
|
|
257
119
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
258
120
|
value: t,
|
|
259
|
-
enumerable:
|
|
260
|
-
configurable:
|
|
261
|
-
writable:
|
|
121
|
+
enumerable: true,
|
|
122
|
+
configurable: true,
|
|
123
|
+
writable: true
|
|
262
124
|
}) : e[r] = t, e;
|
|
263
125
|
}
|
|
264
|
-
function _iterableToArray(r) {
|
|
265
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
266
|
-
}
|
|
267
126
|
function _iterableToArrayLimit(r, l) {
|
|
268
127
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
269
128
|
if (null != t) {
|
|
@@ -272,12 +131,12 @@ function _iterableToArrayLimit(r, l) {
|
|
|
272
131
|
i,
|
|
273
132
|
u,
|
|
274
133
|
a = [],
|
|
275
|
-
f =
|
|
276
|
-
o =
|
|
134
|
+
f = true,
|
|
135
|
+
o = false;
|
|
277
136
|
try {
|
|
278
137
|
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
279
138
|
} catch (r) {
|
|
280
|
-
o =
|
|
139
|
+
o = true, n = r;
|
|
281
140
|
} finally {
|
|
282
141
|
try {
|
|
283
142
|
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
@@ -291,9 +150,6 @@ function _iterableToArrayLimit(r, l) {
|
|
|
291
150
|
function _nonIterableRest() {
|
|
292
151
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
293
152
|
}
|
|
294
|
-
function _nonIterableSpread() {
|
|
295
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
296
|
-
}
|
|
297
153
|
function ownKeys(e, r) {
|
|
298
154
|
var t = Object.keys(e);
|
|
299
155
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -307,7 +163,7 @@ function ownKeys(e, r) {
|
|
|
307
163
|
function _objectSpread2(e) {
|
|
308
164
|
for (var r = 1; r < arguments.length; r++) {
|
|
309
165
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
310
|
-
r % 2 ? ownKeys(Object(t),
|
|
166
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
311
167
|
_defineProperty(e, r, t[r]);
|
|
312
168
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
313
169
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -315,318 +171,14 @@ function _objectSpread2(e) {
|
|
|
315
171
|
}
|
|
316
172
|
return e;
|
|
317
173
|
}
|
|
318
|
-
function _regeneratorRuntime() {
|
|
319
|
-
_regeneratorRuntime = function () {
|
|
320
|
-
return e;
|
|
321
|
-
};
|
|
322
|
-
var t,
|
|
323
|
-
e = {},
|
|
324
|
-
r = Object.prototype,
|
|
325
|
-
n = r.hasOwnProperty,
|
|
326
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
327
|
-
t[e] = r.value;
|
|
328
|
-
},
|
|
329
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
330
|
-
a = i.iterator || "@@iterator",
|
|
331
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
332
|
-
u = i.toStringTag || "@@toStringTag";
|
|
333
|
-
function define(t, e, r) {
|
|
334
|
-
return Object.defineProperty(t, e, {
|
|
335
|
-
value: r,
|
|
336
|
-
enumerable: !0,
|
|
337
|
-
configurable: !0,
|
|
338
|
-
writable: !0
|
|
339
|
-
}), t[e];
|
|
340
|
-
}
|
|
341
|
-
try {
|
|
342
|
-
define({}, "");
|
|
343
|
-
} catch (t) {
|
|
344
|
-
define = function (t, e, r) {
|
|
345
|
-
return t[e] = r;
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
function wrap(t, e, r, n) {
|
|
349
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
350
|
-
a = Object.create(i.prototype),
|
|
351
|
-
c = new Context(n || []);
|
|
352
|
-
return o(a, "_invoke", {
|
|
353
|
-
value: makeInvokeMethod(t, r, c)
|
|
354
|
-
}), a;
|
|
355
|
-
}
|
|
356
|
-
function tryCatch(t, e, r) {
|
|
357
|
-
try {
|
|
358
|
-
return {
|
|
359
|
-
type: "normal",
|
|
360
|
-
arg: t.call(e, r)
|
|
361
|
-
};
|
|
362
|
-
} catch (t) {
|
|
363
|
-
return {
|
|
364
|
-
type: "throw",
|
|
365
|
-
arg: t
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
e.wrap = wrap;
|
|
370
|
-
var h = "suspendedStart",
|
|
371
|
-
l = "suspendedYield",
|
|
372
|
-
f = "executing",
|
|
373
|
-
s = "completed",
|
|
374
|
-
y = {};
|
|
375
|
-
function Generator() {}
|
|
376
|
-
function GeneratorFunction() {}
|
|
377
|
-
function GeneratorFunctionPrototype() {}
|
|
378
|
-
var p = {};
|
|
379
|
-
define(p, a, function () {
|
|
380
|
-
return this;
|
|
381
|
-
});
|
|
382
|
-
var d = Object.getPrototypeOf,
|
|
383
|
-
v = d && d(d(values([])));
|
|
384
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
385
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
386
|
-
function defineIteratorMethods(t) {
|
|
387
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
388
|
-
define(t, e, function (t) {
|
|
389
|
-
return this._invoke(e, t);
|
|
390
|
-
});
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
function AsyncIterator(t, e) {
|
|
394
|
-
function invoke(r, o, i, a) {
|
|
395
|
-
var c = tryCatch(t[r], t, o);
|
|
396
|
-
if ("throw" !== c.type) {
|
|
397
|
-
var u = c.arg,
|
|
398
|
-
h = u.value;
|
|
399
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
400
|
-
invoke("next", t, i, a);
|
|
401
|
-
}, function (t) {
|
|
402
|
-
invoke("throw", t, i, a);
|
|
403
|
-
}) : e.resolve(h).then(function (t) {
|
|
404
|
-
u.value = t, i(u);
|
|
405
|
-
}, function (t) {
|
|
406
|
-
return invoke("throw", t, i, a);
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
a(c.arg);
|
|
410
|
-
}
|
|
411
|
-
var r;
|
|
412
|
-
o(this, "_invoke", {
|
|
413
|
-
value: function (t, n) {
|
|
414
|
-
function callInvokeWithMethodAndArg() {
|
|
415
|
-
return new e(function (e, r) {
|
|
416
|
-
invoke(t, n, e, r);
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
function makeInvokeMethod(e, r, n) {
|
|
424
|
-
var o = h;
|
|
425
|
-
return function (i, a) {
|
|
426
|
-
if (o === f) throw Error("Generator is already running");
|
|
427
|
-
if (o === s) {
|
|
428
|
-
if ("throw" === i) throw a;
|
|
429
|
-
return {
|
|
430
|
-
value: t,
|
|
431
|
-
done: !0
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
for (n.method = i, n.arg = a;;) {
|
|
435
|
-
var c = n.delegate;
|
|
436
|
-
if (c) {
|
|
437
|
-
var u = maybeInvokeDelegate(c, n);
|
|
438
|
-
if (u) {
|
|
439
|
-
if (u === y) continue;
|
|
440
|
-
return u;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
444
|
-
if (o === h) throw o = s, n.arg;
|
|
445
|
-
n.dispatchException(n.arg);
|
|
446
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
447
|
-
o = f;
|
|
448
|
-
var p = tryCatch(e, r, n);
|
|
449
|
-
if ("normal" === p.type) {
|
|
450
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
451
|
-
return {
|
|
452
|
-
value: p.arg,
|
|
453
|
-
done: n.done
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
function maybeInvokeDelegate(e, r) {
|
|
461
|
-
var n = r.method,
|
|
462
|
-
o = e.iterator[n];
|
|
463
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
464
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
465
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
466
|
-
var a = i.arg;
|
|
467
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
468
|
-
}
|
|
469
|
-
function pushTryEntry(t) {
|
|
470
|
-
var e = {
|
|
471
|
-
tryLoc: t[0]
|
|
472
|
-
};
|
|
473
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
474
|
-
}
|
|
475
|
-
function resetTryEntry(t) {
|
|
476
|
-
var e = t.completion || {};
|
|
477
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
478
|
-
}
|
|
479
|
-
function Context(t) {
|
|
480
|
-
this.tryEntries = [{
|
|
481
|
-
tryLoc: "root"
|
|
482
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
483
|
-
}
|
|
484
|
-
function values(e) {
|
|
485
|
-
if (e || "" === e) {
|
|
486
|
-
var r = e[a];
|
|
487
|
-
if (r) return r.call(e);
|
|
488
|
-
if ("function" == typeof e.next) return e;
|
|
489
|
-
if (!isNaN(e.length)) {
|
|
490
|
-
var o = -1,
|
|
491
|
-
i = function next() {
|
|
492
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
493
|
-
return next.value = t, next.done = !0, next;
|
|
494
|
-
};
|
|
495
|
-
return i.next = i;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
499
|
-
}
|
|
500
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
501
|
-
value: GeneratorFunctionPrototype,
|
|
502
|
-
configurable: !0
|
|
503
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
504
|
-
value: GeneratorFunction,
|
|
505
|
-
configurable: !0
|
|
506
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
507
|
-
var e = "function" == typeof t && t.constructor;
|
|
508
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
509
|
-
}, e.mark = function (t) {
|
|
510
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
511
|
-
}, e.awrap = function (t) {
|
|
512
|
-
return {
|
|
513
|
-
__await: t
|
|
514
|
-
};
|
|
515
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
516
|
-
return this;
|
|
517
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
518
|
-
void 0 === i && (i = Promise);
|
|
519
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
520
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
521
|
-
return t.done ? t.value : a.next();
|
|
522
|
-
});
|
|
523
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
524
|
-
return this;
|
|
525
|
-
}), define(g, "toString", function () {
|
|
526
|
-
return "[object Generator]";
|
|
527
|
-
}), e.keys = function (t) {
|
|
528
|
-
var e = Object(t),
|
|
529
|
-
r = [];
|
|
530
|
-
for (var n in e) r.push(n);
|
|
531
|
-
return r.reverse(), function next() {
|
|
532
|
-
for (; r.length;) {
|
|
533
|
-
var t = r.pop();
|
|
534
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
535
|
-
}
|
|
536
|
-
return next.done = !0, next;
|
|
537
|
-
};
|
|
538
|
-
}, e.values = values, Context.prototype = {
|
|
539
|
-
constructor: Context,
|
|
540
|
-
reset: function (e) {
|
|
541
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
542
|
-
},
|
|
543
|
-
stop: function () {
|
|
544
|
-
this.done = !0;
|
|
545
|
-
var t = this.tryEntries[0].completion;
|
|
546
|
-
if ("throw" === t.type) throw t.arg;
|
|
547
|
-
return this.rval;
|
|
548
|
-
},
|
|
549
|
-
dispatchException: function (e) {
|
|
550
|
-
if (this.done) throw e;
|
|
551
|
-
var r = this;
|
|
552
|
-
function handle(n, o) {
|
|
553
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
554
|
-
}
|
|
555
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
556
|
-
var i = this.tryEntries[o],
|
|
557
|
-
a = i.completion;
|
|
558
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
559
|
-
if (i.tryLoc <= this.prev) {
|
|
560
|
-
var c = n.call(i, "catchLoc"),
|
|
561
|
-
u = n.call(i, "finallyLoc");
|
|
562
|
-
if (c && u) {
|
|
563
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
564
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
565
|
-
} else if (c) {
|
|
566
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
567
|
-
} else {
|
|
568
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
569
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
},
|
|
574
|
-
abrupt: function (t, e) {
|
|
575
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
576
|
-
var o = this.tryEntries[r];
|
|
577
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
578
|
-
var i = o;
|
|
579
|
-
break;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
583
|
-
var a = i ? i.completion : {};
|
|
584
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
585
|
-
},
|
|
586
|
-
complete: function (t, e) {
|
|
587
|
-
if ("throw" === t.type) throw t.arg;
|
|
588
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
589
|
-
},
|
|
590
|
-
finish: function (t) {
|
|
591
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
592
|
-
var r = this.tryEntries[e];
|
|
593
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
594
|
-
}
|
|
595
|
-
},
|
|
596
|
-
catch: function (t) {
|
|
597
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
598
|
-
var r = this.tryEntries[e];
|
|
599
|
-
if (r.tryLoc === t) {
|
|
600
|
-
var n = r.completion;
|
|
601
|
-
if ("throw" === n.type) {
|
|
602
|
-
var o = n.arg;
|
|
603
|
-
resetTryEntry(r);
|
|
604
|
-
}
|
|
605
|
-
return o;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
throw Error("illegal catch attempt");
|
|
609
|
-
},
|
|
610
|
-
delegateYield: function (e, r, n) {
|
|
611
|
-
return this.delegate = {
|
|
612
|
-
iterator: values(e),
|
|
613
|
-
resultName: r,
|
|
614
|
-
nextLoc: n
|
|
615
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
616
|
-
}
|
|
617
|
-
}, e;
|
|
618
|
-
}
|
|
619
174
|
function _slicedToArray(r, e) {
|
|
620
175
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
621
176
|
}
|
|
622
|
-
function _toConsumableArray(r) {
|
|
623
|
-
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
624
|
-
}
|
|
625
177
|
function _toPrimitive(t, r) {
|
|
626
178
|
if ("object" != typeof t || !t) return t;
|
|
627
179
|
var e = t[Symbol.toPrimitive];
|
|
628
180
|
if (void 0 !== e) {
|
|
629
|
-
var i = e.call(t, r
|
|
181
|
+
var i = e.call(t, r);
|
|
630
182
|
if ("object" != typeof i) return i;
|
|
631
183
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
632
184
|
}
|
|
@@ -684,6 +236,23 @@ var findEventIndexInLanguage = function findEventIndexInLanguage(language, langu
|
|
|
684
236
|
return languageIndex;
|
|
685
237
|
};
|
|
686
238
|
|
|
239
|
+
/* *
|
|
240
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
241
|
+
* you may not use this file except in compliance with the License.
|
|
242
|
+
* You may obtain a copy of the License at
|
|
243
|
+
*
|
|
244
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
245
|
+
*
|
|
246
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
247
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
248
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
249
|
+
* See the License for the specific language governing permissions and
|
|
250
|
+
* limitations under the License.
|
|
251
|
+
*
|
|
252
|
+
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
253
|
+
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
254
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
255
|
+
* */
|
|
687
256
|
var CAP_NAMESPACE = 'cap';
|
|
688
257
|
var useCapTranslation = function useCapTranslation() {
|
|
689
258
|
return useTranslation(CAP_NAMESPACE);
|
|
@@ -713,7 +282,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
|
713
282
|
expires = _ref.expires;
|
|
714
283
|
var _useCapTranslation = useCapTranslation(),
|
|
715
284
|
t = _useCapTranslation.t;
|
|
716
|
-
return jsxs(
|
|
285
|
+
return jsxs(Grid, {
|
|
717
286
|
container: true,
|
|
718
287
|
sx: {
|
|
719
288
|
border: severityStyles[severity].border,
|
|
@@ -723,7 +292,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
|
723
292
|
marginBottom: '20px',
|
|
724
293
|
width: '100%'
|
|
725
294
|
},
|
|
726
|
-
children: [jsxs(
|
|
295
|
+
children: [jsxs(Grid, {
|
|
727
296
|
size: {
|
|
728
297
|
xs: 4
|
|
729
298
|
},
|
|
@@ -738,7 +307,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
|
738
307
|
"data-testid": "event",
|
|
739
308
|
children: event ? "".concat(event) : ''
|
|
740
309
|
})]
|
|
741
|
-
}), jsxs(
|
|
310
|
+
}), jsxs(Grid, {
|
|
742
311
|
size: {
|
|
743
312
|
xs: 4
|
|
744
313
|
},
|
|
@@ -753,7 +322,7 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
|
753
322
|
"data-testid": "severity",
|
|
754
323
|
children: severity ? "".concat(severity) : ''
|
|
755
324
|
})]
|
|
756
|
-
}), jsxs(
|
|
325
|
+
}), jsxs(Grid, {
|
|
757
326
|
size: {
|
|
758
327
|
xs: 4
|
|
759
328
|
},
|
|
@@ -774,15 +343,12 @@ var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
|
774
343
|
|
|
775
344
|
var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
|
|
776
345
|
var _alert$languages;
|
|
777
|
-
var
|
|
346
|
+
var alert = _ref.alert,
|
|
778
347
|
capWarningPresets = _ref.capWarningPresets;
|
|
779
348
|
var _React$useState = React.useState(0),
|
|
780
349
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
781
350
|
languageIndex = _React$useState2[0],
|
|
782
351
|
setLanguageIndex = _React$useState2[1];
|
|
783
|
-
var alert = useSelector(function (store) {
|
|
784
|
-
return getAlertById(store, alertId);
|
|
785
|
-
});
|
|
786
352
|
var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
|
|
787
353
|
var language = i18n.language;
|
|
788
354
|
React.useEffect(function () {
|
|
@@ -802,16 +368,24 @@ var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
|
|
|
802
368
|
|
|
803
369
|
var WarningListCap = function WarningListCap(_ref) {
|
|
804
370
|
var capWarningPresets = _ref.capWarningPresets,
|
|
805
|
-
|
|
371
|
+
alerts = _ref.alerts,
|
|
372
|
+
_ref$isPending = _ref.isPending,
|
|
373
|
+
isPending = _ref$isPending === void 0 ? false : _ref$isPending;
|
|
806
374
|
var _useCapTranslation = useCapTranslation(),
|
|
807
375
|
t = _useCapTranslation.t;
|
|
808
|
-
return
|
|
376
|
+
return jsxs(Box, {
|
|
809
377
|
sx: {
|
|
810
378
|
width: '100%',
|
|
811
379
|
height: '100%',
|
|
812
380
|
display: 'flex'
|
|
813
381
|
},
|
|
814
|
-
children:
|
|
382
|
+
children: [isPending && jsx(LinearProgress, {
|
|
383
|
+
color: "secondary",
|
|
384
|
+
sx: {
|
|
385
|
+
position: 'absolute',
|
|
386
|
+
width: '100%'
|
|
387
|
+
}
|
|
388
|
+
}), jsxs(Card, {
|
|
815
389
|
sx: {
|
|
816
390
|
justifyContent: 'center',
|
|
817
391
|
alignItems: 'center',
|
|
@@ -824,7 +398,10 @@ var WarningListCap = function WarningListCap(_ref) {
|
|
|
824
398
|
position: 'relative'
|
|
825
399
|
},
|
|
826
400
|
"data-testid": "warningList",
|
|
827
|
-
children: [
|
|
401
|
+
children: [!isPending && !alerts.length && jsx(AlertBanner, {
|
|
402
|
+
title: "No results",
|
|
403
|
+
severity: "warning"
|
|
404
|
+
}), alerts.length > 0 && jsx(Box, {
|
|
828
405
|
sx: {
|
|
829
406
|
position: 'sticky',
|
|
830
407
|
top: 0,
|
|
@@ -833,67 +410,16 @@ var WarningListCap = function WarningListCap(_ref) {
|
|
|
833
410
|
justifyContent: 'center'
|
|
834
411
|
},
|
|
835
412
|
children: jsx(AlertBanner, {
|
|
836
|
-
title: t('warning-list-cap-alert-banner-title')
|
|
413
|
+
title: t('warning-list-cap-alert-banner-title'),
|
|
414
|
+
severity: "info"
|
|
837
415
|
})
|
|
838
|
-
}),
|
|
839
|
-
sx: {
|
|
840
|
-
position: 'absolute',
|
|
841
|
-
left: '50%',
|
|
842
|
-
top: '20%',
|
|
843
|
-
zIndex: '100'
|
|
844
|
-
},
|
|
845
|
-
children: jsx(CircularProgress, {})
|
|
846
|
-
}) : null, alertIds.map(function (id) {
|
|
416
|
+
}), alerts.map(function (alert) {
|
|
847
417
|
return jsx(WarningListRowCapConnect, {
|
|
848
|
-
|
|
418
|
+
alert: alert,
|
|
849
419
|
capWarningPresets: capWarningPresets
|
|
850
|
-
},
|
|
420
|
+
}, alert.identifier);
|
|
851
421
|
})]
|
|
852
|
-
})
|
|
853
|
-
});
|
|
854
|
-
};
|
|
855
|
-
|
|
856
|
-
var WarningListCapConnect = function WarningListCapConnect(_ref) {
|
|
857
|
-
var capWarningPresets = _ref.capWarningPresets;
|
|
858
|
-
var alertIDs = useSelector(function (store) {
|
|
859
|
-
return getAlertIds(store);
|
|
860
|
-
});
|
|
861
|
-
return jsx(WarningListCap, {
|
|
862
|
-
capWarningPresets: capWarningPresets,
|
|
863
|
-
alertIds: alertIDs
|
|
864
|
-
});
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
|
|
868
|
-
var productConfigKey = _ref.productConfigKey;
|
|
869
|
-
var _useApiContext = useApiContext(),
|
|
870
|
-
api = _useApiContext.api;
|
|
871
|
-
var _useCapTranslation = useCapTranslation(),
|
|
872
|
-
t = _useCapTranslation.t;
|
|
873
|
-
var _useApi = useApi(api.getCapConfiguration, productConfigKey),
|
|
874
|
-
productConfig = _useApi.result,
|
|
875
|
-
isConfigLoading = _useApi.isLoading,
|
|
876
|
-
error = _useApi.error;
|
|
877
|
-
if (isConfigLoading) {
|
|
878
|
-
return jsx(Box$1, {
|
|
879
|
-
sx: {
|
|
880
|
-
display: 'flex',
|
|
881
|
-
justifyContent: 'center',
|
|
882
|
-
alignItems: 'center'
|
|
883
|
-
},
|
|
884
|
-
children: jsx(CircularProgress, {
|
|
885
|
-
"data-testid": "loadingSpinner"
|
|
886
|
-
})
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
if (error) {
|
|
890
|
-
return jsx(AlertBanner, {
|
|
891
|
-
title: t('warning-list-cap-error-title'),
|
|
892
|
-
info: error.message
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
return jsx(WarningListCapConnect, {
|
|
896
|
-
capWarningPresets: productConfig
|
|
422
|
+
})]
|
|
897
423
|
});
|
|
898
424
|
};
|
|
899
425
|
|
|
@@ -914,33 +440,44 @@ var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
|
|
|
914
440
|
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
915
441
|
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
916
442
|
* */
|
|
917
|
-
var
|
|
918
|
-
return {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
},
|
|
928
|
-
getSingleAlert: function getSingleAlert(alertUrl) {
|
|
929
|
-
return axiosInstance.get("/singlealert?url=".concat(alertUrl));
|
|
930
|
-
},
|
|
931
|
-
getLastUpdated: function getLastUpdated(thirdPartyApiUrl) {
|
|
932
|
-
return axiosInstance.get("/poll_feed?url=".concat(thirdPartyApiUrl));
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
};
|
|
936
|
-
var createApi = function createApi(props) {
|
|
937
|
-
var axiosInstance = createNonAuthApiInstance(props);
|
|
938
|
-
var nonAuthAxiosInstance = createNonAuthApiInstance({});
|
|
939
|
-
return getApiRoutes(axiosInstance, nonAuthAxiosInstance);
|
|
443
|
+
var addFeedAddressToCustomGeoJSonFeature = function addFeedAddressToCustomGeoJSonFeature(feedAddress, features) {
|
|
444
|
+
return features.reduce(function (list, feature) {
|
|
445
|
+
return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
|
|
446
|
+
properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
|
|
447
|
+
details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
|
|
448
|
+
feedAddress: feedAddress
|
|
449
|
+
})
|
|
450
|
+
})
|
|
451
|
+
}));
|
|
452
|
+
}, []);
|
|
940
453
|
};
|
|
941
454
|
|
|
942
|
-
var
|
|
943
|
-
|
|
455
|
+
var config = sessionStorageProvider.getConfig();
|
|
456
|
+
var capBaseUrl = config.GW_CAP_BASE_URL || '';
|
|
457
|
+
var getConfig = function getConfig(productConfigKey) {
|
|
458
|
+
return fetch("assets/".concat(encodeURIComponent(productConfigKey))).then(handleResponse);
|
|
459
|
+
};
|
|
460
|
+
var getFeedLinks = function getFeedLinks(feedAddress) {
|
|
461
|
+
return fetch("".concat(capBaseUrl, "/feedlinks?url=").concat(encodeURIComponent(feedAddress))).then(handleResponse).then(function (result) {
|
|
462
|
+
return result.map(function (link) {
|
|
463
|
+
return {
|
|
464
|
+
link: link,
|
|
465
|
+
feedAddress: feedAddress
|
|
466
|
+
};
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
var getSingleAlert = function getSingleAlert(alertUrl) {
|
|
471
|
+
return fetch("".concat(capBaseUrl, "/singlealert?url=").concat(encodeURIComponent(alertUrl.link))).then(handleResponse).then(function (result) {
|
|
472
|
+
var alert = _objectSpread2(_objectSpread2({}, result.alert), {}, {
|
|
473
|
+
feedAddress: alertUrl.feedAddress
|
|
474
|
+
});
|
|
475
|
+
var features = addFeedAddressToCustomGeoJSonFeature(alertUrl.feedAddress, result.features.features);
|
|
476
|
+
return {
|
|
477
|
+
alert: alert,
|
|
478
|
+
features: features
|
|
479
|
+
};
|
|
480
|
+
});
|
|
944
481
|
};
|
|
945
482
|
|
|
946
483
|
/* *
|
|
@@ -956,105 +493,126 @@ var mockLastUpdated = {
|
|
|
956
493
|
* See the License for the specific language governing permissions and
|
|
957
494
|
* limitations under the License.
|
|
958
495
|
*
|
|
959
|
-
* Copyright
|
|
960
|
-
* Copyright
|
|
961
|
-
* Copyright
|
|
496
|
+
* Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
497
|
+
* Copyright 2025 - Finnish Meteorological Institute (FMI)
|
|
498
|
+
* Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
|
|
962
499
|
* */
|
|
963
|
-
var
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
identifier: '2.49.0.1.246.0.0.2022',
|
|
969
|
-
feedAddress: 'https://alerts.fmi.fi/cap/feed/rss_en-GB.rss',
|
|
970
|
-
severity: 'Extreme',
|
|
971
|
-
certainty: 'Likely',
|
|
972
|
-
onset: '2022-07-07T00:00:00+03:00',
|
|
973
|
-
expires: '2022-07-07T23:53:10+03:00',
|
|
974
|
-
languages: [{
|
|
975
|
-
areaDesc: 'Uusimaa ja Kymenlaakso',
|
|
976
|
-
language: 'fi-FI',
|
|
977
|
-
event: 'Metsäpalovaroitus',
|
|
978
|
-
senderName: 'Ilmatieteen laitos',
|
|
979
|
-
headline: 'Oranssi metsäpalovaroitus: Uusimaa ja Kymenlaakso, to 0.00 - 23.53',
|
|
980
|
-
description: 'Metsäpalojen vaara on erittäin suuri keskiviikon ja torstain välisestä yöstä torstain ja perjantain väliseen yöhön 30 % todennäköisyydellä.'
|
|
981
|
-
}, {
|
|
982
|
-
areaDesc: 'Nyland och Kymmenedalen',
|
|
983
|
-
language: 'sv-FI',
|
|
984
|
-
event: 'Varning för skogsbrand',
|
|
985
|
-
senderName: 'Meteorologiska institutet',
|
|
986
|
-
headline: 'Orange varning för skogsbrand: Nyland och Kymmenedalen, to 0.00 - 23.53',
|
|
987
|
-
description: 'Risken för skogsbränder är mycket hög på från och med natten mellan onsdag och torsdag fram till natten mellan torsdag och fredag med 30 % sannolikhet.'
|
|
988
|
-
}, {
|
|
989
|
-
areaDesc: 'Uusimaa and Kymenlaakso',
|
|
990
|
-
language: 'en-GB',
|
|
991
|
-
event: 'Forest fire warning',
|
|
992
|
-
senderName: 'Finnish Meteorological Institute',
|
|
993
|
-
headline: 'Orange forest fire warning: Uusimaa and Kymenlaakso, Thu 0.00 - 23.53',
|
|
994
|
-
description: 'A risk of forest fires is very high on from the night between Wednesday and Thursday to the night between Thursday and Friday with probability of 30 %.'
|
|
995
|
-
}]
|
|
996
|
-
}
|
|
500
|
+
var useGetConfig = function useGetConfig(productConfigKey) {
|
|
501
|
+
return useQuery({
|
|
502
|
+
queryKey: ['cap-config', productConfigKey],
|
|
503
|
+
queryFn: function queryFn() {
|
|
504
|
+
return getConfig(productConfigKey);
|
|
997
505
|
}
|
|
998
|
-
}
|
|
999
|
-
feeds: {
|
|
1000
|
-
ids: [],
|
|
1001
|
-
entities: {}
|
|
1002
|
-
}
|
|
506
|
+
});
|
|
1003
507
|
};
|
|
1004
|
-
var
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
508
|
+
var useAllFeedLinks = function useAllFeedLinks(capPresets) {
|
|
509
|
+
var queries = useMemo(function () {
|
|
510
|
+
return capPresets.feeds.map(function (feed) {
|
|
511
|
+
return {
|
|
512
|
+
queryKey: ['feedLinks', feed.feedAddress],
|
|
513
|
+
queryFn: function queryFn() {
|
|
514
|
+
return getFeedLinks(feed.feedAddress);
|
|
515
|
+
},
|
|
516
|
+
refetchInterval: capPresets.pollInterval
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
}, [capPresets]);
|
|
520
|
+
var results = useQueries({
|
|
521
|
+
queries: queries,
|
|
522
|
+
combine: function combine(results) {
|
|
523
|
+
return {
|
|
524
|
+
results: results.flatMap(function (result) {
|
|
525
|
+
return result.data;
|
|
526
|
+
}).filter(function (result) {
|
|
527
|
+
return !!result;
|
|
528
|
+
}),
|
|
529
|
+
pending: results.some(function (result) {
|
|
530
|
+
return result.isPending;
|
|
531
|
+
})
|
|
532
|
+
};
|
|
1020
533
|
}
|
|
1021
|
-
}
|
|
534
|
+
});
|
|
535
|
+
return results;
|
|
536
|
+
};
|
|
537
|
+
var useAllFeedAlerts = function useAllFeedAlerts(capPresets) {
|
|
538
|
+
var _useAllFeedLinks = useAllFeedLinks(capPresets),
|
|
539
|
+
allFeeds = _useAllFeedLinks.results,
|
|
540
|
+
allFeedPending = _useAllFeedLinks.pending;
|
|
541
|
+
var queries = useMemo(function () {
|
|
542
|
+
return allFeeds.map(function (feed) {
|
|
543
|
+
return {
|
|
544
|
+
queryKey: ['feedAlert', feed],
|
|
545
|
+
queryFn: function queryFn() {
|
|
546
|
+
return getSingleAlert(feed);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
});
|
|
550
|
+
}, [allFeeds]);
|
|
551
|
+
var _useQueries = useQueries({
|
|
552
|
+
queries: queries,
|
|
553
|
+
combine: function combine(results) {
|
|
554
|
+
return {
|
|
555
|
+
alertResults: results.map(function (result) {
|
|
556
|
+
return result.data;
|
|
557
|
+
}).filter(function (result) {
|
|
558
|
+
return !!result;
|
|
559
|
+
}),
|
|
560
|
+
pending: results.some(function (result) {
|
|
561
|
+
return result.isPending;
|
|
562
|
+
})
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
}),
|
|
566
|
+
alertResults = _useQueries.alertResults,
|
|
567
|
+
alertsPending = _useQueries.pending;
|
|
568
|
+
return {
|
|
569
|
+
results: alertResults,
|
|
570
|
+
pending: allFeedPending || alertsPending
|
|
571
|
+
};
|
|
1022
572
|
};
|
|
1023
573
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
*
|
|
1037
|
-
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1038
|
-
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
1039
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
1040
|
-
* */
|
|
1041
|
-
var capReducersMap = {
|
|
1042
|
-
webmap: mapReducer,
|
|
1043
|
-
services: serviceReducer,
|
|
1044
|
-
layers: layerReducer,
|
|
1045
|
-
syncGroups: syncGroupsReducer,
|
|
1046
|
-
cap: capReducer
|
|
574
|
+
var WarningListCapConnect = function WarningListCapConnect(_ref) {
|
|
575
|
+
var capWarningPresets = _ref.capWarningPresets;
|
|
576
|
+
var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
|
|
577
|
+
feedAlerts = _useAllFeedAlerts.results,
|
|
578
|
+
pending = _useAllFeedAlerts.pending;
|
|
579
|
+
return jsx(WarningListCap, {
|
|
580
|
+
capWarningPresets: capWarningPresets,
|
|
581
|
+
alerts: feedAlerts.map(function (fa) {
|
|
582
|
+
return fa.alert;
|
|
583
|
+
}),
|
|
584
|
+
isPending: pending
|
|
585
|
+
});
|
|
1047
586
|
};
|
|
1048
|
-
|
|
1049
|
-
var
|
|
1050
|
-
var
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
587
|
+
|
|
588
|
+
var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
|
|
589
|
+
var productConfigKey = _ref.productConfigKey;
|
|
590
|
+
var _useCapTranslation = useCapTranslation(),
|
|
591
|
+
t = _useCapTranslation.t;
|
|
592
|
+
var _useGetConfig = useGetConfig(productConfigKey),
|
|
593
|
+
productConfig = _useGetConfig.data,
|
|
594
|
+
isPending = _useGetConfig.isPending,
|
|
595
|
+
error = _useGetConfig.error;
|
|
596
|
+
if (isPending) {
|
|
597
|
+
return jsx(Box$1, {
|
|
598
|
+
sx: {
|
|
599
|
+
display: 'flex',
|
|
600
|
+
justifyContent: 'center',
|
|
601
|
+
alignItems: 'center'
|
|
602
|
+
},
|
|
603
|
+
children: jsx(CircularProgress, {
|
|
604
|
+
"data-testid": "loadingSpinner"
|
|
605
|
+
})
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
if (error) {
|
|
609
|
+
return jsx(AlertBanner, {
|
|
610
|
+
title: t('warning-list-cap-error-title'),
|
|
611
|
+
info: error.message
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
return jsx(WarningListCapConnect, {
|
|
615
|
+
capWarningPresets: productConfig
|
|
1058
616
|
});
|
|
1059
617
|
};
|
|
1060
618
|
|
|
@@ -1145,45 +703,6 @@ var addColors = function addColors(features) {
|
|
|
1145
703
|
return features;
|
|
1146
704
|
};
|
|
1147
705
|
|
|
1148
|
-
/* *
|
|
1149
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1150
|
-
* you may not use this file except in compliance with the License.
|
|
1151
|
-
* You may obtain a copy of the License at
|
|
1152
|
-
*
|
|
1153
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1154
|
-
*
|
|
1155
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1156
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1157
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1158
|
-
* See the License for the specific language governing permissions and
|
|
1159
|
-
* limitations under the License.
|
|
1160
|
-
*
|
|
1161
|
-
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1162
|
-
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
1163
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
1164
|
-
* */
|
|
1165
|
-
var addFeedAdressToCustomGeoJSonFeature = function addFeedAdressToCustomGeoJSonFeature(feedAddress, features) {
|
|
1166
|
-
return features.reduce(function (list, feature) {
|
|
1167
|
-
return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
|
|
1168
|
-
properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
|
|
1169
|
-
details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
|
|
1170
|
-
feedAddress: feedAddress
|
|
1171
|
-
})
|
|
1172
|
-
})
|
|
1173
|
-
}));
|
|
1174
|
-
}, []);
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
1178
|
-
var isPromiseFulfilled = function isPromiseFulfilled(result) {
|
|
1179
|
-
return result.status === 'fulfilled';
|
|
1180
|
-
};
|
|
1181
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
1182
|
-
var promiseSuccesses = function promiseSuccesses(results) {
|
|
1183
|
-
return results.reduce(function (acc, result) {
|
|
1184
|
-
return isPromiseFulfilled(result) ? [].concat(_toConsumableArray(acc), [result.value]) : acc;
|
|
1185
|
-
}, []);
|
|
1186
|
-
};
|
|
1187
706
|
var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
1188
707
|
var id = _ref.id,
|
|
1189
708
|
title = _ref.title,
|
|
@@ -1192,239 +711,18 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
|
1192
711
|
capWarningPresets = _ref.capWarningPresets,
|
|
1193
712
|
layers = _ref.layers,
|
|
1194
713
|
children = _ref.children;
|
|
1195
|
-
var
|
|
1196
|
-
|
|
1197
|
-
var dispatch = useDispatch();
|
|
1198
|
-
var previousFeatures = React.useRef(null);
|
|
714
|
+
var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
|
|
715
|
+
feedAlertsResult = _useAllFeedAlerts.results;
|
|
1199
716
|
var _React$useState = React.useState({}),
|
|
1200
717
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1201
718
|
featuresByAlert = _React$useState2[0],
|
|
1202
719
|
setFeaturesByAlert = _React$useState2[1];
|
|
1203
|
-
var _React$useState3 = React.useState(
|
|
720
|
+
var _React$useState3 = React.useState(undefined),
|
|
1204
721
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
1205
722
|
selectedFeatureEvent = _React$useState4[0],
|
|
1206
723
|
setSelectedFeatureEvent = _React$useState4[1];
|
|
1207
724
|
var mapIdRef = React.useRef(id || webmapUtils.generateMapId());
|
|
1208
725
|
var layerIdRef = React.useRef(webmapUtils.generateLayerId());
|
|
1209
|
-
var currentLastUpdatedTimes = useSelector(function (store) {
|
|
1210
|
-
return getLastUpdatedTimes(store);
|
|
1211
|
-
});
|
|
1212
|
-
var fetchData = /*#__PURE__*/function () {
|
|
1213
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(links, feedAddress) {
|
|
1214
|
-
var alertsAndFeaturesPromises, alertsAndFeatures, realAlertsAndFeatures, alerts, featuresByAlert, combinedFeatures;
|
|
1215
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1216
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1217
|
-
case 0:
|
|
1218
|
-
alertsAndFeaturesPromises = links.map( /*#__PURE__*/function () {
|
|
1219
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(alertUrl) {
|
|
1220
|
-
var _yield$api$getSingleA, data, alert, features;
|
|
1221
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1222
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1223
|
-
case 0:
|
|
1224
|
-
_context.next = 2;
|
|
1225
|
-
return api.getSingleAlert(alertUrl);
|
|
1226
|
-
case 2:
|
|
1227
|
-
_yield$api$getSingleA = _context.sent;
|
|
1228
|
-
data = _yield$api$getSingleA.data;
|
|
1229
|
-
alert = _objectSpread2(_objectSpread2({}, data.alert), {}, {
|
|
1230
|
-
feedAddress: feedAddress
|
|
1231
|
-
});
|
|
1232
|
-
features = addFeedAdressToCustomGeoJSonFeature(feedAddress, data.features.features);
|
|
1233
|
-
return _context.abrupt("return", {
|
|
1234
|
-
alert: alert,
|
|
1235
|
-
features: features
|
|
1236
|
-
});
|
|
1237
|
-
case 7:
|
|
1238
|
-
case "end":
|
|
1239
|
-
return _context.stop();
|
|
1240
|
-
}
|
|
1241
|
-
}, _callee);
|
|
1242
|
-
}));
|
|
1243
|
-
return function (_x3) {
|
|
1244
|
-
return _ref3.apply(this, arguments);
|
|
1245
|
-
};
|
|
1246
|
-
}());
|
|
1247
|
-
_context2.next = 3;
|
|
1248
|
-
return Promise.allSettled(alertsAndFeaturesPromises);
|
|
1249
|
-
case 3:
|
|
1250
|
-
alertsAndFeatures = _context2.sent;
|
|
1251
|
-
realAlertsAndFeatures = alertsAndFeatures.reduce(function (alerts, result) {
|
|
1252
|
-
return (
|
|
1253
|
-
// endpoints may throttle requests and return empty alerts
|
|
1254
|
-
isPromiseFulfilled(result) && result.value.alert ? [].concat(_toConsumableArray(alerts), [result.value]) : alerts
|
|
1255
|
-
);
|
|
1256
|
-
}, []);
|
|
1257
|
-
alerts = realAlertsAndFeatures.map(function (_ref4) {
|
|
1258
|
-
var alert = _ref4.alert;
|
|
1259
|
-
return _objectSpread2({}, alert);
|
|
1260
|
-
});
|
|
1261
|
-
dispatch(capActions.addManyAlerts(alerts));
|
|
1262
|
-
dispatch(capActions.addManyAlertsToFeed({
|
|
1263
|
-
feedId: feedAddress,
|
|
1264
|
-
alertIds: alerts.map(function (alert) {
|
|
1265
|
-
return alert.identifier;
|
|
1266
|
-
})
|
|
1267
|
-
}));
|
|
1268
|
-
featuresByAlert = realAlertsAndFeatures.reduce(function (byId, _ref5) {
|
|
1269
|
-
var alert = _ref5.alert,
|
|
1270
|
-
features = _ref5.features;
|
|
1271
|
-
return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
|
|
1272
|
-
}, {});
|
|
1273
|
-
combinedFeatures = _objectSpread2(_objectSpread2({}, previousFeatures.current), featuresByAlert);
|
|
1274
|
-
setFeaturesByAlert(combinedFeatures);
|
|
1275
|
-
previousFeatures.current = combinedFeatures;
|
|
1276
|
-
case 12:
|
|
1277
|
-
case "end":
|
|
1278
|
-
return _context2.stop();
|
|
1279
|
-
}
|
|
1280
|
-
}, _callee2);
|
|
1281
|
-
}));
|
|
1282
|
-
return function fetchData(_x, _x2) {
|
|
1283
|
-
return _ref2.apply(this, arguments);
|
|
1284
|
-
};
|
|
1285
|
-
}();
|
|
1286
|
-
var fetchDataFromAllFeeds = /*#__PURE__*/function () {
|
|
1287
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
1288
|
-
var feedPromises, feedLinks;
|
|
1289
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1290
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1291
|
-
case 0:
|
|
1292
|
-
feedPromises = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.feeds.map( /*#__PURE__*/function () {
|
|
1293
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref7) {
|
|
1294
|
-
var feedAddress, _yield$api$getFeedLin, links;
|
|
1295
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1296
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
1297
|
-
case 0:
|
|
1298
|
-
feedAddress = _ref7.feedAddress;
|
|
1299
|
-
_context3.next = 3;
|
|
1300
|
-
return api.getFeedLinks(feedAddress);
|
|
1301
|
-
case 3:
|
|
1302
|
-
_yield$api$getFeedLin = _context3.sent;
|
|
1303
|
-
links = _yield$api$getFeedLin.data;
|
|
1304
|
-
return _context3.abrupt("return", {
|
|
1305
|
-
links: links,
|
|
1306
|
-
feedAddress: feedAddress
|
|
1307
|
-
});
|
|
1308
|
-
case 6:
|
|
1309
|
-
case "end":
|
|
1310
|
-
return _context3.stop();
|
|
1311
|
-
}
|
|
1312
|
-
}, _callee3);
|
|
1313
|
-
}));
|
|
1314
|
-
return function (_x4) {
|
|
1315
|
-
return _ref8.apply(this, arguments);
|
|
1316
|
-
};
|
|
1317
|
-
}());
|
|
1318
|
-
_context4.t0 = promiseSuccesses;
|
|
1319
|
-
_context4.next = 4;
|
|
1320
|
-
return Promise.allSettled(feedPromises);
|
|
1321
|
-
case 4:
|
|
1322
|
-
_context4.t1 = _context4.sent;
|
|
1323
|
-
feedLinks = (0, _context4.t0)(_context4.t1);
|
|
1324
|
-
feedLinks.forEach(function (_ref9) {
|
|
1325
|
-
var links = _ref9.links,
|
|
1326
|
-
feedAddress = _ref9.feedAddress;
|
|
1327
|
-
void fetchData(links, feedAddress);
|
|
1328
|
-
});
|
|
1329
|
-
case 7:
|
|
1330
|
-
case "end":
|
|
1331
|
-
return _context4.stop();
|
|
1332
|
-
}
|
|
1333
|
-
}, _callee4);
|
|
1334
|
-
}));
|
|
1335
|
-
return function fetchDataFromAllFeeds() {
|
|
1336
|
-
return _ref6.apply(this, arguments);
|
|
1337
|
-
};
|
|
1338
|
-
}();
|
|
1339
|
-
var pollAndUpdate = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1340
|
-
var lastUpdatedPromises, lastUpdateTimes;
|
|
1341
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1342
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1343
|
-
case 0:
|
|
1344
|
-
lastUpdatedPromises = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.feeds.map( /*#__PURE__*/function () {
|
|
1345
|
-
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(feed) {
|
|
1346
|
-
var _yield$api$getLastUpd, updated;
|
|
1347
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1348
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
1349
|
-
case 0:
|
|
1350
|
-
_context5.next = 2;
|
|
1351
|
-
return api.getLastUpdated(feed.feedAddress);
|
|
1352
|
-
case 2:
|
|
1353
|
-
_yield$api$getLastUpd = _context5.sent;
|
|
1354
|
-
updated = _yield$api$getLastUpd.data;
|
|
1355
|
-
return _context5.abrupt("return", {
|
|
1356
|
-
id: feed.feedAddress,
|
|
1357
|
-
changes: {
|
|
1358
|
-
lastUpdated: updated.lastUpdated
|
|
1359
|
-
}
|
|
1360
|
-
});
|
|
1361
|
-
case 5:
|
|
1362
|
-
case "end":
|
|
1363
|
-
return _context5.stop();
|
|
1364
|
-
}
|
|
1365
|
-
}, _callee5);
|
|
1366
|
-
}));
|
|
1367
|
-
return function (_x5) {
|
|
1368
|
-
return _ref11.apply(this, arguments);
|
|
1369
|
-
};
|
|
1370
|
-
}());
|
|
1371
|
-
if (!lastUpdatedPromises) {
|
|
1372
|
-
_context7.next = 9;
|
|
1373
|
-
break;
|
|
1374
|
-
}
|
|
1375
|
-
_context7.t0 = promiseSuccesses;
|
|
1376
|
-
_context7.next = 5;
|
|
1377
|
-
return Promise.allSettled(lastUpdatedPromises);
|
|
1378
|
-
case 5:
|
|
1379
|
-
_context7.t1 = _context7.sent;
|
|
1380
|
-
lastUpdateTimes = (0, _context7.t0)(_context7.t1);
|
|
1381
|
-
lastUpdateTimes.forEach( /*#__PURE__*/function () {
|
|
1382
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(feed, i) {
|
|
1383
|
-
var _yield$api$getFeedLin2, links;
|
|
1384
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1385
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
1386
|
-
case 0:
|
|
1387
|
-
if (!dateUtils.isAfter(feed.changes.lastUpdated, currentLastUpdatedTimes[i])) {
|
|
1388
|
-
_context6.next = 6;
|
|
1389
|
-
break;
|
|
1390
|
-
}
|
|
1391
|
-
_context6.next = 3;
|
|
1392
|
-
return api.getFeedLinks(feed.id);
|
|
1393
|
-
case 3:
|
|
1394
|
-
_yield$api$getFeedLin2 = _context6.sent;
|
|
1395
|
-
links = _yield$api$getFeedLin2.data;
|
|
1396
|
-
void fetchData(links, feed.id);
|
|
1397
|
-
case 6:
|
|
1398
|
-
case "end":
|
|
1399
|
-
return _context6.stop();
|
|
1400
|
-
}
|
|
1401
|
-
}, _callee6);
|
|
1402
|
-
}));
|
|
1403
|
-
return function (_x6, _x7) {
|
|
1404
|
-
return _ref12.apply(this, arguments);
|
|
1405
|
-
};
|
|
1406
|
-
}());
|
|
1407
|
-
dispatch(capActions.setFeedLastUpdatedTimes(lastUpdateTimes));
|
|
1408
|
-
case 9:
|
|
1409
|
-
case "end":
|
|
1410
|
-
return _context7.stop();
|
|
1411
|
-
}
|
|
1412
|
-
}, _callee7);
|
|
1413
|
-
})), [currentLastUpdatedTimes]);
|
|
1414
|
-
React.useEffect(function () {
|
|
1415
|
-
void fetchDataFromAllFeeds();
|
|
1416
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1417
|
-
}, []);
|
|
1418
|
-
React.useEffect(function () {
|
|
1419
|
-
var _capWarningPresets$po;
|
|
1420
|
-
var pollInterval = (_capWarningPresets$po = capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.pollInterval) !== null && _capWarningPresets$po !== void 0 ? _capWarningPresets$po : 300000;
|
|
1421
|
-
var timer = setInterval(function () {
|
|
1422
|
-
void pollAndUpdate();
|
|
1423
|
-
}, pollInterval);
|
|
1424
|
-
return function () {
|
|
1425
|
-
clearInterval(timer);
|
|
1426
|
-
};
|
|
1427
|
-
}, [capWarningPresets === null || capWarningPresets === void 0 ? void 0 : capWarningPresets.pollInterval, currentLastUpdatedTimes, pollAndUpdate]);
|
|
1428
726
|
var parentSizeRef = React.useRef(null);
|
|
1429
727
|
var _React$useState5 = React.useState(window.innerWidth / 2),
|
|
1430
728
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
@@ -1440,15 +738,34 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
|
1440
738
|
};
|
|
1441
739
|
}, []);
|
|
1442
740
|
var highLightGeoJsonOnClick = function highLightGeoJsonOnClick(featureResults) {
|
|
1443
|
-
var nextState = highlightGeoJson(featuresByAlert, featureResults);
|
|
1444
741
|
setSelectedFeatureEvent(featureResults);
|
|
1445
|
-
setFeaturesByAlert(
|
|
742
|
+
setFeaturesByAlert(function (previous) {
|
|
743
|
+
return highlightGeoJson(previous, featureResults);
|
|
744
|
+
});
|
|
1446
745
|
};
|
|
746
|
+
var selectedTime = useSelector(function (store) {
|
|
747
|
+
return mapSelectors.getSelectedTime(store, mapIdRef.current);
|
|
748
|
+
});
|
|
749
|
+
var selectedDate = useMemo(function () {
|
|
750
|
+
return dateUtils.createDate(dateUtils.fromUnix(selectedTime).toISOString());
|
|
751
|
+
}, [selectedTime]);
|
|
752
|
+
var alertsInEffect = useMemo(function () {
|
|
753
|
+
return feedAlertsResult.filter(function (alert) {
|
|
754
|
+
return dateUtils.isBetween(selectedDate, dateUtils.createDate(alert.alert.onset), dateUtils.createDate(alert.alert.expires), '[)');
|
|
755
|
+
});
|
|
756
|
+
}, [feedAlertsResult, selectedDate]);
|
|
757
|
+
var alertIdsInEffect = useMemo(function () {
|
|
758
|
+
return alertsInEffect.map(function (_ref2) {
|
|
759
|
+
var alert = _ref2.alert;
|
|
760
|
+
return alert.identifier;
|
|
761
|
+
});
|
|
762
|
+
}, [alertsInEffect]);
|
|
763
|
+
var previousAlertIdsInEffect = usePrevious(alertIdsInEffect);
|
|
1447
764
|
var clickOnFeature = useMemo(function () {
|
|
1448
765
|
return {
|
|
1449
|
-
onClick: function onClick(
|
|
1450
|
-
var featureResults =
|
|
1451
|
-
feature: new GeoJSON().writeFeatureObject(
|
|
766
|
+
onClick: function onClick(feature) {
|
|
767
|
+
var featureResults = feature.length === 0 ? undefined : {
|
|
768
|
+
feature: new GeoJSON().writeFeatureObject(feature[0]),
|
|
1452
769
|
coordinateIndexInFeature: null,
|
|
1453
770
|
featureIndex: null,
|
|
1454
771
|
screenCoords: null,
|
|
@@ -1463,17 +780,17 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
|
1463
780
|
}
|
|
1464
781
|
};
|
|
1465
782
|
}, []);
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
783
|
+
React.useEffect(function () {
|
|
784
|
+
if (JSON.stringify(alertIdsInEffect) !== JSON.stringify(previousAlertIdsInEffect)) {
|
|
785
|
+
var _featuresByAlert = alertsInEffect.reduce(function (byId, _ref3) {
|
|
786
|
+
var alert = _ref3.alert,
|
|
787
|
+
features = _ref3.features;
|
|
788
|
+
return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
|
|
789
|
+
}, {});
|
|
790
|
+
setFeaturesByAlert(_featuresByAlert);
|
|
791
|
+
}
|
|
792
|
+
}, [alertIdsInEffect, alertsInEffect, previousAlertIdsInEffect]);
|
|
1472
793
|
var geoJsonObject = useMemo(function () {
|
|
1473
|
-
var alertIdsInEffect = alertsInEffect.map(function (_ref13) {
|
|
1474
|
-
var identifier = _ref13.identifier;
|
|
1475
|
-
return identifier;
|
|
1476
|
-
});
|
|
1477
794
|
var featuresInEffect = Object.keys(featuresByAlert).filter(function (id) {
|
|
1478
795
|
return alertIdsInEffect.includes(id);
|
|
1479
796
|
}).flatMap(function (id) {
|
|
@@ -1483,7 +800,8 @@ var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
|
1483
800
|
type: 'FeatureCollection',
|
|
1484
801
|
features: featuresInEffect
|
|
1485
802
|
};
|
|
1486
|
-
|
|
803
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
804
|
+
}, [featuresByAlert]);
|
|
1487
805
|
var useOl = isOpenLayersEnabled();
|
|
1488
806
|
return jsx("div", {
|
|
1489
807
|
"data-testid": "mapViewCap",
|
|
@@ -1527,15 +845,13 @@ var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
|
|
|
1527
845
|
srs = _ref.srs,
|
|
1528
846
|
productConfigKey = _ref.productConfigKey,
|
|
1529
847
|
layers = _ref.layers;
|
|
1530
|
-
var _useApiContext = useApiContext(),
|
|
1531
|
-
api = _useApiContext.api;
|
|
1532
848
|
var _useCapTranslation = useCapTranslation(),
|
|
1533
849
|
t = _useCapTranslation.t;
|
|
1534
|
-
var
|
|
1535
|
-
capWarningPresets =
|
|
1536
|
-
|
|
1537
|
-
error =
|
|
1538
|
-
if (
|
|
850
|
+
var _useGetConfig = useGetConfig(productConfigKey),
|
|
851
|
+
capWarningPresets = _useGetConfig.data,
|
|
852
|
+
isPending = _useGetConfig.isPending,
|
|
853
|
+
error = _useGetConfig.error;
|
|
854
|
+
if (isPending) {
|
|
1539
855
|
return jsx(Box$1, {
|
|
1540
856
|
sx: {
|
|
1541
857
|
display: 'flex',
|
|
@@ -1572,38 +888,23 @@ var ComponentsLookUp = function ComponentsLookUp(_ref) {
|
|
|
1572
888
|
var componentType = _ref.componentType,
|
|
1573
889
|
initialProps = _ref.initialProps,
|
|
1574
890
|
productConfigKey = _ref.productConfigKey,
|
|
1575
|
-
config = _ref.config,
|
|
1576
891
|
id = _ref.id;
|
|
1577
|
-
// TODO: implement polling when backend is ready
|
|
1578
|
-
// NOTE: Fetching data inside this component might not work, as using React Hooks causes Invalid Hook Call -errors in tests.
|
|
1579
892
|
switch (componentType) {
|
|
1580
893
|
case 'CapWarningMap':
|
|
1581
894
|
{
|
|
1582
895
|
var _initialProps$mapPres, _initialProps$mapPres2;
|
|
1583
|
-
return jsx(
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
id: id,
|
|
1590
|
-
bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
|
|
1591
|
-
srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs,
|
|
1592
|
-
layers: initialProps.mapPreset.layers,
|
|
1593
|
-
productConfigKey: productConfigKey
|
|
1594
|
-
})
|
|
896
|
+
return jsx(MapViewCapConnectWrapper, {
|
|
897
|
+
id: id,
|
|
898
|
+
bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
|
|
899
|
+
srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs,
|
|
900
|
+
layers: initialProps.mapPreset.layers,
|
|
901
|
+
productConfigKey: productConfigKey
|
|
1595
902
|
});
|
|
1596
903
|
}
|
|
1597
904
|
case 'CapWarningList':
|
|
1598
905
|
{
|
|
1599
|
-
return jsx(
|
|
1600
|
-
|
|
1601
|
-
baseURL: config.baseURL
|
|
1602
|
-
},
|
|
1603
|
-
createApi: createApi,
|
|
1604
|
-
children: jsx(WarningListCapConnectWrapper, {
|
|
1605
|
-
productConfigKey: productConfigKey
|
|
1606
|
-
})
|
|
906
|
+
return jsx(WarningListCapConnectWrapper, {
|
|
907
|
+
productConfigKey: productConfigKey
|
|
1607
908
|
});
|
|
1608
909
|
}
|
|
1609
910
|
default:
|
|
@@ -1611,4 +912,41 @@ var ComponentsLookUp = function ComponentsLookUp(_ref) {
|
|
|
1611
912
|
}
|
|
1612
913
|
};
|
|
1613
914
|
|
|
1614
|
-
|
|
915
|
+
/* *
|
|
916
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
917
|
+
* you may not use this file except in compliance with the License.
|
|
918
|
+
* You may obtain a copy of the License at
|
|
919
|
+
*
|
|
920
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
921
|
+
*
|
|
922
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
923
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
924
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
925
|
+
* See the License for the specific language governing permissions and
|
|
926
|
+
* limitations under the License.
|
|
927
|
+
*
|
|
928
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
929
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
930
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
931
|
+
* */
|
|
932
|
+
var capReducersMap = {
|
|
933
|
+
webmap: mapReducer,
|
|
934
|
+
services: serviceReducer,
|
|
935
|
+
layers: layerReducer,
|
|
936
|
+
syncGroups: syncGroupsReducer
|
|
937
|
+
};
|
|
938
|
+
var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
|
|
939
|
+
var capRootReducer = combineReducers(capReducersMap);
|
|
940
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
941
|
+
var createMockStore = function createMockStore(mockState) {
|
|
942
|
+
return configureStore({
|
|
943
|
+
reducer: capRootReducer,
|
|
944
|
+
preloadedState: mockState,
|
|
945
|
+
middleware: function middleware(getDefaultMiddleware) {
|
|
946
|
+
return getDefaultMiddleware().concat(capMiddlewares);
|
|
947
|
+
},
|
|
948
|
+
devTools: true
|
|
949
|
+
});
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
export { CAP_NAMESPACE, ComponentsLookUp, capTrans as capTranslations, createMockStore };
|