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

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