@eodash/eodash 5.0.0-rc.3 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +1 -0
  2. package/core/client/App.vue +8 -2
  3. package/core/client/asWebComponent.js +5 -5
  4. package/core/client/components/DashboardLayout.vue +42 -25
  5. package/core/client/components/EodashOverlay.vue +1 -1
  6. package/core/client/components/ErrorAlert.vue +2 -2
  7. package/core/client/components/Footer.vue +4 -4
  8. package/core/client/components/Header.vue +3 -3
  9. package/core/client/components/MobileLayout.vue +9 -10
  10. package/core/client/composables/DefineEodash.js +38 -43
  11. package/core/client/composables/DefineTemplate.js +4 -2
  12. package/core/client/composables/DefineWidgets.js +14 -8
  13. package/core/client/composables/index.js +273 -23
  14. package/core/client/eodashSTAC/EodashCollection.js +80 -47
  15. package/core/client/eodashSTAC/helpers.js +136 -27
  16. package/core/client/eodashSTAC/parquet.js +145 -0
  17. package/core/client/eodashSTAC/triggers.js +6 -3
  18. package/core/client/plugins/index.js +4 -3
  19. package/core/client/plugins/vuetify.js +3 -0
  20. package/core/client/store/actions.js +21 -4
  21. package/core/client/store/stac.js +93 -56
  22. package/core/client/store/states.js +15 -5
  23. package/core/client/types.ts +59 -43
  24. package/core/client/utils/index.js +79 -0
  25. package/core/client/utils/keys.js +2 -2
  26. package/core/client/utils/states.js +30 -5
  27. package/core/client/views/Dashboard.vue +36 -32
  28. package/core/client/vite-env.d.ts +7 -0
  29. package/dist/client/{DashboardLayout-t_PavJPO.js → DashboardLayout-ByVs1DrY.js} +23 -12
  30. package/dist/client/{DynamicWebComponent-y07rVJch.js → DynamicWebComponent-C3W7HSQm.js} +1 -1
  31. package/dist/client/{EodashDatePicker-CcOfyzGD.js → EodashDatePicker-BIAf1sMT.js} +59 -32
  32. package/dist/client/{EodashItemFilter-B9HCvIMi.js → EodashItemFilter-DPznh8UB.js} +20 -10
  33. package/dist/client/{EodashLayerControl-KStn7Nb_.js → EodashLayerControl-Bhxjw4V2.js} +29 -16
  34. package/dist/client/EodashLayoutSwitcher-C5qTEffW.js +61 -0
  35. package/dist/client/EodashMapBtns-WoGq8MuV.js +173 -0
  36. package/dist/client/{EodashStacInfo-C_hDy6Pd.js → EodashStacInfo-CSvvF2jI.js} +3 -18
  37. package/dist/client/{EodashTools-BXflvRf8.js → EodashTools-Cv1SXQ5y.js} +13 -13
  38. package/dist/client/{ExportState-C0QRemK1.js → ExportState-D-iuwaad.js} +58 -52
  39. package/dist/client/{Footer-7VGyGUAs.js → Footer-CyF0zRAk.js} +15 -13
  40. package/dist/client/{Header-BQJnXHYq.js → Header-CgD8jDKU.js} +33 -28
  41. package/dist/client/{MobileLayout-b8nQ-Vyl.js → MobileLayout-EKQ_kpSh.js} +69 -60
  42. package/dist/client/{PopUp-DgNrh9Df.js → PopUp-BsYLvWch.js} +19 -10
  43. package/dist/client/ProcessList-C2xsLU2_.js +191 -0
  44. package/dist/client/{VImg-D4eT3IQ1.js → VImg-OHe8YTs2.js} +24 -24
  45. package/dist/client/{VMain-C3hN2-H3.js → VMain-PryTLU4a.js} +7 -7
  46. package/dist/client/{VOverlay-tAeNygaA.js → VOverlay-yUn7p-Uf.js} +64 -27
  47. package/dist/client/{VTooltip-B0Q3iHMZ.js → VTooltip-DZ0fjpB3.js} +13 -10
  48. package/dist/client/{WidgetsContainer-CtDHfCYf.js → WidgetsContainer-B9LBadcC.js} +1 -1
  49. package/dist/client/asWebComponent-By_7_JjS.js +19193 -0
  50. package/dist/client/async-DkSu_u2K.js +740 -0
  51. package/dist/client/eo-dash.js +1 -1
  52. package/dist/client/{forwardRefs-CIFAqXaZ.js → forwardRefs-BXxrv98s.js} +31 -4
  53. package/dist/client/handling-CgmFXkW6.js +1212 -0
  54. package/dist/client/helpers-Dy0Q13tP.js +4534 -0
  55. package/dist/client/{index-DvcUndod.js → index-BuhOHXKv.js} +2 -4
  56. package/dist/client/{index-BQ16n4Sk.js → index-Ch_HchK3.js} +39 -32
  57. package/dist/client/{index-Cv7HBz49.js → index-Dqj4tbx2.js} +2 -2
  58. package/dist/client/index-skjhlH8u.js +376 -0
  59. package/dist/client/{ssrBoot-BP7SYRyC.js → ssrBoot-Zgc_Ttvi.js} +2 -2
  60. package/dist/client/templates.js +850 -0
  61. package/dist/client/transition-C98Yn4Vo.js +40 -0
  62. package/dist/node/cli.js +16 -6
  63. package/dist/node/types.d.ts +1 -1
  64. package/dist/types/core/client/App.vue.d.ts +2 -2
  65. package/dist/types/core/client/asWebComponent.d.ts +1 -1
  66. package/dist/types/core/client/components/DynamicWebComponent.vue.d.ts +1 -3
  67. package/dist/types/core/client/components/Footer.vue.d.ts +1 -105
  68. package/dist/types/core/client/components/IframeWrapper.vue.d.ts +1 -1
  69. package/dist/types/core/client/components/MobileLayout.vue.d.ts +1 -324
  70. package/dist/types/core/client/composables/DefineEodash.d.ts +2 -2
  71. package/dist/types/core/client/composables/DefineTemplate.d.ts +1 -1
  72. package/dist/types/core/client/composables/DefineWidgets.d.ts +4 -4
  73. package/dist/types/core/client/composables/index.d.ts +24 -2
  74. package/dist/types/core/client/eodashSTAC/EodashCollection.d.ts +9 -6
  75. package/dist/types/core/client/eodashSTAC/helpers.d.ts +20 -5
  76. package/dist/types/core/client/eodashSTAC/parquet.d.ts +2 -0
  77. package/dist/types/core/client/plugins/vuetify.d.ts +7 -4
  78. package/dist/types/core/client/store/actions.d.ts +3 -2
  79. package/dist/types/core/client/store/stac.d.ts +16 -13
  80. package/dist/types/core/client/store/states.d.ts +14 -4
  81. package/dist/types/core/client/types.d.ts +45 -30
  82. package/dist/types/core/client/utils/index.d.ts +2 -0
  83. package/dist/types/core/client/utils/keys.d.ts +4 -4
  84. package/dist/types/core/client/utils/states.d.ts +59 -47
  85. package/dist/types/core/client/views/Dashboard.vue.d.ts +2 -2
  86. package/dist/types/templates/baseConfig.d.ts +4 -0
  87. package/dist/types/templates/compare.d.ts +210 -0
  88. package/dist/types/templates/expert.d.ts +151 -0
  89. package/dist/types/templates/index.d.ts +6 -0
  90. package/dist/types/templates/light.d.ts +145 -0
  91. package/dist/types/widgets/EodashDatePicker.vue.d.ts +1 -458
  92. package/dist/types/widgets/EodashItemFilter.vue.d.ts +3 -3
  93. package/dist/types/widgets/EodashLayerControl.vue.d.ts +14 -7
  94. package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +1 -3
  95. package/dist/types/widgets/EodashMap/index.vue.d.ts +1 -4
  96. package/dist/types/widgets/EodashMapBtns.vue.d.ts +8 -8
  97. package/dist/types/widgets/EodashProcess/ProcessList.vue.d.ts +8 -1
  98. package/dist/types/widgets/EodashProcess/index.vue.d.ts +8 -4
  99. package/dist/types/widgets/EodashProcess/methods/async.d.ts +18 -18
  100. package/dist/types/widgets/EodashProcess/methods/composables.d.ts +3 -2
  101. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/index.d.ts +1 -0
  102. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.d.ts +6 -0
  103. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.d.ts +4 -0
  104. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/layers/eoxhub-workspaces-endpoint.d.ts +5 -0
  105. package/dist/types/widgets/EodashProcess/methods/custom-endpoints/layers/index.d.ts +1 -0
  106. package/dist/types/widgets/EodashProcess/methods/handling.d.ts +12 -5
  107. package/dist/types/widgets/EodashProcess/methods/outputs.d.ts +72 -41
  108. package/dist/types/widgets/EodashProcess/methods/utils.d.ts +41 -21
  109. package/dist/types/widgets/EodashProcess/states.d.ts +11 -0
  110. package/dist/types/widgets/EodashProcess/types.d.ts +41 -0
  111. package/dist/types/widgets/EodashStacInfo.vue.d.ts +14 -14
  112. package/dist/types/widgets/EodashTools.vue.d.ts +3 -3
  113. package/dist/types/widgets/ExportState.vue.d.ts +1 -1
  114. package/dist/types/widgets/PopUp.vue.d.ts +11 -16
  115. package/dist/types/widgets/WidgetsContainer.vue.d.ts +3 -6
  116. package/package.json +53 -45
  117. package/templates/baseConfig.js +68 -0
  118. package/templates/compare.js +162 -0
  119. package/templates/expert.js +123 -0
  120. package/templates/index.js +8 -0
  121. package/templates/light.js +130 -0
  122. package/widgets/EodashDatePicker.vue +80 -31
  123. package/widgets/EodashItemFilter.vue +26 -11
  124. package/widgets/EodashLayerControl.vue +20 -11
  125. package/widgets/EodashLayoutSwitcher.vue +6 -3
  126. package/widgets/EodashMap/index.vue +3 -8
  127. package/widgets/EodashMap/methods/create-layers-config.js +4 -3
  128. package/widgets/EodashMap/methods/index.js +33 -23
  129. package/widgets/EodashMapBtns.vue +83 -41
  130. package/widgets/EodashProcess/ProcessList.vue +34 -10
  131. package/widgets/EodashProcess/index.vue +55 -20
  132. package/widgets/EodashProcess/methods/async.js +77 -59
  133. package/widgets/EodashProcess/methods/composables.js +21 -14
  134. package/widgets/EodashProcess/methods/custom-endpoints/chart/index.js +35 -0
  135. package/widgets/EodashProcess/methods/custom-endpoints/chart/sentinelhub-endpoint.js +275 -0
  136. package/widgets/EodashProcess/methods/custom-endpoints/chart/veda-endpoint.js +116 -0
  137. package/widgets/EodashProcess/methods/custom-endpoints/layers/eoxhub-workspaces-endpoint.js +94 -0
  138. package/widgets/EodashProcess/methods/custom-endpoints/layers/index.js +33 -0
  139. package/widgets/EodashProcess/methods/handling.js +127 -80
  140. package/widgets/EodashProcess/methods/outputs.js +376 -125
  141. package/widgets/EodashProcess/methods/utils.js +398 -10
  142. package/widgets/EodashProcess/states.js +13 -0
  143. package/widgets/EodashProcess/types.ts +46 -0
  144. package/widgets/EodashStacInfo.vue +2 -17
  145. package/widgets/EodashTools.vue +13 -13
  146. package/widgets/WidgetsContainer.vue +1 -1
  147. package/core/client/eodash.js +0 -454
  148. package/dist/client/EodashLayoutSwitcher-DqeFO3RN.js +0 -52
  149. package/dist/client/EodashMapBtns-5BF27qJB.js +0 -131
  150. package/dist/client/ProcessList-C62SOVO6.js +0 -484
  151. package/dist/client/asWebComponent-BJ2NWunV.js +0 -12479
  152. package/dist/client/eo-dash.css +0 -5
  153. package/dist/client/index-Da5xXX6Q.js +0 -780
  154. package/dist/client/transition-Cdb4K27U.js +0 -37
  155. package/dist/types/core/client/eodash.d.ts +0 -8
@@ -1,780 +0,0 @@
1
- import { onMounted, watch, nextTick, ref, useTemplateRef, computed, createElementBlock, openBlock, createVNode, createCommentVNode, createElementVNode, normalizeStyle, unref, toRaw, createBlock, withCtx, createTextVNode } from 'vue';
2
- import '@eox/chart';
3
- import '@eox/drawtools';
4
- import '@eox/jsonform';
5
- import { ai as axios, aj as indicator, ak as extractLayerConfig, Y as datetime, al as getLayers, a3 as mapEl, a9 as eoxLayersKey, ac as useOnLayersUpdate, Z as useSTAcStore, V as VBtn } from './asWebComponent-BJ2NWunV.js';
6
- import { storeToRefs } from 'pinia';
7
- import { p as pollProcessStatus, c as createLayerDefinition, g as getBboxProperty, e as extractGeometries, _ as _sfc_main$1, u as updateJobsStatus, d as download, j as jobs } from './ProcessList-C62SOVO6.js';
8
- import log from 'loglevel';
9
- import mustache from 'mustache';
10
- import { useEventBus } from '@vueuse/core';
11
-
12
- /**
13
- * @param {import("stac-ts").StacLink[] | undefined} links
14
- * @param {Record<string,any>|undefined} jsonformValue
15
- * @param {number[]} origBbox
16
- */
17
- function processImage(links, jsonformValue, origBbox) {
18
- if (!links) return;
19
- const imageLinks = links.filter(
20
- (link) => link.rel === "service" && link.type === "image/png",
21
- );
22
- const layers = [];
23
- for (const link of imageLinks) {
24
- layers.push({
25
- type: "Image",
26
- properties: {
27
- id: link.id,
28
- title: "Results " + link.id,
29
- },
30
- source: {
31
- type: "ImageStatic",
32
- imageExtent: origBbox,
33
- url: mustache.render(link.href, {
34
- ...(jsonformValue ?? {}),
35
- }),
36
- },
37
- });
38
- }
39
- return layers;
40
- }
41
-
42
- /**
43
- * @param {import("stac-ts").StacLink[] | undefined} links
44
- * @param {Record<string,any> | undefined} jsonformValue
45
- * @param {string} layerId
46
- */
47
- async function processVector(links, jsonformValue, layerId) {
48
- if (!links) return;
49
- /** @type {Record<string,any>[]} */
50
- const layers = [];
51
- const vectorLinks = links.filter(
52
- (link) => link.rel === "service" && link.type === "application/geo+json",
53
- );
54
- if (vectorLinks.length === 0) return layers;
55
-
56
- let flatStyleJSON = null;
57
-
58
- for (const link of vectorLinks) {
59
- if ("eox:flatstyle" in (link ?? {})) {
60
- flatStyleJSON = await axios
61
- .get(/** @type {string} */ (link["eox:flatstyle"]))
62
- .then((resp) => resp.data);
63
- }
64
-
65
- /** @type {Record<string,any>|undefined} */
66
- let layerConfig;
67
- /** @type {Record<string,any>|undefined} */
68
- let style;
69
- if (flatStyleJSON) {
70
- const extracted = extractLayerConfig(flatStyleJSON);
71
- layerConfig = extracted.layerConfig;
72
- style = extracted.style;
73
- }
74
-
75
- layers.push({
76
- type: "Vector",
77
- source: {
78
- type: "Vector",
79
- url: mustache.render(link.href, {
80
- ...(jsonformValue ?? {}),
81
- }),
82
- format: "GeoJSON",
83
- },
84
- properties: {
85
- id: layerId + "_vector_process",
86
- title: "Results " + layerId,
87
- ...(layerConfig && { ...layerConfig, ...(style && { style: style }) }),
88
- },
89
- });
90
- }
91
- return layers;
92
- }
93
-
94
- /**
95
- * @param {import("stac-ts").StacLink[] | undefined} links
96
- * @param {Record<string,any> | undefined} jsonformValue
97
- * @param {string} specUrl
98
- * @returns {Promise<[import("@eox/chart").EOxChart["spec"] | null,Record<string,any>|null]>}
99
- **/
100
- async function getChartValues(links, jsonformValue, specUrl) {
101
- if (!specUrl || !links) return [null, null];
102
- /** @type {import("vega").Spec} */
103
- const spec = await axios.get(specUrl).then((resp) => {
104
- return resp.data;
105
- });
106
- // //@ts-expect-error NamedData
107
- // const dataName = spec?.data?.name;
108
- const dataLinks = links.filter(
109
- (link) => link.rel === "service", // && dataName && link.id === dataName,
110
- );
111
-
112
- /** @type {Record<string,any>} */
113
- const dataValues = {};
114
- for (const link of dataLinks ?? []) {
115
- if (link.type && ["application/json", "text/csv"].includes(link.type)) {
116
- const dataUrl = mustache.render(link.href, {
117
- ...(jsonformValue ?? {}),
118
- ...(link["eox:flatstyle"] ?? {}),
119
- });
120
-
121
- // Wait for data to be retrieved
122
- const data = await axios.get(dataUrl).then((resp) => {
123
- return resp.data;
124
- });
125
- // @ts-expect-error we assume data to exist in spec
126
- spec.data.values = data;
127
- continue;
128
- }
129
-
130
- dataValues[/** @type {string} */ (link.id)] = await axios
131
- .get(
132
- mustache.render(link.href, {
133
- ...(jsonformValue ?? {}),
134
- ...(link["eox:flatstyle"] ?? {}),
135
- }),
136
- )
137
- .then((resp) => resp.data);
138
- }
139
-
140
- return [spec, dataValues];
141
- }
142
-
143
- /**
144
- * @param {import("stac-ts").StacLink[] | undefined} links
145
- * @param {Record<string,any> | undefined} jsonformValue
146
- * @param {import("vue").Ref<boolean>} isPolling
147
- * @param {string} layerId
148
- * @param {string} projection
149
- */
150
- async function processGeoTiff(
151
- links,
152
- jsonformValue,
153
- layerId,
154
- isPolling,
155
- projection,
156
- ) {
157
- if (!links) return;
158
- const geotiffLinks = links.filter(
159
- (link) => link.rel === "service" && link.type === "image/tiff",
160
- );
161
- let urls = [];
162
- let processId = "";
163
- for (const link of geotiffLinks ?? []) {
164
- if (link.endpoint === "eoxhub_workspaces") {
165
- // TODO: prove of concept, needs to be reworked for sure
166
- // Special handling for eoxhub workspace process endpoints
167
- const postBody = await axios
168
- .get(/** @type {string} */ (link["body"]), { responseType: "text" })
169
- .then((resp) => resp.data);
170
- const jsonData = JSON.parse(
171
- mustache.render(postBody, { ...(jsonformValue ?? {}) }),
172
- );
173
- try {
174
- const responseProcess = await axios.post(link.href, jsonData, {
175
- headers: {
176
- "Content-Type": "application/json",
177
- },
178
- });
179
- console.log(responseProcess.headers.location);
180
- // We save the process status url into localstorage assigning it to the indicator id
181
- const currentJobs = JSON.parse(
182
- localStorage.getItem(indicator.value) || "[]",
183
- );
184
- currentJobs.push(responseProcess.headers.location);
185
- localStorage.setItem(indicator.value, JSON.stringify(currentJobs));
186
- await pollProcessStatus({
187
- processUrl: responseProcess.headers.location,
188
- isPolling,
189
- })
190
- .then((resultItem) => {
191
- // @ts-expect-error we have currently no definition of what is allowed as response
192
- const resultUrls = resultItem?.urls;
193
- if (resultUrls?.length < 1) {
194
- return;
195
- }
196
- //@ts-expect-error todo
197
- processId = resultItem?.id;
198
- urls = resultUrls;
199
- })
200
- .catch((error) => {
201
- if (error instanceof Error) {
202
- console.error("Polling failed:", error.message);
203
- } else {
204
- console.error("Unknown error occurred during polling:", error);
205
- }
206
- });
207
- } catch (error) {
208
- if (error instanceof Error) {
209
- console.error("Error sending POST request:", error.message);
210
- } else {
211
- console.error("Unknown error occurred:", error);
212
- }
213
- }
214
- } else {
215
- urls.push(mustache.render(link.href, { ...(jsonformValue ?? {}) }));
216
- }
217
- }
218
-
219
- return createLayerDefinition(links[0], layerId, urls, projection, processId);
220
- }
221
-
222
- /**
223
- * Fetch and set the jsonform schema to initialize the process
224
- *
225
- * @export
226
- * @async
227
- * @param {Object} params
228
- * @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
229
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
230
- * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
231
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
232
- * @param {import("vue").Ref<any[]>} params.processResults
233
- * @param {import("vue").Ref<boolean>} params.isProcessed
234
- * @param {import("vue").Ref<boolean>} params.loading
235
- * @param {import("vue").Ref<boolean>} params.isPolling
236
- */
237
- async function initProcess({
238
- selectedStac,
239
- jsonformEl,
240
- jsonformSchema,
241
- chartSpec,
242
- isProcessed,
243
- processResults,
244
- loading,
245
- isPolling,
246
- }) {
247
- if (!selectedStac.value) {
248
- return;
249
- }
250
- resetProcess({
251
- loading,
252
- isProcessed,
253
- chartSpec,
254
- jsonformSchema,
255
- isPolling,
256
- processResults,
257
- });
258
- if (selectedStac.value["eodash:jsonform"]) {
259
- jsonformEl.value?.editor.destroy();
260
- // wait for the layers to be rendered
261
- jsonformSchema.value = await axios
262
- //@ts-expect-error eodash extention
263
- .get(selectedStac.value["eodash:jsonform"])
264
- .then((resp) => resp.data);
265
- // remove borders from jsonform
266
- } else {
267
- if (!jsonformSchema.value) {
268
- return;
269
- }
270
- jsonformSchema.value = null;
271
- }
272
- }
273
-
274
- /**
275
- *
276
- * @param {Object} params
277
- * @param {import("vue").Ref<boolean>} params.loading
278
- * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
279
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
280
- * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
281
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
282
- * @param {import("vue").Ref<Record<string, any> | null>} params.chartData
283
- * @param {import("vue").Ref<boolean>} params.isPolling
284
- * @param {import("vue").Ref<any[]>} params.processResults
285
- */
286
- async function handleProcesses({
287
- loading,
288
- selectedStac,
289
- jsonformEl,
290
- jsonformSchema,
291
- chartSpec,
292
- chartData,
293
- isPolling,
294
- processResults,
295
- }) {
296
- if (!jsonformEl.value || !jsonformSchema.value || !selectedStac.value) {
297
- return;
298
- }
299
- log.debug("Processing...");
300
- loading.value = true;
301
- try {
302
- const serviceLinks = selectedStac.value?.links?.filter(
303
- (l) => l.rel === "service",
304
- );
305
- const bboxProperty = getBboxProperty(jsonformSchema.value);
306
- const jsonformValue = /** @type {Record<string,any>} */ (
307
- jsonformEl.value?.value
308
- );
309
-
310
- extractGeometries(jsonformValue, jsonformSchema.value);
311
-
312
- const origBbox = jsonformValue[bboxProperty];
313
-
314
- const specUrl = /** @type {string} */ (
315
- selectedStac.value?.["eodash:vegadefinition"]
316
- );
317
-
318
- [chartSpec.value, chartData.value] = await getChartValues(
319
- serviceLinks,
320
- { ...(jsonformValue ?? {}) },
321
- specUrl,
322
- );
323
- if (Object.keys(chartData.value ?? {}).length) {
324
- processResults.value.push(chartData.value);
325
- }
326
-
327
- //@ts-expect-error we assume that the spec data is of type InlineData
328
- if (chartSpec.value?.data?.values?.length) {
329
- //@ts-expect-error we assume that the spec data is of type InlineData
330
- processResults.value.push(chartSpec.value?.data.values);
331
- }
332
-
333
- if (chartSpec.value && !("background" in chartSpec.value)) {
334
- chartSpec.value["background"] = "transparent";
335
- }
336
-
337
- const geotiffLayer = await processGeoTiff(
338
- serviceLinks,
339
- jsonformValue,
340
- selectedStac.value?.id ?? "",
341
- isPolling,
342
- //@ts-expect-error TODO
343
- selectedStac.value?.["eodash:mapProjection"]?.["name"] ?? null,
344
- );
345
-
346
- if (geotiffLayer && geotiffLayer.source?.sources.length) {
347
- processResults.value.push(
348
- ...(geotiffLayer.source?.sources?.map((source) => source.url) ?? []),
349
- );
350
- }
351
- // 3. vector geojson
352
- const vectorLayers = await processVector(
353
- serviceLinks,
354
- jsonformValue,
355
- selectedStac.value?.id ?? "",
356
- );
357
-
358
- if (vectorLayers?.length) {
359
- processResults.value.push(
360
- ...vectorLayers.map((layer) => layer.source?.url),
361
- );
362
- }
363
-
364
- const imageLayers = processImage(serviceLinks, jsonformValue, origBbox);
365
- if (imageLayers?.length) {
366
- processResults.value.push(
367
- ...imageLayers.map((layer) => layer.source?.url),
368
- );
369
- }
370
-
371
- log.debug(
372
- "rendered layers after processing:",
373
- geotiffLayer,
374
- vectorLayers,
375
- imageLayers,
376
- );
377
-
378
- if (geotiffLayer || vectorLayers?.length || imageLayers?.length) {
379
- const layers = [
380
- ...(geotiffLayer ? [geotiffLayer] : []),
381
- ...(vectorLayers ?? []),
382
- ...(imageLayers ?? []),
383
- ];
384
- let currentLayers = [...getLayers()];
385
- let analysisGroup = currentLayers.find((l) =>
386
- l.properties.id.includes("AnalysisGroup"),
387
- );
388
- analysisGroup?.layers.push(...layers);
389
-
390
- if (mapEl.value) {
391
- mapEl.value.layers = [...currentLayers];
392
- }
393
- }
394
- loading.value = false;
395
- } catch (error) {
396
- console.error("[eodash] Error while running process:", error);
397
- loading.value = false;
398
- throw error;
399
- }
400
- }
401
-
402
- /**
403
- * Reset the process state
404
- * @param {Object} params
405
- * @param {import("vue").Ref<boolean>} params.loading
406
- * @param {import("vue").Ref<boolean>} params.isProcessed
407
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
408
- * @param {import("vue").Ref<boolean>} params.isPolling
409
- * @param {import("vue").Ref<any[]>} params.processResults
410
- * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
411
- */
412
- function resetProcess({
413
- loading,
414
- isProcessed,
415
- chartSpec,
416
- jsonformSchema,
417
- processResults,
418
- isPolling,
419
- }) {
420
- loading.value = false;
421
- isProcessed.value = false;
422
- isPolling.value = false;
423
- chartSpec.value = null;
424
- processResults.value = [];
425
- jsonformSchema.value = null;
426
- }
427
-
428
- /**
429
- * Handles the click event on a chart to extract temporal information and update the global datetime value.
430
- *
431
- * @param {object} evt - The click event object.
432
- * @param {object} evt.target - The target of the event, expected to have a Vega-Lite specification (`spec`).
433
- * @param {object} evt.target.spec - The Vega-Lite specification of the chart.
434
- * @param {Record<string,{type?:string;field?:string;}>} [evt.target.spec.encoding] - The encoding specification of the chart.
435
- * @param {object} evt.detail - The detail of the event, containing information about the clicked item.
436
- * @param {import("vega").Item} evt.detail.item - The Vega item that was clicked.
437
- */
438
- const onChartClick = (evt) => {
439
- const chartSpec = evt.target?.spec;
440
- if (!chartSpec) {
441
- return;
442
- }
443
- const encodingKey = Object.keys(chartSpec.encoding ?? {}).find(
444
- (key) => chartSpec.encoding?.[key].type === "temporal",
445
- );
446
- if (!encodingKey) {
447
- return;
448
- }
449
- const temporalKey = chartSpec.encoding?.[encodingKey].field;
450
- if (!temporalKey) {
451
- return;
452
- }
453
- try {
454
- const vegaItem = evt.detail.item;
455
- const temporalValue = new Date(vegaItem.datum.datum[temporalKey]);
456
- datetime.value = temporalValue.toISOString();
457
- } catch (error) {
458
- console.warn(
459
- "[eodash] Error while setting datetime from eox-chart:",
460
- error,
461
- );
462
- }
463
- };
464
-
465
- /**
466
- * Composable resposible of timing the Initialization of the process
467
- *
468
- * @export
469
- * @async
470
- * @param {Object} params
471
- * @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
472
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
473
- * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
474
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
475
- * @param {import("vue").Ref<any[]>} params.processResults
476
- * @param {import("vue").Ref<boolean>} params.isProcessed
477
- * @param {import("vue").Ref<boolean>} params.loading
478
- * @param {import("vue").Ref<boolean>} params.isPolling
479
- */
480
- const useInitProcess = ({
481
- selectedStac,
482
- jsonformEl,
483
- jsonformSchema,
484
- chartSpec,
485
- isProcessed,
486
- processResults,
487
- loading,
488
- isPolling,
489
- }) => {
490
- const layersEvents = useEventBus(eoxLayersKey);
491
-
492
- onMounted(async () => {
493
- // wait for the layers to be rendered
494
- if (mapEl.value?.layers.length > 1) {
495
- await initProcess({
496
- selectedStac,
497
- jsonformEl,
498
- jsonformSchema,
499
- chartSpec,
500
- isProcessed,
501
- processResults,
502
- loading,
503
- isPolling,
504
- });
505
- } else {
506
- layersEvents.once(async () => {
507
- await initProcess({
508
- selectedStac,
509
- jsonformEl,
510
- jsonformSchema,
511
- chartSpec,
512
- isProcessed,
513
- loading,
514
- processResults,
515
- isPolling,
516
- });
517
- });
518
- }
519
- });
520
-
521
- useOnLayersUpdate(async (evt, _payload) => {
522
- if (evt === "layers:updated") {
523
- await initProcess({
524
- selectedStac,
525
- jsonformEl,
526
- jsonformSchema,
527
- chartSpec,
528
- isProcessed,
529
- processResults,
530
- loading,
531
- isPolling,
532
- });
533
- }
534
- });
535
- };
536
-
537
- /**
538
- * Auto execute the process when the jsonform has the execute option
539
- *
540
- * @param {import("vue").Ref<boolean>} autoExec
541
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
542
- * @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
543
- * @param {() => Promise<void>} startProcess
544
- **/
545
- function useAutoExec(
546
- autoExec,
547
- jsonformEl,
548
- jsonformSchema,
549
- startProcess,
550
- ) {
551
- /**
552
- * @param {CustomEvent} _e
553
- **/
554
- const onJsonFormChange = async (_e) => {
555
- await startProcess();
556
- };
557
-
558
- const addEventListener = async () => {
559
- await nextTick(() => {
560
- //@ts-expect-error TODO
561
- jsonformEl.value?.addEventListener("change", onJsonFormChange);
562
- });
563
- };
564
- const removeEventListener = () => {
565
- //@ts-expect-error TODO
566
- jsonformEl.value?.removeEventListener("change", onJsonFormChange);
567
- };
568
-
569
- watch(jsonformSchema, (updatedSchema) => {
570
- autoExec.value = updatedSchema?.options?.["execute"] || false;
571
- });
572
-
573
- onMounted(() => {
574
- watch(
575
- autoExec,
576
- async (exec) => {
577
- if (exec) {
578
- await addEventListener();
579
- } else {
580
- removeEventListener();
581
- }
582
- },
583
- { immediate: true },
584
- );
585
- });
586
- }
587
-
588
- const _hoisted_1 = {
589
- ref: "container",
590
- class: "process-container"
591
- };
592
- const _hoisted_2 = [".schema"];
593
- const _hoisted_3 = [".spec", ".dataValues"];
594
- const _hoisted_4 = { style: {"text-align":"right"} };
595
-
596
- /** @type {import("vue").Ref<import("vega").Spec|null>} */
597
-
598
- const _sfc_main = {
599
- __name: 'index',
600
- setup(__props) {
601
-
602
- const chartSpec = ref(null);
603
-
604
- /** @type {import("vue").Ref<Record<string,any>|null>} */
605
- const chartData = ref(null);
606
- const isProcessed = ref(false);
607
-
608
- /** @type {import("vue").Ref<Record<string,any>|null>} */
609
- const jsonformSchema = ref(null);
610
-
611
- const jsonformEl =
612
- /** @type {Readonly<import("vue").ShallowRef<import("@eox/jsonform").EOxJSONForm | null>>} */ (
613
- useTemplateRef("jsonformEl")
614
- );
615
- const isAsync = computed(
616
- () =>
617
- selectedStac.value?.links.filter((l) => l.endpoint === "eoxhub_workspaces")
618
- .length,
619
- );
620
- const containerEl = useTemplateRef("container");
621
-
622
- const loading = ref(false);
623
-
624
- const autoExec = ref(false);
625
-
626
- const isPolling = ref(false);
627
- /** @type {import("vue").Ref<any[]>} */
628
- const processResults = ref([]);
629
-
630
- const { selectedStac } = storeToRefs(useSTAcStore());
631
-
632
- useInitProcess({
633
- //@ts-expect-error TODO
634
- selectedStac,
635
- jsonformEl,
636
- jsonformSchema,
637
- chartSpec,
638
- isProcessed,
639
- processResults,
640
- loading,
641
- isPolling,
642
- });
643
-
644
- const downloadResults = () => {
645
- processResults.value.forEach((result) => {
646
- if (!result) {
647
- return;
648
- }
649
- let fileName = "";
650
- if (typeof result === "string") {
651
- fileName = result.includes("/")
652
- ? (result.split("/").pop() ?? "")
653
- : result;
654
- fileName = fileName.includes("?") ? fileName.split("?")[0] : fileName;
655
- } else {
656
- fileName = selectedStac.value?.id + "_process_results.json";
657
- }
658
- download(fileName, result);
659
- });
660
- };
661
-
662
- const startProcess = async () => {
663
- /** @param {*} jsonformSchema */
664
- const getDrawToolsProperty = (jsonformSchema) => {
665
- for (const property in jsonformSchema.properties) {
666
- if (jsonformSchema.properties[property]?.options?.drawtools) {
667
- return property;
668
- }
669
- }
670
- };
671
- const drawToolsProperty = getDrawToolsProperty(jsonformSchema.value);
672
- const propertyIsEmpty =
673
- drawToolsProperty &&
674
- //@ts-expect-error jsonfrom.value is not typed
675
- Array.isArray(jsonformEl.value?.value[drawToolsProperty]) &&
676
- //@ts-expect-error jsonfrom.value is not typed
677
- !jsonformEl.value?.value[drawToolsProperty].length;
678
-
679
- if (propertyIsEmpty) {
680
- isProcessed.value = false;
681
- chartSpec.value = null;
682
- return;
683
- }
684
- const errors = jsonformEl.value?.editor.validate();
685
- if (errors?.length) {
686
- console.warn("[eodash] Form validation failed", errors);
687
- return;
688
- }
689
-
690
- processResults.value = [];
691
-
692
- await handleProcesses({
693
- jsonformEl,
694
- jsonformSchema,
695
- chartSpec,
696
- chartData,
697
- loading,
698
- //@ts-expect-error TODO
699
- selectedStac,
700
- isPolling,
701
- processResults,
702
- });
703
-
704
- isProcessed.value = true;
705
- if (isAsync.value) updateJobsStatus(jobs, indicator);
706
- };
707
- useAutoExec(autoExec, jsonformEl, jsonformSchema, startProcess);
708
-
709
- const chartStyles = computed(() => {
710
- /** @type {Record<string,string> }*/
711
- const styles = {};
712
- if (!chartSpec.value?.["height"]) {
713
- styles["height"] =
714
- Math.max(
715
- (containerEl.value?.offsetHeight ?? 0) -
716
- (jsonformEl.value?.offsetHeight ?? 0),
717
- 200,
718
- ) + "px";
719
- }
720
- return styles;
721
- });
722
-
723
- return (_ctx, _cache) => {
724
-
725
-
726
- return (openBlock(), createElementBlock("div", _hoisted_1, [
727
- createVNode(_sfc_main$1),
728
- (jsonformSchema.value)
729
- ? (openBlock(), createElementBlock("eox-jsonform", {
730
- key: 0,
731
- ref_key: "jsonformEl",
732
- ref: jsonformEl,
733
- ".schema": jsonformSchema.value
734
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2))
735
- : createCommentVNode("v-if", true),
736
- (isProcessed.value && chartSpec.value)
737
- ? (openBlock(), createElementBlock("eox-chart", {
738
- key: 1,
739
- class: "chart",
740
- ".spec": toRaw(chartSpec.value),
741
- ".dataValues": toRaw(chartData.value),
742
- "onClick:item": _cache[0] || (_cache[0] = (...args) => (unref(onChartClick) && unref(onChartClick)(...args))),
743
- style: normalizeStyle(chartStyles.value)
744
- }, null, 44 /* STYLE, PROPS, NEED_HYDRATION */, _hoisted_3))
745
- : createCommentVNode("v-if", true),
746
- createElementVNode("div", _hoisted_4, [
747
- (!autoExec.value)
748
- ? (openBlock(), createBlock(VBtn, {
749
- key: 0,
750
- loading: loading.value,
751
- style: {"margin-right":"20px"},
752
- onClick: startProcess,
753
- color: "primary"
754
- }, {
755
- default: withCtx(() => _cache[1] || (_cache[1] = [
756
- createTextVNode(" Execute ")
757
- ])),
758
- _: 1 /* STABLE */
759
- }, 8 /* PROPS */, ["loading"]))
760
- : createCommentVNode("v-if", true),
761
- (processResults.value.length && isProcessed.value && !isAsync.value)
762
- ? (openBlock(), createBlock(VBtn, {
763
- key: 1,
764
- color: "primary",
765
- onClick: downloadResults
766
- }, {
767
- default: withCtx(() => _cache[2] || (_cache[2] = [
768
- createTextVNode(" Download ")
769
- ])),
770
- _: 1 /* STABLE */
771
- }))
772
- : createCommentVNode("v-if", true)
773
- ])
774
- ], 512 /* NEED_PATCH */))
775
- }
776
- }
777
-
778
- };
779
-
780
- export { _sfc_main as default };