@opengeoweb/cap 17.0.0 → 17.1.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 DELETED
@@ -1,1389 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { CircularProgress, Grid, Typography, Box as Box$1, LinearProgress, Card } from '@mui/material';
3
- import { Box } from '@mui/system';
4
- import { sessionStorageProvider, dateUtils, usePrevious, AlertBanner } from '@opengeoweb/shared';
5
- import i18n from 'i18next';
6
- import { GeoJSON } from 'ol/format';
7
- import { useSelector } from 'react-redux';
8
- import { ConfigurableMapConnect } from '@opengeoweb/core';
9
- import { mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer } from '@opengeoweb/store';
10
- import { webmapUtils } from '@opengeoweb/webmap';
11
- import { OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapWarningProperties } from '@opengeoweb/webmap-react';
12
- import { useQuery, useQueries } from '@tanstack/react-query';
13
- import { handleResponse } from '@opengeoweb/api';
14
- import { jsx, jsxs } from 'react/jsx-runtime';
15
- import { useTranslation } from 'react-i18next';
16
- import '@opengeoweb/time-slider';
17
- import { combineReducers, configureStore } from '@reduxjs/toolkit';
18
-
19
- var en = {
20
- "map-view-cap-error-title": "Something went wrong with loading the configuration file",
21
- "warning-list-cap-alert-banner-title": "Note: Only map is affected by timeslider based filtering",
22
- "warning-list-cap-error-title": "Something went wrong with loading the configuration file",
23
- "warning-list-row-event": "Event",
24
- "warning-list-row-severity": "Severity",
25
- "warning-list-row-expires": "Expires",
26
- "warning-list-row-not-expired": "(not expired)"
27
- };
28
- var fi = {
29
- "map-view-cap-error-title": "Jotain meni pieleen asetustiedostoa ladattaessa",
30
- "warning-list-cap-alert-banner-title": "🚧 ei käännetty",
31
- "warning-list-cap-error-title": "🚧 ei käännetty",
32
- "warning-list-row-event": "🚧 ei käännetty",
33
- "warning-list-row-severity": "🚧 ei käännetty",
34
- "warning-list-row-expires": "🚧 ei käännetty",
35
- "warning-list-row-not-expired": "🚧 ei käännetty"
36
- };
37
- var no = {
38
- "map-view-cap-error-title": "Noe gikk galt med innlesing av konfigurasjonsfilen",
39
- "warning-list-cap-alert-banner-title": "NB: Bare kartet er påvirket av timeslider basert filtrering",
40
- "warning-list-cap-error-title": "Noe gikk galt med innlesing av konfigurasjonsfilen",
41
- "warning-list-row-event": "Event",
42
- "warning-list-row-severity": "Viktighet",
43
- "warning-list-row-expires": "Utløpt",
44
- "warning-list-row-not-expired": "(ikke utløpt)"
45
- };
46
- var nl = {
47
- "map-view-cap-error-title": "Er ging iets mis met het laden van het configuratie bestand",
48
- "warning-list-cap-alert-banner-title": "Let op: Alleen de kaart wordt beïnvloed door filteren op basis van timeslider",
49
- "warning-list-cap-error-title": "Er ging iets mis met het laden van het configuratie bestand",
50
- "warning-list-row-event": "Event",
51
- "warning-list-row-severity": "Hevigheid",
52
- "warning-list-row-expires": "Verloopt",
53
- "warning-list-row-not-expired": "(niet verlopen)"
54
- };
55
- var capTrans = {
56
- en: en,
57
- fi: fi,
58
- no: no,
59
- nl: nl
60
- };
61
-
62
- function _OverloadYield(e, d) {
63
- this.v = e, this.k = d;
64
- }
65
- function _arrayLikeToArray(r, a) {
66
- (null == a || a > r.length) && (a = r.length);
67
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
68
- return n;
69
- }
70
- function _arrayWithHoles(r) {
71
- if (Array.isArray(r)) return r;
72
- }
73
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
74
- try {
75
- var i = n[a](c),
76
- u = i.value;
77
- } catch (n) {
78
- return void e(n);
79
- }
80
- i.done ? t(u) : Promise.resolve(u).then(r, o);
81
- }
82
- function _asyncToGenerator(n) {
83
- return function () {
84
- var t = this,
85
- e = arguments;
86
- return new Promise(function (r, o) {
87
- var a = n.apply(t, e);
88
- function _next(n) {
89
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
90
- }
91
- function _throw(n) {
92
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
93
- }
94
- _next(void 0);
95
- });
96
- };
97
- }
98
- function _createForOfIteratorHelper(r, e) {
99
- var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
100
- if (!t) {
101
- if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
102
- t && (r = t);
103
- var n = 0,
104
- F = function () {};
105
- return {
106
- s: F,
107
- n: function () {
108
- return n >= r.length ? {
109
- done: true
110
- } : {
111
- done: false,
112
- value: r[n++]
113
- };
114
- },
115
- e: function (r) {
116
- throw r;
117
- },
118
- f: F
119
- };
120
- }
121
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
122
- }
123
- var o,
124
- a = true,
125
- u = false;
126
- return {
127
- s: function () {
128
- t = t.call(r);
129
- },
130
- n: function () {
131
- var r = t.next();
132
- return a = r.done, r;
133
- },
134
- e: function (r) {
135
- u = true, o = r;
136
- },
137
- f: function () {
138
- try {
139
- a || null == t.return || t.return();
140
- } finally {
141
- if (u) throw o;
142
- }
143
- }
144
- };
145
- }
146
- function _defineProperty(e, r, t) {
147
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
148
- value: t,
149
- enumerable: true,
150
- configurable: true,
151
- writable: true
152
- }) : e[r] = t, e;
153
- }
154
- function _iterableToArrayLimit(r, l) {
155
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
156
- if (null != t) {
157
- var e,
158
- n,
159
- i,
160
- u,
161
- a = [],
162
- f = true,
163
- o = false;
164
- try {
165
- 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);
166
- } catch (r) {
167
- o = true, n = r;
168
- } finally {
169
- try {
170
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
171
- } finally {
172
- if (o) throw n;
173
- }
174
- }
175
- return a;
176
- }
177
- }
178
- function _nonIterableRest() {
179
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
180
- }
181
- function ownKeys(e, r) {
182
- var t = Object.keys(e);
183
- if (Object.getOwnPropertySymbols) {
184
- var o = Object.getOwnPropertySymbols(e);
185
- r && (o = o.filter(function (r) {
186
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
187
- })), t.push.apply(t, o);
188
- }
189
- return t;
190
- }
191
- function _objectSpread2(e) {
192
- for (var r = 1; r < arguments.length; r++) {
193
- var t = null != arguments[r] ? arguments[r] : {};
194
- r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
195
- _defineProperty(e, r, t[r]);
196
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
197
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
198
- });
199
- }
200
- return e;
201
- }
202
- function _regenerator() {
203
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
204
- var e,
205
- t,
206
- r = "function" == typeof Symbol ? Symbol : {},
207
- n = r.iterator || "@@iterator",
208
- o = r.toStringTag || "@@toStringTag";
209
- function i(r, n, o, i) {
210
- var c = n && n.prototype instanceof Generator ? n : Generator,
211
- u = Object.create(c.prototype);
212
- return _regeneratorDefine(u, "_invoke", function (r, n, o) {
213
- var i,
214
- c,
215
- u,
216
- f = 0,
217
- p = o || [],
218
- y = false,
219
- G = {
220
- p: 0,
221
- n: 0,
222
- v: e,
223
- a: d,
224
- f: d.bind(e, 4),
225
- d: function (t, r) {
226
- return i = t, c = 0, u = e, G.n = r, a;
227
- }
228
- };
229
- function d(r, n) {
230
- for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
231
- var o,
232
- i = p[t],
233
- d = G.p,
234
- l = i[2];
235
- r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
236
- }
237
- if (o || r > 1) return a;
238
- throw y = true, n;
239
- }
240
- return function (o, p, l) {
241
- if (f > 1) throw TypeError("Generator is already running");
242
- for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
243
- i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
244
- try {
245
- if (f = 2, i) {
246
- if (c || (o = "next"), t = i[o]) {
247
- if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
248
- if (!t.done) return t;
249
- u = t.value, c < 2 && (c = 0);
250
- } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
251
- i = e;
252
- } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
253
- } catch (t) {
254
- i = e, c = 1, u = t;
255
- } finally {
256
- f = 1;
257
- }
258
- }
259
- return {
260
- value: t,
261
- done: y
262
- };
263
- };
264
- }(r, o, i), true), u;
265
- }
266
- var a = {};
267
- function Generator() {}
268
- function GeneratorFunction() {}
269
- function GeneratorFunctionPrototype() {}
270
- t = Object.getPrototypeOf;
271
- var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
272
- return this;
273
- }), t),
274
- u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
275
- function f(e) {
276
- return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
277
- }
278
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
279
- return this;
280
- }), _regeneratorDefine(u, "toString", function () {
281
- return "[object Generator]";
282
- }), (_regenerator = function () {
283
- return {
284
- w: i,
285
- m: f
286
- };
287
- })();
288
- }
289
- function _regeneratorAsync(n, e, r, t, o) {
290
- var a = _regeneratorAsyncGen(n, e, r, t, o);
291
- return a.next().then(function (n) {
292
- return n.done ? n.value : a.next();
293
- });
294
- }
295
- function _regeneratorAsyncGen(r, e, t, o, n) {
296
- return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise);
297
- }
298
- function _regeneratorAsyncIterator(t, e) {
299
- function n(r, o, i, f) {
300
- try {
301
- var c = t[r](o),
302
- u = c.value;
303
- return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) {
304
- n("next", t, i, f);
305
- }, function (t) {
306
- n("throw", t, i, f);
307
- }) : e.resolve(u).then(function (t) {
308
- c.value = t, i(c);
309
- }, function (t) {
310
- return n("throw", t, i, f);
311
- });
312
- } catch (t) {
313
- f(t);
314
- }
315
- }
316
- var r;
317
- this.next || (_regeneratorDefine(_regeneratorAsyncIterator.prototype), _regeneratorDefine(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () {
318
- return this;
319
- })), _regeneratorDefine(this, "_invoke", function (t, o, i) {
320
- function f() {
321
- return new e(function (e, r) {
322
- n(t, i, e, r);
323
- });
324
- }
325
- return r = r ? r.then(f, f) : f();
326
- }, true);
327
- }
328
- function _regeneratorDefine(e, r, n, t) {
329
- var i = Object.defineProperty;
330
- try {
331
- i({}, "", {});
332
- } catch (e) {
333
- i = 0;
334
- }
335
- _regeneratorDefine = function (e, r, n, t) {
336
- if (r) i ? i(e, r, {
337
- value: n,
338
- enumerable: !t,
339
- configurable: !t,
340
- writable: !t
341
- }) : e[r] = n;else {
342
- function o(r, n) {
343
- _regeneratorDefine(e, r, function (e) {
344
- return this._invoke(r, n, e);
345
- });
346
- }
347
- o("next", 0), o("throw", 1), o("return", 2);
348
- }
349
- }, _regeneratorDefine(e, r, n, t);
350
- }
351
- function _regeneratorKeys(e) {
352
- var n = Object(e),
353
- r = [];
354
- for (var t in n) r.unshift(t);
355
- return function e() {
356
- for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = false, e;
357
- return e.done = true, e;
358
- };
359
- }
360
- function _regeneratorValues(e) {
361
- if (null != e) {
362
- var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
363
- r = 0;
364
- if (t) return t.call(e);
365
- if ("function" == typeof e.next) return e;
366
- if (!isNaN(e.length)) return {
367
- next: function () {
368
- return e && r >= e.length && (e = void 0), {
369
- value: e && e[r++],
370
- done: !e
371
- };
372
- }
373
- };
374
- }
375
- throw new TypeError(typeof e + " is not iterable");
376
- }
377
- function _slicedToArray(r, e) {
378
- return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
379
- }
380
- function _toPrimitive(t, r) {
381
- if ("object" != typeof t || !t) return t;
382
- var e = t[Symbol.toPrimitive];
383
- if (void 0 !== e) {
384
- var i = e.call(t, r);
385
- if ("object" != typeof i) return i;
386
- throw new TypeError("@@toPrimitive must return a primitive value.");
387
- }
388
- return ("string" === r ? String : Number)(t);
389
- }
390
- function _toPropertyKey(t) {
391
- var i = _toPrimitive(t, "string");
392
- return "symbol" == typeof i ? i : i + "";
393
- }
394
- function _unsupportedIterableToArray(r, a) {
395
- if (r) {
396
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
397
- var t = {}.toString.call(r).slice(8, -1);
398
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
399
- }
400
- }
401
- function _regeneratorRuntime() {
402
-
403
- var r = _regenerator(),
404
- e = r.m(_regeneratorRuntime),
405
- t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
406
- function n(r) {
407
- var e = "function" == typeof r && r.constructor;
408
- return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
409
- }
410
- var o = {
411
- throw: 1,
412
- return: 2,
413
- break: 3,
414
- continue: 3
415
- };
416
- function a(r) {
417
- var e, t;
418
- return function (n) {
419
- e || (e = {
420
- stop: function () {
421
- return t(n.a, 2);
422
- },
423
- catch: function () {
424
- return n.v;
425
- },
426
- abrupt: function (r, e) {
427
- return t(n.a, o[r], e);
428
- },
429
- delegateYield: function (r, o, a) {
430
- return e.resultName = o, t(n.d, _regeneratorValues(r), a);
431
- },
432
- finish: function (r) {
433
- return t(n.f, r);
434
- }
435
- }, t = function (r, t, o) {
436
- n.p = e.prev, n.n = e.next;
437
- try {
438
- return r(t, o);
439
- } finally {
440
- e.next = n.n;
441
- }
442
- }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
443
- try {
444
- return r.call(this, e);
445
- } finally {
446
- n.p = e.prev, n.n = e.next;
447
- }
448
- };
449
- }
450
- return (_regeneratorRuntime = function () {
451
- return {
452
- wrap: function (e, t, n, o) {
453
- return r.w(a(e), t, n, o && o.reverse());
454
- },
455
- isGeneratorFunction: n,
456
- mark: r.m,
457
- awrap: function (r, e) {
458
- return new _OverloadYield(r, e);
459
- },
460
- AsyncIterator: _regeneratorAsyncIterator,
461
- async: function (r, e, t, o, u) {
462
- return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u);
463
- },
464
- keys: _regeneratorKeys,
465
- values: _regeneratorValues
466
- };
467
- })();
468
- }
469
-
470
- /* *
471
- * Licensed under the Apache License, Version 2.0 (the "License");
472
- * you may not use this file except in compliance with the License.
473
- * You may obtain a copy of the License at
474
- *
475
- * http://www.apache.org/licenses/LICENSE-2.0
476
- *
477
- * Unless required by applicable law or agreed to in writing, software
478
- * distributed under the License is distributed on an "AS IS" BASIS,
479
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480
- * See the License for the specific language governing permissions and
481
- * limitations under the License.
482
- *
483
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
484
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
485
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
486
- * */
487
-
488
- var addColors = function addColors(features) {
489
- var severityStyles = {
490
- Extreme: {
491
- stroke: 'rgb(255, 9, 9)',
492
- fill: 'rgba(255, 9, 9, 0.10)'
493
- },
494
- Severe: {
495
- stroke: 'rgb(255, 165, 0)',
496
- fill: 'rgba(255, 165, 0, 0.10)'
497
- },
498
- Moderate: {
499
- stroke: 'rgb(248, 248, 0)',
500
- fill: 'rgba(248, 248, 0, 0.10)'
501
- },
502
- Minor: {
503
- stroke: 'rgb(106, 248, 108)',
504
- fill: 'rgba(106, 248, 108, 0.10)'
505
- }
506
- };
507
- var _iterator = _createForOfIteratorHelper(features),
508
- _step;
509
- try {
510
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
511
- var feature = _step.value;
512
- var severity = feature.properties.details.severity;
513
- feature.properties.stroke = severityStyles[severity].stroke;
514
- feature.properties.fill = severityStyles[severity].fill;
515
- feature.properties['stroke-opacity'] = 1;
516
- feature.properties['stroke-width'] = 2;
517
- }
518
- } catch (err) {
519
- _iterator.e(err);
520
- } finally {
521
- _iterator.f();
522
- }
523
- return features;
524
- };
525
-
526
- /* *
527
- * Licensed under the Apache License, Version 2.0 (the "License");
528
- * you may not use this file except in compliance with the License.
529
- * You may obtain a copy of the License at
530
- *
531
- * http://www.apache.org/licenses/LICENSE-2.0
532
- *
533
- * Unless required by applicable law or agreed to in writing, software
534
- * distributed under the License is distributed on an "AS IS" BASIS,
535
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
536
- * See the License for the specific language governing permissions and
537
- * limitations under the License.
538
- *
539
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
540
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
541
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
542
- * */
543
-
544
- var addFeedAddressToCustomGeoJSonFeature = function addFeedAddressToCustomGeoJSonFeature(feedAddress, features) {
545
- return features.reduce(function (list, feature) {
546
- return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
547
- properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
548
- details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
549
- feedAddress: feedAddress
550
- })
551
- })
552
- }));
553
- }, []);
554
- };
555
-
556
- var _config$GW_CAP_BASE_U;
557
- var config = sessionStorageProvider.getConfig();
558
- var capBaseUrl = (_config$GW_CAP_BASE_U = config.GW_CAP_BASE_URL) !== null && _config$GW_CAP_BASE_U !== void 0 ? _config$GW_CAP_BASE_U : '';
559
- var getConfig = /*#__PURE__*/function () {
560
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(productConfigKey) {
561
- return _regeneratorRuntime().wrap(function _callee$(_context) {
562
- while (1) switch (_context.prev = _context.next) {
563
- case 0:
564
- return _context.abrupt("return",
565
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
566
- fetch("assets/".concat(encodeURIComponent(productConfigKey))).then(handleResponse));
567
- case 1:
568
- case "end":
569
- return _context.stop();
570
- }
571
- }, _callee);
572
- }));
573
- return function getConfig(_x) {
574
- return _ref.apply(this, arguments);
575
- };
576
- }();
577
- var getFeedLinks = /*#__PURE__*/function () {
578
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(feedAddress) {
579
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
580
- while (1) switch (_context2.prev = _context2.next) {
581
- case 0:
582
- return _context2.abrupt("return", fetch("".concat(capBaseUrl, "/feedlinks?url=").concat(encodeURIComponent(feedAddress))).then(handleResponse).then(function (result) {
583
- return result.map(function (link) {
584
- return {
585
- link: link,
586
- feedAddress: feedAddress
587
- };
588
- });
589
- }));
590
- case 1:
591
- case "end":
592
- return _context2.stop();
593
- }
594
- }, _callee2);
595
- }));
596
- return function getFeedLinks(_x2) {
597
- return _ref2.apply(this, arguments);
598
- };
599
- }();
600
- var getSingleAlert = /*#__PURE__*/function () {
601
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(alertUrl) {
602
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
603
- while (1) switch (_context3.prev = _context3.next) {
604
- case 0:
605
- return _context3.abrupt("return", fetch("".concat(capBaseUrl, "/singlealert?url=").concat(encodeURIComponent(alertUrl.link))).then(handleResponse).then(function (result) {
606
- var alert = _objectSpread2(_objectSpread2({}, result.alert), {}, {
607
- feedAddress: alertUrl.feedAddress
608
- });
609
- var features = addFeedAddressToCustomGeoJSonFeature(alertUrl.feedAddress, result.features.features);
610
- return {
611
- alert: alert,
612
- features: features
613
- };
614
- }));
615
- case 1:
616
- case "end":
617
- return _context3.stop();
618
- }
619
- }, _callee3);
620
- }));
621
- return function getSingleAlert(_x3) {
622
- return _ref3.apply(this, arguments);
623
- };
624
- }();
625
-
626
- var useGetConfig = function useGetConfig(productConfigKey) {
627
- return useQuery({
628
- queryKey: ['cap-config', productConfigKey],
629
- queryFn: function () {
630
- var _queryFn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
631
- return _regeneratorRuntime().wrap(function _callee$(_context) {
632
- while (1) switch (_context.prev = _context.next) {
633
- case 0:
634
- return _context.abrupt("return", getConfig(productConfigKey));
635
- case 1:
636
- case "end":
637
- return _context.stop();
638
- }
639
- }, _callee);
640
- }));
641
- function queryFn() {
642
- return _queryFn.apply(this, arguments);
643
- }
644
- return queryFn;
645
- }()
646
- });
647
- };
648
- var useAllFeedLinks = function useAllFeedLinks(capPresets) {
649
- var queries = useMemo(function () {
650
- return capPresets.feeds.map(function (feed) {
651
- return {
652
- queryKey: ['feedLinks', feed.feedAddress],
653
- queryFn: function () {
654
- var _queryFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
655
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
656
- while (1) switch (_context2.prev = _context2.next) {
657
- case 0:
658
- return _context2.abrupt("return", getFeedLinks(feed.feedAddress));
659
- case 1:
660
- case "end":
661
- return _context2.stop();
662
- }
663
- }, _callee2);
664
- }));
665
- function queryFn() {
666
- return _queryFn2.apply(this, arguments);
667
- }
668
- return queryFn;
669
- }(),
670
- refetchInterval: capPresets.pollInterval
671
- };
672
- });
673
- }, [capPresets]);
674
- var results = useQueries({
675
- queries: queries,
676
- combine: function combine(results) {
677
- return {
678
- results: results.flatMap(function (result) {
679
- return result.data;
680
- }).filter(function (result) {
681
- return !!result;
682
- }),
683
- pending: results.some(function (result) {
684
- return result.isPending;
685
- })
686
- };
687
- }
688
- });
689
- return results;
690
- };
691
- var useAllFeedAlerts = function useAllFeedAlerts(capPresets) {
692
- var _useAllFeedLinks = useAllFeedLinks(capPresets),
693
- allFeeds = _useAllFeedLinks.results,
694
- allFeedPending = _useAllFeedLinks.pending;
695
- var queries = useMemo(function () {
696
- return allFeeds.map(function (feed) {
697
- return {
698
- queryKey: ['feedAlert', feed],
699
- queryFn: function () {
700
- var _queryFn3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
701
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
702
- while (1) switch (_context3.prev = _context3.next) {
703
- case 0:
704
- return _context3.abrupt("return", getSingleAlert(feed));
705
- case 1:
706
- case "end":
707
- return _context3.stop();
708
- }
709
- }, _callee3);
710
- }));
711
- function queryFn() {
712
- return _queryFn3.apply(this, arguments);
713
- }
714
- return queryFn;
715
- }()
716
- };
717
- });
718
- }, [allFeeds]);
719
- var _useQueries = useQueries({
720
- queries: queries,
721
- combine: function combine(results) {
722
- return {
723
- alertResults: results.map(function (result) {
724
- return result.data;
725
- }).filter(function (result) {
726
- return !!result;
727
- }),
728
- pending: results.some(function (result) {
729
- return result.isPending;
730
- })
731
- };
732
- }
733
- }),
734
- alertResults = _useQueries.alertResults,
735
- alertsPending = _useQueries.pending;
736
- return {
737
- results: alertResults,
738
- pending: allFeedPending || alertsPending
739
- };
740
- };
741
-
742
- /* *
743
- * Licensed under the Apache License, Version 2.0 (the "License");
744
- * you may not use this file except in compliance with the License.
745
- * You may obtain a copy of the License at
746
- *
747
- * http://www.apache.org/licenses/LICENSE-2.0
748
- *
749
- * Unless required by applicable law or agreed to in writing, software
750
- * distributed under the License is distributed on an "AS IS" BASIS,
751
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
752
- * See the License for the specific language governing permissions and
753
- * limitations under the License.
754
- *
755
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
756
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
757
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
758
- * */
759
-
760
- var findEventIndexInLanguage = function findEventIndexInLanguage(language, languages, capWarningPresets, feedAddressFromProps) {
761
- var correctFeedIndex = capWarningPresets.feeds.findIndex(function (_ref) {
762
- var feedAddress = _ref.feedAddress;
763
- return feedAddress === feedAddressFromProps;
764
- });
765
- if (correctFeedIndex === -1) {
766
- return 0;
767
- }
768
- var languageIndex = languages.findIndex(function (lang) {
769
- return lang.language.startsWith(language);
770
- });
771
- if (languageIndex === -1) {
772
- var fallbackLanguage = languages.findIndex(function (object) {
773
- return object.language.startsWith('en');
774
- });
775
- if (fallbackLanguage === -1) {
776
- return 0;
777
- }
778
- return fallbackLanguage;
779
- }
780
- return languageIndex;
781
- };
782
-
783
- /* *
784
- * Licensed under the Apache License, Version 2.0 (the "License");
785
- * you may not use this file except in compliance with the License.
786
- * You may obtain a copy of the License at
787
- *
788
- * http://www.apache.org/licenses/LICENSE-2.0
789
- *
790
- * Unless required by applicable law or agreed to in writing, software
791
- * distributed under the License is distributed on an "AS IS" BASIS,
792
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
793
- * See the License for the specific language governing permissions and
794
- * limitations under the License.
795
- *
796
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
797
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
798
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
799
- * */
800
-
801
- var highlightGeoJson = function highlightGeoJson(currentFeatures, featureResults) {
802
- return Object.entries(currentFeatures).reduce(function (byId, _ref) {
803
- var _ref2 = _slicedToArray(_ref, 2),
804
- alertId = _ref2[0],
805
- features = _ref2[1];
806
- var isSelected = alertId === (featureResults === null || featureResults === void 0 ? void 0 : featureResults.feature.properties.details.identifier);
807
- return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alertId, features.map(function (feature) {
808
- var recoloredFeature = _objectSpread2({}, feature);
809
- recoloredFeature.properties.fill = isSelected ? feature.properties.fill.replace('0.10', '0.25') : recoloredFeature.properties.fill = feature.properties.fill.replace('0.25', '0.10');
810
- recoloredFeature.properties['stroke-width'] = isSelected ? 3 : 2;
811
- return recoloredFeature;
812
- })));
813
- }, {});
814
- };
815
-
816
- var MapViewCapConnect = function MapViewCapConnect(_ref) {
817
- var id = _ref.id,
818
- title = _ref.title,
819
- bbox = _ref.bbox,
820
- srs = _ref.srs,
821
- capWarningPresets = _ref.capWarningPresets,
822
- layers = _ref.layers,
823
- children = _ref.children;
824
- var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
825
- feedAlertsResult = _useAllFeedAlerts.results;
826
- var _React$useState = React.useState({}),
827
- _React$useState2 = _slicedToArray(_React$useState, 2),
828
- featuresByAlert = _React$useState2[0],
829
- setFeaturesByAlert = _React$useState2[1];
830
- var _React$useState3 = React.useState(undefined),
831
- _React$useState4 = _slicedToArray(_React$useState3, 2),
832
- selectedFeatureEvent = _React$useState4[0],
833
- setSelectedFeatureEvent = _React$useState4[1];
834
- var mapIdRef = React.useRef(id || webmapUtils.generateMapId());
835
- var parentSizeRef = React.useRef(null);
836
- var _React$useState5 = React.useState(window.innerWidth / 2),
837
- _React$useState6 = _slicedToArray(_React$useState5, 2),
838
- parentSize = _React$useState6[0],
839
- setParentSize = _React$useState6[1];
840
- React.useEffect(function () {
841
- var handleWindowResize = function handleWindowResize() {
842
- setParentSize(parentSizeRef.current.parentElement.offsetWidth);
843
- };
844
- window.addEventListener('resize', handleWindowResize);
845
- return function () {
846
- window.removeEventListener('resize', handleWindowResize);
847
- };
848
- }, []);
849
- var selectedTime = useSelector(function (store) {
850
- return mapSelectors.getSelectedTime(store, mapIdRef.current);
851
- });
852
- var selectedDate = useMemo(function () {
853
- return dateUtils.createDate(dateUtils.fromUnix(selectedTime).toISOString());
854
- }, [selectedTime]);
855
- var alertsInEffect = useMemo(function () {
856
- return feedAlertsResult.filter(function (alert) {
857
- return dateUtils.isBetween(selectedDate, dateUtils.createDate(alert.alert.onset), dateUtils.createDate(alert.alert.expires), '[)');
858
- });
859
- }, [feedAlertsResult, selectedDate]);
860
- var alertIdsInEffect = useMemo(function () {
861
- return alertsInEffect.map(function (_ref2) {
862
- var alert = _ref2.alert;
863
- return alert.identifier;
864
- });
865
- }, [alertsInEffect]);
866
- var previousAlertIdsInEffect = usePrevious(alertIdsInEffect);
867
- var clickOnFeature = useMemo(function () {
868
- return {
869
- onClick: function onClick(feature) {
870
- var featureResults = feature.length === 0 ? undefined : {
871
- feature: new GeoJSON().writeFeatureObject(feature[0]),
872
- coordinateIndexInFeature: null,
873
- featureIndex: null,
874
- screenCoords: null,
875
- mouseX: null,
876
- mouseY: null,
877
- isInEditMode: null
878
- };
879
- setSelectedFeatureEvent(featureResults);
880
- setFeaturesByAlert(function (previous) {
881
- return highlightGeoJson(previous, featureResults);
882
- });
883
- }
884
- };
885
- }, []);
886
- React.useEffect(function () {
887
- if (JSON.stringify(alertIdsInEffect) !== JSON.stringify(previousAlertIdsInEffect)) {
888
- var _featuresByAlert = alertsInEffect.reduce(function (byId, _ref3) {
889
- var alert = _ref3.alert,
890
- features = _ref3.features;
891
- return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
892
- }, {});
893
- setFeaturesByAlert(_featuresByAlert);
894
- }
895
- }, [alertIdsInEffect, alertsInEffect, previousAlertIdsInEffect]);
896
- var geoJsonObject = useMemo(function () {
897
- var featuresInEffect = Object.keys(featuresByAlert).filter(function (id) {
898
- return alertIdsInEffect.includes(id);
899
- }).flatMap(function (id) {
900
- return featuresByAlert[id];
901
- });
902
- return {
903
- type: 'FeatureCollection',
904
- features: featuresInEffect
905
- };
906
- // eslint-disable-next-line react-hooks/exhaustive-deps
907
- }, [featuresByAlert]);
908
- return /*#__PURE__*/jsx("div", {
909
- "data-testid": "mapViewCap",
910
- ref: parentSizeRef,
911
- style: {
912
- height: '100%',
913
- width: '100%'
914
- },
915
- children: /*#__PURE__*/jsxs(ConfigurableMapConnect, {
916
- "data-testid": "capWarningMap",
917
- id: mapIdRef.current,
918
- initialBbox: bbox,
919
- layers: layers !== null && layers !== void 0 ? layers : [],
920
- srs: srs,
921
- title: title,
922
- children: [/*#__PURE__*/jsx(OpenLayersFeatureLayer, {
923
- clickOnFeature: clickOnFeature,
924
- featureCollection: geoJsonObject,
925
- style: genericOpenLayersFeatureStyle,
926
- testId: "MapViewCap-features",
927
- zIndex: 1000
928
- }), selectedFeatureEvent ? /*#__PURE__*/jsx(MapWarningProperties, {
929
- "data-testid": "mapWarnings",
930
- languageIndex: findEventIndexInLanguage(i18n.language, selectedFeatureEvent.feature.properties.details.languages, capWarningPresets, selectedFeatureEvent.feature.properties.details.feedAddress),
931
- parentSize: parentSize,
932
- selectedFeatureProperties: selectedFeatureEvent.feature.properties.details
933
- }) : null, children]
934
- })
935
- });
936
- };
937
-
938
- /* *
939
- * Licensed under the Apache License, Version 2.0 (the "License");
940
- * you may not use this file except in compliance with the License.
941
- * You may obtain a copy of the License at
942
- *
943
- * http://www.apache.org/licenses/LICENSE-2.0
944
- *
945
- * Unless required by applicable law or agreed to in writing, software
946
- * distributed under the License is distributed on an "AS IS" BASIS,
947
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
948
- * See the License for the specific language governing permissions and
949
- * limitations under the License.
950
- *
951
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
952
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
953
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
954
- * */
955
-
956
- var CAP_NAMESPACE = 'cap';
957
- var useCapTranslation = function useCapTranslation() {
958
- return useTranslation(CAP_NAMESPACE);
959
- };
960
-
961
- /* *
962
- * Licensed under the Apache License, Version 2.0 (the "License");
963
- * you may not use this file except in compliance with the License.
964
- * You may obtain a copy of the License at
965
- *
966
- * http://www.apache.org/licenses/LICENSE-2.0
967
- *
968
- * Unless required by applicable law or agreed to in writing, software
969
- * distributed under the License is distributed on an "AS IS" BASIS,
970
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
971
- * See the License for the specific language governing permissions and
972
- * limitations under the License.
973
- *
974
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
975
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
976
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
977
- * */
978
-
979
- var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
980
- var id = _ref.id,
981
- title = _ref.title,
982
- bbox = _ref.bbox,
983
- srs = _ref.srs,
984
- productConfigKey = _ref.productConfigKey,
985
- layers = _ref.layers;
986
- var _useCapTranslation = useCapTranslation(),
987
- t = _useCapTranslation.t;
988
- var _useGetConfig = useGetConfig(productConfigKey),
989
- capWarningPresets = _useGetConfig.data,
990
- isPending = _useGetConfig.isPending,
991
- error = _useGetConfig.error;
992
- if (isPending) {
993
- return /*#__PURE__*/jsx(Box, {
994
- sx: {
995
- display: 'flex',
996
- justifyContent: 'center',
997
- alignItems: 'center'
998
- },
999
- children: /*#__PURE__*/jsx(CircularProgress, {
1000
- "data-testid": "loadingSpinner"
1001
- })
1002
- });
1003
- }
1004
- if (error) {
1005
- return /*#__PURE__*/jsx(AlertBanner, {
1006
- info: error.message,
1007
- title: t('map-view-cap-error-title')
1008
- });
1009
- }
1010
- return /*#__PURE__*/jsx(MapViewCapConnect, {
1011
- bbox: bbox,
1012
- capWarningPresets: capWarningPresets,
1013
- id: id,
1014
- layers: layers,
1015
- srs: srs,
1016
- title: title
1017
- });
1018
- };
1019
-
1020
- /* *
1021
- * Licensed under the Apache License, Version 2.0 (the "License");
1022
- * you may not use this file except in compliance with the License.
1023
- * You may obtain a copy of the License at
1024
- *
1025
- * http://www.apache.org/licenses/LICENSE-2.0
1026
- *
1027
- * Unless required by applicable law or agreed to in writing, software
1028
- * distributed under the License is distributed on an "AS IS" BASIS,
1029
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1030
- * See the License for the specific language governing permissions and
1031
- * limitations under the License.
1032
- *
1033
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1034
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1035
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1036
- * */
1037
- var severityStyles = {
1038
- Extreme: {
1039
- border: 'solid 5px rgb(255, 9, 9)',
1040
- background: 'rgba(255, 9, 9, 0.15)'
1041
- },
1042
- Severe: {
1043
- border: 'solid 5px rgb(255, 165, 0)',
1044
- background: 'rgba(255, 165, 0, 0.15)'
1045
- },
1046
- Moderate: {
1047
- border: 'solid 5px rgb(248, 248, 0)',
1048
- background: 'rgba(248, 248, 0, 0.15)'
1049
- },
1050
- Minor: {
1051
- border: 'solid 5px rgb(106, 248, 108)',
1052
- background: 'rgba(106, 248, 108, 0.15)'
1053
- }
1054
- };
1055
- var WarningListRowCap = function WarningListRowCap(_ref) {
1056
- var event = _ref.event,
1057
- severity = _ref.severity,
1058
- expires = _ref.expires;
1059
- var _useCapTranslation = useCapTranslation(),
1060
- t = _useCapTranslation.t;
1061
- return /*#__PURE__*/jsxs(Grid, {
1062
- container: true,
1063
- sx: {
1064
- border: severityStyles[severity].border,
1065
- background: severityStyles[severity].background,
1066
- padding: '5px',
1067
- marginTop: '20px',
1068
- marginBottom: '20px',
1069
- width: '100%'
1070
- },
1071
- children: [/*#__PURE__*/jsxs(Grid, {
1072
- size: {
1073
- xs: 4
1074
- },
1075
- children: [/*#__PURE__*/jsx(Typography, {
1076
- variant: "overline",
1077
- children: t('warning-list-row-event')
1078
- }), /*#__PURE__*/jsx(Typography, {
1079
- "data-testid": "event",
1080
- sx: {
1081
- fontWeight: 'normal'
1082
- },
1083
- variant: "subtitle2",
1084
- children: event || ''
1085
- })]
1086
- }), /*#__PURE__*/jsxs(Grid, {
1087
- size: {
1088
- xs: 4
1089
- },
1090
- children: [/*#__PURE__*/jsx(Typography, {
1091
- variant: "overline",
1092
- children: t('warning-list-row-severity')
1093
- }), /*#__PURE__*/jsx(Typography, {
1094
- "data-testid": "severity",
1095
- sx: {
1096
- fontWeight: 'normal'
1097
- },
1098
- variant: "subtitle2",
1099
- children: severity || ''
1100
- })]
1101
- }), /*#__PURE__*/jsxs(Grid, {
1102
- size: {
1103
- xs: 4
1104
- },
1105
- children: [/*#__PURE__*/jsx(Typography, {
1106
- variant: "overline",
1107
- children: t('warning-list-row-expires')
1108
- }), /*#__PURE__*/jsx(Typography, {
1109
- "data-testid": "expires",
1110
- sx: {
1111
- fontWeight: 'normal'
1112
- },
1113
- variant: "subtitle2",
1114
- children: expires ? dateUtils.dateToString(dateUtils.createDate(expires), "dd MMM yyyy, HH:mm 'UTC'") : t('warning-list-row-not-expired')
1115
- })]
1116
- })]
1117
- });
1118
- };
1119
-
1120
- var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
1121
- var _alert$languages;
1122
- var alert = _ref.alert,
1123
- capWarningPresets = _ref.capWarningPresets;
1124
- var _React$useState = React.useState(0),
1125
- _React$useState2 = _slicedToArray(_React$useState, 2),
1126
- languageIndex = _React$useState2[0],
1127
- setLanguageIndex = _React$useState2[1];
1128
- var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
1129
- var language = i18n.language;
1130
- React.useEffect(function () {
1131
- if (alert && alertHasLanguages) {
1132
- var foundLanguageIndex = findEventIndexInLanguage(language, alert.languages, capWarningPresets, alert.feedAddress);
1133
- setLanguageIndex(foundLanguageIndex);
1134
- }
1135
- }, [alert, language, alertHasLanguages, capWarningPresets]);
1136
- return /*#__PURE__*/jsx("div", {
1137
- children: alert && alertHasLanguages ? /*#__PURE__*/jsx(WarningListRowCap, {
1138
- event: alert.languages[languageIndex].event,
1139
- expires: alert.expires,
1140
- severity: alert.severity
1141
- }) : null
1142
- });
1143
- };
1144
-
1145
- /* *
1146
- * Licensed under the Apache License, Version 2.0 (the "License");
1147
- * you may not use this file except in compliance with the License.
1148
- * You may obtain a copy of the License at
1149
- *
1150
- * http://www.apache.org/licenses/LICENSE-2.0
1151
- *
1152
- * Unless required by applicable law or agreed to in writing, software
1153
- * distributed under the License is distributed on an "AS IS" BASIS,
1154
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1155
- * See the License for the specific language governing permissions and
1156
- * limitations under the License.
1157
- *
1158
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1159
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1160
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1161
- * */
1162
- var WarningListCap = function WarningListCap(_ref) {
1163
- var capWarningPresets = _ref.capWarningPresets,
1164
- alerts = _ref.alerts,
1165
- _ref$isPending = _ref.isPending,
1166
- isPending = _ref$isPending === void 0 ? false : _ref$isPending;
1167
- var _useCapTranslation = useCapTranslation(),
1168
- t = _useCapTranslation.t;
1169
- return /*#__PURE__*/jsxs(Box$1, {
1170
- sx: {
1171
- width: '100%',
1172
- height: '100%',
1173
- display: 'flex'
1174
- },
1175
- children: [isPending ? /*#__PURE__*/jsx(LinearProgress, {
1176
- color: "secondary",
1177
- sx: {
1178
- position: 'absolute',
1179
- width: '100%'
1180
- }
1181
- }) : null, /*#__PURE__*/jsxs(Card, {
1182
- "data-testid": "warningList",
1183
- sx: {
1184
- justifyContent: 'center',
1185
- alignItems: 'center',
1186
- overflow: 'auto',
1187
- height: '95%',
1188
- width: '100%',
1189
- padding: '10px',
1190
- margin: '20px',
1191
- marginBottom: '10px',
1192
- position: 'relative'
1193
- },
1194
- children: [!isPending && !alerts.length && /*#__PURE__*/jsx(AlertBanner, {
1195
- severity: "warning",
1196
- title: "No results"
1197
- }), alerts.length > 0 && /*#__PURE__*/jsx(Box$1, {
1198
- sx: {
1199
- position: 'sticky',
1200
- top: 0,
1201
- width: '100%',
1202
- display: 'flex',
1203
- justifyContent: 'center'
1204
- },
1205
- children: /*#__PURE__*/jsx(AlertBanner, {
1206
- severity: "info",
1207
- title: t('warning-list-cap-alert-banner-title')
1208
- })
1209
- }), alerts.map(function (alert) {
1210
- return /*#__PURE__*/jsx(WarningListRowCapConnect, {
1211
- alert: alert,
1212
- capWarningPresets: capWarningPresets
1213
- }, alert.identifier);
1214
- })]
1215
- })]
1216
- });
1217
- };
1218
-
1219
- /* *
1220
- * Licensed under the Apache License, Version 2.0 (the "License");
1221
- * you may not use this file except in compliance with the License.
1222
- * You may obtain a copy of the License at
1223
- *
1224
- * http://www.apache.org/licenses/LICENSE-2.0
1225
- *
1226
- * Unless required by applicable law or agreed to in writing, software
1227
- * distributed under the License is distributed on an "AS IS" BASIS,
1228
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229
- * See the License for the specific language governing permissions and
1230
- * limitations under the License.
1231
- *
1232
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1233
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1234
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1235
- * */
1236
-
1237
- var WarningListCapConnect = function WarningListCapConnect(_ref) {
1238
- var capWarningPresets = _ref.capWarningPresets;
1239
- var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
1240
- feedAlerts = _useAllFeedAlerts.results,
1241
- pending = _useAllFeedAlerts.pending;
1242
- return /*#__PURE__*/jsx(WarningListCap, {
1243
- alerts: feedAlerts.map(function (fa) {
1244
- return fa.alert;
1245
- }),
1246
- capWarningPresets: capWarningPresets,
1247
- isPending: pending
1248
- });
1249
- };
1250
-
1251
- /* *
1252
- * Licensed under the Apache License, Version 2.0 (the "License");
1253
- * you may not use this file except in compliance with the License.
1254
- * You may obtain a copy of the License at
1255
- *
1256
- * http://www.apache.org/licenses/LICENSE-2.0
1257
- *
1258
- * Unless required by applicable law or agreed to in writing, software
1259
- * distributed under the License is distributed on an "AS IS" BASIS,
1260
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261
- * See the License for the specific language governing permissions and
1262
- * limitations under the License.
1263
- *
1264
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1265
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1266
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1267
- * */
1268
-
1269
- var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
1270
- var productConfigKey = _ref.productConfigKey;
1271
- var _useCapTranslation = useCapTranslation(),
1272
- t = _useCapTranslation.t;
1273
- var _useGetConfig = useGetConfig(productConfigKey),
1274
- productConfig = _useGetConfig.data,
1275
- isPending = _useGetConfig.isPending,
1276
- error = _useGetConfig.error;
1277
- if (isPending) {
1278
- return /*#__PURE__*/jsx(Box, {
1279
- sx: {
1280
- display: 'flex',
1281
- justifyContent: 'center',
1282
- alignItems: 'center'
1283
- },
1284
- children: /*#__PURE__*/jsx(CircularProgress, {
1285
- "data-testid": "loadingSpinner"
1286
- })
1287
- });
1288
- }
1289
- if (error) {
1290
- return /*#__PURE__*/jsx(AlertBanner, {
1291
- info: error.message,
1292
- title: t('warning-list-cap-error-title')
1293
- });
1294
- }
1295
- return /*#__PURE__*/jsx(WarningListCapConnect, {
1296
- capWarningPresets: productConfig
1297
- });
1298
- };
1299
-
1300
- /* *
1301
- * Licensed under the Apache License, Version 2.0 (the "License");
1302
- * you may not use this file except in compliance with the License.
1303
- * You may obtain a copy of the License at
1304
- *
1305
- * http://www.apache.org/licenses/LICENSE-2.0
1306
- *
1307
- * Unless required by applicable law or agreed to in writing, software
1308
- * distributed under the License is distributed on an "AS IS" BASIS,
1309
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1310
- * See the License for the specific language governing permissions and
1311
- * limitations under the License.
1312
- *
1313
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1314
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1315
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1316
- * */
1317
-
1318
- /**
1319
- * The lookup table is for registering your own components with the workspace.
1320
- * @param payload
1321
- * @returns
1322
- */
1323
-
1324
- var ComponentsLookUp = function ComponentsLookUp(_ref) {
1325
- var componentType = _ref.componentType,
1326
- initialProps = _ref.initialProps,
1327
- productConfigKey = _ref.productConfigKey,
1328
- id = _ref.id;
1329
- switch (componentType) {
1330
- case 'CapWarningMap':
1331
- {
1332
- var _initialProps$mapPres, _initialProps$mapPres2;
1333
- return /*#__PURE__*/jsx(MapViewCapConnectWrapper, {
1334
- bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
1335
- id: id,
1336
- layers: initialProps.mapPreset.layers,
1337
- productConfigKey: productConfigKey,
1338
- srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs
1339
- });
1340
- }
1341
- case 'CapWarningList':
1342
- {
1343
- return /*#__PURE__*/jsx(WarningListCapConnectWrapper, {
1344
- productConfigKey: productConfigKey
1345
- });
1346
- }
1347
- default:
1348
- return null;
1349
- }
1350
- };
1351
-
1352
- /* *
1353
- * Licensed under the Apache License, Version 2.0 (the "License");
1354
- * you may not use this file except in compliance with the License.
1355
- * You may obtain a copy of the License at
1356
- *
1357
- * http://www.apache.org/licenses/LICENSE-2.0
1358
- *
1359
- * Unless required by applicable law or agreed to in writing, software
1360
- * distributed under the License is distributed on an "AS IS" BASIS,
1361
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1362
- * See the License for the specific language governing permissions and
1363
- * limitations under the License.
1364
- *
1365
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1366
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1367
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1368
- * */
1369
-
1370
- var capReducersMap = {
1371
- webmap: mapReducer,
1372
- services: serviceReducer,
1373
- layers: layerReducer,
1374
- syncGroups: syncGroupsReducer
1375
- };
1376
- var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
1377
- var capRootReducer = combineReducers(capReducersMap);
1378
- var createMockStore = function createMockStore(mockState) {
1379
- return configureStore({
1380
- reducer: capRootReducer,
1381
- preloadedState: mockState,
1382
- middleware: function middleware(getDefaultMiddleware) {
1383
- return getDefaultMiddleware().concat(capMiddlewares);
1384
- },
1385
- devTools: true
1386
- });
1387
- };
1388
-
1389
- export { CAP_NAMESPACE, ComponentsLookUp, capTrans as capTranslations, createMockStore };