@eodash/eodash 5.0.0-processing → 5.0.0-rc.1

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 (112) hide show
  1. package/core/client/asWebComponent.js +2 -3
  2. package/core/client/components/DashboardLayout.vue +35 -17
  3. package/core/client/components/Loading.vue +6 -9
  4. package/core/client/components/MobileLayout.vue +16 -14
  5. package/core/client/composables/DefineEodash.js +13 -3
  6. package/core/client/composables/DefineTemplate.js +67 -0
  7. package/core/client/composables/DefineWidgets.js +3 -2
  8. package/core/client/composables/EodashMap.js +23 -12
  9. package/core/client/composables/EodashProcess.js +10 -11
  10. package/core/client/composables/index.js +35 -10
  11. package/core/client/eodash.js +381 -139
  12. package/core/client/{utils/eodashSTAC.js → eodashSTAC/EodashCollection.js} +75 -42
  13. package/core/client/{utils → eodashSTAC}/createLayers.js +10 -8
  14. package/core/client/{utils → eodashSTAC}/helpers.js +45 -68
  15. package/core/client/eodashSTAC/triggers.js +43 -0
  16. package/core/client/plugins/vuetify.js +2 -1
  17. package/core/client/store/{Actions.js → actions.js} +16 -2
  18. package/core/client/store/index.js +4 -18
  19. package/core/client/store/stac.js +4 -4
  20. package/core/client/store/{States.js → states.js} +2 -0
  21. package/{dist/types/core/client/types.d.ts → core/client/types.ts} +47 -8
  22. package/core/client/utils/states.js +8 -3
  23. package/core/client/views/Dashboard.vue +6 -4
  24. package/core/client/vite-env.d.ts +1 -1
  25. package/dist/client/{DashboardLayout-CVMJ4l8M.js → DashboardLayout-FS5inBIm.js} +12 -15
  26. package/dist/client/{DynamicWebComponent-Cv8n457T.js → DynamicWebComponent-CBSgT677.js} +1 -1
  27. package/dist/client/{EodashDatePicker-VVkiPmpc.js → EodashDatePicker-BGSS2ZYK.js} +75 -163
  28. package/dist/client/EodashItemFilter-CFNKjm_Z.js +151 -0
  29. package/dist/client/{EodashLayerControl-53WghA8G.js → EodashLayerControl-CzffoPUs.js} +17 -7
  30. package/dist/client/EodashLayoutSwitcher-DM0zDhvI.js +52 -0
  31. package/dist/client/{EodashMap-CQnOePpy.js → EodashMap-BdFZ657e.js} +101 -38
  32. package/dist/client/EodashMapBtns-rC_IPD-Z.js +107 -0
  33. package/dist/client/EodashProcess-SLsTISKV.js +714 -0
  34. package/dist/client/EodashStacInfo-DFD0gtWm.js +85 -0
  35. package/dist/client/EodashTools-ImohD2ys.js +103 -0
  36. package/dist/client/{ExportState-BT8MLAW7.js → ExportState-LNZAovzM.js} +13 -13
  37. package/dist/client/{Footer-C6GUG84G.js → Footer-c19dV1ZR.js} +1 -1
  38. package/dist/client/{Header-D2dtCWp8.js → Header-CcvXFqqt.js} +3 -3
  39. package/dist/client/{MobileLayout-BAo8Wr8T.js → MobileLayout-OM6Wc-vj.js} +28 -31
  40. package/dist/client/{PopUp-Bm01q7Ko.js → PopUp-B0_c0207.js} +29 -8
  41. package/dist/client/{VImg-B8AbetCE.js → VImg-BpDhCbL0.js} +2 -2
  42. package/dist/client/{VMain-DnGlQUyr.js → VMain-DC05bDwX.js} +1 -1
  43. package/dist/client/{VOverlay-B8Qj7LRG.js → VOverlay-C7EUyVe_.js} +3 -3
  44. package/dist/client/VTooltip-C78suika.js +86 -0
  45. package/dist/client/{WidgetsContainer-CwXRRLS1.js → WidgetsContainer-sD1vDnhF.js} +1 -1
  46. package/dist/client/{asWebComponent-DUUoR7MZ.js → asWebComponent-D8bMMCEr.js} +1374 -1052
  47. package/dist/client/{style.css → eo-dash.css} +1 -1
  48. package/dist/client/eo-dash.js +1 -1
  49. package/dist/client/{forwardRefs-CZJhEAKW.js → forwardRefs-yw6tFXER.js} +1 -1
  50. package/dist/client/{index-DlIO7sJ3.js → index-CpK_Yaom.js} +1 -1
  51. package/dist/client/{transition-BiR8wMn1.js → transition-B2YwqAYJ.js} +1 -1
  52. package/dist/node/cli.js +2 -2
  53. package/package.json +48 -37
  54. package/widgets/EodashDatePicker.vue +68 -54
  55. package/widgets/EodashItemFilter.vue +60 -105
  56. package/widgets/EodashLayerControl.vue +17 -4
  57. package/widgets/EodashLayoutSwitcher.vue +36 -0
  58. package/widgets/EodashMap.vue +26 -27
  59. package/widgets/EodashMapBtns.vue +41 -4
  60. package/widgets/EodashProcess.vue +4 -12
  61. package/widgets/EodashStacInfo.vue +82 -0
  62. package/widgets/EodashTools.vue +83 -0
  63. package/widgets/ExportState.vue +12 -12
  64. package/widgets/PopUp.vue +24 -2
  65. package/core/client/asWebComponent.d.ts +0 -23
  66. package/core/client/types.d.ts +0 -279
  67. package/dist/client/EodashItemFilter-CugWNQ86.js +0 -194
  68. package/dist/client/EodashMapBtns-uaRwFtfB.js +0 -66
  69. package/dist/client/EodashProcess-cF0unIy8.js +0 -1477
  70. package/dist/types/core/client/App.vue.d.ts +0 -7
  71. package/dist/types/core/client/asWebComponent.d.ts +0 -9
  72. package/dist/types/core/client/components/DashboardLayout.vue.d.ts +0 -2
  73. package/dist/types/core/client/components/DynamicWebComponent.vue.d.ts +0 -18
  74. package/dist/types/core/client/components/ErrorAlert.vue.d.ts +0 -2
  75. package/dist/types/core/client/components/Footer.vue.d.ts +0 -2
  76. package/dist/types/core/client/components/Header.vue.d.ts +0 -2
  77. package/dist/types/core/client/components/IframeWrapper.vue.d.ts +0 -7
  78. package/dist/types/core/client/components/Loading.vue.d.ts +0 -2
  79. package/dist/types/core/client/components/MobileLayout.vue.d.ts +0 -2
  80. package/dist/types/core/client/composables/DefineEodash.d.ts +0 -2
  81. package/dist/types/core/client/composables/DefineTemplate.d.ts +0 -15
  82. package/dist/types/core/client/composables/DefineWidgets.d.ts +0 -14
  83. package/dist/types/core/client/composables/EodashMap.d.ts +0 -5
  84. package/dist/types/core/client/composables/index.d.ts +0 -30
  85. package/dist/types/core/client/eodash.d.ts +0 -8
  86. package/dist/types/core/client/main.d.ts +0 -2
  87. package/dist/types/core/client/plugins/axios.d.ts +0 -2
  88. package/dist/types/core/client/plugins/index.d.ts +0 -3
  89. package/dist/types/core/client/plugins/vuetify.d.ts +0 -82
  90. package/dist/types/core/client/render.d.ts +0 -1
  91. package/dist/types/core/client/store/Actions.d.ts +0 -12
  92. package/dist/types/core/client/store/States.d.ts +0 -22
  93. package/dist/types/core/client/store/index.d.ts +0 -2
  94. package/dist/types/core/client/store/stac.d.ts +0 -25
  95. package/dist/types/core/client/utils/createLayers.d.ts +0 -45
  96. package/dist/types/core/client/utils/eodashSTAC.d.ts +0 -82
  97. package/dist/types/core/client/utils/helpers.d.ts +0 -84
  98. package/dist/types/core/client/utils/index.d.ts +0 -2
  99. package/dist/types/core/client/utils/keys.d.ts +0 -6
  100. package/dist/types/core/client/utils/states.d.ts +0 -14
  101. package/dist/types/core/client/views/Dashboard.vue.d.ts +0 -9
  102. package/dist/types/widgets/EodashDatePicker.vue.d.ts +0 -7
  103. package/dist/types/widgets/EodashItemFilter.vue.d.ts +0 -42
  104. package/dist/types/widgets/EodashLayerControl.vue.d.ts +0 -11
  105. package/dist/types/widgets/EodashLayoutSwitcher.vue.d.ts +0 -9
  106. package/dist/types/widgets/EodashMap.vue.d.ts +0 -7
  107. package/dist/types/widgets/EodashMapBtns.vue.d.ts +0 -11
  108. package/dist/types/widgets/EodashStacInfo.vue.d.ts +0 -21
  109. package/dist/types/widgets/EodashTools.vue.d.ts +0 -15
  110. package/dist/types/widgets/ExportState.vue.d.ts +0 -7
  111. package/dist/types/widgets/PopUp.vue.d.ts +0 -22
  112. package/dist/types/widgets/WidgetsContainer.vue.d.ts +0 -7
@@ -1,1477 +0,0 @@
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 { ae as axios, af as getLayers, a4 as mapEl, ag as extractLayerConfig, a7 as eoxLayersKey, a0 as useSTAcStore, ah as useOnLayersUpdate, V as VBtn } from './asWebComponent-DUUoR7MZ.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 log from 'loglevel';
10
-
11
- /*!
12
- * mustache.js - Logic-less {{mustache}} templates with JavaScript
13
- * http://github.com/janl/mustache.js
14
- */
15
-
16
- var objectToString = Object.prototype.toString;
17
- var isArray = Array.isArray || function isArrayPolyfill (object) {
18
- return objectToString.call(object) === '[object Array]';
19
- };
20
-
21
- function isFunction (object) {
22
- return typeof object === 'function';
23
- }
24
-
25
- /**
26
- * More correct typeof string handling array
27
- * which normally returns typeof 'object'
28
- */
29
- function typeStr (obj) {
30
- return isArray(obj) ? 'array' : typeof obj;
31
- }
32
-
33
- function escapeRegExp (string) {
34
- return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
35
- }
36
-
37
- /**
38
- * Null safe way of checking whether or not an object,
39
- * including its prototype, has a given property
40
- */
41
- function hasProperty (obj, propName) {
42
- return obj != null && typeof obj === 'object' && (propName in obj);
43
- }
44
-
45
- /**
46
- * Safe way of detecting whether or not the given thing is a primitive and
47
- * whether it has the given property
48
- */
49
- function primitiveHasOwnProperty (primitive, propName) {
50
- return (
51
- primitive != null
52
- && typeof primitive !== 'object'
53
- && primitive.hasOwnProperty
54
- && primitive.hasOwnProperty(propName)
55
- );
56
- }
57
-
58
- // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
59
- // See https://github.com/janl/mustache.js/issues/189
60
- var regExpTest = RegExp.prototype.test;
61
- function testRegExp (re, string) {
62
- return regExpTest.call(re, string);
63
- }
64
-
65
- var nonSpaceRe = /\S/;
66
- function isWhitespace (string) {
67
- return !testRegExp(nonSpaceRe, string);
68
- }
69
-
70
- var entityMap = {
71
- '&': '&',
72
- '<': '&lt;',
73
- '>': '&gt;',
74
- '"': '&quot;',
75
- "'": '&#39;',
76
- '/': '&#x2F;',
77
- '`': '&#x60;',
78
- '=': '&#x3D;'
79
- };
80
-
81
- function escapeHtml (string) {
82
- return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
83
- return entityMap[s];
84
- });
85
- }
86
-
87
- var whiteRe = /\s*/;
88
- var spaceRe = /\s+/;
89
- var equalsRe = /\s*=/;
90
- var curlyRe = /\s*\}/;
91
- var tagRe = /#|\^|\/|>|\{|&|=|!/;
92
-
93
- /**
94
- * Breaks up the given `template` string into a tree of tokens. If the `tags`
95
- * argument is given here it must be an array with two string values: the
96
- * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
97
- * course, the default is to use mustaches (i.e. mustache.tags).
98
- *
99
- * A token is an array with at least 4 elements. The first element is the
100
- * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
101
- * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
102
- * all text that appears outside a symbol this element is "text".
103
- *
104
- * The second element of a token is its "value". For mustache tags this is
105
- * whatever else was inside the tag besides the opening symbol. For text tokens
106
- * this is the text itself.
107
- *
108
- * The third and fourth elements of the token are the start and end indices,
109
- * respectively, of the token in the original template.
110
- *
111
- * Tokens that are the root node of a subtree contain two more elements: 1) an
112
- * array of tokens in the subtree and 2) the index in the original template at
113
- * which the closing tag for that section begins.
114
- *
115
- * Tokens for partials also contain two more elements: 1) a string value of
116
- * indendation prior to that tag and 2) the index of that tag on that line -
117
- * eg a value of 2 indicates the partial is the third tag on this line.
118
- */
119
- function parseTemplate (template, tags) {
120
- if (!template)
121
- return [];
122
- var lineHasNonSpace = false;
123
- var sections = []; // Stack to hold section tokens
124
- var tokens = []; // Buffer to hold the tokens
125
- var spaces = []; // Indices of whitespace tokens on the current line
126
- var hasTag = false; // Is there a {{tag}} on the current line?
127
- var nonSpace = false; // Is there a non-space char on the current line?
128
- var indentation = ''; // Tracks indentation for tags that use it
129
- var tagIndex = 0; // Stores a count of number of tags encountered on a line
130
-
131
- // Strips all whitespace tokens array for the current line
132
- // if there was a {{#tag}} on it and otherwise only space.
133
- function stripSpace () {
134
- if (hasTag && !nonSpace) {
135
- while (spaces.length)
136
- delete tokens[spaces.pop()];
137
- } else {
138
- spaces = [];
139
- }
140
-
141
- hasTag = false;
142
- nonSpace = false;
143
- }
144
-
145
- var openingTagRe, closingTagRe, closingCurlyRe;
146
- function compileTags (tagsToCompile) {
147
- if (typeof tagsToCompile === 'string')
148
- tagsToCompile = tagsToCompile.split(spaceRe, 2);
149
-
150
- if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
151
- throw new Error('Invalid tags: ' + tagsToCompile);
152
-
153
- openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
154
- closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
155
- closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
156
- }
157
-
158
- compileTags(tags || mustache.tags);
159
-
160
- var scanner = new Scanner(template);
161
-
162
- var start, type, value, chr, token, openSection;
163
- while (!scanner.eos()) {
164
- start = scanner.pos;
165
-
166
- // Match any text between tags.
167
- value = scanner.scanUntil(openingTagRe);
168
-
169
- if (value) {
170
- for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
171
- chr = value.charAt(i);
172
-
173
- if (isWhitespace(chr)) {
174
- spaces.push(tokens.length);
175
- indentation += chr;
176
- } else {
177
- nonSpace = true;
178
- lineHasNonSpace = true;
179
- indentation += ' ';
180
- }
181
-
182
- tokens.push([ 'text', chr, start, start + 1 ]);
183
- start += 1;
184
-
185
- // Check for whitespace on the current line.
186
- if (chr === '\n') {
187
- stripSpace();
188
- indentation = '';
189
- tagIndex = 0;
190
- lineHasNonSpace = false;
191
- }
192
- }
193
- }
194
-
195
- // Match the opening tag.
196
- if (!scanner.scan(openingTagRe))
197
- break;
198
-
199
- hasTag = true;
200
-
201
- // Get the tag type.
202
- type = scanner.scan(tagRe) || 'name';
203
- scanner.scan(whiteRe);
204
-
205
- // Get the tag value.
206
- if (type === '=') {
207
- value = scanner.scanUntil(equalsRe);
208
- scanner.scan(equalsRe);
209
- scanner.scanUntil(closingTagRe);
210
- } else if (type === '{') {
211
- value = scanner.scanUntil(closingCurlyRe);
212
- scanner.scan(curlyRe);
213
- scanner.scanUntil(closingTagRe);
214
- type = '&';
215
- } else {
216
- value = scanner.scanUntil(closingTagRe);
217
- }
218
-
219
- // Match the closing tag.
220
- if (!scanner.scan(closingTagRe))
221
- throw new Error('Unclosed tag at ' + scanner.pos);
222
-
223
- if (type == '>') {
224
- token = [ type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace ];
225
- } else {
226
- token = [ type, value, start, scanner.pos ];
227
- }
228
- tagIndex++;
229
- tokens.push(token);
230
-
231
- if (type === '#' || type === '^') {
232
- sections.push(token);
233
- } else if (type === '/') {
234
- // Check section nesting.
235
- openSection = sections.pop();
236
-
237
- if (!openSection)
238
- throw new Error('Unopened section "' + value + '" at ' + start);
239
-
240
- if (openSection[1] !== value)
241
- throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
242
- } else if (type === 'name' || type === '{' || type === '&') {
243
- nonSpace = true;
244
- } else if (type === '=') {
245
- // Set the tags for the next time around.
246
- compileTags(value);
247
- }
248
- }
249
-
250
- stripSpace();
251
-
252
- // Make sure there are no open sections when we're done.
253
- openSection = sections.pop();
254
-
255
- if (openSection)
256
- throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
257
-
258
- return nestTokens(squashTokens(tokens));
259
- }
260
-
261
- /**
262
- * Combines the values of consecutive text tokens in the given `tokens` array
263
- * to a single token.
264
- */
265
- function squashTokens (tokens) {
266
- var squashedTokens = [];
267
-
268
- var token, lastToken;
269
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
270
- token = tokens[i];
271
-
272
- if (token) {
273
- if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
274
- lastToken[1] += token[1];
275
- lastToken[3] = token[3];
276
- } else {
277
- squashedTokens.push(token);
278
- lastToken = token;
279
- }
280
- }
281
- }
282
-
283
- return squashedTokens;
284
- }
285
-
286
- /**
287
- * Forms the given array of `tokens` into a nested tree structure where
288
- * tokens that represent a section have two additional items: 1) an array of
289
- * all tokens that appear in that section and 2) the index in the original
290
- * template that represents the end of that section.
291
- */
292
- function nestTokens (tokens) {
293
- var nestedTokens = [];
294
- var collector = nestedTokens;
295
- var sections = [];
296
-
297
- var token, section;
298
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
299
- token = tokens[i];
300
-
301
- switch (token[0]) {
302
- case '#':
303
- case '^':
304
- collector.push(token);
305
- sections.push(token);
306
- collector = token[4] = [];
307
- break;
308
- case '/':
309
- section = sections.pop();
310
- section[5] = token[2];
311
- collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
312
- break;
313
- default:
314
- collector.push(token);
315
- }
316
- }
317
-
318
- return nestedTokens;
319
- }
320
-
321
- /**
322
- * A simple string scanner that is used by the template parser to find
323
- * tokens in template strings.
324
- */
325
- function Scanner (string) {
326
- this.string = string;
327
- this.tail = string;
328
- this.pos = 0;
329
- }
330
-
331
- /**
332
- * Returns `true` if the tail is empty (end of string).
333
- */
334
- Scanner.prototype.eos = function eos () {
335
- return this.tail === '';
336
- };
337
-
338
- /**
339
- * Tries to match the given regular expression at the current position.
340
- * Returns the matched text if it can match, the empty string otherwise.
341
- */
342
- Scanner.prototype.scan = function scan (re) {
343
- var match = this.tail.match(re);
344
-
345
- if (!match || match.index !== 0)
346
- return '';
347
-
348
- var string = match[0];
349
-
350
- this.tail = this.tail.substring(string.length);
351
- this.pos += string.length;
352
-
353
- return string;
354
- };
355
-
356
- /**
357
- * Skips all text until the given regular expression can be matched. Returns
358
- * the skipped string, which is the entire tail if no match can be made.
359
- */
360
- Scanner.prototype.scanUntil = function scanUntil (re) {
361
- var index = this.tail.search(re), match;
362
-
363
- switch (index) {
364
- case -1:
365
- match = this.tail;
366
- this.tail = '';
367
- break;
368
- case 0:
369
- match = '';
370
- break;
371
- default:
372
- match = this.tail.substring(0, index);
373
- this.tail = this.tail.substring(index);
374
- }
375
-
376
- this.pos += match.length;
377
-
378
- return match;
379
- };
380
-
381
- /**
382
- * Represents a rendering context by wrapping a view object and
383
- * maintaining a reference to the parent context.
384
- */
385
- function Context (view, parentContext) {
386
- this.view = view;
387
- this.cache = { '.': this.view };
388
- this.parent = parentContext;
389
- }
390
-
391
- /**
392
- * Creates a new context using the given view with this context
393
- * as the parent.
394
- */
395
- Context.prototype.push = function push (view) {
396
- return new Context(view, this);
397
- };
398
-
399
- /**
400
- * Returns the value of the given name in this context, traversing
401
- * up the context hierarchy if the value is absent in this context's view.
402
- */
403
- Context.prototype.lookup = function lookup (name) {
404
- var cache = this.cache;
405
-
406
- var value;
407
- if (cache.hasOwnProperty(name)) {
408
- value = cache[name];
409
- } else {
410
- var context = this, intermediateValue, names, index, lookupHit = false;
411
-
412
- while (context) {
413
- if (name.indexOf('.') > 0) {
414
- intermediateValue = context.view;
415
- names = name.split('.');
416
- index = 0;
417
-
418
- /**
419
- * Using the dot notion path in `name`, we descend through the
420
- * nested objects.
421
- *
422
- * To be certain that the lookup has been successful, we have to
423
- * check if the last object in the path actually has the property
424
- * we are looking for. We store the result in `lookupHit`.
425
- *
426
- * This is specially necessary for when the value has been set to
427
- * `undefined` and we want to avoid looking up parent contexts.
428
- *
429
- * In the case where dot notation is used, we consider the lookup
430
- * to be successful even if the last "object" in the path is
431
- * not actually an object but a primitive (e.g., a string, or an
432
- * integer), because it is sometimes useful to access a property
433
- * of an autoboxed primitive, such as the length of a string.
434
- **/
435
- while (intermediateValue != null && index < names.length) {
436
- if (index === names.length - 1)
437
- lookupHit = (
438
- hasProperty(intermediateValue, names[index])
439
- || primitiveHasOwnProperty(intermediateValue, names[index])
440
- );
441
-
442
- intermediateValue = intermediateValue[names[index++]];
443
- }
444
- } else {
445
- intermediateValue = context.view[name];
446
-
447
- /**
448
- * Only checking against `hasProperty`, which always returns `false` if
449
- * `context.view` is not an object. Deliberately omitting the check
450
- * against `primitiveHasOwnProperty` if dot notation is not used.
451
- *
452
- * Consider this example:
453
- * ```
454
- * Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"})
455
- * ```
456
- *
457
- * If we were to check also against `primitiveHasOwnProperty`, as we do
458
- * in the dot notation case, then render call would return:
459
- *
460
- * "The length of a football field is 9."
461
- *
462
- * rather than the expected:
463
- *
464
- * "The length of a football field is 100 yards."
465
- **/
466
- lookupHit = hasProperty(context.view, name);
467
- }
468
-
469
- if (lookupHit) {
470
- value = intermediateValue;
471
- break;
472
- }
473
-
474
- context = context.parent;
475
- }
476
-
477
- cache[name] = value;
478
- }
479
-
480
- if (isFunction(value))
481
- value = value.call(this.view);
482
-
483
- return value;
484
- };
485
-
486
- /**
487
- * A Writer knows how to take a stream of tokens and render them to a
488
- * string, given a context. It also maintains a cache of templates to
489
- * avoid the need to parse the same template twice.
490
- */
491
- function Writer () {
492
- this.templateCache = {
493
- _cache: {},
494
- set: function set (key, value) {
495
- this._cache[key] = value;
496
- },
497
- get: function get (key) {
498
- return this._cache[key];
499
- },
500
- clear: function clear () {
501
- this._cache = {};
502
- }
503
- };
504
- }
505
-
506
- /**
507
- * Clears all cached templates in this writer.
508
- */
509
- Writer.prototype.clearCache = function clearCache () {
510
- if (typeof this.templateCache !== 'undefined') {
511
- this.templateCache.clear();
512
- }
513
- };
514
-
515
- /**
516
- * Parses and caches the given `template` according to the given `tags` or
517
- * `mustache.tags` if `tags` is omitted, and returns the array of tokens
518
- * that is generated from the parse.
519
- */
520
- Writer.prototype.parse = function parse (template, tags) {
521
- var cache = this.templateCache;
522
- var cacheKey = template + ':' + (tags || mustache.tags).join(':');
523
- var isCacheEnabled = typeof cache !== 'undefined';
524
- var tokens = isCacheEnabled ? cache.get(cacheKey) : undefined;
525
-
526
- if (tokens == undefined) {
527
- tokens = parseTemplate(template, tags);
528
- isCacheEnabled && cache.set(cacheKey, tokens);
529
- }
530
- return tokens;
531
- };
532
-
533
- /**
534
- * High-level method that is used to render the given `template` with
535
- * the given `view`.
536
- *
537
- * The optional `partials` argument may be an object that contains the
538
- * names and templates of partials that are used in the template. It may
539
- * also be a function that is used to load partial templates on the fly
540
- * that takes a single argument: the name of the partial.
541
- *
542
- * If the optional `config` argument is given here, then it should be an
543
- * object with a `tags` attribute or an `escape` attribute or both.
544
- * If an array is passed, then it will be interpreted the same way as
545
- * a `tags` attribute on a `config` object.
546
- *
547
- * The `tags` attribute of a `config` object must be an array with two
548
- * string values: the opening and closing tags used in the template (e.g.
549
- * [ "<%", "%>" ]). The default is to mustache.tags.
550
- *
551
- * The `escape` attribute of a `config` object must be a function which
552
- * accepts a string as input and outputs a safely escaped string.
553
- * If an `escape` function is not provided, then an HTML-safe string
554
- * escaping function is used as the default.
555
- */
556
- Writer.prototype.render = function render (template, view, partials, config) {
557
- var tags = this.getConfigTags(config);
558
- var tokens = this.parse(template, tags);
559
- var context = (view instanceof Context) ? view : new Context(view, undefined);
560
- return this.renderTokens(tokens, context, partials, template, config);
561
- };
562
-
563
- /**
564
- * Low-level method that renders the given array of `tokens` using
565
- * the given `context` and `partials`.
566
- *
567
- * Note: The `originalTemplate` is only ever used to extract the portion
568
- * of the original template that was contained in a higher-order section.
569
- * If the template doesn't use higher-order sections, this argument may
570
- * be omitted.
571
- */
572
- Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate, config) {
573
- var buffer = '';
574
-
575
- var token, symbol, value;
576
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
577
- value = undefined;
578
- token = tokens[i];
579
- symbol = token[0];
580
-
581
- if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate, config);
582
- else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate, config);
583
- else if (symbol === '>') value = this.renderPartial(token, context, partials, config);
584
- else if (symbol === '&') value = this.unescapedValue(token, context);
585
- else if (symbol === 'name') value = this.escapedValue(token, context, config);
586
- else if (symbol === 'text') value = this.rawValue(token);
587
-
588
- if (value !== undefined)
589
- buffer += value;
590
- }
591
-
592
- return buffer;
593
- };
594
-
595
- Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate, config) {
596
- var self = this;
597
- var buffer = '';
598
- var value = context.lookup(token[1]);
599
-
600
- // This function is used to render an arbitrary template
601
- // in the current context by higher-order sections.
602
- function subRender (template) {
603
- return self.render(template, context, partials, config);
604
- }
605
-
606
- if (!value) return;
607
-
608
- if (isArray(value)) {
609
- for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
610
- buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
611
- }
612
- } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
613
- buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
614
- } else if (isFunction(value)) {
615
- if (typeof originalTemplate !== 'string')
616
- throw new Error('Cannot use higher-order sections without the original template');
617
-
618
- // Extract the portion of the original template that the section contains.
619
- value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
620
-
621
- if (value != null)
622
- buffer += value;
623
- } else {
624
- buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
625
- }
626
- return buffer;
627
- };
628
-
629
- Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate, config) {
630
- var value = context.lookup(token[1]);
631
-
632
- // Use JavaScript's definition of falsy. Include empty arrays.
633
- // See https://github.com/janl/mustache.js/issues/186
634
- if (!value || (isArray(value) && value.length === 0))
635
- return this.renderTokens(token[4], context, partials, originalTemplate, config);
636
- };
637
-
638
- Writer.prototype.indentPartial = function indentPartial (partial, indentation, lineHasNonSpace) {
639
- var filteredIndentation = indentation.replace(/[^ \t]/g, '');
640
- var partialByNl = partial.split('\n');
641
- for (var i = 0; i < partialByNl.length; i++) {
642
- if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
643
- partialByNl[i] = filteredIndentation + partialByNl[i];
644
- }
645
- }
646
- return partialByNl.join('\n');
647
- };
648
-
649
- Writer.prototype.renderPartial = function renderPartial (token, context, partials, config) {
650
- if (!partials) return;
651
- var tags = this.getConfigTags(config);
652
-
653
- var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
654
- if (value != null) {
655
- var lineHasNonSpace = token[6];
656
- var tagIndex = token[5];
657
- var indentation = token[4];
658
- var indentedValue = value;
659
- if (tagIndex == 0 && indentation) {
660
- indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
661
- }
662
- var tokens = this.parse(indentedValue, tags);
663
- return this.renderTokens(tokens, context, partials, indentedValue, config);
664
- }
665
- };
666
-
667
- Writer.prototype.unescapedValue = function unescapedValue (token, context) {
668
- var value = context.lookup(token[1]);
669
- if (value != null)
670
- return value;
671
- };
672
-
673
- Writer.prototype.escapedValue = function escapedValue (token, context, config) {
674
- var escape = this.getConfigEscape(config) || mustache.escape;
675
- var value = context.lookup(token[1]);
676
- if (value != null)
677
- return (typeof value === 'number' && escape === mustache.escape) ? String(value) : escape(value);
678
- };
679
-
680
- Writer.prototype.rawValue = function rawValue (token) {
681
- return token[1];
682
- };
683
-
684
- Writer.prototype.getConfigTags = function getConfigTags (config) {
685
- if (isArray(config)) {
686
- return config;
687
- }
688
- else if (config && typeof config === 'object') {
689
- return config.tags;
690
- }
691
- else {
692
- return undefined;
693
- }
694
- };
695
-
696
- Writer.prototype.getConfigEscape = function getConfigEscape (config) {
697
- if (config && typeof config === 'object' && !isArray(config)) {
698
- return config.escape;
699
- }
700
- else {
701
- return undefined;
702
- }
703
- };
704
-
705
- var mustache = {
706
- name: 'mustache.js',
707
- version: '4.2.0',
708
- tags: [ '{{', '}}' ],
709
- clearCache: undefined,
710
- escape: undefined,
711
- parse: undefined,
712
- render: undefined,
713
- Scanner: undefined,
714
- Context: undefined,
715
- Writer: undefined,
716
- /**
717
- * Allows a user to override the default caching strategy, by providing an
718
- * object with set, get and clear methods. This can also be used to disable
719
- * the cache by setting it to the literal `undefined`.
720
- */
721
- set templateCache (cache) {
722
- defaultWriter.templateCache = cache;
723
- },
724
- /**
725
- * Gets the default or overridden caching object from the default writer.
726
- */
727
- get templateCache () {
728
- return defaultWriter.templateCache;
729
- }
730
- };
731
-
732
- // All high-level mustache.* functions use this writer.
733
- var defaultWriter = new Writer();
734
-
735
- /**
736
- * Clears all cached templates in the default writer.
737
- */
738
- mustache.clearCache = function clearCache () {
739
- return defaultWriter.clearCache();
740
- };
741
-
742
- /**
743
- * Parses and caches the given template in the default writer and returns the
744
- * array of tokens it contains. Doing this ahead of time avoids the need to
745
- * parse templates on the fly as they are rendered.
746
- */
747
- mustache.parse = function parse (template, tags) {
748
- return defaultWriter.parse(template, tags);
749
- };
750
-
751
- /**
752
- * Renders the `template` with the given `view`, `partials`, and `config`
753
- * using the default writer.
754
- */
755
- mustache.render = function render (template, view, partials, config) {
756
- if (typeof template !== 'string') {
757
- throw new TypeError('Invalid template! Template should be a "string" ' +
758
- 'but "' + typeStr(template) + '" was given as the first ' +
759
- 'argument for mustache#render(template, view, partials)');
760
- }
761
-
762
- return defaultWriter.render(template, view, partials, config);
763
- };
764
-
765
- // Export the escaping function so that the user may override it.
766
- // See https://github.com/janl/mustache.js/issues/244
767
- mustache.escape = escapeHtml;
768
-
769
- // Export these mainly for testing, but also for advanced usage.
770
- mustache.Scanner = Scanner;
771
- mustache.Context = Context;
772
- mustache.Writer = Writer;
773
-
774
- /**
775
- * Polls the process status and fetches a result item when the process is successful.
776
- *
777
- * @param {Object} params - Parameters for polling the process status.
778
- * @param {string} params.processUrl - The URL of the process JSON report.
779
- * @param {import("vue").Ref<boolean>} params.isPolling - checks wether the polling should continue
780
- * @param {number} [params.pollInterval=5000] - The interval (in milliseconds) between polling attempts.
781
- * @param {number} [params.maxRetries=60] - The maximum number of polling attempts.
782
- * @returns {Promise<JSON>} The fetched results JSON.
783
- * @throws {Error} If the process does not complete successfully within the maximum retries.
784
- */
785
- async function pollProcessStatus({
786
- processUrl,
787
- isPolling,
788
- pollInterval = 5000,
789
- maxRetries = 60,
790
- }) {
791
- let retries = 0;
792
- isPolling.value = true;
793
- while (retries < maxRetries && isPolling.value) {
794
- try {
795
- // Fetch the process JSON report
796
- const cacheBuster = new Date().getTime(); // Add a timestamp for cache busting
797
- const response = await axios.get(`${processUrl}?t=${cacheBuster}`);
798
- const processReport = response.data;
799
-
800
- // Check if the status is "successful"
801
- if (processReport.status === "successful") {
802
- console.log("Process completed successfully. Fetching result item...");
803
-
804
- // Extract the result item URL
805
- const resultsUrl = processReport.links[1].href;
806
- if (!resultsUrl) {
807
- throw new Error(`Result links not found in the process report.`);
808
- }
809
-
810
- // Fetch the result item
811
- const resultResponse = await axios.get(resultsUrl);
812
- console.log("Result file fetched successfully:", resultResponse.data);
813
- return resultResponse.data; // Return the json result list
814
- }
815
-
816
- // Log the current status if not successful
817
- console.log(
818
- `Status: ${processReport.status}. Retrying in ${pollInterval / 1000} seconds...`,
819
- );
820
- } catch (error) {
821
- if (error instanceof Error) {
822
- console.error("Error while polling process status:", error.message);
823
- } else {
824
- console.error("Unknown error occurred:", error);
825
- }
826
- }
827
-
828
- // Wait for the next poll
829
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
830
- retries++;
831
- }
832
- if (!isPolling.value) {
833
- console.warn("Polling was stopped before the process was completed.");
834
- return JSON.parse("{}");
835
- }
836
-
837
- throw new Error(
838
- "Max retries reached. Process did not complete successfully.",
839
- );
840
- }
841
-
842
- /**
843
- * Auto execute the process when the jsonform has the execute option
844
- *
845
- * @param {import("vue").Ref<boolean>} autoExec
846
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} jsonformEl
847
- * @param {import("vue").Ref<Record<string,any> | null>} jsonformSchema
848
- * @param {import("vue").Ref<boolean>} isProcessed
849
- * @param {() => Promise<void>} startProcess
850
- **/
851
- function useAutoExec(
852
- autoExec,
853
- jsonformEl,
854
- jsonformSchema,
855
- isProcessed,
856
- startProcess,
857
- ) {
858
- /**
859
- * @param {CustomEvent} _e
860
- **/
861
- const onJsonFormChange = async (_e) => {
862
- if (!isProcessed.value) {
863
- await startProcess();
864
- }
865
- };
866
-
867
- const addEventListener = async () => {
868
- await nextTick(() => {
869
- //@ts-expect-error TODO
870
- jsonformEl.value?.addEventListener("change", onJsonFormChange);
871
- });
872
- };
873
- const removeEventListener = () => {
874
- //@ts-expect-error TODO
875
- jsonformEl.value?.removeEventListener("change", onJsonFormChange);
876
- };
877
-
878
- watch(jsonformSchema, (updatedSchema) => {
879
- autoExec.value = updatedSchema?.options?.["execute"] || false;
880
- });
881
-
882
- onMounted(() => {
883
- watch(
884
- autoExec,
885
- async (exec) => {
886
- if (exec) {
887
- await addEventListener();
888
- } else {
889
- removeEventListener();
890
- }
891
- },
892
- { immediate: true },
893
- );
894
- });
895
- }
896
-
897
- /**
898
- * @param {Record<string,any> |null} [jsonformSchema]
899
- **/
900
- function getBboxProperty(jsonformSchema) {
901
- return /** @type {string} */ (
902
- Object.keys(jsonformSchema?.properties ?? {}).find(
903
- (key) => jsonformSchema?.properties[key].format === "bounding-box",
904
- )
905
- );
906
- }
907
-
908
- /**
909
- * Extracts the keys of type "geojson" from the jsonform schema
910
- * @param {Record<string,any> |null} [jsonformSchema]
911
- **/
912
- function getGeoJsonProperties(jsonformSchema) {
913
- return /** @type {string[]} */ (
914
- Object.keys(jsonformSchema?.properties ?? {}).filter(
915
- (key) => jsonformSchema?.properties[key].type === "geojson",
916
- )
917
- );
918
- }
919
-
920
- /**
921
- * Converts jsonform geojson values to stringified geometries
922
- * @param {Record<string,any> |null} [jsonformSchema]
923
- * @param {Record<string,any>} jsonformValue
924
- **/
925
- function extractGeometries(jsonformValue, jsonformSchema) {
926
- const geojsonKeys = getGeoJsonProperties(jsonformSchema);
927
-
928
- for (const key of geojsonKeys) {
929
- if (!jsonformValue[key]) {
930
- continue;
931
- }
932
-
933
- if (isMulti(jsonformSchema?.properties[key])) {
934
- // jsonformValue[key] is a feature collection
935
- jsonformValue[key] =
936
- /** @type {import("ol/format/GeoJSON").GeoJSONFeatureCollection} */ (
937
- jsonformValue[key]
938
- ).features.map((feature) => JSON.stringify(feature.geometry));
939
- } else {
940
- // jsonformValue[key] is a single feature
941
- jsonformValue[key] = JSON.stringify(jsonformValue[key].geometry);
942
- }
943
- }
944
- }
945
-
946
- /**
947
- * Injects CSS to remove the borders of the jsonform from inside the shadowRoot
948
- * @param {import("@eox/jsonform").EOxJSONForm | null} jsonFormEl
949
- **/
950
- function injectJsonformCSS(jsonFormEl) {
951
- if (!jsonFormEl?.shadowRoot) {
952
- console.error("jsonform has no shadowRoot");
953
- return;
954
- }
955
- const stylesheet = new CSSStyleSheet();
956
- stylesheet.replaceSync(`.je-indented-panel {
957
- border: none !important;
958
- }`);
959
- jsonFormEl.shadowRoot.adoptedStyleSheets = [stylesheet];
960
- }
961
-
962
- /**
963
- * @param {import("stac-ts").StacLink[] | undefined} links
964
- * @param {Record<string,any>|undefined} jsonformValue
965
- * @param {number[]} origBbox
966
- */
967
- function processImage(links, jsonformValue, origBbox) {
968
- if (!links) return;
969
- const imageLinks = links.filter(
970
- (link) => link.rel === "service" && link.type === "image/png",
971
- );
972
- const layers = [];
973
- for (const link of imageLinks) {
974
- layers.push({
975
- type: "Image",
976
- properties: {
977
- id: link.id,
978
- title: "Results " + link.id,
979
- },
980
- source: {
981
- type: "ImageStatic",
982
- imageExtent: origBbox,
983
- url: mustache.render(link.href, {
984
- ...(jsonformValue ?? {}),
985
- }),
986
- },
987
- });
988
- }
989
- return layers;
990
- }
991
-
992
- /**
993
- * @param {import("stac-ts").StacLink[] | undefined} links
994
- * @param {Record<string,any> | undefined} jsonformValue
995
- * @param {string} layerId
996
- */
997
- async function processVector(links, jsonformValue, layerId) {
998
- if (!links) return;
999
- /** @type {Record<string,any>[]} */
1000
- const layers = [];
1001
- const vectorLinks = links.filter(
1002
- (link) => link.rel === "service" && link.type === "application/geo+json",
1003
- );
1004
- if (vectorLinks.length === 0) return layers;
1005
-
1006
- let flatStyleJSON = null;
1007
-
1008
- for (const link of vectorLinks) {
1009
- if ("eox:flatstyle" in (link ?? {})) {
1010
- flatStyleJSON = await axios
1011
- .get(/** @type {string} */ (link["eox:flatstyle"]))
1012
- .then((resp) => resp.data);
1013
- }
1014
-
1015
- /** @type {Record<string,any>|undefined} */
1016
- let layerConfig;
1017
- /** @type {Record<string,any>|undefined} */
1018
- let style;
1019
- if (flatStyleJSON) {
1020
- const extracted = extractLayerConfig(flatStyleJSON);
1021
- layerConfig = extracted.layerConfig;
1022
- style = extracted.style;
1023
- }
1024
-
1025
- layers.push({
1026
- type: "Vector",
1027
- source: {
1028
- type: "Vector",
1029
- url: mustache.render(link.href, {
1030
- ...(jsonformValue ?? {}),
1031
- }),
1032
- format: "GeoJSON",
1033
- },
1034
- properties: {
1035
- id: layerId + "_vector_process",
1036
- title: "Results " + layerId,
1037
- ...(layerConfig && { ...layerConfig, ...(style && { style: style }) }),
1038
- },
1039
- });
1040
- }
1041
- return layers;
1042
- }
1043
-
1044
- /**
1045
- * @param {import("stac-ts").StacLink[] | undefined} links
1046
- * @param {Record<string,any> | undefined} jsonformValue
1047
- * @param {import("vue").Ref<boolean>} isPolling
1048
- * @param {string} layerId
1049
- */
1050
- async function processGeoTiff(links, jsonformValue, layerId, isPolling) {
1051
- if (!links) return;
1052
- const geotiffLinks = links.filter(
1053
- (link) => link.rel === "service" && link.type === "image/tiff",
1054
- );
1055
- let urls = [];
1056
- let flatStyleJSON = null;
1057
- for (const link of geotiffLinks ?? []) {
1058
- if (link.endpoint === "eoxhub_workspaces") {
1059
- // TODO: prove of concept, needs to be reworked for sure
1060
- // Special handling for eoxhub workspace process endpoints
1061
- const postBody = await axios
1062
- .get(/** @type {string} */ (link["body"]), { responseType: "text" })
1063
- .then((resp) => resp.data);
1064
- const jsonData = JSON.parse(
1065
- mustache.render(postBody, { ...(jsonformValue ?? {}) }),
1066
- );
1067
- try {
1068
- const responseProcess = await axios.post(link.href, jsonData, {
1069
- headers: {
1070
- "Content-Type": "application/json",
1071
- },
1072
- });
1073
- console.log(responseProcess.headers.location);
1074
- await pollProcessStatus({
1075
- processUrl: responseProcess.headers.location,
1076
- isPolling,
1077
- })
1078
- .then((resultItem) => {
1079
- // @ts-expect-error we have currently no definition of what is allowed as response
1080
- const resultUrls = resultItem?.urls;
1081
- if (!resultUrls?.length) {
1082
- return;
1083
- }
1084
-
1085
- urls.push(resultUrls[0]);
1086
- })
1087
- .catch((error) => {
1088
- if (error instanceof Error) {
1089
- console.error("Polling failed:", error.message);
1090
- } else {
1091
- console.error("Unknown error occurred during polling:", error);
1092
- }
1093
- });
1094
- } catch (error) {
1095
- if (error instanceof Error) {
1096
- console.error("Error sending POST request:", error.message);
1097
- } else {
1098
- console.error("Unknown error occurred:", error);
1099
- }
1100
- }
1101
- } else {
1102
- urls.push(mustache.render(link.href, { ...(jsonformValue ?? {}) }));
1103
- }
1104
- if ("eox:flatstyle" in (link ?? {})) {
1105
- flatStyleJSON = await axios
1106
- .get(/** @type {string} */ (link["eox:flatstyle"]))
1107
- .then((resp) => resp.data);
1108
- }
1109
- }
1110
- /** @type {Record<string,any>|undefined} */
1111
- let layerConfig;
1112
- /** @type {Record<string,any>|undefined} */
1113
- let style;
1114
- if (flatStyleJSON) {
1115
- const extracted = extractLayerConfig(flatStyleJSON);
1116
- layerConfig = extracted.layerConfig;
1117
- style = extracted.style;
1118
- }
1119
- return urls.length
1120
- ? {
1121
- type: "WebGLTile",
1122
- source: {
1123
- type: "GeoTIFF",
1124
- normalize: !style,
1125
- sources: urls.map((url) => ({ url })),
1126
- },
1127
- properties: {
1128
- id: layerId + "_geotiff_process",
1129
- title: "Results " + layerId,
1130
- ...(layerConfig && { layerConfig: layerConfig }),
1131
- },
1132
- ...(style && { style: style }),
1133
- }
1134
- : undefined;
1135
- }
1136
-
1137
- /**
1138
- * @param {import("stac-ts").StacLink[] | undefined} links
1139
- * @param {Record<string,any> | undefined} jsonformValue
1140
- * @param {string} specUrl
1141
- * @returns {Promise<[import("vega").Spec|null,Record<string,any>|null]>}
1142
- **/
1143
- async function getChartValues(links, jsonformValue, specUrl) {
1144
- if (!specUrl || !links) return [null, null];
1145
- /** @type {import("vega").Spec} */
1146
- const spec = await axios.get(specUrl).then((resp) => {
1147
- return resp.data;
1148
- });
1149
- //@ts-expect-error NamedData
1150
- const dataName = spec?.data?.name;
1151
- const dataLinks = links.filter(
1152
- (link) => link.rel === "service" && dataName && link.id === dataName,
1153
- );
1154
-
1155
- /** @type {Record<string,any>} */
1156
- const dataValues = {};
1157
- for (const link of dataLinks ?? []) {
1158
- if (link.type && ["application/json", "text/csv"].includes(link.type)) {
1159
- const dataUrl = mustache.render(link.href, {
1160
- ...(jsonformValue ?? {}),
1161
- ...(link["eox:flatstyle"] ?? {}),
1162
- });
1163
- // Wait for data to be retrieved
1164
- const data = await axios.get(dataUrl).then((resp) => {
1165
- return resp.data;
1166
- });
1167
- // @ts-expect-error we assume data to exist in spec
1168
- spec.data.values = data;
1169
- continue;
1170
- }
1171
-
1172
- dataValues[/** @type {string} */ (link.id)] = await axios
1173
- .get(
1174
- mustache.render(link.href, {
1175
- ...(jsonformValue ?? {}),
1176
- ...(link["eox:flatstyle"] ?? {}),
1177
- }),
1178
- )
1179
- .then((resp) => resp.data);
1180
- }
1181
- return [spec, dataValues];
1182
- }
1183
-
1184
- /**
1185
- * @param {Object} params
1186
- * @param {import("vue").Ref<boolean>} params.loading
1187
- * @param {import("vue").Ref<import("stac-ts").StacCollection | null>} params.selectedStac
1188
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
1189
- * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
1190
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
1191
- * @param {import("vue").Ref<Record<string, any> | null>} params.chartData
1192
- * @param {import("vue").Ref<boolean>} params.isPolling
1193
- */
1194
- async function handleProcesses({
1195
- loading,
1196
- selectedStac,
1197
- jsonformEl,
1198
- jsonformSchema,
1199
- chartSpec,
1200
- chartData,
1201
- isPolling,
1202
- }) {
1203
- log.debug("Processing...");
1204
- loading.value = true;
1205
- try {
1206
- const serviceLinks = selectedStac.value?.links?.filter(
1207
- (l) => l.rel === "service",
1208
- );
1209
- const bboxProperty = getBboxProperty(jsonformSchema.value);
1210
- const jsonformValue = /** @type {Record<string,any>} */ (
1211
- jsonformEl.value?.value
1212
- );
1213
-
1214
- extractGeometries(jsonformValue, jsonformSchema.value);
1215
-
1216
- const origBbox = jsonformValue[bboxProperty];
1217
-
1218
- const specUrl = /** @type {string} */ (
1219
- selectedStac.value?.["eodash:vegadefinition"]
1220
- );
1221
-
1222
- [chartSpec.value, chartData.value] = await getChartValues(
1223
- serviceLinks,
1224
- { ...(jsonformValue ?? {}) },
1225
- specUrl,
1226
- );
1227
- const geotiffLayer = await processGeoTiff(
1228
- serviceLinks,
1229
- jsonformValue,
1230
- selectedStac.value?.id ?? "",
1231
- isPolling,
1232
- );
1233
- const vectorLayers = await processVector(
1234
- serviceLinks,
1235
- jsonformValue,
1236
- selectedStac.value?.id ?? "",
1237
- );
1238
-
1239
- const imageLayers = processImage(serviceLinks, jsonformValue, origBbox);
1240
-
1241
- log.debug(
1242
- "rendered layers after processing:",
1243
- geotiffLayer,
1244
- vectorLayers,
1245
- imageLayers,
1246
- );
1247
-
1248
- if (geotiffLayer || vectorLayers?.length || imageLayers?.length) {
1249
- const layers = [
1250
- ...(geotiffLayer ? [geotiffLayer] : []),
1251
- ...(vectorLayers ?? []),
1252
- ...(imageLayers ?? []),
1253
- ];
1254
- let currentLayers = [...getLayers()];
1255
- let analysisGroup = currentLayers.find((l) =>
1256
- l.properties.id.includes("AnalysisGroup"),
1257
- );
1258
- analysisGroup?.layers.push(...layers);
1259
-
1260
- if (mapEl.value) {
1261
- mapEl.value.layers = [...currentLayers];
1262
- }
1263
- }
1264
- loading.value = false;
1265
- } catch (error) {
1266
- console.error("[eodash] Error while running process:", error);
1267
- loading.value = false;
1268
- throw error;
1269
- }
1270
- }
1271
-
1272
- /**
1273
- * Reset the process state
1274
- * @param {Object} params
1275
- * @param {import("vue").Ref<boolean>} params.loading
1276
- * @param {import("vue").Ref<boolean>} params.isProcessed
1277
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
1278
- * @param {import("vue").Ref<boolean>} params.isPolling
1279
- * @param {import("vue").Ref<Record<string,any>|null>} params.jsonformSchema
1280
- */
1281
- function resetProcess({
1282
- loading,
1283
- isProcessed,
1284
- chartSpec,
1285
- jsonformSchema,
1286
- isPolling,
1287
- }) {
1288
- loading.value = false;
1289
- isProcessed.value = false;
1290
- isPolling.value = false;
1291
- chartSpec.value = null;
1292
- jsonformSchema.value = null;
1293
- }
1294
-
1295
- /**
1296
- * Description placeholder
1297
- *
1298
- * @export
1299
- * @async
1300
- * @param {Object} params
1301
- * @param {import("vue").Ref<import("stac-ts").StacCollection>} params.selectedStac
1302
- * @param {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} params.jsonformEl
1303
- * @param {import("vue").Ref<Record<string,any> | null>} params.jsonformSchema
1304
- * @param {import("vue").Ref<import("@eox/chart").EOxChart["spec"]>} params.chartSpec
1305
- * @param {import("vue").Ref<boolean>} params.isProcessed
1306
- * @param {import("vue").Ref<boolean>} params.loading
1307
- * @param {import("vue").Ref<boolean>} params.isPolling
1308
- */
1309
- async function initProcess({
1310
- selectedStac,
1311
- jsonformEl,
1312
- jsonformSchema,
1313
- chartSpec,
1314
- isProcessed,
1315
- loading,
1316
- isPolling,
1317
- }) {
1318
- if (!selectedStac.value) {
1319
- return;
1320
- }
1321
- resetProcess({ loading, isProcessed, chartSpec, jsonformSchema, isPolling });
1322
- if (selectedStac.value["eodash:jsonform"]) {
1323
- jsonformEl.value?.editor.destroy();
1324
- // wait for the layers to be rendered
1325
- jsonformSchema.value = await axios
1326
- //@ts-expect-error eodash extention
1327
- .get(selectedStac.value["eodash:jsonform"])
1328
- .then((resp) => resp.data);
1329
- // remove borders from jsonform
1330
- await nextTick(() => {
1331
- injectJsonformCSS(jsonformEl.value);
1332
- });
1333
- } else {
1334
- if (!jsonformSchema.value) {
1335
- return;
1336
- }
1337
- jsonformSchema.value = null;
1338
- }
1339
- }
1340
-
1341
- const _hoisted_1 = { class: "process-container" };
1342
- const _hoisted_2 = [".schema"];
1343
- const _hoisted_3 = [".spec", ".dataValues"];
1344
-
1345
-
1346
- const _sfc_main = {
1347
- __name: 'EodashProcess',
1348
- setup(__props) {
1349
-
1350
- const layersEvents = useEventBus(eoxLayersKey);
1351
- const { selectedStac } = storeToRefs(useSTAcStore());
1352
-
1353
- /** @type {import("vue").Ref<import("vega").Spec|null>} */
1354
- const chartSpec = ref(null);
1355
-
1356
- /** @type {import("vue").Ref<Record<string,any>|null>} */
1357
- const chartData = ref(null);
1358
- const isProcessed = ref(false);
1359
-
1360
- /** @type {import("vue").Ref<Record<string,any>|null>} */
1361
- const jsonformSchema = ref(null);
1362
-
1363
- /** @type {import("vue").Ref<import("@eox/jsonform").EOxJSONForm | null>} */
1364
- const jsonformEl = ref(null);
1365
- const loading = ref(false);
1366
-
1367
- const autoExec = ref(false);
1368
-
1369
- const isPolling = ref(false);
1370
-
1371
- onMounted(async () => {
1372
- // wait for the layers to be rendered
1373
- if (mapEl.value?.layers.length <= 1) {
1374
- layersEvents.once(async () => {
1375
- await initProcess({
1376
- //@ts-expect-error TODO
1377
- selectedStac,
1378
- jsonformEl,
1379
- jsonformSchema,
1380
- chartSpec,
1381
- isProcessed,
1382
- loading,
1383
- isPolling,
1384
- });
1385
- });
1386
- } else {
1387
- await initProcess({
1388
- //@ts-expect-error TODO
1389
- selectedStac,
1390
- jsonformEl,
1391
- jsonformSchema,
1392
- chartSpec,
1393
- isProcessed,
1394
- loading,
1395
- isPolling,
1396
- });
1397
- }
1398
- });
1399
-
1400
- useOnLayersUpdate(
1401
- async () =>
1402
- await initProcess({
1403
- //@ts-expect-error TODO
1404
- selectedStac,
1405
- jsonformEl,
1406
- jsonformSchema,
1407
- chartSpec,
1408
- isProcessed,
1409
- loading,
1410
- isPolling,
1411
- }),
1412
- );
1413
-
1414
- const startProcess = async () => {
1415
- const errors = jsonformEl.value?.editor.validate();
1416
- if (errors?.length) {
1417
- console.warn("[eodash] Form validation failed", errors);
1418
- return;
1419
- }
1420
- await handleProcesses({
1421
- jsonformEl,
1422
- jsonformSchema,
1423
- chartSpec,
1424
- chartData,
1425
- loading,
1426
- //@ts-expect-error TODO
1427
- selectedStac,
1428
- isProcessed,
1429
- isPolling,
1430
- });
1431
- isProcessed.value = true;
1432
- };
1433
- useAutoExec(autoExec, jsonformEl, jsonformSchema, isProcessed, startProcess);
1434
-
1435
- return (_ctx, _cache) => {
1436
-
1437
-
1438
- return (openBlock(), createElementBlock("div", _hoisted_1, [
1439
- (jsonformSchema.value)
1440
- ? (openBlock(), createElementBlock("eox-jsonform", {
1441
- key: 0,
1442
- ref_key: "jsonformEl",
1443
- ref: jsonformEl,
1444
- ".schema": jsonformSchema.value
1445
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_2))
1446
- : createCommentVNode("v-if", true),
1447
- (isProcessed.value && chartSpec.value)
1448
- ? (openBlock(), createElementBlock("eox-chart", {
1449
- key: 1,
1450
- class: "chart",
1451
- ".spec": toRaw(chartSpec.value),
1452
- ".dataValues": toRaw(chartData.value)
1453
- }, null, 40 /* PROPS, NEED_HYDRATION */, _hoisted_3))
1454
- : createCommentVNode("v-if", true),
1455
- createElementVNode("span", null, [
1456
- (!autoExec.value)
1457
- ? (openBlock(), createBlock(VBtn, {
1458
- key: 0,
1459
- loading: loading.value,
1460
- style: {"float":"right","margin-right":"20px"},
1461
- onClick: startProcess,
1462
- color: "primary"
1463
- }, {
1464
- default: withCtx(() => _cache[0] || (_cache[0] = [
1465
- createTextVNode(" Execute ")
1466
- ])),
1467
- _: 1 /* STABLE */
1468
- }, 8 /* PROPS */, ["loading"]))
1469
- : createCommentVNode("v-if", true)
1470
- ])
1471
- ]))
1472
- }
1473
- }
1474
-
1475
- };
1476
-
1477
- export { _sfc_main as default };