@geode/opengeodeweb-front 10.44.0-rc.2 → 10.44.0-rc.4

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 (160) hide show
  1. package/.build/server/utils/cleanup.js +7 -2
  2. package/.build/server/utils/microservices.js +9 -81
  3. package/.build/server/utils/microservices_process.js +85 -0
  4. package/.build/server/utils/typed_handler.js +5 -1
  5. package/.build/server/utils/ws_client.js +7 -2
  6. package/.build/shared/utils/fetch_raw.js +2 -2
  7. package/.build/shared/utils/parse_boolean.js +2 -1
  8. package/app/components/ClippingPlanes.vue +22 -78
  9. package/app/components/DragAndDrop.vue +16 -79
  10. package/app/components/FileSelector.vue +9 -6
  11. package/app/components/HybridViewerTooltip.vue +8 -2
  12. package/app/components/MissingFilesSelector.vue +10 -6
  13. package/app/components/ObjectSelector.vue +6 -3
  14. package/app/components/Screenshot.vue +9 -2
  15. package/app/components/ThresholdCard.vue +205 -0
  16. package/app/components/ThresholdFilter.vue +81 -216
  17. package/app/components/ViewToolbar.vue +15 -231
  18. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  19. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  20. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +228 -0
  21. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  22. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  23. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  24. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +234 -0
  25. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  26. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  27. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  28. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +7 -5
  29. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  30. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  31. package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -292
  32. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  33. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  34. package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
  35. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  36. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +12 -10
  37. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +12 -10
  38. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +9 -5
  39. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
  40. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +6 -1
  41. package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
  42. package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
  43. package/app/components/Viewer/Options/ColorPicker.vue +4 -1
  44. package/app/components/Viewer/Options/ColoringTypeSelector.vue +36 -74
  45. package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
  46. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  47. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  48. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  49. package/app/components/Viewer/Surface/PolygonsColoring.vue +231 -0
  50. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  51. package/app/components/csv-preview/CsvPreviewer.vue +4 -1
  52. package/app/composables/attribute_coloring_style.ts +8 -2
  53. package/app/composables/attribute_selector.ts +126 -0
  54. package/app/composables/clipping_slices.ts +166 -0
  55. package/app/composables/global_attribute_style.ts +4 -3
  56. package/app/composables/hover_highlight.ts +6 -5
  57. package/app/composables/project_manager.ts +5 -5
  58. package/app/composables/stepper_tree.ts +10 -2
  59. package/app/composables/tree_filter.ts +11 -2
  60. package/app/composables/tree_keyboard_nav.ts +4 -2
  61. package/app/composables/use_overlapping_picker.ts +5 -5
  62. package/app/composables/view_toolbar_options.ts +126 -0
  63. package/app/composables/view_toolbar_tool_options.ts +115 -0
  64. package/app/composables/view_toolbar_tools.ts +108 -0
  65. package/app/composables/virtual_tree.ts +20 -131
  66. package/app/composables/virtual_tree_flatten.ts +86 -0
  67. package/app/composables/virtual_tree_types.ts +81 -0
  68. package/app/stores/app.ts +8 -55
  69. package/app/stores/app_helpers/extension.ts +1 -1
  70. package/app/stores/app_helpers/registry.ts +69 -0
  71. package/app/stores/feedback.ts +2 -2
  72. package/app/stores/hybrid_viewer.ts +1 -1
  73. package/app/stores/menu.ts +1 -124
  74. package/app/stores/menu_helpers/menus_data.ts +127 -0
  75. package/app/stores/treeview.ts +17 -10
  76. package/app/stores/viewer.ts +17 -78
  77. package/app/stores/viewer_helpers/actions.ts +68 -0
  78. package/app/stores/viewer_helpers/request.ts +61 -0
  79. package/app/utils/clipping_planes.ts +4 -131
  80. package/app/utils/clipping_planes_scene.ts +131 -0
  81. package/app/utils/coloring_styles.ts +101 -0
  82. package/app/utils/default_styles/mesh_components.ts +168 -0
  83. package/app/utils/default_styles/meshes.ts +13 -153
  84. package/app/utils/default_styles/model_components.ts +170 -0
  85. package/app/utils/default_styles/models.ts +16 -153
  86. package/app/utils/drag_and_drop.ts +80 -0
  87. package/app/utils/extension.ts +1 -1
  88. package/app/utils/import_workflow.ts +6 -4
  89. package/app/utils/model_component_coloring.ts +46 -0
  90. package/app/utils/threshold.ts +33 -0
  91. package/app/utils/threshold_sources.ts +51 -0
  92. package/app/utils/upload_path.ts +15 -9
  93. package/internal/database/database.ts +4 -1
  94. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  95. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  96. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  97. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  98. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  99. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  100. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  101. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  102. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  103. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  104. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  105. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  106. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  107. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  108. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  109. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  110. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  111. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  112. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  113. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  114. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  115. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  116. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  117. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  118. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  119. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  120. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  121. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  122. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  123. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  124. package/internal/stores/data_style/model/blocks/polyhedron.ts +14 -10
  125. package/internal/stores/data_style/model/blocks/vertex.ts +14 -10
  126. package/internal/stores/data_style/model/common.ts +10 -119
  127. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  128. package/internal/stores/data_style/model/corners/vertex.ts +14 -10
  129. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  130. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  131. package/internal/stores/data_style/model/lines/edge.ts +14 -10
  132. package/internal/stores/data_style/model/lines/index.ts +10 -134
  133. package/internal/stores/data_style/model/lines/vertex.ts +14 -10
  134. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  135. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  136. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  137. package/internal/stores/data_style/model/surfaces/polygon.ts +14 -10
  138. package/internal/stores/data_style/model/surfaces/vertex.ts +14 -10
  139. package/internal/stores/data_style/model/visibility.ts +3 -156
  140. package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
  141. package/internal/stores/data_style/state.ts +1 -181
  142. package/internal/stores/data_style/state_shared.ts +191 -0
  143. package/internal/stores/hybrid_viewer/brightness.ts +8 -2
  144. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  145. package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
  146. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  147. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  148. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  149. package/internal/stores/hybrid_viewer/highlight.ts +10 -9
  150. package/internal/stores/hybrid_viewer/ruler.ts +4 -3
  151. package/internal/utils/ws_client.ts +8 -1
  152. package/package.json +2 -2
  153. package/server/api/local/extensions/run.post.ts +6 -4
  154. package/server/utils/cleanup.ts +12 -2
  155. package/server/utils/microservices.ts +10 -102
  156. package/server/utils/microservices_process.ts +127 -0
  157. package/server/utils/typed_handler.ts +8 -1
  158. package/server/utils/ws_client.ts +15 -2
  159. package/shared/utils/fetch_raw.ts +2 -2
  160. package/shared/utils/parse_boolean.ts +4 -1
@@ -56,9 +56,12 @@ const mandatory_files = ref<string[]>([]);
56
56
  const additional_files = ref<string[]>([]);
57
57
  const missing_by_file = ref<FileMissingFiles[]>([]);
58
58
  // Files left out at the data type step are not checked
59
- const checked_filenames = computed(() =>
60
- timeSeries ? filenames : filenames.filter((filename) => filename in geodeObjectTypes),
61
- );
59
+ const checked_filenames = computed(() => {
60
+ if (timeSeries) {
61
+ return filenames;
62
+ }
63
+ return filenames.filter((filename) => filename in geodeObjectTypes);
64
+ });
62
65
  // Files whose mandatory files are missing are skipped when the step is skipped
63
66
  const files_without_mandatory = computed(() =>
64
67
  checked_filenames.value.filter(
@@ -160,9 +163,10 @@ async function upload_missing_from(
160
163
  }
161
164
  const found = expected.flatMap((expected_path, index) => {
162
165
  const file = folder_files[match.indices[index] ?? -1];
163
- return file && !uploaded.includes(file)
164
- ? [Object.assign(file, { relativePath: expected_path })]
165
- : [];
166
+ if (file && !uploaded.includes(file)) {
167
+ return [Object.assign(file, { relativePath: expected_path })];
168
+ }
169
+ return [];
166
170
  });
167
171
  if (found.length === 0) {
168
172
  useFeedbackStore().add_warning(`The selected folder does not contain: ${expected.join(", ")}`);
@@ -131,9 +131,12 @@ function resolvePerFile(allowedObjectsList: readonly AllowedObjectMap[]): boolea
131
131
  }
132
132
  const pending = loadable.filter((file) => file.selectedGeodeObject === undefined);
133
133
  resolvedTypes.value = Object.fromEntries(
134
- loadable.flatMap((file) =>
135
- file.selectedGeodeObject === undefined ? [] : [[file.filename, file.selectedGeodeObject]],
136
- ),
134
+ loadable.flatMap((file) => {
135
+ if (file.selectedGeodeObject === undefined) {
136
+ return [];
137
+ }
138
+ return [[file.filename, file.selectedGeodeObject]];
139
+ }),
137
140
  );
138
141
  pendingFilenames.value = pending.map((file) => file.filename);
139
142
  skippedFiles.value = files
@@ -23,6 +23,13 @@ interface Props {
23
23
 
24
24
  const { width = DEFAULT_PANEL_WIDTH, escapeFunction = undefined } = defineProps<Props>();
25
25
 
26
+ function getErrorMessage(error: unknown): string {
27
+ if (error instanceof Error) {
28
+ return error.message;
29
+ }
30
+ return String(error);
31
+ }
32
+
26
33
  const output_extensions =
27
34
  viewer_schemas.opengeodeweb_viewer.viewer.take_screenshot.properties.output_extension.enum;
28
35
  const filename = ref<string>("");
@@ -64,7 +71,7 @@ async function deliverScreenshot(blob: Blob | Uint8Array, current_filename: stri
64
71
  await copy([new ClipboardItem({ "image/png": pngBlob })]);
65
72
  feedbackStore.add_success("Screenshot copied to clipboard");
66
73
  } catch (error) {
67
- const message = error instanceof Error ? error.message : String(error);
74
+ const message = getErrorMessage(error);
68
75
  feedbackStore.add_error(
69
76
  0,
70
77
  "",
@@ -138,7 +145,7 @@ async function takeUiScreenshot(current_filename: string): Promise<void> {
138
145
  const blob = await captureTab(mime_type);
139
146
  await deliverScreenshot(blob, current_filename);
140
147
  } catch (error) {
141
- const message = error instanceof Error ? error.message : String(error);
148
+ const message = getErrorMessage(error);
142
149
  feedbackStore.add_error(0, "", "Screenshot Error", `Failed to capture the page: ${message}`);
143
150
  }
144
151
  }
@@ -0,0 +1,205 @@
1
+ <script setup lang="ts">
2
+ import {
3
+ type AttributeInfo,
4
+ type AttributeSource,
5
+ isValidThresholdAttribute,
6
+ } from "@ogw_front/utils/threshold";
7
+ import type { Threshold, ThresholdAttribute } from "@ogw_internal/stores/hybrid_viewer/filters";
8
+ import { attributeArrayName, getAttributeRange } from "@ogw_front/utils/attributes";
9
+ import ViewerOptionsAttributeRangeSelector from "@ogw_front/components/Viewer/Options/AttributeRangeSelector.vue";
10
+ import { fetchAttributeRange } from "@ogw_front/utils/attribute_range";
11
+ import { useBackStore } from "@ogw_front/stores/back";
12
+ import { useDataStyleStore } from "@ogw_front/stores/data_style";
13
+
14
+ interface Props {
15
+ datasetId: string;
16
+ sources: AttributeSource[];
17
+ index: number;
18
+ threshold: Threshold;
19
+ }
20
+
21
+ const { datasetId, sources, index, threshold } = defineProps<Props>();
22
+
23
+ interface Emits {
24
+ remove: [];
25
+ }
26
+
27
+ const emit = defineEmits<Emits>();
28
+
29
+ const backStore = useBackStore();
30
+ const dataStyleStore = useDataStyleStore();
31
+ const {
32
+ sourceIndex: selectedSourceIndex,
33
+ attributeName,
34
+ item: attributeItem,
35
+ minimum,
36
+ maximum,
37
+ thresholdAttribute,
38
+ } = toRefs(threshold);
39
+ const attributes = ref<AttributeInfo[]>([]);
40
+
41
+ const availableSources = computed<{ title: string; value: number }[]>(() =>
42
+ sources.map((source, sourceIndex) => ({
43
+ title: source.title,
44
+ value: sourceIndex,
45
+ })),
46
+ );
47
+ const currentSource = computed<AttributeSource | undefined>(
48
+ () => sources[selectedSourceIndex.value ?? -1],
49
+ );
50
+ const currentAttribute = computed<AttributeInfo | undefined>(() =>
51
+ attributes.value.find((attribute) => attribute.attribute_name === attributeName.value),
52
+ );
53
+ const currentTimeStep = computed<number | undefined>(() => {
54
+ if (!currentSource.value || !currentAttribute.value?.time_steps?.length) {
55
+ return undefined;
56
+ }
57
+ const step =
58
+ dataStyleStore.attributeTimeStep(
59
+ datasetId,
60
+ currentSource.value.timeStepKey,
61
+ attributeName.value,
62
+ ) ?? 0;
63
+ return Math.min(step, currentAttribute.value.time_steps.length - 1);
64
+ });
65
+ const itemOptions = computed<{ title: string; value: number }[]>(() =>
66
+ Array.from({ length: currentAttribute.value?.nb_items ?? 0 }, (_, itemIndex) => ({
67
+ title: `Item ${itemIndex + 1}`,
68
+ value: itemIndex,
69
+ })),
70
+ );
71
+ const currentThresholdAttribute = computed<ThresholdAttribute | undefined>(() => {
72
+ if (!currentAttribute.value) {
73
+ return undefined;
74
+ }
75
+ const attribute = {
76
+ name: attributeArrayName(currentAttribute.value.attribute_name, currentTimeStep.value),
77
+ location: currentSource.value?.location,
78
+ item: attributeItem.value,
79
+ minimum: minimum.value,
80
+ maximum: maximum.value,
81
+ };
82
+ return isValidThresholdAttribute(attribute) ? attribute : undefined;
83
+ });
84
+
85
+ async function resetRange(): Promise<void> {
86
+ const source = currentSource.value;
87
+ const name = attributeName.value;
88
+ if (!source || name === undefined) {
89
+ return;
90
+ }
91
+ const range = await fetchAttributeRange(source.schemas.range, source.params, name);
92
+ if (name !== attributeName.value) {
93
+ return;
94
+ }
95
+ const { min, max } = getAttributeRange(range, attributeItem.value);
96
+ minimum.value = min;
97
+ maximum.value = max;
98
+ }
99
+
100
+ async function fetchAttributes(): Promise<void> {
101
+ attributes.value = [];
102
+ const source = currentSource.value;
103
+ if (!source) {
104
+ return;
105
+ }
106
+ const response = (await backStore.request({
107
+ schema: source.schemas.names,
108
+ params: source.params,
109
+ })) as { attributes: AttributeInfo[] };
110
+ attributes.value = response.attributes;
111
+ }
112
+
113
+ onMounted(fetchAttributes);
114
+
115
+ watch(selectedSourceIndex, async () => {
116
+ attributeName.value = undefined;
117
+ await fetchAttributes();
118
+ });
119
+
120
+ watch(attributeName, async () => {
121
+ attributeItem.value = 0;
122
+ await resetRange();
123
+ });
124
+
125
+ watch(attributeItem, async () => {
126
+ await resetRange();
127
+ });
128
+
129
+ watch(currentThresholdAttribute, (value) => {
130
+ thresholdAttribute.value = value;
131
+ });
132
+
133
+ defineExpose({ resetRange });
134
+ </script>
135
+
136
+ <template>
137
+ <v-card
138
+ data-testid="thresholdCard"
139
+ variant="outlined"
140
+ class="pa-2 mb-3 rounded-lg border-opacity-50"
141
+ >
142
+ <v-row align="center" justify="space-between" no-gutters class="mb-2">
143
+ <v-col cols="auto">
144
+ <v-chip size="x-small" variant="flat" color="primary" class="font-weight-bold">
145
+ Threshold #{{ index + 1 }}
146
+ </v-chip>
147
+ </v-col>
148
+ <v-col cols="auto">
149
+ <v-btn
150
+ data-testid="removeThresholdCardButton"
151
+ icon="mdi-trash-can-outline"
152
+ size="x-small"
153
+ variant="text"
154
+ color="error"
155
+ @click="emit('remove')"
156
+ />
157
+ </v-col>
158
+ </v-row>
159
+
160
+ <v-select
161
+ v-model="selectedSourceIndex"
162
+ data-testid="thresholdAttributeTypeSelect"
163
+ :items="availableSources"
164
+ label="Select an attribute type"
165
+ variant="outlined"
166
+ density="compact"
167
+ hide-details
168
+ class="mb-3 text-caption"
169
+ />
170
+
171
+ <v-select
172
+ v-if="selectedSourceIndex !== undefined"
173
+ v-model="attributeName"
174
+ data-testid="thresholdAttributeSelect"
175
+ :items="attributes.map((attribute) => attribute.attribute_name)"
176
+ label="Select an attribute"
177
+ variant="outlined"
178
+ density="compact"
179
+ hide-details
180
+ class="mb-3 text-caption"
181
+ />
182
+
183
+ <v-select
184
+ v-if="currentAttribute && currentAttribute.nb_items > 1"
185
+ v-model="attributeItem"
186
+ data-testid="thresholdItemSelect"
187
+ :items="itemOptions"
188
+ label="Select an item"
189
+ variant="outlined"
190
+ density="compact"
191
+ hide-details
192
+ class="mb-3 text-caption"
193
+ />
194
+
195
+ <template v-if="attributeName">
196
+ <span class="text-caption font-weight-bold">Range</span>
197
+ <ViewerOptionsAttributeRangeSelector
198
+ v-model:minimum="minimum"
199
+ v-model:maximum="maximum"
200
+ class="mt-2"
201
+ @reset="resetRange"
202
+ />
203
+ </template>
204
+ </v-card>
205
+ </template>
@@ -1,19 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { type AttributeSchemas, fetchAttributeRange } from "@ogw_front/utils/attribute_range";
3
- import {
4
- MESH_ELEMENT_KINDS,
5
- MODEL_COMPONENT_ATTRIBUTE_SCHEMAS,
6
- MODEL_COMPONENT_KINDS,
7
- attributeArrayName,
8
- getAttributeRange,
9
- } from "@ogw_front/utils/attributes";
10
- import type { JsonRpcSchema } from "@ogw_shared/utils/types.js";
2
+ import type { Threshold, ThresholdAttribute } from "@ogw_internal/stores/hybrid_viewer/filters";
3
+ import type { AttributeSource } from "@ogw_front/utils/threshold";
4
+ import ThresholdCard from "@ogw_front/components/ThresholdCard.vue";
11
5
  import ToolPanel from "@ogw_front/components/ToolPanel.vue";
12
- import ViewerOptionsAttributeRangeSelector from "@ogw_front/components/Viewer/Options/AttributeRangeSelector.vue";
13
- import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
14
- import { useBackStore } from "@ogw_front/stores/back";
6
+ import { fetchSources } from "@ogw_front/utils/threshold_sources";
15
7
  import { useDataStore } from "@ogw_front/stores/data";
16
- import { useDataStyleStore } from "@ogw_front/stores/data_style";
17
8
  import { useDebounceFn } from "@vueuse/core";
18
9
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
19
10
 
@@ -25,34 +16,18 @@ interface Props {
25
16
 
26
17
  const { escapeFunction = undefined } = defineProps<Props>();
27
18
 
28
- interface AttributeSource {
29
- title: string;
30
- schemas: AttributeSchemas;
31
- timeStepKey: string;
32
- params: { id: string; component_ids?: string[] };
33
- location: "point" | "cell";
34
- }
35
-
36
- interface AttributeInfo {
37
- attribute_name: string;
38
- nb_items: number;
39
- time_steps?: number[];
40
- [key: string]: unknown;
41
- }
42
-
43
19
  const show = defineModel<boolean>("show", { default: false });
44
- const backStore = useBackStore();
45
20
  const dataStore = useDataStore();
46
- const dataStyleStore = useDataStyleStore();
47
21
  const hybridViewerStore = useHybridViewerStore();
48
22
  const selectedDatasetId = ref<string>();
49
23
  const sources = ref<AttributeSource[]>([]);
50
- const selectedSourceIndex = ref<number>();
51
- const attributes = ref<AttributeInfo[]>([]);
52
- const attributeName = ref<string>();
53
- const attributeItem = ref<number>(0);
54
- const minimum = ref<number>();
55
- const maximum = ref<number>();
24
+ const thresholds = computed<Threshold[]>(() => {
25
+ if (!selectedDatasetId.value) {
26
+ return [];
27
+ }
28
+ return hybridViewerStore.getThresholds(selectedDatasetId.value);
29
+ });
30
+ const cards = useTemplateRef("cards");
56
31
 
57
32
  const allItems = dataStore.refAllItems();
58
33
  const availableDatasets = computed<{ title: string; value: string }[]>(() =>
@@ -61,165 +36,74 @@ const availableDatasets = computed<{ title: string; value: string }[]>(() =>
61
36
  value: item.id,
62
37
  })),
63
38
  );
64
- const availableSources = computed<{ title: string; value: number }[]>(() =>
65
- sources.value.map((source, index) => ({ title: source.title, value: index })),
66
- );
67
- const currentAttribute = computed<AttributeInfo | undefined>(() =>
68
- attributes.value.find((attribute) => attribute.attribute_name === attributeName.value),
69
- );
70
- const currentTimeStep = computed<number | undefined>(() => {
71
- const source = sources.value[selectedSourceIndex.value ?? -1];
72
- if (!selectedDatasetId.value || !source || !currentAttribute.value?.time_steps?.length) {
73
- return undefined;
74
- }
75
- const step =
76
- dataStyleStore.attributeTimeStep(
77
- selectedDatasetId.value,
78
- source.timeStepKey,
79
- attributeName.value,
80
- ) ?? 0;
81
- return Math.min(step, currentAttribute.value.time_steps.length - 1);
82
- });
83
- const itemOptions = computed<{ title: string; value: number }[]>(() =>
84
- Array.from({ length: currentAttribute.value?.nb_items ?? 0 }, (_, index) => ({
85
- title: `Item ${index + 1}`,
86
- value: index,
87
- })),
88
- );
89
39
 
90
- function attributeSchema(kind: string, isModel: boolean, route: "names" | "range"): JsonRpcSchema {
91
- const prefix = isModel ? "model_component_" : "";
92
- return back_schemas.opengeodeweb_back[
93
- `${prefix}${kind}_attribute_${route}` as keyof typeof back_schemas.opengeodeweb_back
94
- ] as JsonRpcSchema;
40
+ async function applyThresholds(): Promise<void> {
41
+ if (!selectedDatasetId.value) {
42
+ return;
43
+ }
44
+ await hybridViewerStore.setThreshold(
45
+ [selectedDatasetId.value],
46
+ thresholds.value
47
+ .map((threshold) => threshold.thresholdAttribute)
48
+ .filter((attribute): attribute is ThresholdAttribute => attribute !== undefined),
49
+ );
95
50
  }
96
51
 
97
- function attributeSource(
98
- kind: string,
99
- title: string,
100
- params: { id: string; component_ids?: string[] },
101
- modelType?: string,
102
- ): AttributeSource {
103
- const isModel = modelType !== undefined;
104
- const schema = attributeSchema(kind, isModel, "names");
105
- return {
106
- title: `${title}${kind} attribute`,
107
- schemas: { names: schema, range: attributeSchema(kind, isModel, "range") },
108
- timeStepKey:
109
- modelType === undefined
110
- ? schema.$id
111
- : (MODEL_COMPONENT_ATTRIBUTE_SCHEMAS[modelType]?.[kind]?.$id ?? schema.$id),
112
- params,
113
- location: kind === "vertex" ? "point" : "cell",
114
- };
115
- }
52
+ const debouncedApply = useDebounceFn(() => applyThresholds(), DEBOUNCE_DELAY);
116
53
 
117
- async function fetchSources(id: string): Promise<AttributeSource[]> {
118
- const item = await dataStore.item(id);
119
- if (item.viewer_type !== "model") {
120
- return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
121
- .filter((kind): kind is string => kind !== undefined)
122
- .map((kind) => attributeSource(kind, "", { id }));
54
+ function addThreshold(): void {
55
+ if (selectedDatasetId.value) {
56
+ hybridViewerStore.addThreshold(selectedDatasetId.value);
123
57
  }
124
- const modelSources = await Promise.all(
125
- Object.entries(MODEL_COMPONENT_KINDS).map(async ([type, kinds]) => {
126
- const component_ids = await dataStore.getMeshComponentGeodeIds(id, type);
127
- if (component_ids.length === 0) {
128
- return [];
129
- }
130
- return kinds.map((kind) => attributeSource(kind, `${type} `, { id, component_ids }, type));
131
- }),
132
- );
133
- return modelSources.flat();
134
58
  }
135
59
 
136
- async function applyThreshold(): Promise<void> {
137
- const source = sources.value[selectedSourceIndex.value ?? -1];
138
- if (
139
- !selectedDatasetId.value ||
140
- !source ||
141
- !attributeName.value ||
142
- minimum.value === undefined ||
143
- maximum.value === undefined ||
144
- minimum.value > maximum.value
145
- ) {
146
- return;
60
+ function removeThreshold(index: number): void {
61
+ if (selectedDatasetId.value) {
62
+ hybridViewerStore.removeThreshold(selectedDatasetId.value, index);
147
63
  }
148
- await hybridViewerStore.setThreshold([selectedDatasetId.value], {
149
- name: attributeArrayName(attributeName.value, currentTimeStep.value),
150
- location: source.location,
151
- item: attributeItem.value,
152
- minimum: minimum.value,
153
- maximum: maximum.value,
154
- });
155
64
  }
156
65
 
157
- const debouncedApply = useDebounceFn(() => applyThreshold(), DEBOUNCE_DELAY);
66
+ async function clearThresholds(id: string): Promise<void> {
67
+ hybridViewerStore.removeThresholds(id);
68
+ await hybridViewerStore.setThreshold([id], []);
69
+ }
158
70
 
159
- async function resetRange(): Promise<void> {
160
- const source = sources.value[selectedSourceIndex.value ?? -1];
161
- const name = attributeName.value;
162
- if (!source || name === undefined) {
163
- return;
164
- }
165
- const range = await fetchAttributeRange(source.schemas.range, source.params, name);
166
- if (name !== attributeName.value) {
167
- return;
168
- }
169
- const { min, max } = getAttributeRange(range, attributeItem.value);
170
- minimum.value = min;
171
- maximum.value = max;
71
+ async function resetRanges(): Promise<void> {
72
+ await Promise.all((cards.value ?? []).map((card) => card?.resetRange()));
172
73
  }
173
74
 
174
- async function removeThreshold(): Promise<void> {
175
- attributeName.value = undefined;
75
+ async function removeThresholds(): Promise<void> {
176
76
  if (selectedDatasetId.value) {
177
- await hybridViewerStore.setThreshold([selectedDatasetId.value]);
77
+ await clearThresholds(selectedDatasetId.value);
78
+ hybridViewerStore.addThreshold(selectedDatasetId.value);
178
79
  }
179
80
  }
180
81
 
181
82
  watch(selectedDatasetId, async (id, previousId) => {
182
83
  if (previousId) {
183
- await hybridViewerStore.setThreshold([previousId]);
84
+ await clearThresholds(previousId);
184
85
  }
185
- selectedSourceIndex.value = undefined;
186
- sources.value = id ? await fetchSources(id) : [];
187
- });
188
-
189
- watch(selectedSourceIndex, async (index) => {
190
- attributeName.value = undefined;
191
- attributes.value = [];
192
- const source = sources.value[index ?? -1];
193
- if (!source) {
194
- return;
86
+ if (id) {
87
+ sources.value = await fetchSources(dataStore, id);
88
+ } else {
89
+ sources.value = [];
90
+ }
91
+ if (id && hybridViewerStore.getThresholds(id).length === 0) {
92
+ hybridViewerStore.addThreshold(id);
195
93
  }
196
- const response = (await backStore.request({
197
- schema: source.schemas.names,
198
- params: source.params,
199
- })) as { attributes: AttributeInfo[] };
200
- attributes.value = response.attributes;
201
- });
202
-
203
- watch(attributeName, async () => {
204
- attributeItem.value = 0;
205
- await resetRange();
206
- });
207
-
208
- watch(attributeItem, async () => {
209
- await resetRange();
210
- });
211
-
212
- watch(currentTimeStep, () => {
213
- debouncedApply();
214
94
  });
215
95
 
216
- watch([minimum, maximum], () => {
217
- debouncedApply();
218
- });
96
+ watch(
97
+ thresholds,
98
+ () => {
99
+ debouncedApply();
100
+ },
101
+ { deep: true },
102
+ );
219
103
 
220
104
  watch(show, (visible) => {
221
105
  if (visible) {
222
- applyThreshold();
106
+ applyThresholds();
223
107
  }
224
108
  });
225
109
  </script>
@@ -245,50 +129,31 @@ watch(show, (visible) => {
245
129
  class="mb-3 text-caption"
246
130
  />
247
131
 
248
- <v-select
249
- v-if="selectedDatasetId"
250
- v-model="selectedSourceIndex"
251
- data-testid="thresholdAttributeTypeSelect"
252
- :items="availableSources"
253
- label="Select an attribute type"
254
- variant="outlined"
255
- density="compact"
256
- hide-details
257
- class="mb-3 text-caption"
258
- />
259
-
260
- <v-select
261
- v-if="selectedSourceIndex !== undefined"
262
- v-model="attributeName"
263
- data-testid="thresholdAttributeSelect"
264
- :items="attributes.map((attribute) => attribute.attribute_name)"
265
- label="Select an attribute"
266
- variant="outlined"
267
- density="compact"
268
- hide-details
269
- class="mb-3 text-caption"
270
- />
271
-
272
- <v-select
273
- v-if="currentAttribute && currentAttribute.nb_items > 1"
274
- v-model="attributeItem"
275
- data-testid="thresholdItemSelect"
276
- :items="itemOptions"
277
- label="Select an item"
278
- variant="outlined"
279
- density="compact"
280
- hide-details
281
- class="mb-3 text-caption"
282
- />
283
-
284
- <template v-if="attributeName">
285
- <v-divider class="my-3" />
286
- <span class="text-caption font-weight-bold">Range</span>
287
- <ViewerOptionsAttributeRangeSelector
288
- v-model:minimum="minimum"
289
- v-model:maximum="maximum"
290
- class="mt-2"
291
- @reset="resetRange"
132
+ <template v-if="selectedDatasetId">
133
+ <v-divider class="my-2" />
134
+ <v-row align="center" justify="space-between" no-gutters class="mb-2">
135
+ <v-col class="text-caption font-weight-bold">Thresholds ({{ thresholds.length }})</v-col>
136
+ <v-col cols="auto">
137
+ <v-btn
138
+ data-testid="addThresholdButton"
139
+ size="x-small"
140
+ variant="tonal"
141
+ color="primary"
142
+ icon="mdi-plus"
143
+ @click="addThreshold"
144
+ />
145
+ </v-col>
146
+ </v-row>
147
+
148
+ <ThresholdCard
149
+ v-for="(threshold, idx) in thresholds"
150
+ :key="threshold.id"
151
+ ref="cards"
152
+ :threshold="threshold"
153
+ :dataset-id="selectedDatasetId"
154
+ :sources="sources"
155
+ :index="idx"
156
+ @remove="removeThreshold(idx)"
292
157
  />
293
158
  </template>
294
159
  </v-card-text>
@@ -301,9 +166,9 @@ watch(show, (visible) => {
301
166
  size="small"
302
167
  color="error"
303
168
  class="text-caption text-none"
304
- @click="removeThreshold"
169
+ @click="removeThresholds"
305
170
  >
306
- Remove Threshold
171
+ Remove all thresholds
307
172
  </v-btn>
308
173
  <v-btn
309
174
  data-testid="resetThresholdButton"
@@ -311,7 +176,7 @@ watch(show, (visible) => {
311
176
  size="small"
312
177
  color="secondary"
313
178
  class="text-caption text-none"
314
- @click="resetRange"
179
+ @click="resetRanges"
315
180
  >
316
181
  Reset
317
182
  </v-btn>