@geode/opengeodeweb-front 10.44.0-rc.1 → 10.44.0-rc.10
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.
- package/.build/server/utils/cleanup.js +7 -2
- package/.build/server/utils/microservices.js +9 -81
- package/.build/server/utils/microservices_process.js +85 -0
- package/.build/server/utils/scripts.js +34 -23
- package/.build/server/utils/typed_handler.js +5 -1
- package/.build/server/utils/ws_client.js +7 -2
- package/.build/shared/utils/fetch_raw.js +2 -2
- package/.build/shared/utils/parse_boolean.js +2 -1
- package/app/assets/geode_objects.ts +1 -0
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/ClippingPlanes.vue +22 -78
- package/app/components/DragAndDrop.vue +16 -79
- package/app/components/FileSelector.vue +9 -6
- package/app/components/HybridViewerTooltip.vue +8 -2
- package/app/components/MissingFilesSelector.vue +40 -23
- package/app/components/ObjectSelector.vue +34 -20
- package/app/components/Screenshot.vue +17 -59
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +81 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -11
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
- package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
- package/app/components/Viewer/Options/ColorPicker.vue +4 -1
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/components/Viewer/Ui.vue +6 -1
- package/app/components/csv-preview/CsvPreviewer.vue +4 -1
- package/app/composables/attribute_coloring_style.ts +8 -2
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/batch_style_model.ts +34 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/global_attribute_style.ts +4 -3
- package/app/composables/hover_highlight.ts +19 -18
- package/app/composables/model_tabs.ts +86 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager.ts +6 -97
- package/app/composables/project_manager_helpers/reset.ts +34 -0
- package/app/composables/project_manager_helpers/restore.ts +67 -0
- package/app/composables/project_manager_helpers/types.ts +24 -0
- package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
- package/app/composables/stepper_tree.ts +10 -2
- package/app/composables/tree_filter.ts +11 -2
- package/app/composables/tree_keyboard_nav.ts +4 -2
- package/app/composables/use_overlapping_picker.ts +30 -42
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/viewer_context_menu.ts +19 -1
- package/app/composables/virtual_tree.ts +20 -131
- package/app/composables/virtual_tree_flatten.ts +109 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/data_style.ts +8 -0
- package/app/stores/feedback.ts +2 -2
- package/app/stores/hybrid_viewer.ts +1 -1
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu.ts +8 -124
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +27 -0
- package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
- package/app/stores/menu_helpers/mesh/grid.ts +24 -0
- package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
- package/app/stores/menu_helpers/mesh/solid.ts +29 -0
- package/app/stores/menu_helpers/mesh/surface.ts +22 -0
- package/app/stores/menu_helpers/model.ts +25 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/stores/menu_helpers/types.ts +5 -0
- package/app/stores/treeview.ts +17 -10
- package/app/stores/viewer.ts +17 -79
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/clipping_planes.ts +4 -131
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/extension.ts +1 -1
- package/app/utils/import_workflow.ts +6 -4
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/upload_path.ts +15 -9
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/base_database.ts +2 -0
- package/internal/database/database.ts +47 -29
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/color.ts +3 -1
- package/internal/stores/data_style/mesh/cells/index.ts +17 -1
- package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/color.ts +3 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/index.ts +17 -1
- package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/mesh/points/color.ts +3 -1
- package/internal/stores/data_style/mesh/points/index.ts +17 -1
- package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
- package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
- package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +97 -49
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/edge.ts +102 -54
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/lines/vertex.ts +102 -54
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
- package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +5 -181
- package/internal/stores/data_style/state_shared.ts +199 -0
- package/internal/stores/data_style/types.ts +24 -1
- package/internal/stores/hybrid_viewer/brightness.ts +8 -2
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/internal/stores/hybrid_viewer/highlight.ts +80 -63
- package/internal/stores/hybrid_viewer/ruler.ts +4 -3
- package/internal/stores/hybrid_viewer/scene.ts +31 -25
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/internal/utils/ws_client.ts +8 -1
- package/package.json +2 -2
- package/server/api/local/extensions/run.post.ts +6 -4
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/cleanup.ts +12 -2
- package/server/utils/microservices.ts +10 -102
- package/server/utils/microservices_process.ts +127 -0
- package/server/utils/scripts.ts +35 -30
- package/server/utils/typed_handler.ts +8 -1
- package/server/utils/ws_client.ts +15 -2
- package/shared/utils/fetch_raw.ts +2 -2
- package/shared/utils/parse_boolean.ts +4 -1
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { filesFromEntry, isFileAccepted } from "@ogw_front/utils/drag_and_drop";
|
|
2
3
|
import DragAndDropInline from "./DragAndDropInternal/DragAndDropInline.vue";
|
|
3
4
|
import DragAndDropOverlay from "./DragAndDropInternal/DragAndDropOverlay.vue";
|
|
4
5
|
import type { UploadFile } from "@ogw_front/utils/upload_path";
|
|
@@ -38,11 +39,12 @@ const {
|
|
|
38
39
|
// oxlint-disable-next-line vue/max-props
|
|
39
40
|
} = defineProps<Props>();
|
|
40
41
|
|
|
41
|
-
const displayed_texts = computed<DragAndDropTexts>(() =>
|
|
42
|
-
directory
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const displayed_texts = computed<DragAndDropTexts>(() => {
|
|
43
|
+
if (directory) {
|
|
44
|
+
return { ...texts, idle: "Click or drag and drop a folder", drop: "Drop the folder here" };
|
|
45
|
+
}
|
|
46
|
+
return texts;
|
|
47
|
+
});
|
|
46
48
|
|
|
47
49
|
const emit = defineEmits<{
|
|
48
50
|
"files-selected": [files: UploadFile[]];
|
|
@@ -55,50 +57,11 @@ const isInternalDrag = ref(false);
|
|
|
55
57
|
const dragCounter = ref(0);
|
|
56
58
|
const fileInput = ref<HTMLInputElement | undefined>(undefined);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const fileName = (file.name || "").toLowerCase();
|
|
62
|
-
const fileType = (file.type || "").toLowerCase();
|
|
63
|
-
const isVext = fileName.endsWith(".vext");
|
|
64
|
-
|
|
65
|
-
if (!acceptValue) {
|
|
66
|
-
return !isVext;
|
|
67
|
-
}
|
|
68
|
-
let rules: string[] = [];
|
|
69
|
-
if (Array.isArray(acceptValue)) {
|
|
70
|
-
rules = acceptValue;
|
|
71
|
-
} else if (typeof acceptValue === "string") {
|
|
72
|
-
rules = acceptValue.split(",");
|
|
60
|
+
function getErrorMessage(error: unknown): string {
|
|
61
|
+
if (error instanceof Error) {
|
|
62
|
+
return error.message;
|
|
73
63
|
}
|
|
74
|
-
|
|
75
|
-
if (rules.length === 0) {
|
|
76
|
-
return !isVext;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return rules.some((rule) => {
|
|
80
|
-
let cleanRule = rule.toLowerCase();
|
|
81
|
-
if (!cleanRule) {
|
|
82
|
-
return !isVext;
|
|
83
|
-
}
|
|
84
|
-
if (cleanRule === "*" || cleanRule === "*.*") {
|
|
85
|
-
return !isVext;
|
|
86
|
-
}
|
|
87
|
-
if (cleanRule.startsWith("*.")) {
|
|
88
|
-
cleanRule = cleanRule.slice(1);
|
|
89
|
-
}
|
|
90
|
-
if (cleanRule.startsWith(".")) {
|
|
91
|
-
return fileName.endsWith(cleanRule);
|
|
92
|
-
}
|
|
93
|
-
if (cleanRule.includes("/")) {
|
|
94
|
-
if (cleanRule.endsWith("/*")) {
|
|
95
|
-
const typeGroup = cleanRule.slice(0, -WILDCARD_SUFFIX_LENGTH);
|
|
96
|
-
return fileType.startsWith(typeGroup);
|
|
97
|
-
}
|
|
98
|
-
return fileType === cleanRule;
|
|
99
|
-
}
|
|
100
|
-
return fileName.endsWith(`.${cleanRule}`);
|
|
101
|
-
});
|
|
64
|
+
return String(error);
|
|
102
65
|
}
|
|
103
66
|
|
|
104
67
|
function triggerFileDialog(): void {
|
|
@@ -126,41 +89,16 @@ function onDragOver(event: DragEvent): void {
|
|
|
126
89
|
}
|
|
127
90
|
}
|
|
128
91
|
|
|
129
|
-
async function readAllEntries(reader: FileSystemDirectoryReader): Promise<FileSystemEntry[]> {
|
|
130
|
-
// oxlint-disable-next-line promise/avoid-new
|
|
131
|
-
const batch = await new Promise<FileSystemEntry[]>((resolve, reject) => {
|
|
132
|
-
reader.readEntries(resolve, reject);
|
|
133
|
-
});
|
|
134
|
-
if (batch.length === 0) {
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
return [...batch, ...(await readAllEntries(reader))];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function filesFromEntry(entry: FileSystemEntry, path: string): Promise<UploadFile[]> {
|
|
141
|
-
if (entry.isFile) {
|
|
142
|
-
// oxlint-disable-next-line promise/avoid-new
|
|
143
|
-
const file = await new Promise<File>((resolve, reject) => {
|
|
144
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- isFile guarantees a FileSystemFileEntry
|
|
145
|
-
(entry as FileSystemFileEntry).file(resolve, reject);
|
|
146
|
-
});
|
|
147
|
-
return [Object.assign(file, { relativePath: path })];
|
|
148
|
-
}
|
|
149
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- not a file, so a FileSystemDirectoryEntry
|
|
150
|
-
const children = await readAllEntries((entry as FileSystemDirectoryEntry).createReader());
|
|
151
|
-
const nested = await Promise.all(
|
|
152
|
-
children.map((child) => filesFromEntry(child, `${path}/${child.name}`)),
|
|
153
|
-
);
|
|
154
|
-
return nested.flat();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
92
|
async function emitDroppedEntries(entries: FileSystemEntry[]): Promise<void> {
|
|
158
93
|
try {
|
|
159
94
|
const groups = await Promise.all(
|
|
160
95
|
entries.map(async (entry) => {
|
|
161
96
|
const files = await filesFromEntry(entry, entry.name);
|
|
162
97
|
// Files inside a dropped folder are all needed: never filtered out.
|
|
163
|
-
|
|
98
|
+
if (entry.isDirectory) {
|
|
99
|
+
return files;
|
|
100
|
+
}
|
|
101
|
+
return files.filter((file) => isFileAccepted(file, accept));
|
|
164
102
|
}),
|
|
165
103
|
);
|
|
166
104
|
const files = groups.flat();
|
|
@@ -168,8 +106,7 @@ async function emitDroppedEntries(entries: FileSystemEntry[]): Promise<void> {
|
|
|
168
106
|
emit("files-selected", files);
|
|
169
107
|
}
|
|
170
108
|
} catch (error) {
|
|
171
|
-
|
|
172
|
-
emit("folder-read-error", message);
|
|
109
|
+
emit("folder-read-error", getErrorMessage(error));
|
|
173
110
|
}
|
|
174
111
|
}
|
|
175
112
|
|
|
@@ -55,12 +55,15 @@ const toggle_loading = useToggle(loading);
|
|
|
55
55
|
|
|
56
56
|
function files_uploaded_event(value: unknown[]): void {
|
|
57
57
|
if (value.length > 0) {
|
|
58
|
-
|
|
59
|
-
"update_values",
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
:
|
|
63
|
-
|
|
58
|
+
if (timeSeries) {
|
|
59
|
+
emit("update_values", {
|
|
60
|
+
files: value,
|
|
61
|
+
autoUpload: false,
|
|
62
|
+
time_series: time_series.value,
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
emit("update_values", { files: value, autoUpload: false });
|
|
66
|
+
}
|
|
64
67
|
emit("increment_step");
|
|
65
68
|
}
|
|
66
69
|
}
|
|
@@ -92,7 +92,10 @@ function capitalize(val: string): string {
|
|
|
92
92
|
|
|
93
93
|
const fieldTypeLabel = computed<string>(() => {
|
|
94
94
|
const fieldType = hybridViewerStore.hoverData?.fieldType;
|
|
95
|
-
|
|
95
|
+
if (typeof fieldType !== "string") {
|
|
96
|
+
return "";
|
|
97
|
+
}
|
|
98
|
+
return capitalize(fieldType.toLowerCase());
|
|
96
99
|
});
|
|
97
100
|
|
|
98
101
|
const coordinates = computed<number[] | undefined>(() => {
|
|
@@ -114,7 +117,10 @@ function formatAttributeValue(val: unknown): string {
|
|
|
114
117
|
return `[ ${formattedValues.join(", ")} ]`;
|
|
115
118
|
}
|
|
116
119
|
if (typeof val === "number") {
|
|
117
|
-
|
|
120
|
+
if (Number.isInteger(val)) {
|
|
121
|
+
return String(val);
|
|
122
|
+
}
|
|
123
|
+
return Number(val).toFixed(4);
|
|
118
124
|
}
|
|
119
125
|
return val;
|
|
120
126
|
}
|
|
@@ -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
|
-
|
|
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(
|
|
@@ -91,29 +94,30 @@ function isCsvFile(filename: string): boolean {
|
|
|
91
94
|
return filename.toLowerCase().endsWith(".csv") || filename.toLowerCase().endsWith(".csv.json");
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
toggle_loading();
|
|
97
|
+
function reset_missing_state(): void {
|
|
96
98
|
has_missing_files.value = false;
|
|
97
99
|
mandatory_files.value = [];
|
|
98
100
|
additional_files.value = [];
|
|
99
101
|
missing_by_file.value = [];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function request_file_plan(filename: string): Promise<FilePlan> {
|
|
105
|
+
if (isCsvFile(filename)) {
|
|
106
|
+
return Promise.resolve({
|
|
107
|
+
has_missing_files: false,
|
|
108
|
+
mandatory_files: [],
|
|
109
|
+
additional_files: [],
|
|
110
|
+
});
|
|
111
|
+
}
|
|
100
112
|
const backStore = useBackStore();
|
|
113
|
+
if (timeSeries) {
|
|
114
|
+
return backStore.request({ schema: time_series_schema, params: { filename } });
|
|
115
|
+
}
|
|
116
|
+
const params = { geode_object_type: geodeObjectTypes[filename] ?? "", filename };
|
|
117
|
+
return backStore.request({ schema, params });
|
|
118
|
+
}
|
|
101
119
|
|
|
102
|
-
|
|
103
|
-
if (isCsvFile(filename)) {
|
|
104
|
-
return Promise.resolve({
|
|
105
|
-
has_missing_files: false,
|
|
106
|
-
mandatory_files: [],
|
|
107
|
-
additional_files: [],
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
if (timeSeries) {
|
|
111
|
-
return backStore.request({ schema: time_series_schema, params: { filename } });
|
|
112
|
-
}
|
|
113
|
-
const params = { geode_object_type: geodeObjectTypes[filename] ?? "", filename };
|
|
114
|
-
return backStore.request({ schema, params });
|
|
115
|
-
});
|
|
116
|
-
const values = await Promise.all(promise_array);
|
|
120
|
+
function collect_file_plans(values: FilePlan[]): void {
|
|
117
121
|
for (const [index, value] of values.entries()) {
|
|
118
122
|
if (value.has_missing_files) {
|
|
119
123
|
has_missing_files.value = true;
|
|
@@ -126,6 +130,9 @@ async function missing_files(): Promise<void> {
|
|
|
126
130
|
mandatory_files.value = [...mandatory_files.value, ...value.mandatory_files];
|
|
127
131
|
additional_files.value = [...additional_files.value, ...value.additional_files];
|
|
128
132
|
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function flag_unconfigured_csvs(): void {
|
|
129
136
|
const unconfigured_csvs = files.filter((file) => isCsvFile(file.name) && !file.isConfigured);
|
|
130
137
|
if (unconfigured_csvs.length > 0) {
|
|
131
138
|
has_missing_files.value = true;
|
|
@@ -133,6 +140,15 @@ async function missing_files(): Promise<void> {
|
|
|
133
140
|
accept.value = ".json";
|
|
134
141
|
}
|
|
135
142
|
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function missing_files(): Promise<void> {
|
|
146
|
+
toggle_loading();
|
|
147
|
+
reset_missing_state();
|
|
148
|
+
|
|
149
|
+
const values = await Promise.all(checked_filenames.value.map(request_file_plan));
|
|
150
|
+
collect_file_plans(values);
|
|
151
|
+
flag_unconfigured_csvs();
|
|
136
152
|
|
|
137
153
|
if (!has_missing_files.value) {
|
|
138
154
|
emit("update_values", { skipped_files: [] });
|
|
@@ -160,9 +176,10 @@ async function upload_missing_from(
|
|
|
160
176
|
}
|
|
161
177
|
const found = expected.flatMap((expected_path, index) => {
|
|
162
178
|
const file = folder_files[match.indices[index] ?? -1];
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
if (file && !uploaded.includes(file)) {
|
|
180
|
+
return [Object.assign(file, { relativePath: expected_path })];
|
|
181
|
+
}
|
|
182
|
+
return [];
|
|
166
183
|
});
|
|
167
184
|
if (found.length === 0) {
|
|
168
185
|
useFeedbackStore().add_warning(`The selected folder does not contain: ${expected.join(", ")}`);
|
|
@@ -120,6 +120,37 @@ function showCommonGeodeObjects(
|
|
|
120
120
|
return resolved.selectedGeodeObject;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
function toResolvedEntries(loadable: readonly FileAllowedObjects[]): [string, string][] {
|
|
124
|
+
return loadable.flatMap((file): [string, string][] => {
|
|
125
|
+
if (file.selectedGeodeObject === undefined) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
return [[file.filename, file.selectedGeodeObject]];
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Tries to settle the pending files without the per file panel. Returns true when it did
|
|
133
|
+
function resolveWithoutPanel(
|
|
134
|
+
pending: readonly FileAllowedObjects[],
|
|
135
|
+
allowedObjectsList: readonly AllowedObjectMap[],
|
|
136
|
+
): boolean {
|
|
137
|
+
if (pending.length === 0) {
|
|
138
|
+
autoResolved.value = true;
|
|
139
|
+
emitGeodeObjectTypes(resolvedTypes.value);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
const pendingAllowedObjects = pending.map(
|
|
143
|
+
(file) => allowedObjectsList[filenames.indexOf(file.filename)] ?? {},
|
|
144
|
+
);
|
|
145
|
+
// Pending files sharing a loadable type: one choice for all of them
|
|
146
|
+
const selected = showCommonGeodeObjects(pendingFilenames.value, pendingAllowedObjects);
|
|
147
|
+
if (Object.values(allowedGeodeObjects.value).some((object) => object.is_loadable > 0)) {
|
|
148
|
+
setGeodeObject(selected);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
123
154
|
// Each file gets its own type. Returns true when the per file panel is needed, i.e. the files cannot be handled by a single choice
|
|
124
155
|
function resolvePerFile(allowedObjectsList: readonly AllowedObjectMap[]): boolean {
|
|
125
156
|
const files = resolveAllowedObjectsPerFile(filenames, allowedObjectsList);
|
|
@@ -130,30 +161,13 @@ function resolvePerFile(allowedObjectsList: readonly AllowedObjectMap[]): boolea
|
|
|
130
161
|
return false;
|
|
131
162
|
}
|
|
132
163
|
const pending = loadable.filter((file) => file.selectedGeodeObject === undefined);
|
|
133
|
-
resolvedTypes.value = Object.fromEntries(
|
|
134
|
-
loadable.flatMap((file) =>
|
|
135
|
-
file.selectedGeodeObject === undefined ? [] : [[file.filename, file.selectedGeodeObject]],
|
|
136
|
-
),
|
|
137
|
-
);
|
|
164
|
+
resolvedTypes.value = Object.fromEntries(toResolvedEntries(loadable));
|
|
138
165
|
pendingFilenames.value = pending.map((file) => file.filename);
|
|
139
166
|
skippedFiles.value = files
|
|
140
167
|
.filter((file) => file.candidates.length === 0)
|
|
141
168
|
.map((file) => file.filename);
|
|
142
|
-
if (skippedFiles.value.length === 0) {
|
|
143
|
-
|
|
144
|
-
autoResolved.value = true;
|
|
145
|
-
emitGeodeObjectTypes(resolvedTypes.value);
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
const pendingAllowedObjects = pending.map(
|
|
149
|
-
(file) => allowedObjectsList[filenames.indexOf(file.filename)] ?? {},
|
|
150
|
-
);
|
|
151
|
-
// Pending files sharing a loadable type: one choice for all of them
|
|
152
|
-
const selected = showCommonGeodeObjects(pendingFilenames.value, pendingAllowedObjects);
|
|
153
|
-
if (Object.values(allowedGeodeObjects.value).some((object) => object.is_loadable > 0)) {
|
|
154
|
-
setGeodeObject(selected);
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
169
|
+
if (skippedFiles.value.length === 0 && resolveWithoutPanel(pending, allowedObjectsList)) {
|
|
170
|
+
return false;
|
|
157
171
|
}
|
|
158
172
|
pendingGroups.value = groupPendingFiles(pending);
|
|
159
173
|
return true;
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
import viewer_schemas, {
|
|
3
3
|
type ViewerTakeScreenshotParams,
|
|
4
4
|
} from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
|
-
import { BACKGROUND_GREY_VALUE } from "@ogw_internal/stores/hybrid_viewer/constants";
|
|
6
|
-
import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
|
|
7
5
|
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
8
|
-
import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue";
|
|
9
6
|
import fileDownload from "js-file-download";
|
|
10
7
|
import { useClipboardItems } from "@vueuse/core";
|
|
11
8
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
12
|
-
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
13
9
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
14
10
|
|
|
15
11
|
const DEFAULT_PANEL_WIDTH = 260;
|
|
@@ -23,6 +19,13 @@ interface Props {
|
|
|
23
19
|
|
|
24
20
|
const { width = DEFAULT_PANEL_WIDTH, escapeFunction = undefined } = defineProps<Props>();
|
|
25
21
|
|
|
22
|
+
function getErrorMessage(error: unknown): string {
|
|
23
|
+
if (error instanceof Error) {
|
|
24
|
+
return error.message;
|
|
25
|
+
}
|
|
26
|
+
return String(error);
|
|
27
|
+
}
|
|
28
|
+
|
|
26
29
|
const output_extensions =
|
|
27
30
|
viewer_schemas.opengeodeweb_viewer.viewer.take_screenshot.properties.output_extension.enum;
|
|
28
31
|
const filename = ref<string>("");
|
|
@@ -30,28 +33,9 @@ const output_extension = ref<ViewerTakeScreenshotParams["output_extension"]>("pn
|
|
|
30
33
|
const include_background = ref<boolean>(true);
|
|
31
34
|
const include_ui = ref<boolean>(false);
|
|
32
35
|
const screenshot_type = ref<string>("file");
|
|
33
|
-
const DEFAULT_BACKGROUND_COLOR: RGBAColor = {
|
|
34
|
-
red: BACKGROUND_GREY_VALUE,
|
|
35
|
-
green: BACKGROUND_GREY_VALUE,
|
|
36
|
-
blue: BACKGROUND_GREY_VALUE,
|
|
37
|
-
alpha: 1,
|
|
38
|
-
};
|
|
39
|
-
const background_color = ref<RGBAColor>({ ...DEFAULT_BACKGROUND_COLOR });
|
|
40
|
-
let is_capturing = false;
|
|
41
36
|
|
|
42
37
|
const { copy } = useClipboardItems();
|
|
43
38
|
|
|
44
|
-
function applyBackgroundColor(color: RGBAColor): Promise<void> {
|
|
45
|
-
const hybridViewerStore = useHybridViewerStore();
|
|
46
|
-
// oxlint-disable-next-line id-length -- the viewer schema requires { r, g, b }
|
|
47
|
-
return hybridViewerStore.setBackgroundColor({ r: color.red, g: color.green, b: color.blue });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function restoreBackgroundColor(): Promise<void> {
|
|
51
|
-
background_color.value = { ...DEFAULT_BACKGROUND_COLOR };
|
|
52
|
-
await applyBackgroundColor(DEFAULT_BACKGROUND_COLOR);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
39
|
async function deliverScreenshot(blob: Blob | Uint8Array, current_filename: string): Promise<void> {
|
|
56
40
|
const feedbackStore = useFeedbackStore();
|
|
57
41
|
if (screenshot_type.value === "file") {
|
|
@@ -64,7 +48,7 @@ async function deliverScreenshot(blob: Blob | Uint8Array, current_filename: stri
|
|
|
64
48
|
await copy([new ClipboardItem({ "image/png": pngBlob })]);
|
|
65
49
|
feedbackStore.add_success("Screenshot copied to clipboard");
|
|
66
50
|
} catch (error) {
|
|
67
|
-
const message =
|
|
51
|
+
const message = getErrorMessage(error);
|
|
68
52
|
feedbackStore.add_error(
|
|
69
53
|
0,
|
|
70
54
|
"",
|
|
@@ -138,42 +122,24 @@ async function takeUiScreenshot(current_filename: string): Promise<void> {
|
|
|
138
122
|
const blob = await captureTab(mime_type);
|
|
139
123
|
await deliverScreenshot(blob, current_filename);
|
|
140
124
|
} catch (error) {
|
|
141
|
-
const message =
|
|
125
|
+
const message = getErrorMessage(error);
|
|
142
126
|
feedbackStore.add_error(0, "", "Screenshot Error", `Failed to capture the page: ${message}`);
|
|
143
127
|
}
|
|
144
128
|
}
|
|
145
129
|
|
|
146
130
|
async function takeScreenshot(): Promise<void> {
|
|
147
131
|
const current_filename = screenshot_type.value === "file" ? filename.value : "screenshot";
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
await takeSceneScreenshot(current_filename);
|
|
157
|
-
show.value = false;
|
|
158
|
-
}
|
|
159
|
-
} finally {
|
|
160
|
-
await restoreBackgroundColor();
|
|
161
|
-
is_capturing = false;
|
|
132
|
+
if (include_ui.value) {
|
|
133
|
+
// Close the panel first so it does not appear on the captured page
|
|
134
|
+
show.value = false;
|
|
135
|
+
await nextTick();
|
|
136
|
+
await takeUiScreenshot(current_filename);
|
|
137
|
+
} else {
|
|
138
|
+
await takeSceneScreenshot(current_filename);
|
|
139
|
+
show.value = false;
|
|
162
140
|
}
|
|
163
141
|
}
|
|
164
142
|
|
|
165
|
-
watch(background_color, async (color) => {
|
|
166
|
-
if (show.value) {
|
|
167
|
-
await applyBackgroundColor(color);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
watch(show, async (value) => {
|
|
172
|
-
if (!value && !is_capturing) {
|
|
173
|
-
await restoreBackgroundColor();
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
|
|
177
143
|
watch([output_extension, include_ui], ([extension, with_ui]) => {
|
|
178
144
|
if (extension !== "png" || with_ui) {
|
|
179
145
|
include_background.value = true;
|
|
@@ -288,14 +254,6 @@ function handleClose(): void {
|
|
|
288
254
|
class="text-caption"
|
|
289
255
|
></v-switch>
|
|
290
256
|
</v-col>
|
|
291
|
-
<v-col v-if="include_background" cols="12" class="py-1">
|
|
292
|
-
<span class="text-caption">Background color</span>
|
|
293
|
-
<ViewerOptionsColorPicker
|
|
294
|
-
data-testid="screenshotBackgroundColorPicker"
|
|
295
|
-
v-model="background_color"
|
|
296
|
-
disabled-alpha
|
|
297
|
-
/>
|
|
298
|
-
</v-col>
|
|
299
257
|
</v-row>
|
|
300
258
|
</v-container>
|
|
301
259
|
|
|
@@ -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>
|