@opengeoweb/cap 19.0.0 → 19.1.1
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/dist/README.md +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1120 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/lib/components/ComponentsLookUp/componentsLookUp.d.ts +32 -0
- package/dist/src/lib/components/ComponentsLookUp/index.d.ts +1 -0
- package/dist/src/lib/components/GanttChart/Gantt.d.ts +40 -0
- package/dist/src/lib/components/GanttChart/GanttModule.d.ts +7 -0
- package/dist/src/lib/components/GanttChart/GanttReactWrapper.d.ts +37 -0
- package/dist/src/lib/components/GanttChart/GanttWrapper.d.ts +9 -0
- package/dist/src/lib/components/GanttChart/Task.d.ts +29 -0
- package/dist/src/lib/components/GanttChart/ViewMode.d.ts +9 -0
- package/dist/src/lib/components/GanttChart/mockTasks.d.ts +2 -0
- package/dist/src/lib/components/GanttChart/utils.d.ts +5 -0
- package/dist/src/lib/components/MapViewCap/MapViewCapConnect.d.ts +18 -0
- package/dist/src/lib/components/MapViewCap/MapViewCapConnectWrapper.d.ts +17 -0
- package/dist/src/lib/components/MapViewCap/index.d.ts +1 -0
- package/dist/src/lib/components/Providers/Providers.d.ts +32 -0
- package/dist/src/lib/components/Providers/index.d.ts +1 -0
- package/dist/src/lib/components/WarningListCap/WarningListCap.d.ts +10 -0
- package/dist/src/lib/components/WarningListCap/WarningListCapConnect.d.ts +7 -0
- package/dist/src/lib/components/WarningListCap/WarningListCapConnectWrapper.d.ts +6 -0
- package/dist/src/lib/components/WarningListCap/WarningListRowCap/WarningListRowCap.d.ts +7 -0
- package/dist/src/lib/components/WarningListCap/WarningListRowCap/WarningListRowCapConnect.d.ts +9 -0
- package/dist/src/lib/components/WarningListCap/index.d.ts +1 -0
- package/dist/src/lib/components/WarningListCap/types.d.ts +47 -0
- package/dist/src/lib/components/types.d.ts +69 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/store/index.d.ts +1 -0
- package/dist/src/lib/store/store.d.ts +3 -0
- package/dist/src/lib/store/types.d.ts +15 -0
- package/dist/src/lib/utils/addColors.d.ts +2 -0
- package/dist/src/lib/utils/addFeedAddressToCustomGeoJsonFeature.d.ts +2 -0
- package/dist/src/lib/utils/cap-api/api.d.ts +12 -0
- package/dist/src/lib/utils/cap-api/fakeApi.d.ts +2 -0
- package/dist/src/lib/utils/cap-api/hooks.d.ts +10 -0
- package/dist/src/lib/utils/findEventIndexInLanguage.d.ts +10 -0
- package/dist/src/lib/utils/highlightGeoJson.d.ts +3 -0
- package/dist/src/lib/utils/i18n.d.ts +6 -0
- package/dist/src/lib/utils/mockAlert.d.ts +2 -0
- package/dist/src/lib/utils/mockCapData.d.ts +3 -0
- package/dist/src/lib/utils/mockGeoJson.d.ts +2 -0
- package/dist/src/lib/utils/mockGeoJsonMultipleFeatures.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,1120 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
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 React, { useMemo } from 'react';
|
|
8
|
+
import { useSelector } from 'react-redux';
|
|
9
|
+
import { ConfigurableMapConnect } from '@opengeoweb/core';
|
|
10
|
+
import { mapSelectors, mapListener, serviceListener, layersListener, syncGroupsListener, genericListener, openlayersListener, syncGroupsReducer, layerReducer, serviceReducer, mapReducer } from '@opengeoweb/store';
|
|
11
|
+
import { webmapUtils } from '@opengeoweb/webmap';
|
|
12
|
+
import { OpenLayersFeatureLayer, genericOpenLayersFeatureStyle, MapWarningProperties } from '@opengeoweb/webmap-react';
|
|
13
|
+
import { useQuery, useQueries } from '@tanstack/react-query';
|
|
14
|
+
import { handleResponse } from '@opengeoweb/api';
|
|
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 _arrayLikeToArray(r, a) {
|
|
63
|
+
(null == a || a > r.length) && (a = r.length);
|
|
64
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
function _arrayWithHoles(r) {
|
|
68
|
+
if (Array.isArray(r)) return r;
|
|
69
|
+
}
|
|
70
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
71
|
+
try {
|
|
72
|
+
var i = n[a](c),
|
|
73
|
+
u = i.value;
|
|
74
|
+
} catch (n) {
|
|
75
|
+
return void e(n);
|
|
76
|
+
}
|
|
77
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
78
|
+
}
|
|
79
|
+
function _asyncToGenerator(n) {
|
|
80
|
+
return function () {
|
|
81
|
+
var t = this,
|
|
82
|
+
e = arguments;
|
|
83
|
+
return new Promise(function (r, o) {
|
|
84
|
+
var a = n.apply(t, e);
|
|
85
|
+
function _next(n) {
|
|
86
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
87
|
+
}
|
|
88
|
+
function _throw(n) {
|
|
89
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
90
|
+
}
|
|
91
|
+
_next(void 0);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function _createForOfIteratorHelper(r, e) {
|
|
96
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
97
|
+
if (!t) {
|
|
98
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
99
|
+
t && (r = t);
|
|
100
|
+
var n = 0,
|
|
101
|
+
F = function () {};
|
|
102
|
+
return {
|
|
103
|
+
s: F,
|
|
104
|
+
n: function () {
|
|
105
|
+
return n >= r.length ? {
|
|
106
|
+
done: true
|
|
107
|
+
} : {
|
|
108
|
+
done: false,
|
|
109
|
+
value: r[n++]
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
e: function (r) {
|
|
113
|
+
throw r;
|
|
114
|
+
},
|
|
115
|
+
f: F
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
119
|
+
}
|
|
120
|
+
var o,
|
|
121
|
+
a = true,
|
|
122
|
+
u = false;
|
|
123
|
+
return {
|
|
124
|
+
s: function () {
|
|
125
|
+
t = t.call(r);
|
|
126
|
+
},
|
|
127
|
+
n: function () {
|
|
128
|
+
var r = t.next();
|
|
129
|
+
return a = r.done, r;
|
|
130
|
+
},
|
|
131
|
+
e: function (r) {
|
|
132
|
+
u = true, o = r;
|
|
133
|
+
},
|
|
134
|
+
f: function () {
|
|
135
|
+
try {
|
|
136
|
+
a || null == t.return || t.return();
|
|
137
|
+
} finally {
|
|
138
|
+
if (u) throw o;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function _defineProperty(e, r, t) {
|
|
144
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
145
|
+
value: t,
|
|
146
|
+
enumerable: true,
|
|
147
|
+
configurable: true,
|
|
148
|
+
writable: true
|
|
149
|
+
}) : e[r] = t, e;
|
|
150
|
+
}
|
|
151
|
+
function _iterableToArrayLimit(r, l) {
|
|
152
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
153
|
+
if (null != t) {
|
|
154
|
+
var e,
|
|
155
|
+
n,
|
|
156
|
+
i,
|
|
157
|
+
u,
|
|
158
|
+
a = [],
|
|
159
|
+
f = true,
|
|
160
|
+
o = false;
|
|
161
|
+
try {
|
|
162
|
+
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);
|
|
163
|
+
} catch (r) {
|
|
164
|
+
o = true, n = r;
|
|
165
|
+
} finally {
|
|
166
|
+
try {
|
|
167
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
168
|
+
} finally {
|
|
169
|
+
if (o) throw n;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return a;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function _nonIterableRest() {
|
|
176
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
177
|
+
}
|
|
178
|
+
function ownKeys(e, r) {
|
|
179
|
+
var t = Object.keys(e);
|
|
180
|
+
if (Object.getOwnPropertySymbols) {
|
|
181
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
182
|
+
r && (o = o.filter(function (r) {
|
|
183
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
184
|
+
})), t.push.apply(t, o);
|
|
185
|
+
}
|
|
186
|
+
return t;
|
|
187
|
+
}
|
|
188
|
+
function _objectSpread2(e) {
|
|
189
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
190
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
191
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
192
|
+
_defineProperty(e, r, t[r]);
|
|
193
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
194
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return e;
|
|
198
|
+
}
|
|
199
|
+
function _regenerator() {
|
|
200
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
201
|
+
var e,
|
|
202
|
+
t,
|
|
203
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
204
|
+
n = r.iterator || "@@iterator",
|
|
205
|
+
o = r.toStringTag || "@@toStringTag";
|
|
206
|
+
function i(r, n, o, i) {
|
|
207
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
208
|
+
u = Object.create(c.prototype);
|
|
209
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
210
|
+
var i,
|
|
211
|
+
c,
|
|
212
|
+
u,
|
|
213
|
+
f = 0,
|
|
214
|
+
p = o || [],
|
|
215
|
+
y = false,
|
|
216
|
+
G = {
|
|
217
|
+
p: 0,
|
|
218
|
+
n: 0,
|
|
219
|
+
v: e,
|
|
220
|
+
a: d,
|
|
221
|
+
f: d.bind(e, 4),
|
|
222
|
+
d: function (t, r) {
|
|
223
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
function d(r, n) {
|
|
227
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
228
|
+
var o,
|
|
229
|
+
i = p[t],
|
|
230
|
+
d = G.p,
|
|
231
|
+
l = i[2];
|
|
232
|
+
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));
|
|
233
|
+
}
|
|
234
|
+
if (o || r > 1) return a;
|
|
235
|
+
throw y = true, n;
|
|
236
|
+
}
|
|
237
|
+
return function (o, p, l) {
|
|
238
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
239
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
240
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
241
|
+
try {
|
|
242
|
+
if (f = 2, i) {
|
|
243
|
+
if (c || (o = "next"), t = i[o]) {
|
|
244
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
245
|
+
if (!t.done) return t;
|
|
246
|
+
u = t.value, c < 2 && (c = 0);
|
|
247
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
248
|
+
i = e;
|
|
249
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
250
|
+
} catch (t) {
|
|
251
|
+
i = e, c = 1, u = t;
|
|
252
|
+
} finally {
|
|
253
|
+
f = 1;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
value: t,
|
|
258
|
+
done: y
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
}(r, o, i), true), u;
|
|
262
|
+
}
|
|
263
|
+
var a = {};
|
|
264
|
+
function Generator() {}
|
|
265
|
+
function GeneratorFunction() {}
|
|
266
|
+
function GeneratorFunctionPrototype() {}
|
|
267
|
+
t = Object.getPrototypeOf;
|
|
268
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
269
|
+
return this;
|
|
270
|
+
}), t),
|
|
271
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
272
|
+
function f(e) {
|
|
273
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
274
|
+
}
|
|
275
|
+
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 () {
|
|
276
|
+
return this;
|
|
277
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
278
|
+
return "[object Generator]";
|
|
279
|
+
}), (_regenerator = function () {
|
|
280
|
+
return {
|
|
281
|
+
w: i,
|
|
282
|
+
m: f
|
|
283
|
+
};
|
|
284
|
+
})();
|
|
285
|
+
}
|
|
286
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
287
|
+
var i = Object.defineProperty;
|
|
288
|
+
try {
|
|
289
|
+
i({}, "", {});
|
|
290
|
+
} catch (e) {
|
|
291
|
+
i = 0;
|
|
292
|
+
}
|
|
293
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
294
|
+
function o(r, n) {
|
|
295
|
+
_regeneratorDefine(e, r, function (e) {
|
|
296
|
+
return this._invoke(r, n, e);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
r ? i ? i(e, r, {
|
|
300
|
+
value: n,
|
|
301
|
+
enumerable: !t,
|
|
302
|
+
configurable: !t,
|
|
303
|
+
writable: !t
|
|
304
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
305
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
306
|
+
}
|
|
307
|
+
function _slicedToArray(r, e) {
|
|
308
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
309
|
+
}
|
|
310
|
+
function _toPrimitive(t, r) {
|
|
311
|
+
if ("object" != typeof t || !t) return t;
|
|
312
|
+
var e = t[Symbol.toPrimitive];
|
|
313
|
+
if (void 0 !== e) {
|
|
314
|
+
var i = e.call(t, r);
|
|
315
|
+
if ("object" != typeof i) return i;
|
|
316
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
317
|
+
}
|
|
318
|
+
return ("string" === r ? String : Number)(t);
|
|
319
|
+
}
|
|
320
|
+
function _toPropertyKey(t) {
|
|
321
|
+
var i = _toPrimitive(t, "string");
|
|
322
|
+
return "symbol" == typeof i ? i : i + "";
|
|
323
|
+
}
|
|
324
|
+
function _unsupportedIterableToArray(r, a) {
|
|
325
|
+
if (r) {
|
|
326
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
327
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
328
|
+
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;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* *
|
|
333
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
334
|
+
* you may not use this file except in compliance with the License.
|
|
335
|
+
* You may obtain a copy of the License at
|
|
336
|
+
*
|
|
337
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
338
|
+
*
|
|
339
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
340
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
341
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
342
|
+
* See the License for the specific language governing permissions and
|
|
343
|
+
* limitations under the License.
|
|
344
|
+
*
|
|
345
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
346
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
347
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
348
|
+
* */
|
|
349
|
+
var addColors = function addColors(features) {
|
|
350
|
+
var severityStyles = {
|
|
351
|
+
Extreme: {
|
|
352
|
+
stroke: 'rgb(255, 9, 9)',
|
|
353
|
+
fill: 'rgba(255, 9, 9, 0.10)'
|
|
354
|
+
},
|
|
355
|
+
Severe: {
|
|
356
|
+
stroke: 'rgb(255, 165, 0)',
|
|
357
|
+
fill: 'rgba(255, 165, 0, 0.10)'
|
|
358
|
+
},
|
|
359
|
+
Moderate: {
|
|
360
|
+
stroke: 'rgb(248, 248, 0)',
|
|
361
|
+
fill: 'rgba(248, 248, 0, 0.10)'
|
|
362
|
+
},
|
|
363
|
+
Minor: {
|
|
364
|
+
stroke: 'rgb(106, 248, 108)',
|
|
365
|
+
fill: 'rgba(106, 248, 108, 0.10)'
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
var _iterator = _createForOfIteratorHelper(features),
|
|
369
|
+
_step;
|
|
370
|
+
try {
|
|
371
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
372
|
+
var feature = _step.value;
|
|
373
|
+
var severity = feature.properties.details.severity;
|
|
374
|
+
feature.properties.stroke = severityStyles[severity].stroke;
|
|
375
|
+
feature.properties.fill = severityStyles[severity].fill;
|
|
376
|
+
feature.properties['stroke-opacity'] = 1;
|
|
377
|
+
feature.properties['stroke-width'] = 2;
|
|
378
|
+
}
|
|
379
|
+
} catch (err) {
|
|
380
|
+
_iterator.e(err);
|
|
381
|
+
} finally {
|
|
382
|
+
_iterator.f();
|
|
383
|
+
}
|
|
384
|
+
return features;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/* *
|
|
388
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
389
|
+
* you may not use this file except in compliance with the License.
|
|
390
|
+
* You may obtain a copy of the License at
|
|
391
|
+
*
|
|
392
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
393
|
+
*
|
|
394
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
395
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
396
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
397
|
+
* See the License for the specific language governing permissions and
|
|
398
|
+
* limitations under the License.
|
|
399
|
+
*
|
|
400
|
+
* Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
401
|
+
* Copyright 2023 - Finnish Meteorological Institute (FMI)
|
|
402
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
403
|
+
* */
|
|
404
|
+
var addFeedAddressToCustomGeoJSonFeature = function addFeedAddressToCustomGeoJSonFeature(feedAddress, features) {
|
|
405
|
+
return features.reduce(function (list, feature) {
|
|
406
|
+
return list.concat(_objectSpread2(_objectSpread2({}, feature), {}, {
|
|
407
|
+
properties: _objectSpread2(_objectSpread2({}, feature.properties), {}, {
|
|
408
|
+
details: _objectSpread2(_objectSpread2({}, feature.properties.details), {}, {
|
|
409
|
+
feedAddress: feedAddress
|
|
410
|
+
})
|
|
411
|
+
})
|
|
412
|
+
}));
|
|
413
|
+
}, []);
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
var _config$GW_CAP_BASE_U;
|
|
417
|
+
var config = sessionStorageProvider.getConfig();
|
|
418
|
+
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 : '';
|
|
419
|
+
var getConfig = /*#__PURE__*/function () {
|
|
420
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(productConfigKey) {
|
|
421
|
+
return _regenerator().w(function (_context) {
|
|
422
|
+
while (1) switch (_context.n) {
|
|
423
|
+
case 0:
|
|
424
|
+
return _context.a(2,
|
|
425
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
426
|
+
fetch("assets/".concat(encodeURIComponent(productConfigKey))).then(handleResponse));
|
|
427
|
+
}
|
|
428
|
+
}, _callee);
|
|
429
|
+
}));
|
|
430
|
+
return function getConfig(_x) {
|
|
431
|
+
return _ref.apply(this, arguments);
|
|
432
|
+
};
|
|
433
|
+
}();
|
|
434
|
+
var getFeedLinks = /*#__PURE__*/function () {
|
|
435
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(feedAddress) {
|
|
436
|
+
return _regenerator().w(function (_context2) {
|
|
437
|
+
while (1) switch (_context2.n) {
|
|
438
|
+
case 0:
|
|
439
|
+
return _context2.a(2, fetch("".concat(capBaseUrl, "/feedlinks?url=").concat(encodeURIComponent(feedAddress))).then(handleResponse).then(function (result) {
|
|
440
|
+
return result.map(function (link) {
|
|
441
|
+
return {
|
|
442
|
+
link: link,
|
|
443
|
+
feedAddress: feedAddress
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
}, _callee2);
|
|
449
|
+
}));
|
|
450
|
+
return function getFeedLinks(_x2) {
|
|
451
|
+
return _ref2.apply(this, arguments);
|
|
452
|
+
};
|
|
453
|
+
}();
|
|
454
|
+
var getSingleAlert = /*#__PURE__*/function () {
|
|
455
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(alertUrl) {
|
|
456
|
+
return _regenerator().w(function (_context3) {
|
|
457
|
+
while (1) switch (_context3.n) {
|
|
458
|
+
case 0:
|
|
459
|
+
return _context3.a(2, fetch("".concat(capBaseUrl, "/singlealert?url=").concat(encodeURIComponent(alertUrl.link))).then(handleResponse).then(function (result) {
|
|
460
|
+
var alert = _objectSpread2(_objectSpread2({}, result.alert), {}, {
|
|
461
|
+
feedAddress: alertUrl.feedAddress
|
|
462
|
+
});
|
|
463
|
+
var features = addFeedAddressToCustomGeoJSonFeature(alertUrl.feedAddress, result.features.features);
|
|
464
|
+
return {
|
|
465
|
+
alert: alert,
|
|
466
|
+
features: features
|
|
467
|
+
};
|
|
468
|
+
}));
|
|
469
|
+
}
|
|
470
|
+
}, _callee3);
|
|
471
|
+
}));
|
|
472
|
+
return function getSingleAlert(_x3) {
|
|
473
|
+
return _ref3.apply(this, arguments);
|
|
474
|
+
};
|
|
475
|
+
}();
|
|
476
|
+
|
|
477
|
+
var useGetConfig = function useGetConfig(productConfigKey) {
|
|
478
|
+
return useQuery({
|
|
479
|
+
queryKey: ['cap-config', productConfigKey],
|
|
480
|
+
queryFn: function () {
|
|
481
|
+
var _queryFn = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
482
|
+
return _regenerator().w(function (_context) {
|
|
483
|
+
while (1) switch (_context.n) {
|
|
484
|
+
case 0:
|
|
485
|
+
return _context.a(2, getConfig(productConfigKey));
|
|
486
|
+
}
|
|
487
|
+
}, _callee);
|
|
488
|
+
}));
|
|
489
|
+
function queryFn() {
|
|
490
|
+
return _queryFn.apply(this, arguments);
|
|
491
|
+
}
|
|
492
|
+
return queryFn;
|
|
493
|
+
}()
|
|
494
|
+
});
|
|
495
|
+
};
|
|
496
|
+
var useAllFeedLinks = function useAllFeedLinks(capPresets) {
|
|
497
|
+
var queries = useMemo(function () {
|
|
498
|
+
return capPresets.feeds.map(function (feed) {
|
|
499
|
+
return {
|
|
500
|
+
queryKey: ['feedLinks', feed.feedAddress],
|
|
501
|
+
queryFn: function () {
|
|
502
|
+
var _queryFn2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
503
|
+
return _regenerator().w(function (_context2) {
|
|
504
|
+
while (1) switch (_context2.n) {
|
|
505
|
+
case 0:
|
|
506
|
+
return _context2.a(2, getFeedLinks(feed.feedAddress));
|
|
507
|
+
}
|
|
508
|
+
}, _callee2);
|
|
509
|
+
}));
|
|
510
|
+
function queryFn() {
|
|
511
|
+
return _queryFn2.apply(this, arguments);
|
|
512
|
+
}
|
|
513
|
+
return queryFn;
|
|
514
|
+
}(),
|
|
515
|
+
refetchInterval: capPresets.pollInterval
|
|
516
|
+
};
|
|
517
|
+
});
|
|
518
|
+
}, [capPresets]);
|
|
519
|
+
var results = useQueries({
|
|
520
|
+
queries: queries,
|
|
521
|
+
combine: function combine(results) {
|
|
522
|
+
return {
|
|
523
|
+
results: results.flatMap(function (result) {
|
|
524
|
+
return result.data;
|
|
525
|
+
}).filter(function (result) {
|
|
526
|
+
return !!result;
|
|
527
|
+
}),
|
|
528
|
+
pending: results.some(function (result) {
|
|
529
|
+
return result.isPending;
|
|
530
|
+
})
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
return results;
|
|
535
|
+
};
|
|
536
|
+
var useAllFeedAlerts = function useAllFeedAlerts(capPresets) {
|
|
537
|
+
var _useAllFeedLinks = useAllFeedLinks(capPresets),
|
|
538
|
+
allFeeds = _useAllFeedLinks.results,
|
|
539
|
+
allFeedPending = _useAllFeedLinks.pending;
|
|
540
|
+
var queries = useMemo(function () {
|
|
541
|
+
return allFeeds.map(function (feed) {
|
|
542
|
+
return {
|
|
543
|
+
queryKey: ['feedAlert', feed],
|
|
544
|
+
queryFn: function () {
|
|
545
|
+
var _queryFn3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
546
|
+
return _regenerator().w(function (_context3) {
|
|
547
|
+
while (1) switch (_context3.n) {
|
|
548
|
+
case 0:
|
|
549
|
+
return _context3.a(2, getSingleAlert(feed));
|
|
550
|
+
}
|
|
551
|
+
}, _callee3);
|
|
552
|
+
}));
|
|
553
|
+
function queryFn() {
|
|
554
|
+
return _queryFn3.apply(this, arguments);
|
|
555
|
+
}
|
|
556
|
+
return queryFn;
|
|
557
|
+
}()
|
|
558
|
+
};
|
|
559
|
+
});
|
|
560
|
+
}, [allFeeds]);
|
|
561
|
+
var _useQueries = useQueries({
|
|
562
|
+
queries: queries,
|
|
563
|
+
combine: function combine(results) {
|
|
564
|
+
return {
|
|
565
|
+
alertResults: results.map(function (result) {
|
|
566
|
+
return result.data;
|
|
567
|
+
}).filter(function (result) {
|
|
568
|
+
return !!result;
|
|
569
|
+
}),
|
|
570
|
+
pending: results.some(function (result) {
|
|
571
|
+
return result.isPending;
|
|
572
|
+
})
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}),
|
|
576
|
+
alertResults = _useQueries.alertResults,
|
|
577
|
+
alertsPending = _useQueries.pending;
|
|
578
|
+
return {
|
|
579
|
+
results: alertResults,
|
|
580
|
+
pending: allFeedPending || alertsPending
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/* *
|
|
585
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
586
|
+
* you may not use this file except in compliance with the License.
|
|
587
|
+
* You may obtain a copy of the License at
|
|
588
|
+
*
|
|
589
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
590
|
+
*
|
|
591
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
592
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
593
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
594
|
+
* See the License for the specific language governing permissions and
|
|
595
|
+
* limitations under the License.
|
|
596
|
+
*
|
|
597
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
598
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
599
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
600
|
+
* */
|
|
601
|
+
var findEventIndexInLanguage = function findEventIndexInLanguage(language, languages, capWarningPresets, feedAddressFromProps) {
|
|
602
|
+
var correctFeedIndex = capWarningPresets.feeds.findIndex(function (_ref) {
|
|
603
|
+
var feedAddress = _ref.feedAddress;
|
|
604
|
+
return feedAddress === feedAddressFromProps;
|
|
605
|
+
});
|
|
606
|
+
if (correctFeedIndex === -1) {
|
|
607
|
+
return 0;
|
|
608
|
+
}
|
|
609
|
+
var languageIndex = languages.findIndex(function (lang) {
|
|
610
|
+
return lang.language.startsWith(language);
|
|
611
|
+
});
|
|
612
|
+
if (languageIndex === -1) {
|
|
613
|
+
var fallbackLanguage = languages.findIndex(function (object) {
|
|
614
|
+
return object.language.startsWith('en');
|
|
615
|
+
});
|
|
616
|
+
if (fallbackLanguage === -1) {
|
|
617
|
+
return 0;
|
|
618
|
+
}
|
|
619
|
+
return fallbackLanguage;
|
|
620
|
+
}
|
|
621
|
+
return languageIndex;
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
/* *
|
|
625
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
626
|
+
* you may not use this file except in compliance with the License.
|
|
627
|
+
* You may obtain a copy of the License at
|
|
628
|
+
*
|
|
629
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
630
|
+
*
|
|
631
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
632
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
633
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
634
|
+
* See the License for the specific language governing permissions and
|
|
635
|
+
* limitations under the License.
|
|
636
|
+
*
|
|
637
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
638
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
639
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
640
|
+
* */
|
|
641
|
+
var highlightGeoJson = function highlightGeoJson(currentFeatures, featureResults) {
|
|
642
|
+
return Object.entries(currentFeatures).reduce(function (byId, _ref) {
|
|
643
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
644
|
+
alertId = _ref2[0],
|
|
645
|
+
features = _ref2[1];
|
|
646
|
+
var isSelected = alertId === (featureResults === null || featureResults === void 0 ? void 0 : featureResults.feature.properties.details.identifier);
|
|
647
|
+
return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alertId, features.map(function (feature) {
|
|
648
|
+
var recoloredFeature = _objectSpread2({}, feature);
|
|
649
|
+
recoloredFeature.properties.fill = isSelected ? feature.properties.fill.replace('0.10', '0.25') : recoloredFeature.properties.fill = feature.properties.fill.replace('0.25', '0.10');
|
|
650
|
+
recoloredFeature.properties['stroke-width'] = isSelected ? 3 : 2;
|
|
651
|
+
return recoloredFeature;
|
|
652
|
+
})));
|
|
653
|
+
}, {});
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
var MapViewCapConnect = function MapViewCapConnect(_ref) {
|
|
657
|
+
var id = _ref.id,
|
|
658
|
+
title = _ref.title,
|
|
659
|
+
bbox = _ref.bbox,
|
|
660
|
+
srs = _ref.srs,
|
|
661
|
+
capWarningPresets = _ref.capWarningPresets,
|
|
662
|
+
layers = _ref.layers,
|
|
663
|
+
children = _ref.children;
|
|
664
|
+
var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
|
|
665
|
+
feedAlertsResult = _useAllFeedAlerts.results;
|
|
666
|
+
var _React$useState = React.useState({}),
|
|
667
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
668
|
+
featuresByAlert = _React$useState2[0],
|
|
669
|
+
setFeaturesByAlert = _React$useState2[1];
|
|
670
|
+
var _React$useState3 = React.useState(undefined),
|
|
671
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
672
|
+
selectedFeatureEvent = _React$useState4[0],
|
|
673
|
+
setSelectedFeatureEvent = _React$useState4[1];
|
|
674
|
+
var mapIdRef = React.useRef(id || webmapUtils.generateMapId());
|
|
675
|
+
var parentSizeRef = React.useRef(null);
|
|
676
|
+
var _React$useState5 = React.useState(window.innerWidth / 2),
|
|
677
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
678
|
+
parentSize = _React$useState6[0],
|
|
679
|
+
setParentSize = _React$useState6[1];
|
|
680
|
+
React.useEffect(function () {
|
|
681
|
+
var handleWindowResize = function handleWindowResize() {
|
|
682
|
+
setParentSize(parentSizeRef.current.parentElement.offsetWidth);
|
|
683
|
+
};
|
|
684
|
+
window.addEventListener('resize', handleWindowResize);
|
|
685
|
+
return function () {
|
|
686
|
+
window.removeEventListener('resize', handleWindowResize);
|
|
687
|
+
};
|
|
688
|
+
}, []);
|
|
689
|
+
var selectedTime = useSelector(function (store) {
|
|
690
|
+
return mapSelectors.getSelectedTime(store, mapIdRef.current);
|
|
691
|
+
});
|
|
692
|
+
var selectedDate = useMemo(function () {
|
|
693
|
+
return dateUtils.createDate(dateUtils.fromUnix(selectedTime).toISOString());
|
|
694
|
+
}, [selectedTime]);
|
|
695
|
+
var alertsInEffect = useMemo(function () {
|
|
696
|
+
return feedAlertsResult.filter(function (alert) {
|
|
697
|
+
return dateUtils.isBetween(selectedDate, dateUtils.createDate(alert.alert.onset), dateUtils.createDate(alert.alert.expires), '[)');
|
|
698
|
+
});
|
|
699
|
+
}, [feedAlertsResult, selectedDate]);
|
|
700
|
+
var alertIdsInEffect = useMemo(function () {
|
|
701
|
+
return alertsInEffect.map(function (_ref2) {
|
|
702
|
+
var alert = _ref2.alert;
|
|
703
|
+
return alert.identifier;
|
|
704
|
+
});
|
|
705
|
+
}, [alertsInEffect]);
|
|
706
|
+
var previousAlertIdsInEffect = usePrevious(alertIdsInEffect);
|
|
707
|
+
var clickOnFeature = useMemo(function () {
|
|
708
|
+
return {
|
|
709
|
+
onClick: function onClick(feature) {
|
|
710
|
+
var featureResults = feature.length === 0 ? undefined : {
|
|
711
|
+
feature: new GeoJSON().writeFeatureObject(feature[0]),
|
|
712
|
+
coordinateIndexInFeature: null,
|
|
713
|
+
featureIndex: null,
|
|
714
|
+
screenCoords: null,
|
|
715
|
+
mouseX: null,
|
|
716
|
+
mouseY: null,
|
|
717
|
+
isInEditMode: null
|
|
718
|
+
};
|
|
719
|
+
setSelectedFeatureEvent(featureResults);
|
|
720
|
+
setFeaturesByAlert(function (previous) {
|
|
721
|
+
return highlightGeoJson(previous, featureResults);
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
}, []);
|
|
726
|
+
React.useEffect(function () {
|
|
727
|
+
if (JSON.stringify(alertIdsInEffect) !== JSON.stringify(previousAlertIdsInEffect)) {
|
|
728
|
+
var _featuresByAlert = alertsInEffect.reduce(function (byId, _ref3) {
|
|
729
|
+
var alert = _ref3.alert,
|
|
730
|
+
features = _ref3.features;
|
|
731
|
+
return _objectSpread2(_objectSpread2({}, byId), {}, _defineProperty({}, alert.identifier, addColors(features)));
|
|
732
|
+
}, {});
|
|
733
|
+
setFeaturesByAlert(_featuresByAlert);
|
|
734
|
+
}
|
|
735
|
+
}, [alertIdsInEffect, alertsInEffect, previousAlertIdsInEffect]);
|
|
736
|
+
var geoJsonObject = useMemo(function () {
|
|
737
|
+
var featuresInEffect = Object.keys(featuresByAlert).filter(function (id) {
|
|
738
|
+
return alertIdsInEffect.includes(id);
|
|
739
|
+
}).flatMap(function (id) {
|
|
740
|
+
return featuresByAlert[id];
|
|
741
|
+
});
|
|
742
|
+
return {
|
|
743
|
+
type: 'FeatureCollection',
|
|
744
|
+
features: featuresInEffect
|
|
745
|
+
};
|
|
746
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
747
|
+
}, [featuresByAlert]);
|
|
748
|
+
return jsx("div", {
|
|
749
|
+
"data-testid": "mapViewCap",
|
|
750
|
+
ref: parentSizeRef,
|
|
751
|
+
style: {
|
|
752
|
+
height: '100%',
|
|
753
|
+
width: '100%'
|
|
754
|
+
},
|
|
755
|
+
children: jsxs(ConfigurableMapConnect, {
|
|
756
|
+
"data-testid": "capWarningMap",
|
|
757
|
+
id: mapIdRef.current,
|
|
758
|
+
initialBbox: bbox,
|
|
759
|
+
layers: layers !== null && layers !== void 0 ? layers : [],
|
|
760
|
+
srs: srs,
|
|
761
|
+
title: title,
|
|
762
|
+
children: [jsx(OpenLayersFeatureLayer, {
|
|
763
|
+
clickOnFeature: clickOnFeature,
|
|
764
|
+
featureCollection: geoJsonObject,
|
|
765
|
+
style: genericOpenLayersFeatureStyle,
|
|
766
|
+
testId: "MapViewCap-features",
|
|
767
|
+
zIndex: 1000
|
|
768
|
+
}), selectedFeatureEvent ? jsx(MapWarningProperties, {
|
|
769
|
+
"data-testid": "mapWarnings",
|
|
770
|
+
languageIndex: findEventIndexInLanguage(i18n.language, selectedFeatureEvent.feature.properties.details.languages, capWarningPresets, selectedFeatureEvent.feature.properties.details.feedAddress),
|
|
771
|
+
parentSize: parentSize,
|
|
772
|
+
selectedFeatureProperties: selectedFeatureEvent.feature.properties.details
|
|
773
|
+
}) : null, children]
|
|
774
|
+
})
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
/* *
|
|
779
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
780
|
+
* you may not use this file except in compliance with the License.
|
|
781
|
+
* You may obtain a copy of the License at
|
|
782
|
+
*
|
|
783
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
784
|
+
*
|
|
785
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
786
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
787
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
788
|
+
* See the License for the specific language governing permissions and
|
|
789
|
+
* limitations under the License.
|
|
790
|
+
*
|
|
791
|
+
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
792
|
+
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
793
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
794
|
+
* */
|
|
795
|
+
var CAP_NAMESPACE = 'cap';
|
|
796
|
+
var useCapTranslation = function useCapTranslation() {
|
|
797
|
+
return useTranslation(CAP_NAMESPACE);
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
var MapViewCapConnectWrapper = function MapViewCapConnectWrapper(_ref) {
|
|
801
|
+
var id = _ref.id,
|
|
802
|
+
title = _ref.title,
|
|
803
|
+
bbox = _ref.bbox,
|
|
804
|
+
srs = _ref.srs,
|
|
805
|
+
productConfigKey = _ref.productConfigKey,
|
|
806
|
+
layers = _ref.layers;
|
|
807
|
+
var _useCapTranslation = useCapTranslation(),
|
|
808
|
+
t = _useCapTranslation.t;
|
|
809
|
+
var _useGetConfig = useGetConfig(productConfigKey),
|
|
810
|
+
capWarningPresets = _useGetConfig.data,
|
|
811
|
+
isPending = _useGetConfig.isPending,
|
|
812
|
+
error = _useGetConfig.error;
|
|
813
|
+
if (isPending) {
|
|
814
|
+
return jsx(Box, {
|
|
815
|
+
sx: {
|
|
816
|
+
display: 'flex',
|
|
817
|
+
justifyContent: 'center',
|
|
818
|
+
alignItems: 'center'
|
|
819
|
+
},
|
|
820
|
+
children: jsx(CircularProgress, {
|
|
821
|
+
"data-testid": "loadingSpinner"
|
|
822
|
+
})
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
if (error) {
|
|
826
|
+
return jsx(AlertBanner, {
|
|
827
|
+
info: error.message,
|
|
828
|
+
title: t('map-view-cap-error-title')
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
return jsx(MapViewCapConnect, {
|
|
832
|
+
bbox: bbox,
|
|
833
|
+
capWarningPresets: capWarningPresets,
|
|
834
|
+
id: id,
|
|
835
|
+
layers: layers,
|
|
836
|
+
srs: srs,
|
|
837
|
+
title: title
|
|
838
|
+
});
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
var severityStyles = {
|
|
842
|
+
Extreme: {
|
|
843
|
+
border: 'solid 5px rgb(255, 9, 9)',
|
|
844
|
+
background: 'rgba(255, 9, 9, 0.15)'
|
|
845
|
+
},
|
|
846
|
+
Severe: {
|
|
847
|
+
border: 'solid 5px rgb(255, 165, 0)',
|
|
848
|
+
background: 'rgba(255, 165, 0, 0.15)'
|
|
849
|
+
},
|
|
850
|
+
Moderate: {
|
|
851
|
+
border: 'solid 5px rgb(248, 248, 0)',
|
|
852
|
+
background: 'rgba(248, 248, 0, 0.15)'
|
|
853
|
+
},
|
|
854
|
+
Minor: {
|
|
855
|
+
border: 'solid 5px rgb(106, 248, 108)',
|
|
856
|
+
background: 'rgba(106, 248, 108, 0.15)'
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
var WarningListRowCap = function WarningListRowCap(_ref) {
|
|
860
|
+
var event = _ref.event,
|
|
861
|
+
severity = _ref.severity,
|
|
862
|
+
expires = _ref.expires;
|
|
863
|
+
var _useCapTranslation = useCapTranslation(),
|
|
864
|
+
t = _useCapTranslation.t;
|
|
865
|
+
return jsxs(Grid, {
|
|
866
|
+
container: true,
|
|
867
|
+
sx: {
|
|
868
|
+
border: severityStyles[severity].border,
|
|
869
|
+
background: severityStyles[severity].background,
|
|
870
|
+
padding: '5px',
|
|
871
|
+
marginTop: '20px',
|
|
872
|
+
marginBottom: '20px',
|
|
873
|
+
width: '100%'
|
|
874
|
+
},
|
|
875
|
+
children: [jsxs(Grid, {
|
|
876
|
+
size: {
|
|
877
|
+
xs: 4
|
|
878
|
+
},
|
|
879
|
+
children: [jsx(Typography, {
|
|
880
|
+
variant: "overline",
|
|
881
|
+
children: t('warning-list-row-event')
|
|
882
|
+
}), jsx(Typography, {
|
|
883
|
+
"data-testid": "event",
|
|
884
|
+
sx: {
|
|
885
|
+
fontWeight: 'normal'
|
|
886
|
+
},
|
|
887
|
+
variant: "subtitle2",
|
|
888
|
+
children: event || ''
|
|
889
|
+
})]
|
|
890
|
+
}), jsxs(Grid, {
|
|
891
|
+
size: {
|
|
892
|
+
xs: 4
|
|
893
|
+
},
|
|
894
|
+
children: [jsx(Typography, {
|
|
895
|
+
variant: "overline",
|
|
896
|
+
children: t('warning-list-row-severity')
|
|
897
|
+
}), jsx(Typography, {
|
|
898
|
+
"data-testid": "severity",
|
|
899
|
+
sx: {
|
|
900
|
+
fontWeight: 'normal'
|
|
901
|
+
},
|
|
902
|
+
variant: "subtitle2",
|
|
903
|
+
children: severity || ''
|
|
904
|
+
})]
|
|
905
|
+
}), jsxs(Grid, {
|
|
906
|
+
size: {
|
|
907
|
+
xs: 4
|
|
908
|
+
},
|
|
909
|
+
children: [jsx(Typography, {
|
|
910
|
+
variant: "overline",
|
|
911
|
+
children: t('warning-list-row-expires')
|
|
912
|
+
}), jsx(Typography, {
|
|
913
|
+
"data-testid": "expires",
|
|
914
|
+
sx: {
|
|
915
|
+
fontWeight: 'normal'
|
|
916
|
+
},
|
|
917
|
+
variant: "subtitle2",
|
|
918
|
+
children: expires ? dateUtils.dateToString(dateUtils.createDate(expires), "dd MMM yyyy, HH:mm 'UTC'") : t('warning-list-row-not-expired')
|
|
919
|
+
})]
|
|
920
|
+
})]
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
var WarningListRowCapConnect = function WarningListRowCapConnect(_ref) {
|
|
925
|
+
var _alert$languages;
|
|
926
|
+
var alert = _ref.alert,
|
|
927
|
+
capWarningPresets = _ref.capWarningPresets;
|
|
928
|
+
var _React$useState = React.useState(0),
|
|
929
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
930
|
+
languageIndex = _React$useState2[0],
|
|
931
|
+
setLanguageIndex = _React$useState2[1];
|
|
932
|
+
var alertHasLanguages = Boolean(alert === null || alert === void 0 || (_alert$languages = alert.languages) === null || _alert$languages === void 0 ? void 0 : _alert$languages.length);
|
|
933
|
+
var language = i18n.language;
|
|
934
|
+
React.useEffect(function () {
|
|
935
|
+
if (alert && alertHasLanguages) {
|
|
936
|
+
var foundLanguageIndex = findEventIndexInLanguage(language, alert.languages, capWarningPresets, alert.feedAddress);
|
|
937
|
+
setLanguageIndex(foundLanguageIndex);
|
|
938
|
+
}
|
|
939
|
+
}, [alert, language, alertHasLanguages, capWarningPresets]);
|
|
940
|
+
return jsx("div", {
|
|
941
|
+
children: alert && alertHasLanguages ? jsx(WarningListRowCap, {
|
|
942
|
+
event: alert.languages[languageIndex].event,
|
|
943
|
+
expires: alert.expires,
|
|
944
|
+
severity: alert.severity
|
|
945
|
+
}) : null
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
var WarningListCap = function WarningListCap(_ref) {
|
|
950
|
+
var capWarningPresets = _ref.capWarningPresets,
|
|
951
|
+
alerts = _ref.alerts,
|
|
952
|
+
_ref$isPending = _ref.isPending,
|
|
953
|
+
isPending = _ref$isPending === void 0 ? false : _ref$isPending;
|
|
954
|
+
var _useCapTranslation = useCapTranslation(),
|
|
955
|
+
t = _useCapTranslation.t;
|
|
956
|
+
return jsxs(Box$1, {
|
|
957
|
+
sx: {
|
|
958
|
+
width: '100%',
|
|
959
|
+
height: '100%',
|
|
960
|
+
display: 'flex'
|
|
961
|
+
},
|
|
962
|
+
children: [isPending ? jsx(LinearProgress, {
|
|
963
|
+
color: "secondary",
|
|
964
|
+
sx: {
|
|
965
|
+
position: 'absolute',
|
|
966
|
+
width: '100%'
|
|
967
|
+
}
|
|
968
|
+
}) : null, jsxs(Card, {
|
|
969
|
+
"data-testid": "warningList",
|
|
970
|
+
sx: {
|
|
971
|
+
justifyContent: 'center',
|
|
972
|
+
alignItems: 'center',
|
|
973
|
+
overflow: 'auto',
|
|
974
|
+
height: '95%',
|
|
975
|
+
width: '100%',
|
|
976
|
+
padding: '10px',
|
|
977
|
+
margin: '20px',
|
|
978
|
+
marginBottom: '10px',
|
|
979
|
+
position: 'relative'
|
|
980
|
+
},
|
|
981
|
+
children: [!isPending && !alerts.length && jsx(AlertBanner, {
|
|
982
|
+
severity: "warning",
|
|
983
|
+
title: "No results"
|
|
984
|
+
}), alerts.length > 0 && jsx(Box$1, {
|
|
985
|
+
sx: {
|
|
986
|
+
position: 'sticky',
|
|
987
|
+
top: 0,
|
|
988
|
+
width: '100%',
|
|
989
|
+
display: 'flex',
|
|
990
|
+
justifyContent: 'center'
|
|
991
|
+
},
|
|
992
|
+
children: jsx(AlertBanner, {
|
|
993
|
+
severity: "info",
|
|
994
|
+
title: t('warning-list-cap-alert-banner-title')
|
|
995
|
+
})
|
|
996
|
+
}), alerts.map(function (alert) {
|
|
997
|
+
return jsx(WarningListRowCapConnect, {
|
|
998
|
+
alert: alert,
|
|
999
|
+
capWarningPresets: capWarningPresets
|
|
1000
|
+
}, alert.identifier);
|
|
1001
|
+
})]
|
|
1002
|
+
})]
|
|
1003
|
+
});
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
var WarningListCapConnect = function WarningListCapConnect(_ref) {
|
|
1007
|
+
var capWarningPresets = _ref.capWarningPresets;
|
|
1008
|
+
var _useAllFeedAlerts = useAllFeedAlerts(capWarningPresets),
|
|
1009
|
+
feedAlerts = _useAllFeedAlerts.results,
|
|
1010
|
+
pending = _useAllFeedAlerts.pending;
|
|
1011
|
+
return jsx(WarningListCap, {
|
|
1012
|
+
alerts: feedAlerts.map(function (fa) {
|
|
1013
|
+
return fa.alert;
|
|
1014
|
+
}),
|
|
1015
|
+
capWarningPresets: capWarningPresets,
|
|
1016
|
+
isPending: pending
|
|
1017
|
+
});
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
var WarningListCapConnectWrapper = function WarningListCapConnectWrapper(_ref) {
|
|
1021
|
+
var productConfigKey = _ref.productConfigKey;
|
|
1022
|
+
var _useCapTranslation = useCapTranslation(),
|
|
1023
|
+
t = _useCapTranslation.t;
|
|
1024
|
+
var _useGetConfig = useGetConfig(productConfigKey),
|
|
1025
|
+
productConfig = _useGetConfig.data,
|
|
1026
|
+
isPending = _useGetConfig.isPending,
|
|
1027
|
+
error = _useGetConfig.error;
|
|
1028
|
+
if (isPending) {
|
|
1029
|
+
return jsx(Box, {
|
|
1030
|
+
sx: {
|
|
1031
|
+
display: 'flex',
|
|
1032
|
+
justifyContent: 'center',
|
|
1033
|
+
alignItems: 'center'
|
|
1034
|
+
},
|
|
1035
|
+
children: jsx(CircularProgress, {
|
|
1036
|
+
"data-testid": "loadingSpinner"
|
|
1037
|
+
})
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
if (error) {
|
|
1041
|
+
return jsx(AlertBanner, {
|
|
1042
|
+
info: error.message,
|
|
1043
|
+
title: t('warning-list-cap-error-title')
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
return jsx(WarningListCapConnect, {
|
|
1047
|
+
capWarningPresets: productConfig
|
|
1048
|
+
});
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* The lookup table is for registering your own components with the workspace.
|
|
1053
|
+
* @param payload
|
|
1054
|
+
* @returns
|
|
1055
|
+
*/
|
|
1056
|
+
var ComponentsLookUp = function ComponentsLookUp(_ref) {
|
|
1057
|
+
var componentType = _ref.componentType,
|
|
1058
|
+
initialProps = _ref.initialProps,
|
|
1059
|
+
productConfigKey = _ref.productConfigKey,
|
|
1060
|
+
id = _ref.id;
|
|
1061
|
+
switch (componentType) {
|
|
1062
|
+
case 'CapWarningMap':
|
|
1063
|
+
{
|
|
1064
|
+
var _initialProps$mapPres, _initialProps$mapPres2;
|
|
1065
|
+
return jsx(MapViewCapConnectWrapper, {
|
|
1066
|
+
bbox: (_initialProps$mapPres = initialProps.mapPreset.proj) === null || _initialProps$mapPres === void 0 ? void 0 : _initialProps$mapPres.bbox,
|
|
1067
|
+
id: id,
|
|
1068
|
+
layers: initialProps.mapPreset.layers,
|
|
1069
|
+
productConfigKey: productConfigKey,
|
|
1070
|
+
srs: (_initialProps$mapPres2 = initialProps.mapPreset.proj) === null || _initialProps$mapPres2 === void 0 ? void 0 : _initialProps$mapPres2.srs
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
case 'CapWarningList':
|
|
1074
|
+
{
|
|
1075
|
+
return jsx(WarningListCapConnectWrapper, {
|
|
1076
|
+
productConfigKey: productConfigKey
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
default:
|
|
1080
|
+
return null;
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
/* *
|
|
1085
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1086
|
+
* you may not use this file except in compliance with the License.
|
|
1087
|
+
* You may obtain a copy of the License at
|
|
1088
|
+
*
|
|
1089
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1090
|
+
*
|
|
1091
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1092
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1093
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1094
|
+
* See the License for the specific language governing permissions and
|
|
1095
|
+
* limitations under the License.
|
|
1096
|
+
*
|
|
1097
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1098
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
1099
|
+
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
1100
|
+
* */
|
|
1101
|
+
var capReducersMap = {
|
|
1102
|
+
webmap: mapReducer,
|
|
1103
|
+
services: serviceReducer,
|
|
1104
|
+
layers: layerReducer,
|
|
1105
|
+
syncGroups: syncGroupsReducer
|
|
1106
|
+
};
|
|
1107
|
+
var capMiddlewares = [mapListener.middleware, serviceListener.middleware, layersListener.middleware, syncGroupsListener.middleware, genericListener.middleware, openlayersListener.middleware];
|
|
1108
|
+
var capRootReducer = combineReducers(capReducersMap);
|
|
1109
|
+
var createMockStore = function createMockStore(mockState) {
|
|
1110
|
+
return configureStore({
|
|
1111
|
+
reducer: capRootReducer,
|
|
1112
|
+
preloadedState: mockState,
|
|
1113
|
+
middleware: function middleware(getDefaultMiddleware) {
|
|
1114
|
+
return getDefaultMiddleware().concat(capMiddlewares);
|
|
1115
|
+
},
|
|
1116
|
+
devTools: true
|
|
1117
|
+
});
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
export { CAP_NAMESPACE, ComponentsLookUp, capTrans as capTranslations, createMockStore };
|