@eodash/eodash 5.0.0-rc → 5.0.0-rc.1.5

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 (78) hide show
  1. package/core/client/eodashSTAC/createLayers.js +4 -3
  2. package/dist/client/{DashboardLayout-232tRmjz.js → DashboardLayout-B-4X57-t.js} +2 -2
  3. package/dist/client/{DynamicWebComponent-Cl4LqHU6.js → DynamicWebComponent-Dj3QYwag.js} +1 -1
  4. package/dist/client/{EodashDatePicker-Pok6bZwU.js → EodashDatePicker-DGRJrJ0s.js} +2 -2
  5. package/dist/client/{EodashItemFilter-16eMMjTV.js → EodashItemFilter-DBQwJQPh.js} +1 -1
  6. package/dist/client/{EodashLayerControl-De7IlCm_.js → EodashLayerControl-C5fOCvoI.js} +1 -1
  7. package/dist/client/{EodashLayoutSwitcher-C-3-jjn5.js → EodashLayoutSwitcher-BMO9k_20.js} +2 -2
  8. package/dist/client/{EodashMap-CMvbfI6-.js → EodashMap-D2bnMLAC.js} +1 -1
  9. package/dist/client/{EodashMapBtns-BeknGDtc.js → EodashMapBtns-l9B977id.js} +4 -4
  10. package/dist/client/EodashProcess-BtIlJvF1.js +714 -0
  11. package/dist/client/{EodashStacInfo-_BfonNUG.js → EodashStacInfo-CPVvp_Hm.js} +1 -1
  12. package/dist/client/{EodashTools-PD3XPYuR.js → EodashTools-DY2dlNXW.js} +4 -4
  13. package/dist/client/{ExportState-DOrT7M15.js → ExportState-BvD5A0XG.js} +13 -13
  14. package/dist/client/{Footer-CCigxYBo.js → Footer-w95gBnSH.js} +1 -1
  15. package/dist/client/{Header-C2cdx4gb.js → Header-BpiorKy9.js} +3 -3
  16. package/dist/client/{MobileLayout-BdiFjHg7.js → MobileLayout-CmVlZe7S.js} +5 -5
  17. package/dist/client/{PopUp--_xn1Cms.js → PopUp-CREaSybs.js} +3 -3
  18. package/dist/client/{VImg-9xu2l99m.js → VImg-DF9esgdd.js} +2 -2
  19. package/dist/client/{VMain-BUs3kDTd.js → VMain-BWLMf-rn.js} +1 -1
  20. package/dist/client/{VOverlay-D89omJis.js → VOverlay-DmNfblmy.js} +3 -3
  21. package/dist/client/{VTooltip-CDu3bErh.js → VTooltip-C3PeE7iO.js} +3 -3
  22. package/dist/client/{WidgetsContainer-aFG9yFT6.js → WidgetsContainer-6FHEEXns.js} +1 -1
  23. package/dist/client/{asWebComponent-BRGyP_j5.js → asWebComponent-BnFMd0T6.js} +10 -9
  24. package/dist/client/eo-dash.css +1 -1
  25. package/dist/client/eo-dash.js +1 -1
  26. package/dist/client/{forwardRefs-CYrR6bMw.js → forwardRefs-BF3Me2RX.js} +1 -1
  27. package/dist/client/{index-BZwk0V42.js → index-CRd5-RSy.js} +1 -1
  28. package/dist/client/{transition-DG9nRSW4.js → transition-Cpn_g5jE.js} +1 -1
  29. package/dist/types/core/client/App.vue.d.ts +7 -0
  30. package/dist/types/core/client/asWebComponent.d.ts +9 -0
  31. package/dist/types/core/client/components/DashboardLayout.vue.d.ts +2 -0
  32. package/dist/types/core/client/components/DynamicWebComponent.vue.d.ts +20 -0
  33. package/dist/types/core/client/components/ErrorAlert.vue.d.ts +2 -0
  34. package/dist/types/core/client/components/Footer.vue.d.ts +106 -0
  35. package/dist/types/core/client/components/Header.vue.d.ts +2 -0
  36. package/dist/types/core/client/components/IframeWrapper.vue.d.ts +7 -0
  37. package/dist/types/core/client/components/Loading.vue.d.ts +2 -0
  38. package/dist/types/core/client/components/MobileLayout.vue.d.ts +312 -0
  39. package/dist/types/core/client/composables/DefineEodash.d.ts +2 -0
  40. package/dist/types/core/client/composables/DefineTemplate.d.ts +15 -0
  41. package/dist/types/core/client/composables/DefineWidgets.d.ts +14 -0
  42. package/dist/types/core/client/composables/EodashMap.d.ts +5 -0
  43. package/dist/types/core/client/composables/EodashProcess.d.ts +156 -0
  44. package/dist/types/core/client/composables/index.d.ts +9 -0
  45. package/dist/types/core/client/eodash.d.ts +8 -0
  46. package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +108 -0
  47. package/dist/types/core/client/eodashSTAC/createLayers.d.ts +45 -0
  48. package/dist/types/core/client/eodashSTAC/helpers.d.ts +80 -0
  49. package/dist/types/core/client/eodashSTAC/triggers.d.ts +1 -0
  50. package/dist/types/core/client/main.d.ts +2 -0
  51. package/dist/types/core/client/plugins/axios.d.ts +2 -0
  52. package/dist/types/core/client/plugins/index.d.ts +3 -0
  53. package/dist/types/core/client/plugins/vuetify.d.ts +82 -0
  54. package/dist/types/core/client/render.d.ts +1 -0
  55. package/dist/types/core/client/store/actions.d.ts +12 -0
  56. package/dist/types/core/client/store/index.d.ts +11 -0
  57. package/dist/types/core/client/store/stac.d.ts +25 -0
  58. package/dist/types/core/client/store/states.d.ts +22 -0
  59. package/dist/types/core/client/types.d.ts +269 -0
  60. package/dist/types/core/client/utils/index.d.ts +2 -0
  61. package/dist/types/core/client/utils/keys.d.ts +8 -0
  62. package/dist/types/core/client/utils/states.d.ts +18 -0
  63. package/dist/types/core/client/views/Dashboard.vue.d.ts +9 -0
  64. package/dist/types/widgets/EodashDatePicker.vue.d.ts +13 -0
  65. package/dist/types/widgets/EodashItemFilter.vue.d.ts +44 -0
  66. package/dist/types/widgets/EodashLayerControl.vue.d.ts +13 -0
  67. package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +11 -0
  68. package/dist/types/widgets/EodashMap.vue.d.ts +14 -0
  69. package/dist/types/widgets/EodashMapBtns.vue.d.ts +13 -0
  70. package/dist/types/widgets/EodashProcess.vue.d.ts +4 -0
  71. package/dist/types/widgets/EodashStacInfo.vue.d.ts +21 -0
  72. package/dist/types/widgets/EodashTools.vue.d.ts +19 -0
  73. package/dist/types/widgets/ExportState.vue.d.ts +7 -0
  74. package/dist/types/widgets/PopUp.vue.d.ts +28 -0
  75. package/dist/types/widgets/WidgetsContainer.vue.d.ts +10 -0
  76. package/package.json +5 -8
  77. package/widgets/ExportState.vue +10 -10
  78. package/dist/client/EodashProcess-BwKAa9Ee.js +0 -1476
@@ -0,0 +1,714 @@
1
+ import { watch, onMounted, nextTick, ref, openBlock, createElementBlock, createCommentVNode, toRaw, createElementVNode, createBlock, withCtx, createTextVNode } from 'vue';
2
+ import '@eox/chart';
3
+ import '@eox/drawtools';
4
+ import '@eox/jsonform';
5
+ import { af as axios, ag as getLayers, a3 as mapEl, ah as extractLayerConfig, aa as eoxLayersKey, $ as useSTAcStore, ai as useOnLayersUpdate, V as VBtn } from './asWebComponent-BnFMd0T6.js';
6
+ import { storeToRefs } from 'pinia';
7
+ import { useEventBus } from '@vueuse/core';
8
+ import { isMulti } from '@eox/jsonform/src/custom-inputs/spatial/utils';
9
+ import mustache from 'mustache';
10
+ import log from 'loglevel';
11
+
12
+ /**
13
+ * Polls the process status and fetches a result item when the process is successful.
14
+ *
15
+ * @param {Object} params - Parameters for polling the process status.
16
+ * @param {string} params.processUrl - The URL of the process JSON report.
17
+ * @param {import("vue").Ref<boolean>} params.isPolling - checks wether the polling should continue
18
+ * @param {number} [params.pollInterval=5000] - The interval (in milliseconds) between polling attempts.
19
+ * @param {number} [params.maxRetries=60] - The maximum number of polling attempts.
20
+ * @returns {Promise<JSON>} The fetched results JSON.
21
+ * @throws {Error} If the process does not complete successfully within the maximum retries.
22
+ */
23
+ async function pollProcessStatus({
24
+ processUrl,
25
+ isPolling,
26
+ pollInterval = 5000,
27
+ maxRetries = 60,
28
+ }) {
29
+ let retries = 0;
30
+ isPolling.value = true;
31
+ while (retries < maxRetries && isPolling.value) {
32
+ try {
33
+ // Fetch the process JSON report
34
+ const cacheBuster = new Date().getTime(); // Add a timestamp for cache busting
35
+ const response = await axios.get(`${processUrl}?t=${cacheBuster}`);
36
+ const processReport = response.data;
37
+
38
+ // Check if the status is "successful"
39
+ if (processReport.status === "successful") {
40
+ console.log("Process completed successfully. Fetching result item...");
41
+
42
+ // Extract the result item URL
43
+ const resultsUrl = processReport.links[1].href;
44
+ if (!resultsUrl) {
45
+ throw new Error(`Result links not found in the process report.`);
46
+ }
47
+
48
+ // Fetch the result item
49
+ const resultResponse = await axios.get(resultsUrl);
50
+ console.log("Result file fetched successfully:", resultResponse.data);
51
+ return resultResponse.data; // Return the json result list
52
+ }
53
+
54
+ // Log the current status if not successful
55
+ console.log(
56
+ `Status: ${processReport.status}. Retrying in ${pollInterval / 1000} seconds...`,
57
+ );
58
+ } catch (error) {
59
+ if (error instanceof Error) {
60
+ console.error("Error while polling process status:", error.message);
61
+ } else {
62
+ console.error("Unknown error occurred:", error);
63
+ }
64
+ }
65
+
66
+ // Wait for the next poll
67
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
68
+ retries++;
69
+ }
70
+ if (!isPolling.value) {
71
+ console.warn("Polling was stopped before the process was completed.");
72
+ return JSON.parse("{}");
73
+ }
74
+
75
+ throw new Error(
76
+ "Max retries reached. Process did not complete successfully.",
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Auto execute the process when the jsonform has the execute option
82
+ *
83
+ * @param {import("vue").Ref<boolean>} autoExec
84
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
85
+ * @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
86
+ * @param {() => Promise<void>} startProcess
87
+ **/
88
+ function useAutoExec(
89
+ autoExec,
90
+ jsonformEl,
91
+ jsonformSchema,
92
+ startProcess,
93
+ ) {
94
+ /**
95
+ * @param {CustomEvent} _e
96
+ **/
97
+ const onJsonFormChange = async (_e) => {
98
+ await startProcess();
99
+ };
100
+
101
+ const addEventListener = async () => {
102
+ await nextTick(() => {
103
+ //@ts-expect-error TODO
104
+ jsonformEl.value?.addEventListener("change", onJsonFormChange);
105
+ });
106
+ };
107
+ const removeEventListener = () => {
108
+ //@ts-expect-error TODO
109
+ jsonformEl.value?.removeEventListener("change", onJsonFormChange);
110
+ };
111
+
112
+ watch(jsonformSchema, (updatedSchema) => {
113
+ autoExec.value = updatedSchema?.options?.["execute"] || false;
114
+ });
115
+
116
+ onMounted(() => {
117
+ watch(
118
+ autoExec,
119
+ async (exec) => {
120
+ if (exec) {
121
+ await addEventListener();
122
+ } else {
123
+ removeEventListener();
124
+ }
125
+ },
126
+ { immediate: true },
127
+ );
128
+ });
129
+ }
130
+
131
+ /**
132
+ * @param {Record<string,any> |null} [jsonformSchema]
133
+ **/
134
+ function getBboxProperty(jsonformSchema) {
135
+ return /** @type {string} */ (
136
+ Object.keys(jsonformSchema?.properties ?? {}).find(
137
+ (key) => jsonformSchema?.properties[key].format === "bounding-box",
138
+ )
139
+ );
140
+ }
141
+
142
+ /**
143
+ * Extracts the keys of type "geojson" from the jsonform schema
144
+ * @param {Record<string,any> |null} [jsonformSchema]
145
+ **/
146
+ function getGeoJsonProperties(jsonformSchema) {
147
+ return /** @type {string[]} */ (
148
+ Object.keys(jsonformSchema?.properties ?? {}).filter(
149
+ (key) => jsonformSchema?.properties[key].type === "geojson",
150
+ )
151
+ );
152
+ }
153
+
154
+ /**
155
+ * Converts jsonform geojson values to stringified geometries
156
+ * @param {Record<string,any> |null} [jsonformSchema]
157
+ * @param {Record<string,any>} jsonformValue
158
+ **/
159
+ function extractGeometries(jsonformValue, jsonformSchema) {
160
+ const geojsonKeys = getGeoJsonProperties(jsonformSchema);
161
+
162
+ for (const key of geojsonKeys) {
163
+ if (!jsonformValue[key]) {
164
+ continue;
165
+ }
166
+
167
+ if (isMulti(jsonformSchema?.properties[key])) {
168
+ // jsonformValue[key] is a feature collection
169
+ jsonformValue[key] =
170
+ /** @type {import("ol/format/GeoJSON").GeoJSONFeatureCollection} */ (
171
+ jsonformValue[key]
172
+ ).features.map((feature) => JSON.stringify(feature.geometry));
173
+ } else {
174
+ // jsonformValue[key] is a single feature
175
+ jsonformValue[key] = JSON.stringify(jsonformValue[key].geometry);
176
+ }
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Injects CSS to remove the borders of the jsonform from inside the shadowRoot
182
+ * @param {import("@eox/jsonform").EOxJSONForm | null} jsonFormEl
183
+ **/
184
+ function injectJsonformCSS(jsonFormEl) {
185
+ if (!jsonFormEl?.shadowRoot) {
186
+ console.error("jsonform has no shadowRoot");
187
+ return;
188
+ }
189
+ const stylesheet = new CSSStyleSheet();
190
+ stylesheet.replaceSync(`.je-indented-panel {
191
+ border: none !important;
192
+ }`);
193
+ jsonFormEl.shadowRoot.adoptedStyleSheets = [stylesheet];
194
+ }
195
+
196
+ /**
197
+ * @param {import("stac-ts").StacLink[] | undefined} links
198
+ * @param {Record<string,any>|undefined} jsonformValue
199
+ * @param {number[]} origBbox
200
+ */
201
+ function processImage(links, jsonformValue, origBbox) {
202
+ if (!links) return;
203
+ const imageLinks = links.filter(
204
+ (link) => link.rel === "service" && link.type === "image/png",
205
+ );
206
+ const layers = [];
207
+ for (const link of imageLinks) {
208
+ layers.push({
209
+ type: "Image",
210
+ properties: {
211
+ id: link.id,
212
+ title: "Results " + link.id,
213
+ },
214
+ source: {
215
+ type: "ImageStatic",
216
+ imageExtent: origBbox,
217
+ url: mustache.render(link.href, {
218
+ ...(jsonformValue ?? {}),
219
+ }),
220
+ },
221
+ });
222
+ }
223
+ return layers;
224
+ }
225
+
226
+ /**
227
+ * @param {import("stac-ts").StacLink[] | undefined} links
228
+ * @param {Record<string,any> | undefined} jsonformValue
229
+ * @param {string} layerId
230
+ */
231
+ async function processVector(links, jsonformValue, layerId) {
232
+ if (!links) return;
233
+ /** @type {Record<string,any>[]} */
234
+ const layers = [];
235
+ const vectorLinks = links.filter(
236
+ (link) => link.rel === "service" && link.type === "application/geo+json",
237
+ );
238
+ if (vectorLinks.length === 0) return layers;
239
+
240
+ let flatStyleJSON = null;
241
+
242
+ for (const link of vectorLinks) {
243
+ if ("eox:flatstyle" in (link ?? {})) {
244
+ flatStyleJSON = await axios
245
+ .get(/** @type {string} */ (link["eox:flatstyle"]))
246
+ .then((resp) => resp.data);
247
+ }
248
+
249
+ /** @type {Record<string,any>|undefined} */
250
+ let layerConfig;
251
+ /** @type {Record<string,any>|undefined} */
252
+ let style;
253
+ if (flatStyleJSON) {
254
+ const extracted = extractLayerConfig(flatStyleJSON);
255
+ layerConfig = extracted.layerConfig;
256
+ style = extracted.style;
257
+ }
258
+
259
+ layers.push({
260
+ type: "Vector",
261
+ source: {
262
+ type: "Vector",
263
+ url: mustache.render(link.href, {
264
+ ...(jsonformValue ?? {}),
265
+ }),
266
+ format: "GeoJSON",
267
+ },
268
+ properties: {
269
+ id: layerId + "_vector_process",
270
+ title: "Results " + layerId,
271
+ ...(layerConfig && { ...layerConfig, ...(style && { style: style }) }),
272
+ },
273
+ });
274
+ }
275
+ return layers;
276
+ }
277
+
278
+ /**
279
+ * @param {import("stac-ts").StacLink[] | undefined} links
280
+ * @param {Record<string,any> | undefined} jsonformValue
281
+ * @param {import("vue").Ref<boolean>} isPolling
282
+ * @param {string} layerId
283
+ */
284
+ async function processGeoTiff(links, jsonformValue, layerId, isPolling) {
285
+ if (!links) return;
286
+ const geotiffLinks = links.filter(
287
+ (link) => link.rel === "service" && link.type === "image/tiff",
288
+ );
289
+ let urls = [];
290
+ let flatStyleJSON = null;
291
+ for (const link of geotiffLinks ?? []) {
292
+ if (link.endpoint === "eoxhub_workspaces") {
293
+ // TODO: prove of concept, needs to be reworked for sure
294
+ // Special handling for eoxhub workspace process endpoints
295
+ const postBody = await axios
296
+ .get(/** @type {string} */ (link["body"]), { responseType: "text" })
297
+ .then((resp) => resp.data);
298
+ const jsonData = JSON.parse(
299
+ mustache.render(postBody, { ...(jsonformValue ?? {}) }),
300
+ );
301
+ try {
302
+ const responseProcess = await axios.post(link.href, jsonData, {
303
+ headers: {
304
+ "Content-Type": "application/json",
305
+ },
306
+ });
307
+ console.log(responseProcess.headers.location);
308
+ await pollProcessStatus({
309
+ processUrl: responseProcess.headers.location,
310
+ isPolling,
311
+ })
312
+ .then((resultItem) => {
313
+ // @ts-expect-error we have currently no definition of what is allowed as response
314
+ const resultUrls = resultItem?.urls;
315
+ if (!resultUrls?.length) {
316
+ return;
317
+ }
318
+
319
+ urls.push(resultUrls[0]);
320
+ })
321
+ .catch((error) => {
322
+ if (error instanceof Error) {
323
+ console.error("Polling failed:", error.message);
324
+ } else {
325
+ console.error("Unknown error occurred during polling:", error);
326
+ }
327
+ });
328
+ } catch (error) {
329
+ if (error instanceof Error) {
330
+ console.error("Error sending POST request:", error.message);
331
+ } else {
332
+ console.error("Unknown error occurred:", error);
333
+ }
334
+ }
335
+ } else {
336
+ urls.push(mustache.render(link.href, { ...(jsonformValue ?? {}) }));
337
+ }
338
+ if ("eox:flatstyle" in (link ?? {})) {
339
+ flatStyleJSON = await axios
340
+ .get(/** @type {string} */ (link["eox:flatstyle"]))
341
+ .then((resp) => resp.data);
342
+ }
343
+ }
344
+ /** @type {Record<string,any>|undefined} */
345
+ let layerConfig;
346
+ /** @type {Record<string,any>|undefined} */
347
+ let style;
348
+ if (flatStyleJSON) {
349
+ const extracted = extractLayerConfig(flatStyleJSON);
350
+ layerConfig = extracted.layerConfig;
351
+ style = extracted.style;
352
+ }
353
+ return urls.length
354
+ ? {
355
+ type: "WebGLTile",
356
+ source: {
357
+ type: "GeoTIFF",
358
+ normalize: !style,
359
+ sources: urls.map((url) => ({ url })),
360
+ },
361
+ properties: {
362
+ id: layerId + "_geotiff_process",
363
+ title: "Results " + layerId,
364
+ ...(layerConfig && { layerConfig: layerConfig }),
365
+ },
366
+ ...(style && { style: style }),
367
+ }
368
+ : undefined;
369
+ }
370
+
371
+ /**
372
+ * @param {import("stac-ts").StacLink[] | undefined} links
373
+ * @param {Record<string,any> | undefined} jsonformValue
374
+ * @param {string} specUrl
375
+ * @returns {Promise<[import("vega").Spec|null,Record<string,any>|null]>}
376
+ **/
377
+ async function getChartValues(links, jsonformValue, specUrl) {
378
+ if (!specUrl || !links) return [null, null];
379
+ /** @type {import("vega").Spec} */
380
+ const spec = await axios.get(specUrl).then((resp) => {
381
+ return resp.data;
382
+ });
383
+ // //@ts-expect-error NamedData
384
+ // const dataName = spec?.data?.name;
385
+ const dataLinks = links.filter(
386
+ (link) => link.rel === "service", // && dataName && link.id === dataName,
387
+ );
388
+
389
+ /** @type {Record<string,any>} */
390
+ const dataValues = {};
391
+ for (const link of dataLinks ?? []) {
392
+ if (link.type && ["application/json", "text/csv"].includes(link.type)) {
393
+ const dataUrl = mustache.render(link.href, {
394
+ ...(jsonformValue ?? {}),
395
+ ...(link["eox:flatstyle"] ?? {}),
396
+ });
397
+ // Wait for data to be retrieved
398
+ const data = await axios.get(dataUrl).then((resp) => {
399
+ return resp.data;
400
+ });
401
+ // @ts-expect-error we assume data to exist in spec
402
+ spec.data.values = data;
403
+ continue;
404
+ }
405
+
406
+ dataValues[/** @type {string} */ (link.id)] = await axios
407
+ .get(
408
+ mustache.render(link.href, {
409
+ ...(jsonformValue ?? {}),
410
+ ...(link["eox:flatstyle"] ?? {}),
411
+ }),
412
+ )
413
+ .then((resp) => resp.data);
414
+ }
415
+ return [spec, dataValues];
416
+ }
417
+
418
+ /**
419
+ * @param {Object} params
420
+ * @param {import("vue").Ref<boolean>} params.loading
421
+ * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
422
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
423
+ * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
424
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
425
+ * @param {import("vue").Ref<Record<string, any> | null>} params.chartData
426
+ * @param {import("vue").Ref<boolean>} params.isPolling
427
+ */
428
+ async function handleProcesses({
429
+ loading,
430
+ selectedStac,
431
+ jsonformEl,
432
+ jsonformSchema,
433
+ chartSpec,
434
+ chartData,
435
+ isPolling,
436
+ }) {
437
+ log.debug("Processing...");
438
+ loading.value = true;
439
+ try {
440
+ const serviceLinks = selectedStac.value?.links?.filter(
441
+ (l) => l.rel === "service",
442
+ );
443
+ const bboxProperty = getBboxProperty(jsonformSchema.value);
444
+ const jsonformValue = /** @type {Record<string,any>} */ (
445
+ jsonformEl.value?.value
446
+ );
447
+
448
+ extractGeometries(jsonformValue, jsonformSchema.value);
449
+
450
+ const origBbox = jsonformValue[bboxProperty];
451
+
452
+ const specUrl = /** @type {string} */ (
453
+ selectedStac.value?.["eodash:vegadefinition"]
454
+ );
455
+
456
+ [chartSpec.value, chartData.value] = await getChartValues(
457
+ serviceLinks,
458
+ { ...(jsonformValue ?? {}) },
459
+ specUrl,
460
+ );
461
+ if (chartSpec.value && !("background" in chartSpec.value)) {
462
+ chartSpec.value["background"] = "transparent";
463
+ }
464
+ const geotiffLayer = await processGeoTiff(
465
+ serviceLinks,
466
+ jsonformValue,
467
+ selectedStac.value?.id ?? "",
468
+ isPolling,
469
+ );
470
+ const vectorLayers = await processVector(
471
+ serviceLinks,
472
+ jsonformValue,
473
+ selectedStac.value?.id ?? "",
474
+ );
475
+
476
+ const imageLayers = processImage(serviceLinks, jsonformValue, origBbox);
477
+
478
+ log.debug(
479
+ "rendered layers after processing:",
480
+ geotiffLayer,
481
+ vectorLayers,
482
+ imageLayers,
483
+ );
484
+
485
+ if (geotiffLayer || vectorLayers?.length || imageLayers?.length) {
486
+ const layers = [
487
+ ...(geotiffLayer ? [geotiffLayer] : []),
488
+ ...(vectorLayers ?? []),
489
+ ...(imageLayers ?? []),
490
+ ];
491
+ let currentLayers = [...getLayers()];
492
+ let analysisGroup = currentLayers.find((l) =>
493
+ l.properties.id.includes("AnalysisGroup"),
494
+ );
495
+ analysisGroup?.layers.push(...layers);
496
+
497
+ if (mapEl.value) {
498
+ mapEl.value.layers = [...currentLayers];
499
+ }
500
+ }
501
+ loading.value = false;
502
+ } catch (error) {
503
+ console.error("[eodash] Error while running process:", error);
504
+ loading.value = false;
505
+ throw error;
506
+ }
507
+ }
508
+
509
+ /**
510
+ * Reset the process state
511
+ * @param {Object} params
512
+ * @param {import("vue").Ref<boolean>} params.loading
513
+ * @param {import("vue").Ref<boolean>} params.isProcessed
514
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
515
+ * @param {import("vue").Ref<boolean>} params.isPolling
516
+ * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
517
+ */
518
+ function resetProcess({
519
+ loading,
520
+ isProcessed,
521
+ chartSpec,
522
+ jsonformSchema,
523
+ isPolling,
524
+ }) {
525
+ loading.value = false;
526
+ isProcessed.value = false;
527
+ isPolling.value = false;
528
+ chartSpec.value = null;
529
+ jsonformSchema.value = null;
530
+ }
531
+
532
+ /**
533
+ * Description placeholder
534
+ *
535
+ * @export
536
+ * @async
537
+ * @param {Object} params
538
+ * @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
539
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
540
+ * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
541
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
542
+ * @param {import("vue").Ref<boolean>} params.isProcessed
543
+ * @param {import("vue").Ref<boolean>} params.loading
544
+ * @param {import("vue").Ref<boolean>} params.isPolling
545
+ */
546
+ async function initProcess({
547
+ selectedStac,
548
+ jsonformEl,
549
+ jsonformSchema,
550
+ chartSpec,
551
+ isProcessed,
552
+ loading,
553
+ isPolling,
554
+ }) {
555
+ if (!selectedStac.value) {
556
+ return;
557
+ }
558
+ resetProcess({ loading, isProcessed, chartSpec, jsonformSchema, isPolling });
559
+ if (selectedStac.value["eodash:jsonform"]) {
560
+ jsonformEl.value?.editor.destroy();
561
+ // wait for the layers to be rendered
562
+ jsonformSchema.value = await axios
563
+ //@ts-expect-error eodash extention
564
+ .get(selectedStac.value["eodash:jsonform"])
565
+ .then((resp) => resp.data);
566
+ // remove borders from jsonform
567
+ await nextTick(() => {
568
+ injectJsonformCSS(jsonformEl.value);
569
+ });
570
+ } else {
571
+ if (!jsonformSchema.value) {
572
+ return;
573
+ }
574
+ jsonformSchema.value = null;
575
+ }
576
+ }
577
+
578
+ const _hoisted_1 = { class: "process-container" };
579
+ const _hoisted_2 = [".schema"];
580
+ const _hoisted_3 = [".spec", ".dataValues"];
581
+
582
+
583
+ const _sfc_main = {
584
+ __name: 'EodashProcess',
585
+ setup(__props) {
586
+
587
+ const layersEvents = useEventBus(eoxLayersKey);
588
+ const { selectedStac } = storeToRefs(useSTAcStore());
589
+
590
+ /** @type {import("vue").Ref<import("vega").Spec|null>} */
591
+ const chartSpec = ref(null);
592
+
593
+ /** @type {import("vue").Ref<Record<string,any>|null>} */
594
+ const chartData = ref(null);
595
+ const isProcessed = ref(false);
596
+
597
+ /** @type {import("vue").Ref<Record<string,any>|null>} */
598
+ const jsonformSchema = ref(null);
599
+
600
+ /** @type {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} */
601
+ const jsonformEl = ref(null);
602
+ const loading = ref(false);
603
+
604
+ const autoExec = ref(false);
605
+
606
+ const isPolling = ref(false);
607
+
608
+ onMounted(async () => {
609
+ // wait for the layers to be rendered
610
+ if (mapEl.value?.layers.length <= 1) {
611
+ layersEvents.once(async () => {
612
+ await initProcess({
613
+ //@ts-expect-error TODO
614
+ selectedStac,
615
+ jsonformEl,
616
+ jsonformSchema,
617
+ chartSpec,
618
+ isProcessed,
619
+ loading,
620
+ isPolling,
621
+ });
622
+ });
623
+ } else {
624
+ await initProcess({
625
+ //@ts-expect-error TODO
626
+ selectedStac,
627
+ jsonformEl,
628
+ jsonformSchema,
629
+ chartSpec,
630
+ isProcessed,
631
+ loading,
632
+ isPolling,
633
+ });
634
+ }
635
+ });
636
+
637
+ useOnLayersUpdate(
638
+ async () =>
639
+ await initProcess({
640
+ //@ts-expect-error TODO
641
+ selectedStac,
642
+ jsonformEl,
643
+ jsonformSchema,
644
+ chartSpec,
645
+ isProcessed,
646
+ loading,
647
+ isPolling,
648
+ }),
649
+ );
650
+
651
+ const startProcess = async () => {
652
+ const errors = jsonformEl.value?.editor.validate();
653
+ if (errors?.length) {
654
+ console.warn("[eodash] Form validation failed", errors);
655
+ return;
656
+ }
657
+ await handleProcesses({
658
+ jsonformEl,
659
+ jsonformSchema,
660
+ chartSpec,
661
+ chartData,
662
+ loading,
663
+ //@ts-expect-error TODO
664
+ selectedStac,
665
+ isProcessed,
666
+ isPolling,
667
+ });
668
+ isProcessed.value = true;
669
+ };
670
+ useAutoExec(autoExec, jsonformEl, jsonformSchema, startProcess);
671
+
672
+ return (_ctx, _cache) => {
673
+
674
+
675
+ return (openBlock(), createElementBlock("div", _hoisted_1, [
676
+ (jsonformSchema.value)
677
+ ? (openBlock(), createElementBlock("eox-jsonform", {
678
+ key: 0,
679
+ ref_key: "jsonformEl",
680
+ ref: jsonformEl,
681
+ ".schema": jsonformSchema.value
682
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2))
683
+ : createCommentVNode("v-if", true),
684
+ (isProcessed.value && chartSpec.value)
685
+ ? (openBlock(), createElementBlock("eox-chart", {
686
+ key: 1,
687
+ class: "chart",
688
+ ".spec": toRaw(chartSpec.value),
689
+ ".dataValues": toRaw(chartData.value)
690
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_3))
691
+ : createCommentVNode("v-if", true),
692
+ createElementVNode("span", null, [
693
+ (!autoExec.value)
694
+ ? (openBlock(), createBlock(VBtn, {
695
+ key: 0,
696
+ loading: loading.value,
697
+ style: {"float":"right","margin-right":"20px"},
698
+ onClick: startProcess,
699
+ color: "primary"
700
+ }, {
701
+ default: withCtx(() => _cache[0] || (_cache[0] = [
702
+ createTextVNode(" Execute ")
703
+ ])),
704
+ _: 1 /* STABLE */
705
+ }, 8 /* PROPS */, ["loading"]))
706
+ : createCommentVNode("v-if", true)
707
+ ])
708
+ ]))
709
+ }
710
+ }
711
+
712
+ };
713
+
714
+ export { _sfc_main as default };