@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,5 +1,5 @@
1
- import { TransitionGroup, Transition, h, camelize } from 'vue';
2
- import { g as genericComponent, p as propsFactory } from './asWebComponent-BJ2NWunV.js';
1
+ import { h, TransitionGroup, Transition, camelize } from 'vue';
2
+ import { g as genericComponent, p as propsFactory } from './asWebComponent-By_7_JjS.js';
3
3
 
4
4
  // Utilities
5
5
  const makeTransitionProps = propsFactory({
@@ -136,7 +136,6 @@ function ExpandTransitionGenerator () {
136
136
  el.style.overflow = 'hidden';
137
137
  const offset = `${el[offsetProperty]}px`;
138
138
  el.style[sizeProperty] = '0';
139
- void el.offsetHeight; // force reflow
140
139
 
141
140
  el.style.transition = initialStyle.transition;
142
141
  if (expandedParentClass && el._parent) {
@@ -156,7 +155,6 @@ function ExpandTransitionGenerator () {
156
155
  };
157
156
  el.style.overflow = 'hidden';
158
157
  el.style[sizeProperty] = `${el[offsetProperty]}px`;
159
- void el.offsetHeight; // force reflow
160
158
 
161
159
  requestAnimationFrame(() => el.style[sizeProperty] = '0');
162
160
  },
@@ -1,10 +1,10 @@
1
- import { onMounted, onUnmounted, watch, nextTick, ref, toRaw, computed, createElementBlock, openBlock, createElementVNode, unref, normalizeStyle } from 'vue';
1
+ import { onMounted, onUnmounted, watch, ref, toRaw, computed, createElementBlock, openBlock, createElementVNode, unref, normalizeStyle } from 'vue';
2
2
  import '@eox/map';
3
3
  import '@eox/map/src/plugins/advancedLayersAndSources';
4
- import { a8 as EodashCollection, a9 as eoxLayersKey, Z as useSTAcStore, aa as setMapProjFromCol, ab as posIsSetFromUrl, ac as useOnLayersUpdate, ad as mapPosition, a3 as mapEl, a2 as mapCompareEl, Y as datetime, $ as eodashCollections, a6 as layerControlFormValue, a5 as layerControlFormValueCompare, a4 as eodashCompareCollections } from './asWebComponent-BJ2NWunV.js';
4
+ import { J as setMapProjFromCol, A as mapPosition, d as mapEl, H as mapCompareEl, x as datetime } from './helpers-Dy0Q13tP.js';
5
5
  import { storeToRefs } from 'pinia';
6
+ import { a3 as EodashCollection, Y as useSTAcStore, a4 as useEmitLayersUpdate, a5 as isFirstLoad, a6 as useOnLayersUpdate, a2 as layerControlFormValue, a1 as layerControlFormValueCompare, a0 as eodashCompareCollections, $ as eodashCollections } from './asWebComponent-By_7_JjS.js';
6
7
  import log from 'loglevel';
7
- import { useEventBus } from '@vueuse/core';
8
8
  import mustache from 'mustache';
9
9
 
10
10
  /**
@@ -59,9 +59,10 @@ const createLayersConfig = async (
59
59
  const indicatorLayers =
60
60
  //@ts-expect-error indicator is collection
61
61
  await EodashCollection.getIndicatorLayers(selectedIndicator);
62
- const geodbLayer = EodashCollection.getGeoDBLayer(eodashCols);
63
- if (geodbLayer) {
64
- dataLayers.layers.unshift(geodbLayer);
62
+ const observationPointsLayer =
63
+ EodashCollection.getObservationPointsLayer(eodashCols);
64
+ if (observationPointsLayer) {
65
+ dataLayers.layers.unshift(observationPointsLayer);
65
66
  }
66
67
  const baseLayers = {
67
68
  type: "Group",
@@ -183,9 +184,6 @@ const useHandleMapMoveEnd = (mapElement, mapPosition) => {
183
184
  !Number.isNaN(z)
184
185
  ) {
185
186
  mapPosition.value = [lonlat[0], lonlat[1], z];
186
- if (posIsSetFromUrl.value) {
187
- posIsSetFromUrl.value = false;
188
- }
189
187
  }
190
188
  };
191
189
 
@@ -227,7 +225,6 @@ const useInitMap = (
227
225
  eodashCols.values,
228
226
  datetime.value,
229
227
  );
230
- const layersEvent = useEventBus(eoxLayersKey);
231
228
 
232
229
  const stopIndicatorWatcher = watch(
233
230
  [selectedIndicator, datetime],
@@ -280,9 +277,14 @@ const useInitMap = (
280
277
  JSON.parse(JSON.stringify(layersCollection)),
281
278
  );
282
279
  mapLayers.value = layersCollection;
283
- await nextTick(() => {
284
- layersEvent.emit("time:updated", mapLayers.value);
285
- });
280
+
281
+ useEmitLayersUpdate(
282
+ mapElement.value?.id === "compare"
283
+ ? "compareTime:updated"
284
+ : "time:updated",
285
+ mapElement.value,
286
+ layersCollection,
287
+ );
286
288
  return;
287
289
  }
288
290
 
@@ -306,7 +308,8 @@ const useInitMap = (
306
308
  }
307
309
  if (
308
310
  endInterval !== null &&
309
- endInterval.toISOString() !== datetime.value
311
+ endInterval.toISOString() !== datetime.value &&
312
+ !isFirstLoad.value
310
313
  ) {
311
314
  datetime.value = endInterval.toISOString();
312
315
  }
@@ -317,7 +320,11 @@ const useInitMap = (
317
320
  if (
318
321
  mapElement?.value?.id === "main" &&
319
322
  updatedStac.extent?.spatial.bbox &&
320
- !posIsSetFromUrl.value
323
+ !(
324
+ isFirstLoad.value &&
325
+ mapPosition.value?.[0] &&
326
+ mapPosition.value?.[1]
327
+ )
321
328
  ) {
322
329
  // Sanitize extent,
323
330
  const b = updatedStac.extent?.spatial.bbox[0];
@@ -337,9 +344,6 @@ const useInitMap = (
337
344
  (mapElement.value).zoomExtent = reprojExtent;
338
345
  }
339
346
  }
340
- if (posIsSetFromUrl.value) {
341
- posIsSetFromUrl.value = false;
342
- }
343
347
 
344
348
  log.debug(
345
349
  "Assigned layers",
@@ -347,11 +351,13 @@ const useInitMap = (
347
351
  );
348
352
  mapLayers.value = layersCollection;
349
353
  // Emit event to update layers
350
- await nextTick(() => {
351
- mapElement.value?.updateComplete.then(() => {
352
- layersEvent.emit("layers:updated", mapLayers.value);
353
- });
354
- });
354
+ await useEmitLayersUpdate(
355
+ mapElement.value?.id === "compare"
356
+ ? "compareLayers:updated"
357
+ : "layers:updated",
358
+ mapElement.value,
359
+ mapLayers.value,
360
+ );
355
361
  }
356
362
  },
357
363
  { immediate: true },
@@ -366,8 +372,14 @@ const useInitMap = (
366
372
  * @param {import("@/eodashSTAC/EodashCollection").EodashCollection[]} eodashCols
367
373
  * @param {import("vue").Ref<Exclude<import("@/types").EodashStyleJson["tooltip"],undefined>>} tooltipProperties
368
374
  */
375
+
369
376
  const useUpdateTooltipProperties = (eodashCols, tooltipProperties) => {
370
- useOnLayersUpdate(async () => {
377
+ useOnLayersUpdate(async (evt, _payload) => {
378
+ if (evt.includes("compare")) {
379
+ // TODO: support compare map tooltips
380
+ // Do not update tooltip properties on compare map
381
+ return;
382
+ }
371
383
  const tooltips = [];
372
384
  for (const ec of eodashCols) {
373
385
  tooltips.push(...(await ec.getToolTipProperties()));
@@ -410,11 +422,11 @@ const _sfc_main = {
410
422
  center: {
411
423
  //@ts-expect-error todo
412
424
  type: Array,
413
- default: () => [15, 48],
425
+ default: () => [mapPosition.value?.[0] ?? 15, mapPosition.value?.[1] ?? 48],
414
426
  },
415
427
  zoom: {
416
428
  type: Number,
417
- default: 4,
429
+ default: mapPosition.value?.[2] ?? 4,
418
430
  },
419
431
  zoomToExtent: {
420
432
  type: Boolean,
@@ -435,10 +447,7 @@ const controls = {
435
447
  collapsible: true,
436
448
  },
437
449
  };
438
- const initialCenter = toRaw([
439
- mapPosition.value?.[0] ?? props.center?.[0],
440
- mapPosition.value?.[1] ?? props.center?.[1],
441
- ]);
450
+ const initialCenter = toRaw(props.center);
442
451
  const initialZoom = toRaw(mapPosition.value?.[2] ?? props.zoom);
443
452
  /** @type {import("vue").Ref<Record<string,any>[]>} */
444
453
  const eoxMapLayers = ref([
@@ -492,7 +501,6 @@ onMounted(() => {
492
501
  if (props.enableCompare) {
493
502
  useInitMap(
494
503
  compareMap,
495
- //@ts-expect-error todo selectedStac as collection
496
504
  selectedCompareStac,
497
505
  eodashCompareCollections,
498
506
  datetime,
@@ -506,7 +514,6 @@ onMounted(() => {
506
514
 
507
515
  useInitMap(
508
516
  eoxMap,
509
- //@ts-expect-error todo selectedStac as collection
510
517
  selectedStac,
511
518
  eodashCollections,
512
519
  datetime,
@@ -1,6 +1,6 @@
1
1
  import { resolveComponent, render, h, mergeProps } from 'vue';
2
- import { E as isObject, an as consoleError } from './asWebComponent-BJ2NWunV.js';
3
- import { V as VTooltip } from './VTooltip-B0Q3iHMZ.js';
2
+ import { a9 as consoleError, E as isObject } from './asWebComponent-By_7_JjS.js';
3
+ import { V as VTooltip } from './VTooltip-DZ0fjpB3.js';
4
4
 
5
5
  // Utilities
6
6
  function useDirectiveComponent(component, props) {
@@ -0,0 +1,376 @@
1
+ import { onMounted, watch, nextTick, ref, useTemplateRef, computed, createElementBlock, openBlock, createVNode, createCommentVNode, createElementVNode, unref, normalizeStyle, toRaw, createBlock, withCtx, createTextVNode } from 'vue';
2
+ import '@eox/chart';
3
+ import '@eox/drawtools';
4
+ import '@eox/jsonform';
5
+ import { a7 as eoxLayersKey, a6 as useOnLayersUpdate, _ as _export_sfc, Y as useSTAcStore, V as VBtn } from './asWebComponent-By_7_JjS.js';
6
+ import { storeToRefs } from 'pinia';
7
+ import { P as ProcessList, c as compareJobs, j as jobs } from './ProcessList-C2xsLU2_.js';
8
+ import { i as initProcess, o as onChartClick, h as handleProcesses } from './handling-CgmFXkW6.js';
9
+ import { useEventBus } from '@vueuse/core';
10
+ import { u as updateJobsStatus, d as download } from './async-DkSu_u2K.js';
11
+ import { C as compareIndicator, B as indicator, H as mapCompareEl, d as mapEl } from './helpers-Dy0Q13tP.js';
12
+ import { mdiCogPlayOutline, mdiDownloadCircleOutline } from '@mdi/js';
13
+
14
+ /**
15
+ * Composable resposible of timing the Initialization of the process
16
+ *
17
+ * @export
18
+ * @async
19
+ * @param {Object} params
20
+ * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
21
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
22
+ * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
23
+ * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"] | null>} params.chartSpec
24
+ * @param {import("vue").Ref<any[]>} params.processResults
25
+ * @param {import("vue").Ref<boolean>} params.isProcessed
26
+ * @param {import("vue").Ref<boolean>} params.loading
27
+ * @param {import("vue").Ref<boolean>} params.isPolling
28
+ * @param {import("@eox/map").EOxMap | null} params.mapElement
29
+ */
30
+ const useInitProcess = ({
31
+ selectedStac,
32
+ jsonformEl,
33
+ jsonformSchema,
34
+ chartSpec,
35
+ isProcessed,
36
+ processResults,
37
+ loading,
38
+ isPolling,
39
+ mapElement,
40
+ }) => {
41
+ const layersEvents = useEventBus(eoxLayersKey);
42
+
43
+ onMounted(async () => {
44
+ // wait for the layers to be rendered
45
+ if ((mapElement?.layers.length ?? 0) > 1) {
46
+ await initProcess({
47
+ enableCompare: mapElement?.id === "compare",
48
+ selectedStac,
49
+ jsonformEl,
50
+ jsonformSchema,
51
+ chartSpec,
52
+ isProcessed,
53
+ processResults,
54
+ loading,
55
+ isPolling,
56
+ });
57
+ } else {
58
+ layersEvents.once(async () => {
59
+ await initProcess({
60
+ enableCompare: mapElement?.id === "compare",
61
+ selectedStac,
62
+ jsonformEl,
63
+ jsonformSchema,
64
+ chartSpec,
65
+ isProcessed,
66
+ loading,
67
+ processResults,
68
+ isPolling,
69
+ });
70
+ });
71
+ }
72
+ });
73
+
74
+ const evtKey =
75
+ mapElement?.id === "compare" ? "compareLayers:updated" : "layers:updated";
76
+ useOnLayersUpdate(async (evt, _payload) => {
77
+ if (evt !== evtKey) {
78
+ return;
79
+ }
80
+ await initProcess({
81
+ enableCompare: mapElement?.id === "compare",
82
+ selectedStac,
83
+ jsonformEl,
84
+ jsonformSchema,
85
+ chartSpec,
86
+ isProcessed,
87
+ processResults,
88
+ loading,
89
+ isPolling,
90
+ });
91
+ });
92
+ };
93
+
94
+ /**
95
+ * Auto execute the process when the jsonform has the execute option
96
+ *
97
+ * @param {import("vue").Ref<boolean>} autoExec
98
+ * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
99
+ * @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
100
+ * @param {() => Promise<void>} startProcess
101
+ **/
102
+ function useAutoExec(
103
+ autoExec,
104
+ jsonformEl,
105
+ jsonformSchema,
106
+ startProcess,
107
+ ) {
108
+ /**
109
+ * @param {CustomEvent} _e
110
+ **/
111
+ const onJsonFormChange = async (_e) => {
112
+ await startProcess();
113
+ };
114
+
115
+ const addEventListener = async () => {
116
+ await nextTick(() => {
117
+ //@ts-expect-error TODO
118
+ jsonformEl.value?.addEventListener("change", onJsonFormChange);
119
+ });
120
+ };
121
+ const removeEventListener = () => {
122
+ //@ts-expect-error TODO
123
+ jsonformEl.value?.removeEventListener("change", onJsonFormChange);
124
+ };
125
+
126
+ watch(jsonformSchema, (updatedSchema) => {
127
+ autoExec.value = updatedSchema?.options?.["execute"] || false;
128
+ });
129
+
130
+ onMounted(() => {
131
+ watch(
132
+ autoExec,
133
+ async (exec) => {
134
+ if (exec) {
135
+ await addEventListener();
136
+ } else {
137
+ removeEventListener();
138
+ }
139
+ },
140
+ { immediate: true },
141
+ );
142
+ });
143
+ }
144
+
145
+ const _style_0 = "eox-chart{--background-color: transparent;padding-top:1em}eox-jsonform{padding:.7em;min-height:0px}";
146
+
147
+ const _hoisted_1 = {
148
+ ref: "container",
149
+ class: "pb-4"
150
+ };
151
+ const _hoisted_2 = [".schema"];
152
+ const _hoisted_3 = [".spec", ".dataValues", ".opt"];
153
+ const _hoisted_4 = { class: "mt-4 text-right" };
154
+
155
+
156
+ const _sfc_main = {
157
+ __name: 'index',
158
+ props: {
159
+ enableCompare: {
160
+ type: Boolean,
161
+ default: false,
162
+ },
163
+ vegaEmbedOptions: {
164
+ type: Object,
165
+ default() {
166
+ return { actions: true };
167
+ },
168
+ },
169
+ },
170
+ setup(__props) {
171
+
172
+
173
+ /** @type {import("vue").Ref<import("vega").Spec|null>} */
174
+ const chartSpec = ref(null);
175
+
176
+ /** @type {import("vue").Ref<Record<string,any>|null>} */
177
+ const chartData = ref(null);
178
+ const isProcessed = ref(false);
179
+
180
+ /** @type {import("vue").Ref<Record<string,any>|null>} */
181
+ const jsonformSchema = ref(null);
182
+
183
+ const jsonformEl =
184
+ /** @type {Readonly<import("vue").ShallowRef<import("@eox/jsonform").EOxJSONForm | null>>} */ (
185
+ useTemplateRef("jsonformEl")
186
+ );
187
+ const isAsync = computed(
188
+ () =>
189
+ selectedStac.value?.links.filter((l) => l.endpoint === "eoxhub_workspaces")
190
+ .length,
191
+ );
192
+ const containerEl = useTemplateRef("container");
193
+
194
+ const loading = ref(false);
195
+
196
+ const autoExec = ref(false);
197
+
198
+ const isPolling = ref(false);
199
+ /** @type {import("vue").Ref<any[]>} */
200
+ const processResults = ref([]);
201
+
202
+ const showExecBtn = computed(
203
+ () =>
204
+ !autoExec.value &&
205
+ (!!jsonformSchema.value || !!chartSpec.value) &&
206
+ !!jsonformEl.value,
207
+ );
208
+ const { selectedStac, selectedCompareStac } = storeToRefs(useSTAcStore());
209
+ const currentSelectedStac = __props.enableCompare ? selectedCompareStac : selectedStac;
210
+ const mapElement = __props.enableCompare ? mapCompareEl : mapEl;
211
+ const currentIndicator = __props.enableCompare ? compareIndicator : indicator;
212
+ const currentJobs = __props.enableCompare ? compareJobs : jobs;
213
+
214
+ const jsonformKey = computed(
215
+ () => currentIndicator.value + mapElement.value?.id,
216
+ );
217
+
218
+ useInitProcess({
219
+ selectedStac: currentSelectedStac,
220
+ mapElement: mapElement.value,
221
+ jsonformEl,
222
+ jsonformSchema,
223
+ chartSpec,
224
+ isProcessed,
225
+ processResults,
226
+ loading,
227
+ isPolling,
228
+ });
229
+
230
+ const downloadResults = () => {
231
+ processResults.value.forEach((result) => {
232
+ if (!result) {
233
+ return;
234
+ }
235
+ let fileName = "";
236
+ if (typeof result === "string") {
237
+ fileName = result.includes("/")
238
+ ? (result.split("/").pop() ?? "")
239
+ : result;
240
+ fileName = fileName.includes("?") ? fileName.split("?")[0] : fileName;
241
+ } else {
242
+ fileName = currentSelectedStac.value?.id + "_process_results.json";
243
+ }
244
+ download(fileName, result);
245
+ });
246
+ };
247
+
248
+ const startProcess = async () => {
249
+ /** @param {*} jsonformSchema */
250
+ const getDrawToolsProperty = (jsonformSchema) => {
251
+ for (const property in jsonformSchema.properties) {
252
+ if (jsonformSchema.properties[property]?.options?.drawtools) {
253
+ return property;
254
+ }
255
+ }
256
+ };
257
+ const drawToolsProperty = getDrawToolsProperty(jsonformSchema.value);
258
+ const propertyIsEmpty =
259
+ drawToolsProperty &&
260
+ //@ts-expect-error jsonfrom.value is not typed
261
+ Array.isArray(jsonformEl.value?.value[drawToolsProperty]) &&
262
+ //@ts-expect-error jsonfrom.value is not typed
263
+ !jsonformEl.value?.value[drawToolsProperty].length;
264
+
265
+ if (propertyIsEmpty) {
266
+ isProcessed.value = false;
267
+ chartSpec.value = null;
268
+ return;
269
+ }
270
+ const errors = jsonformEl.value?.editor.validate();
271
+ if (errors?.length) {
272
+ console.warn("[eodash] Form validation failed", errors);
273
+ return;
274
+ }
275
+
276
+ processResults.value = [];
277
+
278
+ await handleProcesses({
279
+ jobs: currentJobs,
280
+ selectedStac: currentSelectedStac,
281
+ jsonformEl,
282
+ jsonformSchema,
283
+ chartSpec,
284
+ chartData,
285
+ loading,
286
+ isPolling,
287
+ processResults,
288
+ mapElement: mapElement.value,
289
+ });
290
+
291
+ isProcessed.value = true;
292
+ if (isAsync.value) updateJobsStatus(currentJobs, currentIndicator.value);
293
+ };
294
+ useAutoExec(autoExec, jsonformEl, jsonformSchema, startProcess);
295
+
296
+ const chartStyles = computed(() => {
297
+ /** @type {Record<string,string>} */
298
+ const styles = {};
299
+ if (!chartSpec.value?.["height"]) {
300
+ styles["height"] =
301
+ Math.max(
302
+ (containerEl.value?.offsetHeight ?? 0) -
303
+ (jsonformEl.value?.offsetHeight ?? 0),
304
+ 200,
305
+ ) + "px";
306
+ }
307
+ return styles;
308
+ });
309
+
310
+ return (_ctx, _cache) => {
311
+
312
+
313
+ return (openBlock(), createElementBlock("div", _hoisted_1, [
314
+ createVNode(ProcessList, {
315
+ "map-element": unref(mapElement),
316
+ "enable-compare": __props.enableCompare
317
+ }, null, 8 /* PROPS */, ["map-element", "enable-compare"]),
318
+ (jsonformSchema.value)
319
+ ? (openBlock(), createElementBlock("eox-jsonform", {
320
+ key: jsonformKey.value,
321
+ ref_key: "jsonformEl",
322
+ ref: jsonformEl,
323
+ ".schema": jsonformSchema.value
324
+ }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2))
325
+ : createCommentVNode("v-if", true),
326
+ (isProcessed.value && chartSpec.value)
327
+ ? (openBlock(), createElementBlock("eox-chart", {
328
+ key: 1,
329
+ class: "chart",
330
+ ".spec": toRaw(chartSpec.value),
331
+ ".dataValues": toRaw(chartData.value),
332
+ "onClick:item": _cache[0] || (_cache[0] = (...args) => (unref(onChartClick) && unref(onChartClick)(...args))),
333
+ style: normalizeStyle(chartStyles.value),
334
+ ".opt": __props.vegaEmbedOptions
335
+ }, null, 44 /* STYLE, PROPS, NEED_HYDRATION */, _hoisted_3))
336
+ : createCommentVNode("v-if", true),
337
+ createElementVNode("div", _hoisted_4, [
338
+ (showExecBtn.value)
339
+ ? (openBlock(), createBlock(VBtn, {
340
+ key: 0,
341
+ loading: loading.value,
342
+ style: {"margin-right":"20px"},
343
+ "append-icon": [unref(mdiCogPlayOutline)],
344
+ onClick: startProcess,
345
+ color: "primary"
346
+ }, {
347
+ default: withCtx(() => _cache[1] || (_cache[1] = [
348
+ createTextVNode(" Execute ", -1 /* CACHED */)
349
+ ])),
350
+ _: 1 /* STABLE */,
351
+ __: [1]
352
+ }, 8 /* PROPS */, ["loading", "append-icon"]))
353
+ : createCommentVNode("v-if", true),
354
+ (processResults.value.length && isProcessed.value && !isAsync.value)
355
+ ? (openBlock(), createBlock(VBtn, {
356
+ key: 1,
357
+ color: "primary",
358
+ "append-icon": [unref(mdiDownloadCircleOutline)],
359
+ onClick: downloadResults
360
+ }, {
361
+ default: withCtx(() => _cache[2] || (_cache[2] = [
362
+ createTextVNode(" Download ", -1 /* CACHED */)
363
+ ])),
364
+ _: 1 /* STABLE */,
365
+ __: [2]
366
+ }, 8 /* PROPS */, ["append-icon"]))
367
+ : createCommentVNode("v-if", true)
368
+ ])
369
+ ], 512 /* NEED_PATCH */))
370
+ }
371
+ }
372
+
373
+ };
374
+ const index = /*#__PURE__*/_export_sfc(_sfc_main, [['styles',[_style_0]]]);
375
+
376
+ export { index as default };
@@ -1,4 +1,4 @@
1
- import { shallowRef, onMounted, computed, readonly } from 'vue';
1
+ import { shallowRef, onMounted, toRef, readonly } from 'vue';
2
2
 
3
3
  // Utilities
4
4
 
@@ -10,7 +10,7 @@ function useSsrBoot() {
10
10
  isBooted.value = true;
11
11
  });
12
12
  });
13
- const ssrBootStyles = computed(() => !isBooted.value ? {
13
+ const ssrBootStyles = toRef(() => !isBooted.value ? {
14
14
  transition: 'none !important'
15
15
  } : undefined);
16
16
  return {