@eodash/eodash 5.0.0-alpha.2.9 → 5.0.0-rc

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.
Files changed (113) hide show
  1. package/README.md +1 -1
  2. package/core/client/App.vue +13 -1
  3. package/core/client/asWebComponent.js +13 -4
  4. package/core/client/components/DashboardLayout.vue +36 -14
  5. package/core/client/components/Loading.vue +6 -9
  6. package/core/client/components/MobileLayout.vue +16 -14
  7. package/core/client/composables/DefineEodash.js +14 -4
  8. package/core/client/composables/DefineTemplate.js +67 -0
  9. package/core/client/composables/DefineWidgets.js +3 -2
  10. package/core/client/composables/EodashMap.js +360 -0
  11. package/core/client/composables/EodashProcess.js +574 -0
  12. package/core/client/composables/index.js +136 -28
  13. package/core/client/eodash.js +395 -80
  14. package/core/client/eodashSTAC/EodashCollection.js +432 -0
  15. package/core/client/eodashSTAC/createLayers.js +315 -0
  16. package/core/client/eodashSTAC/helpers.js +375 -0
  17. package/core/client/eodashSTAC/triggers.js +43 -0
  18. package/core/client/plugins/axios.js +8 -0
  19. package/core/client/plugins/index.js +2 -1
  20. package/core/client/plugins/vuetify.js +2 -1
  21. package/core/client/store/actions.js +79 -0
  22. package/core/client/store/index.js +4 -18
  23. package/core/client/store/stac.js +99 -9
  24. package/core/client/store/states.js +37 -0
  25. package/core/client/{types.d.ts → types.ts} +66 -20
  26. package/core/client/utils/keys.js +2 -0
  27. package/core/client/utils/states.js +22 -0
  28. package/core/client/views/Dashboard.vue +22 -49
  29. package/core/client/vite-env.d.ts +2 -10
  30. package/dist/client/DashboardLayout-232tRmjz.js +84 -0
  31. package/dist/client/DynamicWebComponent-Cl4LqHU6.js +88 -0
  32. package/dist/client/EodashDatePicker-Pok6bZwU.js +306 -0
  33. package/dist/client/EodashItemFilter-16eMMjTV.js +151 -0
  34. package/dist/client/EodashLayerControl-De7IlCm_.js +120 -0
  35. package/dist/client/EodashLayoutSwitcher-C-3-jjn5.js +52 -0
  36. package/dist/client/EodashMap-CMvbfI6-.js +549 -0
  37. package/dist/client/EodashMapBtns-BeknGDtc.js +107 -0
  38. package/dist/client/EodashProcess-BwKAa9Ee.js +1476 -0
  39. package/dist/client/EodashStacInfo-_BfonNUG.js +85 -0
  40. package/dist/client/EodashTools-PD3XPYuR.js +103 -0
  41. package/dist/client/ExportState-DOrT7M15.js +644 -0
  42. package/dist/client/Footer-CCigxYBo.js +141 -0
  43. package/dist/client/Header-C2cdx4gb.js +437 -0
  44. package/dist/client/IframeWrapper-BgM9aU8f.js +28 -0
  45. package/dist/client/MobileLayout-BdiFjHg7.js +1207 -0
  46. package/dist/client/PopUp--_xn1Cms.js +410 -0
  47. package/dist/client/VImg-9xu2l99m.js +384 -0
  48. package/dist/client/VMain-BUs3kDTd.js +43 -0
  49. package/dist/client/VOverlay-D89omJis.js +1453 -0
  50. package/dist/client/VTooltip-CDu3bErh.js +86 -0
  51. package/dist/client/WidgetsContainer-aFG9yFT6.js +83 -0
  52. package/dist/client/asWebComponent-BRGyP_j5.js +11943 -0
  53. package/dist/client/{style.css → eo-dash.css} +2 -2
  54. package/dist/client/eo-dash.js +2 -6
  55. package/dist/client/forwardRefs-CYrR6bMw.js +245 -0
  56. package/dist/client/index-BZwk0V42.js +199 -0
  57. package/dist/client/ssrBoot-BP7SYRyC.js +22 -0
  58. package/dist/client/transition-DG9nRSW4.js +37 -0
  59. package/dist/node/cli.js +4 -4
  60. package/dist/node/types.d.ts +2 -0
  61. package/package.json +73 -38
  62. package/widgets/EodashDatePicker.vue +176 -134
  63. package/widgets/EodashItemFilter.vue +79 -38
  64. package/widgets/EodashLayerControl.vue +111 -0
  65. package/widgets/EodashLayoutSwitcher.vue +36 -0
  66. package/widgets/EodashMap.vue +108 -133
  67. package/widgets/EodashMapBtns.vue +62 -8
  68. package/widgets/EodashProcess.vue +143 -0
  69. package/widgets/EodashStacInfo.vue +82 -0
  70. package/widgets/EodashTools.vue +83 -0
  71. package/widgets/ExportState.vue +17 -13
  72. package/widgets/PopUp.vue +24 -2
  73. package/core/client/SuspensedDashboard.ce.vue +0 -105
  74. package/core/client/asWebComponent.d.ts +0 -23
  75. package/core/client/store/Actions.js +0 -14
  76. package/core/client/store/States.js +0 -16
  77. package/core/client/utils/eodashSTAC.js +0 -249
  78. package/core/client/utils/helpers.js +0 -38
  79. package/dist/client/DashboardLayout-D0ZF6V2S.js +0 -156
  80. package/dist/client/DynamicWebComponent-CPsMSBHi.js +0 -57
  81. package/dist/client/EodashDatePicker-CBQP7u2X.js +0 -252
  82. package/dist/client/EodashItemFilter-DL2ScI-5.js +0 -7671
  83. package/dist/client/EodashMap-CkKoQlmR.js +0 -86917
  84. package/dist/client/EodashMapBtns-yuO2QmiR.js +0 -36
  85. package/dist/client/ExportState-CCzOhppU.js +0 -558
  86. package/dist/client/Footer-BPAND0yG.js +0 -115
  87. package/dist/client/Header-DLhebNvG.js +0 -350
  88. package/dist/client/IframeWrapper-1GEMHlsW.js +0 -19
  89. package/dist/client/MobileLayout-mGkOYRhu.js +0 -945
  90. package/dist/client/PopUp-1d2bBFjw.js +0 -300
  91. package/dist/client/VImg-DxHcztfM.js +0 -291
  92. package/dist/client/VMain-BLX5vRRn.js +0 -39
  93. package/dist/client/VOverlay-CvrYEmLu.js +0 -967
  94. package/dist/client/WidgetsContainer-CmYjvGm7.js +0 -129
  95. package/dist/client/_commonjsHelpers-DaMA6jEr.js +0 -8
  96. package/dist/client/asWebComponent-B91uK0U7.js +0 -20361
  97. package/dist/client/basedecoder-DHcBySSe-BmCFNFnw.js +0 -88
  98. package/dist/client/decoder-CP4lv0Kb-B6yqkcfC.js +0 -10
  99. package/dist/client/deflate-BXt-9JA_-CWfClgpK.js +0 -10
  100. package/dist/client/eodashSTAC-DBjqe_Ho.js +0 -2788
  101. package/dist/client/eox-stacinfo-l7ALSV90.js +0 -13969
  102. package/dist/client/forwardRefs-BJJiadQP.js +0 -185
  103. package/dist/client/index-Q-bHLjxx.js +0 -153
  104. package/dist/client/jpeg-BAgeD1d3-oeHbFPUL.js +0 -514
  105. package/dist/client/lerc-DzVumYtB-P-KXC0TO.js +0 -1027
  106. package/dist/client/lzw-LAGDNbSC-DkP96qO9.js +0 -84
  107. package/dist/client/packbits-BlDR4Kj5-C66n1-zr.js +0 -24
  108. package/dist/client/pako.esm-CB1uQYY0-DB0PYm1P.js +0 -1081
  109. package/dist/client/raw-CMGvRjfu-BRi6E4i1.js +0 -9
  110. package/dist/client/ssrBoot-yo11mybw.js +0 -17
  111. package/dist/client/transition-CSJhuYGK.js +0 -34
  112. package/dist/client/webfontloader-qotgY98I.js +0 -435
  113. package/dist/client/webimage-BM_pbLN3-L2cGWK5l.js +0 -19
@@ -0,0 +1,574 @@
1
+ import { isMulti } from "@eox/jsonform/src/custom-inputs/spatial/utils";
2
+ import { nextTick, onMounted, watch } from "vue";
3
+ import mustache from "mustache";
4
+ import axios from "axios";
5
+ import { extractLayerConfig } from "@/eodashSTAC/helpers";
6
+ import log from "loglevel";
7
+ import { getLayers } from "@/store/actions";
8
+ import { mapEl } from "@/store/states";
9
+
10
+ /**
11
+ * Polls the process status and fetches a result item when the process is successful.
12
+ *
13
+ * @param {Object} params - Parameters for polling the process status.
14
+ * @param {string} params.processUrl - The URL of the process JSON report.
15
+ * @param {import("vue").Ref<boolean>} params.isPolling - checks wether the polling should continue
16
+ * @param {number} [params.pollInterval=5000] - The interval (in milliseconds) between polling attempts.
17
+ * @param {number} [params.maxRetries=60] - The maximum number of polling attempts.
18
+ * @returns {Promise<JSON>} The fetched results JSON.
19
+ * @throws {Error} If the process does not complete successfully within the maximum retries.
20
+ */
21
+ export async function pollProcessStatus({
22
+ processUrl,
23
+ isPolling,
24
+ pollInterval = 5000,
25
+ maxRetries = 60,
26
+ }) {
27
+ let retries = 0;
28
+ isPolling.value = true;
29
+ while (retries < maxRetries && isPolling.value) {
30
+ try {
31
+ // Fetch the process JSON report
32
+ const cacheBuster = new Date().getTime(); // Add a timestamp for cache busting
33
+ const response = await axios.get(`${processUrl}?t=${cacheBuster}`);
34
+ const processReport = response.data;
35
+
36
+ // Check if the status is "successful"
37
+ if (processReport.status === "successful") {
38
+ console.log("Process completed successfully. Fetching result item...");
39
+
40
+ // Extract the result item URL
41
+ const resultsUrl = processReport.links[1].href;
42
+ if (!resultsUrl) {
43
+ throw new Error(`Result links not found in the process report.`);
44
+ }
45
+
46
+ // Fetch the result item
47
+ const resultResponse = await axios.get(resultsUrl);
48
+ console.log("Result file fetched successfully:", resultResponse.data);
49
+ return resultResponse.data; // Return the json result list
50
+ }
51
+
52
+ // Log the current status if not successful
53
+ console.log(
54
+ `Status: ${processReport.status}. Retrying in ${pollInterval / 1000} seconds...`,
55
+ );
56
+ } catch (error) {
57
+ if (error instanceof Error) {
58
+ console.error("Error while polling process status:", error.message);
59
+ } else {
60
+ console.error("Unknown error occurred:", error);
61
+ }
62
+ }
63
+
64
+ // Wait for the next poll
65
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
66
+ retries++;
67
+ }
68
+ if (!isPolling.value) {
69
+ console.warn("Polling was stopped before the process was completed.");
70
+ return JSON.parse("{}");
71
+ }
72
+
73
+ throw new Error(
74
+ "Max retries reached. Process did not complete successfully.",
75
+ );
76
+ }
77
+
78
+ /**
79
+ * Auto execute the process when the jsonform has the execute option
80
+ *
81
+ * @param {import("vue").Ref<boolean>} autoExec
82
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
83
+ * @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
84
+ * @param {() => Promise<void>} startProcess
85
+ **/
86
+ export function useAutoExec(
87
+ autoExec,
88
+ jsonformEl,
89
+ jsonformSchema,
90
+ startProcess,
91
+ ) {
92
+ /**
93
+ * @param {CustomEvent} _e
94
+ **/
95
+ const onJsonFormChange = async (_e) => {
96
+ await startProcess();
97
+ };
98
+
99
+ const addEventListener = async () => {
100
+ await nextTick(() => {
101
+ //@ts-expect-error TODO
102
+ jsonformEl.value?.addEventListener("change", onJsonFormChange);
103
+ });
104
+ };
105
+ const removeEventListener = () => {
106
+ //@ts-expect-error TODO
107
+ jsonformEl.value?.removeEventListener("change", onJsonFormChange);
108
+ };
109
+
110
+ watch(jsonformSchema, (updatedSchema) => {
111
+ autoExec.value = updatedSchema?.options?.["execute"] || false;
112
+ });
113
+
114
+ onMounted(() => {
115
+ watch(
116
+ autoExec,
117
+ async (exec) => {
118
+ if (exec) {
119
+ await addEventListener();
120
+ } else {
121
+ removeEventListener();
122
+ }
123
+ },
124
+ { immediate: true },
125
+ );
126
+ });
127
+ }
128
+
129
+ /**
130
+ * @param {Record<string,any> |null} [jsonformSchema]
131
+ **/
132
+ export function getBboxProperty(jsonformSchema) {
133
+ return /** @type {string} */ (
134
+ Object.keys(jsonformSchema?.properties ?? {}).find(
135
+ (key) => jsonformSchema?.properties[key].format === "bounding-box",
136
+ )
137
+ );
138
+ }
139
+
140
+ /**
141
+ * Extracts the keys of type "geojson" from the jsonform schema
142
+ * @param {Record<string,any> |null} [jsonformSchema]
143
+ **/
144
+ export function getGeoJsonProperties(jsonformSchema) {
145
+ return /** @type {string[]} */ (
146
+ Object.keys(jsonformSchema?.properties ?? {}).filter(
147
+ (key) => jsonformSchema?.properties[key].type === "geojson",
148
+ )
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Converts jsonform geojson values to stringified geometries
154
+ * @param {Record<string,any> |null} [jsonformSchema]
155
+ * @param {Record<string,any>} jsonformValue
156
+ **/
157
+ export function extractGeometries(jsonformValue, jsonformSchema) {
158
+ const geojsonKeys = getGeoJsonProperties(jsonformSchema);
159
+
160
+ for (const key of geojsonKeys) {
161
+ if (!jsonformValue[key]) {
162
+ continue;
163
+ }
164
+
165
+ if (isMulti(jsonformSchema?.properties[key])) {
166
+ // jsonformValue[key] is a feature collection
167
+ jsonformValue[key] =
168
+ /** @type {import("ol/format/GeoJSON").GeoJSONFeatureCollection} */ (
169
+ jsonformValue[key]
170
+ ).features.map((feature) => JSON.stringify(feature.geometry));
171
+ } else {
172
+ // jsonformValue[key] is a single feature
173
+ jsonformValue[key] = JSON.stringify(jsonformValue[key].geometry);
174
+ }
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Injects CSS to remove the borders of the jsonform from inside the shadowRoot
180
+ * @param {import("@eox/jsonform").EOxJSONForm | null} jsonFormEl
181
+ **/
182
+ export function injectJsonformCSS(jsonFormEl) {
183
+ if (!jsonFormEl?.shadowRoot) {
184
+ console.error("jsonform has no shadowRoot");
185
+ return;
186
+ }
187
+ const stylesheet = new CSSStyleSheet();
188
+ stylesheet.replaceSync(`.je-indented-panel {
189
+ border: none !important;
190
+ }`);
191
+ jsonFormEl.shadowRoot.adoptedStyleSheets = [stylesheet];
192
+ }
193
+
194
+ /**
195
+ * @param {import("stac-ts").StacLink[] | undefined} links
196
+ * @param {Record<string,any>|undefined} jsonformValue
197
+ * @param {number[]} origBbox
198
+ */
199
+ export function processImage(links, jsonformValue, origBbox) {
200
+ if (!links) return;
201
+ const imageLinks = links.filter(
202
+ (link) => link.rel === "service" && link.type === "image/png",
203
+ );
204
+ const layers = [];
205
+ for (const link of imageLinks) {
206
+ layers.push({
207
+ type: "Image",
208
+ properties: {
209
+ id: link.id,
210
+ title: "Results " + link.id,
211
+ },
212
+ source: {
213
+ type: "ImageStatic",
214
+ imageExtent: origBbox,
215
+ url: mustache.render(link.href, {
216
+ ...(jsonformValue ?? {}),
217
+ }),
218
+ },
219
+ });
220
+ }
221
+ return layers;
222
+ }
223
+
224
+ /**
225
+ * @param {import("stac-ts").StacLink[] | undefined} links
226
+ * @param {Record<string,any> | undefined} jsonformValue
227
+ * @param {string} layerId
228
+ */
229
+ export async function processVector(links, jsonformValue, layerId) {
230
+ if (!links) return;
231
+ /** @type {Record<string,any>[]} */
232
+ const layers = [];
233
+ const vectorLinks = links.filter(
234
+ (link) => link.rel === "service" && link.type === "application/geo+json",
235
+ );
236
+ if (vectorLinks.length === 0) return layers;
237
+
238
+ let flatStyleJSON = null;
239
+
240
+ for (const link of vectorLinks) {
241
+ if ("eox:flatstyle" in (link ?? {})) {
242
+ flatStyleJSON = await axios
243
+ .get(/** @type {string} */ (link["eox:flatstyle"]))
244
+ .then((resp) => resp.data);
245
+ }
246
+
247
+ /** @type {Record<string,any>|undefined} */
248
+ let layerConfig;
249
+ /** @type {Record<string,any>|undefined} */
250
+ let style;
251
+ if (flatStyleJSON) {
252
+ const extracted = extractLayerConfig(flatStyleJSON);
253
+ layerConfig = extracted.layerConfig;
254
+ style = extracted.style;
255
+ }
256
+
257
+ layers.push({
258
+ type: "Vector",
259
+ source: {
260
+ type: "Vector",
261
+ url: mustache.render(link.href, {
262
+ ...(jsonformValue ?? {}),
263
+ }),
264
+ format: "GeoJSON",
265
+ },
266
+ properties: {
267
+ id: layerId + "_vector_process",
268
+ title: "Results " + layerId,
269
+ ...(layerConfig && { ...layerConfig, ...(style && { style: style }) }),
270
+ },
271
+ });
272
+ }
273
+ return layers;
274
+ }
275
+
276
+ /**
277
+ * @param {import("stac-ts").StacLink[] | undefined} links
278
+ * @param {Record<string,any> | undefined} jsonformValue
279
+ * @param {import("vue").Ref<boolean>} isPolling
280
+ * @param {string} layerId
281
+ */
282
+ export async function processGeoTiff(links, jsonformValue, layerId, isPolling) {
283
+ if (!links) return;
284
+ const geotiffLinks = links.filter(
285
+ (link) => link.rel === "service" && link.type === "image/tiff",
286
+ );
287
+ let urls = [];
288
+ let flatStyleJSON = null;
289
+ for (const link of geotiffLinks ?? []) {
290
+ if (link.endpoint === "eoxhub_workspaces") {
291
+ // TODO: prove of concept, needs to be reworked for sure
292
+ // Special handling for eoxhub workspace process endpoints
293
+ const postBody = await axios
294
+ .get(/** @type {string} */ (link["body"]), { responseType: "text" })
295
+ .then((resp) => resp.data);
296
+ const jsonData = JSON.parse(
297
+ mustache.render(postBody, { ...(jsonformValue ?? {}) }),
298
+ );
299
+ try {
300
+ const responseProcess = await axios.post(link.href, jsonData, {
301
+ headers: {
302
+ "Content-Type": "application/json",
303
+ },
304
+ });
305
+ console.log(responseProcess.headers.location);
306
+ await pollProcessStatus({
307
+ processUrl: responseProcess.headers.location,
308
+ isPolling,
309
+ })
310
+ .then((resultItem) => {
311
+ // @ts-expect-error we have currently no definition of what is allowed as response
312
+ const resultUrls = resultItem?.urls;
313
+ if (!resultUrls?.length) {
314
+ return;
315
+ }
316
+
317
+ urls.push(resultUrls[0]);
318
+ })
319
+ .catch((error) => {
320
+ if (error instanceof Error) {
321
+ console.error("Polling failed:", error.message);
322
+ } else {
323
+ console.error("Unknown error occurred during polling:", error);
324
+ }
325
+ });
326
+ } catch (error) {
327
+ if (error instanceof Error) {
328
+ console.error("Error sending POST request:", error.message);
329
+ } else {
330
+ console.error("Unknown error occurred:", error);
331
+ }
332
+ }
333
+ } else {
334
+ urls.push(mustache.render(link.href, { ...(jsonformValue ?? {}) }));
335
+ }
336
+ if ("eox:flatstyle" in (link ?? {})) {
337
+ flatStyleJSON = await axios
338
+ .get(/** @type {string} */ (link["eox:flatstyle"]))
339
+ .then((resp) => resp.data);
340
+ }
341
+ }
342
+ /** @type {Record<string,any>|undefined} */
343
+ let layerConfig;
344
+ /** @type {Record<string,any>|undefined} */
345
+ let style;
346
+ if (flatStyleJSON) {
347
+ const extracted = extractLayerConfig(flatStyleJSON);
348
+ layerConfig = extracted.layerConfig;
349
+ style = extracted.style;
350
+ }
351
+ return urls.length
352
+ ? {
353
+ type: "WebGLTile",
354
+ source: {
355
+ type: "GeoTIFF",
356
+ normalize: !style,
357
+ sources: urls.map((url) => ({ url })),
358
+ },
359
+ properties: {
360
+ id: layerId + "_geotiff_process",
361
+ title: "Results " + layerId,
362
+ ...(layerConfig && { layerConfig: layerConfig }),
363
+ },
364
+ ...(style && { style: style }),
365
+ }
366
+ : undefined;
367
+ }
368
+
369
+ /**
370
+ * @param {import("stac-ts").StacLink[] | undefined} links
371
+ * @param {Record<string,any> | undefined} jsonformValue
372
+ * @param {string} specUrl
373
+ * @returns {Promise<[import("vega").Spec|null,Record<string,any>|null]>}
374
+ **/
375
+ export async function getChartValues(links, jsonformValue, specUrl) {
376
+ if (!specUrl || !links) return [null, null];
377
+ /** @type {import("vega").Spec} */
378
+ const spec = await axios.get(specUrl).then((resp) => {
379
+ return resp.data;
380
+ });
381
+ // //@ts-expect-error NamedData
382
+ // const dataName = spec?.data?.name;
383
+ const dataLinks = links.filter(
384
+ (link) => link.rel === "service", // && dataName && link.id === dataName,
385
+ );
386
+
387
+ /** @type {Record<string,any>} */
388
+ const dataValues = {};
389
+ for (const link of dataLinks ?? []) {
390
+ if (link.type && ["application/json", "text/csv"].includes(link.type)) {
391
+ const dataUrl = mustache.render(link.href, {
392
+ ...(jsonformValue ?? {}),
393
+ ...(link["eox:flatstyle"] ?? {}),
394
+ });
395
+ // Wait for data to be retrieved
396
+ const data = await axios.get(dataUrl).then((resp) => {
397
+ return resp.data;
398
+ });
399
+ // @ts-expect-error we assume data to exist in spec
400
+ spec.data.values = data;
401
+ continue;
402
+ }
403
+
404
+ dataValues[/** @type {string} */ (link.id)] = await axios
405
+ .get(
406
+ mustache.render(link.href, {
407
+ ...(jsonformValue ?? {}),
408
+ ...(link["eox:flatstyle"] ?? {}),
409
+ }),
410
+ )
411
+ .then((resp) => resp.data);
412
+ }
413
+ return [spec, dataValues];
414
+ }
415
+
416
+ /**
417
+ * @param {Object} params
418
+ * @param {import("vue").Ref<boolean>} params.loading
419
+ * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
420
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
421
+ * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
422
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
423
+ * @param {import("vue").Ref<Record<string, any> | null>} params.chartData
424
+ * @param {import("vue").Ref<boolean>} params.isPolling
425
+ */
426
+ export async function handleProcesses({
427
+ loading,
428
+ selectedStac,
429
+ jsonformEl,
430
+ jsonformSchema,
431
+ chartSpec,
432
+ chartData,
433
+ isPolling,
434
+ }) {
435
+ log.debug("Processing...");
436
+ loading.value = true;
437
+ try {
438
+ const serviceLinks = selectedStac.value?.links?.filter(
439
+ (l) => l.rel === "service",
440
+ );
441
+ const bboxProperty = getBboxProperty(jsonformSchema.value);
442
+ const jsonformValue = /** @type {Record<string,any>} */ (
443
+ jsonformEl.value?.value
444
+ );
445
+
446
+ extractGeometries(jsonformValue, jsonformSchema.value);
447
+
448
+ const origBbox = jsonformValue[bboxProperty];
449
+
450
+ const specUrl = /** @type {string} */ (
451
+ selectedStac.value?.["eodash:vegadefinition"]
452
+ );
453
+
454
+ [chartSpec.value, chartData.value] = await getChartValues(
455
+ serviceLinks,
456
+ { ...(jsonformValue ?? {}) },
457
+ specUrl,
458
+ );
459
+ if (chartSpec.value && !("background" in chartSpec.value)) {
460
+ chartSpec.value["background"] = "transparent";
461
+ }
462
+ const geotiffLayer = await processGeoTiff(
463
+ serviceLinks,
464
+ jsonformValue,
465
+ selectedStac.value?.id ?? "",
466
+ isPolling,
467
+ );
468
+ const vectorLayers = await processVector(
469
+ serviceLinks,
470
+ jsonformValue,
471
+ selectedStac.value?.id ?? "",
472
+ );
473
+
474
+ const imageLayers = processImage(serviceLinks, jsonformValue, origBbox);
475
+
476
+ log.debug(
477
+ "rendered layers after processing:",
478
+ geotiffLayer,
479
+ vectorLayers,
480
+ imageLayers,
481
+ );
482
+
483
+ if (geotiffLayer || vectorLayers?.length || imageLayers?.length) {
484
+ const layers = [
485
+ ...(geotiffLayer ? [geotiffLayer] : []),
486
+ ...(vectorLayers ?? []),
487
+ ...(imageLayers ?? []),
488
+ ];
489
+ let currentLayers = [...getLayers()];
490
+ let analysisGroup = currentLayers.find((l) =>
491
+ l.properties.id.includes("AnalysisGroup"),
492
+ );
493
+ analysisGroup?.layers.push(...layers);
494
+
495
+ if (mapEl.value) {
496
+ mapEl.value.layers = [...currentLayers];
497
+ }
498
+ }
499
+ loading.value = false;
500
+ } catch (error) {
501
+ console.error("[eodash] Error while running process:", error);
502
+ loading.value = false;
503
+ throw error;
504
+ }
505
+ }
506
+
507
+ /**
508
+ * Reset the process state
509
+ * @param {Object} params
510
+ * @param {import("vue").Ref<boolean>} params.loading
511
+ * @param {import("vue").Ref<boolean>} params.isProcessed
512
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
513
+ * @param {import("vue").Ref<boolean>} params.isPolling
514
+ * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
515
+ */
516
+ export function resetProcess({
517
+ loading,
518
+ isProcessed,
519
+ chartSpec,
520
+ jsonformSchema,
521
+ isPolling,
522
+ }) {
523
+ loading.value = false;
524
+ isProcessed.value = false;
525
+ isPolling.value = false;
526
+ chartSpec.value = null;
527
+ jsonformSchema.value = null;
528
+ }
529
+
530
+ /**
531
+ * Description placeholder
532
+ *
533
+ * @export
534
+ * @async
535
+ * @param {Object} params
536
+ * @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
537
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
538
+ * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
539
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
540
+ * @param {import("vue").Ref<boolean>} params.isProcessed
541
+ * @param {import("vue").Ref<boolean>} params.loading
542
+ * @param {import("vue").Ref<boolean>} params.isPolling
543
+ */
544
+ export async function initProcess({
545
+ selectedStac,
546
+ jsonformEl,
547
+ jsonformSchema,
548
+ chartSpec,
549
+ isProcessed,
550
+ loading,
551
+ isPolling,
552
+ }) {
553
+ if (!selectedStac.value) {
554
+ return;
555
+ }
556
+ resetProcess({ loading, isProcessed, chartSpec, jsonformSchema, isPolling });
557
+ if (selectedStac.value["eodash:jsonform"]) {
558
+ jsonformEl.value?.editor.destroy();
559
+ // wait for the layers to be rendered
560
+ jsonformSchema.value = await axios
561
+ //@ts-expect-error eodash extention
562
+ .get(selectedStac.value["eodash:jsonform"])
563
+ .then((resp) => resp.data);
564
+ // remove borders from jsonform
565
+ await nextTick(() => {
566
+ injectJsonformCSS(jsonformEl.value);
567
+ });
568
+ } else {
569
+ if (!jsonformSchema.value) {
570
+ return;
571
+ }
572
+ jsonformSchema.value = null;
573
+ }
574
+ }