@geode/opengeodeweb-front 10.44.0 → 10.44.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.
- package/app/components/ClippingPlanes.vue +7 -5
- package/app/components/CrsSelector.vue +2 -1
- package/app/components/ExtensionSelector.vue +8 -7
- package/app/components/FactorFilterPanel.vue +4 -4
- package/app/components/MissingFilesSelector.vue +2 -1
- package/app/components/ObjectSelector.vue +4 -3
- package/app/components/ThresholdCard.vue +6 -5
- package/app/components/ThresholdFilter.vue +11 -10
- package/app/components/TimeSeriesTargetSelector.vue +10 -7
- package/app/components/Viewer/ContextMenu/InfoCard.vue +12 -10
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +72 -63
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +12 -10
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +76 -71
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -6
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +72 -63
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +12 -10
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +54 -45
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +76 -73
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +8 -6
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +72 -67
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -6
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +29 -21
- package/app/components/Viewer/Generic/Model/ComponentEdgesOptions.vue +8 -6
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +8 -6
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +15 -7
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +2 -1
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +13 -6
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +19 -11
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +2 -1
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +17 -10
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +3 -2
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +2 -1
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +3 -2
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +29 -21
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +2 -2
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +2 -3
- package/app/components/Viewer/Options/AttributeSelector.vue +11 -7
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +10 -13
- package/app/components/Viewer/Options/TextureItem.vue +5 -4
- package/app/components/Viewer/Options/TexturesSelector.vue +5 -8
- package/app/components/Viewer/Options/TimeStepSlider.vue +3 -1
- package/app/components/Viewer/OverlappingObjectsPicker.vue +6 -13
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +40 -38
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +69 -65
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -6
- package/app/components/Viewer/Surface/PolygonsColoring.vue +73 -71
- package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -6
- package/app/composables/attribute_coloring_style.ts +17 -12
- package/app/composables/attribute_selector.ts +9 -15
- package/app/composables/batch_style.ts +25 -16
- package/app/composables/batch_style_model.ts +6 -5
- package/app/composables/clipping_planes_widget.ts +2 -5
- package/app/composables/clipping_slices.ts +2 -1
- package/app/composables/hover_highlight.ts +17 -16
- package/app/composables/live_data_item.ts +3 -2
- package/app/composables/model_attribute_style.ts +2 -1
- package/app/composables/model_menu_context.ts +3 -4
- package/app/composables/model_tree.ts +3 -2
- package/app/composables/project_manager_helpers/types.ts +10 -4
- package/app/composables/tree_filter.ts +3 -3
- package/app/composables/tree_keyboard_nav.ts +1 -6
- package/app/composables/tree_scroll.ts +2 -0
- package/app/composables/use_overlapping_picker.ts +9 -9
- package/app/stores/basemap_helpers/georeferenced.ts +1 -1
- package/app/stores/basemap_helpers/viewer.ts +2 -1
- package/app/stores/crs.ts +6 -5
- package/app/stores/data.ts +84 -69
- package/app/stores/data_helpers/collections.ts +13 -21
- package/app/stores/data_helpers/mesh.ts +19 -24
- package/app/stores/data_helpers/relations.ts +12 -12
- package/app/stores/data_style.ts +26 -20
- package/app/stores/menu.ts +17 -11
- package/app/stores/treeview.ts +28 -27
- package/app/types/attribute.ts +37 -0
- package/app/types/identifiers.ts +72 -0
- package/app/types/style.ts +13 -0
- package/app/types/texture.ts +6 -0
- package/app/types/tree.ts +17 -0
- package/app/utils/attribute_range.ts +2 -1
- package/app/utils/attributes.ts +13 -4
- package/app/utils/basemap_tree.ts +3 -5
- package/app/utils/clipping_planes.ts +6 -4
- package/app/utils/clipping_planes_scene.ts +4 -3
- package/app/utils/crs.ts +4 -1
- package/app/utils/default_styles/constants.ts +8 -1
- package/app/utils/default_styles/mesh_components.ts +21 -25
- package/app/utils/default_styles/meshes.ts +7 -22
- package/app/utils/default_styles/model_components.ts +22 -26
- package/app/utils/default_styles/models.ts +11 -13
- package/app/utils/import_workflow.ts +37 -29
- package/app/utils/legacy_data_id.ts +16 -0
- package/app/utils/slice.ts +7 -2
- package/app/utils/threshold.ts +1 -8
- package/app/utils/threshold_sources.ts +8 -5
- package/app/utils/treeview.ts +3 -2
- package/internal/database/tables/data.ts +1 -1
- package/internal/database/tables/data_style.ts +1 -1
- package/internal/database/tables/model_components.ts +1 -1
- package/internal/database/tables/model_components_relation.ts +1 -1
- package/internal/stores/data_style/attribute_default.ts +14 -0
- package/internal/stores/data_style/attribute_types.ts +59 -0
- package/internal/stores/data_style/attribute_valid.ts +16 -0
- package/internal/stores/data_style/mesh/base_style.ts +17 -15
- package/internal/stores/data_style/mesh/cells/cell.ts +64 -49
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +42 -66
- package/internal/stores/data_style/mesh/cells/cell_config.ts +59 -53
- package/internal/stores/data_style/mesh/cells/color.ts +8 -7
- package/internal/stores/data_style/mesh/cells/common.ts +16 -15
- package/internal/stores/data_style/mesh/cells/index.ts +49 -47
- package/internal/stores/data_style/mesh/cells/opacity.ts +12 -10
- package/internal/stores/data_style/mesh/cells/textures.ts +8 -7
- package/internal/stores/data_style/mesh/cells/vertex.ts +66 -50
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +62 -53
- package/internal/stores/data_style/mesh/cells/visibility.ts +11 -7
- package/internal/stores/data_style/mesh/edges/color.ts +8 -7
- package/internal/stores/data_style/mesh/edges/common.ts +13 -12
- package/internal/stores/data_style/mesh/edges/edge.ts +64 -49
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +42 -66
- package/internal/stores/data_style/mesh/edges/edge_config.ts +59 -53
- package/internal/stores/data_style/mesh/edges/index.ts +49 -47
- package/internal/stores/data_style/mesh/edges/opacity.ts +12 -10
- package/internal/stores/data_style/mesh/edges/vertex.ts +66 -50
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +62 -53
- package/internal/stores/data_style/mesh/edges/visibility.ts +11 -7
- package/internal/stores/data_style/mesh/edges/width.ts +9 -7
- package/internal/stores/data_style/mesh/index.ts +27 -24
- package/internal/stores/data_style/mesh/points/color.ts +8 -7
- package/internal/stores/data_style/mesh/points/common.ts +16 -14
- package/internal/stores/data_style/mesh/points/index.ts +39 -37
- package/internal/stores/data_style/mesh/points/opacity.ts +12 -10
- package/internal/stores/data_style/mesh/points/size.ts +9 -7
- package/internal/stores/data_style/mesh/points/vertex.ts +66 -50
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/points/vertex_config.ts +62 -53
- package/internal/stores/data_style/mesh/points/visibility.ts +8 -6
- package/internal/stores/data_style/mesh/polygons/color.ts +8 -7
- package/internal/stores/data_style/mesh/polygons/common.ts +19 -15
- package/internal/stores/data_style/mesh/polygons/index.ts +49 -50
- package/internal/stores/data_style/mesh/polygons/opacity.ts +12 -10
- package/internal/stores/data_style/mesh/polygons/polygon.ts +66 -50
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +65 -53
- package/internal/stores/data_style/mesh/polygons/textures.ts +8 -7
- package/internal/stores/data_style/mesh/polygons/vertex.ts +66 -50
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +65 -53
- package/internal/stores/data_style/mesh/polygons/visibility.ts +12 -7
- package/internal/stores/data_style/mesh/polyhedra/color.ts +13 -9
- package/internal/stores/data_style/mesh/polyhedra/common.ts +13 -12
- package/internal/stores/data_style/mesh/polyhedra/index.ts +51 -51
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +12 -10
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +59 -53
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +46 -69
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +65 -55
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +66 -50
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +37 -67
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +65 -53
- package/internal/stores/data_style/mesh/polyhedra/visibility.ts +12 -7
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +11 -12
- package/internal/stores/data_style/model/blocks/color.ts +25 -26
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +5 -9
- package/internal/stores/data_style/model/blocks/common.ts +26 -22
- package/internal/stores/data_style/model/blocks/index.ts +8 -7
- package/internal/stores/data_style/model/blocks/polyhedron.ts +114 -135
- package/internal/stores/data_style/model/blocks/vertex.ts +110 -132
- package/internal/stores/data_style/model/blocks/visibility.ts +11 -9
- package/internal/stores/data_style/model/color.ts +55 -41
- package/internal/stores/data_style/model/common.ts +16 -14
- package/internal/stores/data_style/model/component_style.ts +0 -16
- package/internal/stores/data_style/model/corners/color.ts +21 -19
- package/internal/stores/data_style/model/corners/common.ts +26 -22
- package/internal/stores/data_style/model/corners/index.ts +21 -24
- package/internal/stores/data_style/model/corners/vertex.ts +103 -122
- package/internal/stores/data_style/model/corners/visibility.ts +11 -9
- package/internal/stores/data_style/model/edges/common.ts +7 -6
- package/internal/stores/data_style/model/edges/component.ts +63 -55
- package/internal/stores/data_style/model/edges/visibility.ts +24 -16
- package/internal/stores/data_style/model/edges/width.ts +10 -8
- package/internal/stores/data_style/model/index.ts +7 -6
- package/internal/stores/data_style/model/lines/apply_coloring.ts +11 -9
- package/internal/stores/data_style/model/lines/color.ts +25 -23
- package/internal/stores/data_style/model/lines/coloring_groups.ts +5 -9
- package/internal/stores/data_style/model/lines/common.ts +29 -21
- package/internal/stores/data_style/model/lines/edge.ts +109 -128
- package/internal/stores/data_style/model/lines/index.ts +8 -7
- package/internal/stores/data_style/model/lines/vertex.ts +109 -128
- package/internal/stores/data_style/model/lines/visibility.ts +11 -9
- package/internal/stores/data_style/model/points/common.ts +7 -6
- package/internal/stores/data_style/model/points/component.ts +62 -54
- package/internal/stores/data_style/model/points/index.ts +12 -7
- package/internal/stores/data_style/model/points/size.ts +10 -8
- package/internal/stores/data_style/model/points/visibility.ts +13 -8
- package/internal/stores/data_style/model/selection.ts +6 -11
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +11 -15
- package/internal/stores/data_style/model/surfaces/color.ts +31 -23
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +5 -9
- package/internal/stores/data_style/model/surfaces/common.ts +26 -22
- package/internal/stores/data_style/model/surfaces/index.ts +8 -7
- package/internal/stores/data_style/model/surfaces/polygon.ts +113 -138
- package/internal/stores/data_style/model/surfaces/vertex.ts +117 -133
- package/internal/stores/data_style/model/surfaces/visibility.ts +11 -9
- package/internal/stores/data_style/model/visibility.ts +18 -16
- package/internal/stores/data_style/model/visibility_dispatch.ts +4 -4
- package/internal/stores/data_style/state.ts +7 -6
- package/internal/stores/data_style/state_shared.ts +11 -10
- package/internal/stores/data_style/time_step.ts +21 -15
- package/internal/stores/data_style/types.ts +4 -3
- package/internal/stores/hybrid_viewer/camera.ts +11 -6
- package/internal/stores/hybrid_viewer/filters.ts +16 -14
- package/internal/stores/hybrid_viewer/highlight.ts +6 -5
- package/internal/stores/hybrid_viewer/scene.ts +20 -18
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -2
- package/internal/utils/api_fetch.ts +1 -1
- package/internal/utils/upload_file.ts +1 -7
- package/package.json +1 -1
- package/shared/utils/fetch_raw.ts +7 -8
|
@@ -2,6 +2,7 @@ import back_schemas, {
|
|
|
2
2
|
type BasemapBuildResponse,
|
|
3
3
|
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
4
4
|
import type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
5
|
+
import type { Opacity } from "@ogw_front/types/style";
|
|
5
6
|
import { useBackStore } from "@ogw_front/stores/back";
|
|
6
7
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
7
8
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
@@ -10,7 +11,7 @@ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed
|
|
|
10
11
|
interface Layer {
|
|
11
12
|
map: MapStyle;
|
|
12
13
|
visible: boolean;
|
|
13
|
-
opacity:
|
|
14
|
+
opacity: Opacity;
|
|
14
15
|
crop: boolean;
|
|
15
16
|
}
|
|
16
17
|
|
package/app/stores/crs.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataId, GeodeObjectType } from "@ogw_front/types/identifiers";
|
|
1
2
|
import back_schemas, {
|
|
2
3
|
type CRSList,
|
|
3
4
|
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
@@ -46,13 +47,13 @@ export const useCrsStore = defineStore("crs", () => {
|
|
|
46
47
|
const mismatched = new Map<string, CRSList | undefined>();
|
|
47
48
|
for (const item of crsItems.value) {
|
|
48
49
|
if (project !== undefined && !sameCrs(item.crs, project)) {
|
|
49
|
-
mismatched.set(item.
|
|
50
|
+
mismatched.set(item.data_id, item.crs);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
return mismatched;
|
|
53
54
|
});
|
|
54
55
|
|
|
55
|
-
async function fetchGeographicList(geodeObjectType:
|
|
56
|
+
async function fetchGeographicList(geodeObjectType: GeodeObjectType): Promise<CRSList[]> {
|
|
56
57
|
try {
|
|
57
58
|
const response = await backStore.request({
|
|
58
59
|
schema: back_schemas.opengeodeweb_back.crs.geographic_list,
|
|
@@ -69,7 +70,7 @@ export const useCrsStore = defineStore("crs", () => {
|
|
|
69
70
|
return [];
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
async function geographicList(geodeObjectType:
|
|
73
|
+
async function geographicList(geodeObjectType: GeodeObjectType): Promise<CRSList[]> {
|
|
73
74
|
// The promise is cached, so dialogs opened together share a single request.
|
|
74
75
|
// The back still checks each CRS against the list of the data dimension
|
|
75
76
|
geographicListPromise ??= fetchGeographicList(geodeObjectType);
|
|
@@ -81,8 +82,8 @@ export const useCrsStore = defineStore("crs", () => {
|
|
|
81
82
|
crsEditEnabled.value = true;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
function requestCrsEdit(
|
|
85
|
-
crsEditRequest.value =
|
|
85
|
+
function requestCrsEdit(dataId: DataId): void {
|
|
86
|
+
crsEditRequest.value = dataId;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
function clearCrsEditRequest(): void {
|
package/app/stores/data.ts
CHANGED
|
@@ -6,19 +6,25 @@ import { useObservable } from "@vueuse/rxjs";
|
|
|
6
6
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
7
7
|
|
|
8
8
|
// Local imports
|
|
9
|
+
import type {
|
|
10
|
+
DataId,
|
|
11
|
+
DataIdentified,
|
|
12
|
+
GeodeId,
|
|
13
|
+
GeodeIdentified,
|
|
14
|
+
GeodeObjectTyped,
|
|
15
|
+
ModelId,
|
|
16
|
+
ViewerTyped,
|
|
17
|
+
} from "@ogw_front/types/identifiers";
|
|
18
|
+
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
9
19
|
import { type ModelComponentRecord, useDataMesh } from "./data_helpers/mesh.js";
|
|
20
|
+
import { type ModelComponentRelationRecord, useDataRelations } from "./data_helpers/relations.js";
|
|
10
21
|
import { database } from "@ogw_internal/database/database.js";
|
|
11
22
|
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
12
23
|
import { useDataCollections } from "./data_helpers/collections.js";
|
|
13
|
-
import { useDataRelations } from "./data_helpers/relations.js";
|
|
14
24
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
15
25
|
|
|
16
|
-
interface DataItem {
|
|
17
|
-
id: string;
|
|
18
|
-
geode_id: string;
|
|
26
|
+
interface DataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerTyped {
|
|
19
27
|
name: string;
|
|
20
|
-
viewer_type: string;
|
|
21
|
-
geode_object_type: string;
|
|
22
28
|
visible: boolean;
|
|
23
29
|
created_at: string;
|
|
24
30
|
is_viewable?: boolean;
|
|
@@ -27,10 +33,9 @@ interface DataItem {
|
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
// What the CRS features read of a data: light to copy on each change
|
|
30
|
-
type CrsItem = Pick<DataItem, "
|
|
36
|
+
type CrsItem = Pick<DataItem, "data_id" | "name" | "crs" | "created_at">;
|
|
31
37
|
|
|
32
|
-
interface ModelComponentInput {
|
|
33
|
-
geode_id: string;
|
|
38
|
+
interface ModelComponentInput extends GeodeIdentified {
|
|
34
39
|
type: string;
|
|
35
40
|
viewer_id: string | number;
|
|
36
41
|
name: string;
|
|
@@ -40,12 +45,8 @@ interface ModelComponentInput {
|
|
|
40
45
|
items?: string[];
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
interface NewDataItem {
|
|
44
|
-
id: string;
|
|
45
|
-
geode_id: string;
|
|
48
|
+
interface NewDataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerTyped {
|
|
46
49
|
name?: string;
|
|
47
|
-
viewer_type: string;
|
|
48
|
-
geode_object_type: string;
|
|
49
50
|
is_viewable?: boolean;
|
|
50
51
|
binary_light_viewable?: string;
|
|
51
52
|
crs?: CRSList;
|
|
@@ -56,18 +57,10 @@ interface NewDataItem {
|
|
|
56
57
|
nb_vertices?: number;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
interface
|
|
60
|
-
id: string;
|
|
61
|
-
parent: string;
|
|
62
|
-
child: string;
|
|
63
|
-
type: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface ViewableItemLike {
|
|
60
|
+
interface ViewableItemLike extends Partial<GeodeObjectTyped> {
|
|
67
61
|
is_viewable?: boolean;
|
|
68
62
|
binary_light_viewable?: string;
|
|
69
|
-
|
|
70
|
-
id?: string;
|
|
63
|
+
data_id?: DataId;
|
|
71
64
|
title?: string;
|
|
72
65
|
}
|
|
73
66
|
|
|
@@ -88,7 +81,7 @@ function checkItemViewable(item: ViewableItemLike | undefined | null): boolean {
|
|
|
88
81
|
}
|
|
89
82
|
if (
|
|
90
83
|
item.geode_object_type === "HorizonStack3D" ||
|
|
91
|
-
item.
|
|
84
|
+
item.data_id === "HorizonStack3D" ||
|
|
92
85
|
item.title === "HorizonStack3D"
|
|
93
86
|
) {
|
|
94
87
|
return false;
|
|
@@ -137,10 +130,10 @@ export const useDataStore = defineStore("data", () => {
|
|
|
137
130
|
const { getComponentRelations } = useDataRelations();
|
|
138
131
|
// Ids the viewer holds a pipeline for: an item is stored before it is registered, and non viewable items never are
|
|
139
132
|
const registeredIds = reactive(new Set<string>());
|
|
140
|
-
async function item(
|
|
141
|
-
const data_item = await data_db.get(
|
|
133
|
+
async function item(dataId: DataId): Promise<DataItem> {
|
|
134
|
+
const data_item = await data_db.get(dataId);
|
|
142
135
|
if (!data_item) {
|
|
143
|
-
throw new Error(`Item not found: ${
|
|
136
|
+
throw new Error(`Item not found: ${dataId}`);
|
|
144
137
|
}
|
|
145
138
|
return data_item;
|
|
146
139
|
}
|
|
@@ -148,10 +141,10 @@ export const useDataStore = defineStore("data", () => {
|
|
|
148
141
|
const items = await data_db.toArray();
|
|
149
142
|
return items;
|
|
150
143
|
}
|
|
151
|
-
function refItem(
|
|
144
|
+
function refItem(dataId: DataId): Ref<DataItem | undefined> {
|
|
152
145
|
return useObservable(
|
|
153
146
|
liveObservable(async () => {
|
|
154
|
-
const data_item = await data_db.get(
|
|
147
|
+
const data_item = await data_db.get(dataId);
|
|
155
148
|
return data_item;
|
|
156
149
|
}),
|
|
157
150
|
{
|
|
@@ -165,7 +158,12 @@ export const useDataStore = defineStore("data", () => {
|
|
|
165
158
|
return useObservable(
|
|
166
159
|
liveObservable(async () => {
|
|
167
160
|
const items = await data_db.toArray();
|
|
168
|
-
return items.map(({
|
|
161
|
+
return items.map(({ data_id, name, crs, created_at }) => ({
|
|
162
|
+
data_id,
|
|
163
|
+
name,
|
|
164
|
+
crs,
|
|
165
|
+
created_at,
|
|
166
|
+
}));
|
|
169
167
|
}),
|
|
170
168
|
{ initialValue: [] as CrsItem[] },
|
|
171
169
|
);
|
|
@@ -182,24 +180,27 @@ export const useDataStore = defineStore("data", () => {
|
|
|
182
180
|
},
|
|
183
181
|
);
|
|
184
182
|
}
|
|
185
|
-
function isRegistered(
|
|
186
|
-
return registeredIds.has(
|
|
183
|
+
function isRegistered(dataId: DataId): boolean {
|
|
184
|
+
return registeredIds.has(dataId);
|
|
187
185
|
}
|
|
188
186
|
function refRegisteredItems(): ComputedRef<DataItem[]> {
|
|
189
187
|
const items = refAllItems();
|
|
190
|
-
return computed(() => items.value.filter((data_item) => isRegistered(data_item.
|
|
188
|
+
return computed(() => items.value.filter((data_item) => isRegistered(data_item.data_id)));
|
|
191
189
|
}
|
|
192
|
-
async function meshComponentType(
|
|
190
|
+
async function meshComponentType(
|
|
191
|
+
modelId: ModelId,
|
|
192
|
+
geode_id: GeodeId,
|
|
193
|
+
): Promise<string | undefined> {
|
|
193
194
|
const component = await model_components_db
|
|
194
|
-
.where("[
|
|
195
|
+
.where("[data_id+geode_id]")
|
|
195
196
|
.equals([modelId, geode_id])
|
|
196
197
|
.first();
|
|
197
198
|
return component?.type;
|
|
198
199
|
}
|
|
199
|
-
async function registerObject(
|
|
200
|
+
async function registerObject(dataId: DataId, name: string): Promise<unknown> {
|
|
200
201
|
const schema = viewer_generic_schemas.register;
|
|
201
202
|
const params = {
|
|
202
|
-
id,
|
|
203
|
+
id: dataId,
|
|
203
204
|
name,
|
|
204
205
|
};
|
|
205
206
|
const result = await viewerStore.request({
|
|
@@ -207,15 +208,15 @@ export const useDataStore = defineStore("data", () => {
|
|
|
207
208
|
params,
|
|
208
209
|
timeout: 0,
|
|
209
210
|
});
|
|
210
|
-
registeredIds.add(
|
|
211
|
+
registeredIds.add(dataId);
|
|
211
212
|
return result;
|
|
212
213
|
}
|
|
213
|
-
async function deregisterObject(
|
|
214
|
+
async function deregisterObject(dataId: DataId): Promise<unknown> {
|
|
214
215
|
const schema = viewer_generic_schemas.deregister;
|
|
215
216
|
const params = {
|
|
216
|
-
id,
|
|
217
|
+
id: dataId,
|
|
217
218
|
};
|
|
218
|
-
registeredIds.delete(
|
|
219
|
+
registeredIds.delete(dataId);
|
|
219
220
|
const result = await viewerStore.request({
|
|
220
221
|
schema,
|
|
221
222
|
params,
|
|
@@ -226,9 +227,9 @@ export const useDataStore = defineStore("data", () => {
|
|
|
226
227
|
// Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
|
|
227
228
|
async function addItem(new_item: NewDataItem): Promise<string> {
|
|
228
229
|
const itemData: DataItem = {
|
|
229
|
-
|
|
230
|
+
data_id: new_item.data_id,
|
|
230
231
|
geode_id: new_item.geode_id,
|
|
231
|
-
name: new_item.name ?? new_item.
|
|
232
|
+
name: new_item.name ?? new_item.data_id,
|
|
232
233
|
viewer_type: new_item.viewer_type,
|
|
233
234
|
geode_object_type: new_item.geode_object_type,
|
|
234
235
|
visible: true,
|
|
@@ -241,8 +242,8 @@ export const useDataStore = defineStore("data", () => {
|
|
|
241
242
|
if (new_item.crs !== undefined) {
|
|
242
243
|
itemData.crs = new_item.crs;
|
|
243
244
|
}
|
|
244
|
-
const
|
|
245
|
-
return
|
|
245
|
+
const dataId = await data_db.put(itemData);
|
|
246
|
+
return dataId;
|
|
246
247
|
}
|
|
247
248
|
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
248
249
|
// Satisfy prefer-readonly-parameter-types deeply; same pattern as app/utils/import_workflow.ts.
|
|
@@ -253,7 +254,7 @@ export const useDataStore = defineStore("data", () => {
|
|
|
253
254
|
function addModelComponents(components: readonly ModelComponentInput[]): void {
|
|
254
255
|
for (const component of components) {
|
|
255
256
|
allComponents.push({
|
|
256
|
-
|
|
257
|
+
data_id: new_item.data_id,
|
|
257
258
|
geode_id: component.geode_id,
|
|
258
259
|
type: component.type,
|
|
259
260
|
viewer_id: component.viewer_id,
|
|
@@ -282,7 +283,7 @@ export const useDataStore = defineStore("data", () => {
|
|
|
282
283
|
): void {
|
|
283
284
|
for (const child of components) {
|
|
284
285
|
relations.push({
|
|
285
|
-
|
|
286
|
+
data_id: new_item.data_id,
|
|
286
287
|
parent,
|
|
287
288
|
child,
|
|
288
289
|
type,
|
|
@@ -310,53 +311,53 @@ export const useDataStore = defineStore("data", () => {
|
|
|
310
311
|
return lastKey;
|
|
311
312
|
}
|
|
312
313
|
async function getComponentByViewerId(
|
|
313
|
-
modelId:
|
|
314
|
+
modelId: ModelId,
|
|
314
315
|
viewer_id: string | number,
|
|
315
316
|
): Promise<ModelComponentRecord | undefined> {
|
|
316
317
|
const component = await model_components_db
|
|
317
318
|
.where("viewer_id")
|
|
318
319
|
.equals(Number(viewer_id))
|
|
319
|
-
.and((model_component: ModelComponentRecord) => model_component.
|
|
320
|
+
.and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
|
|
320
321
|
.first();
|
|
321
322
|
return component;
|
|
322
323
|
}
|
|
323
324
|
async function getComponentsByViewerIds(
|
|
324
|
-
modelId:
|
|
325
|
+
modelId: ModelId,
|
|
325
326
|
viewer_ids: number[],
|
|
326
327
|
): Promise<ModelComponentRecord[]> {
|
|
327
328
|
const components = await model_components_db
|
|
328
329
|
.where("viewer_id")
|
|
329
330
|
.anyOf(viewer_ids)
|
|
330
|
-
.and((model_component: ModelComponentRecord) => model_component.
|
|
331
|
+
.and((model_component: ModelComponentRecord) => model_component.data_id === modelId)
|
|
331
332
|
.toArray();
|
|
332
333
|
return components;
|
|
333
334
|
}
|
|
334
|
-
async function deleteModelComponents(modelId:
|
|
335
|
-
await model_components_db.where("
|
|
336
|
-
await model_components_relation_db.where("
|
|
335
|
+
async function deleteModelComponents(modelId: ModelId): Promise<void> {
|
|
336
|
+
await model_components_db.where("data_id").equals(modelId).delete();
|
|
337
|
+
await model_components_relation_db.where("data_id").equals(modelId).delete();
|
|
337
338
|
}
|
|
338
339
|
|
|
339
|
-
async function deleteItem(
|
|
340
|
-
await data_db.delete(
|
|
341
|
-
await deleteModelComponents(
|
|
340
|
+
async function deleteItem(dataId: DataId): Promise<void> {
|
|
341
|
+
await data_db.delete(dataId);
|
|
342
|
+
await deleteModelComponents(dataId);
|
|
342
343
|
}
|
|
343
344
|
|
|
344
|
-
async function updateItem(
|
|
345
|
-
await data_db.update(
|
|
345
|
+
async function updateItem(dataId: DataId, changes: Partial<DataItem>): Promise<void> {
|
|
346
|
+
await data_db.update(dataId, changes);
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
async function getAllModelComponentsViewerIds(modelId:
|
|
349
|
-
const components = await model_components_db.where("
|
|
349
|
+
async function getAllModelComponentsViewerIds(modelId: ModelId): Promise<number[]> {
|
|
350
|
+
const components = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
350
351
|
return components.map((component: ModelComponentRecord) =>
|
|
351
352
|
Math.trunc(Number(component.viewer_id)),
|
|
352
353
|
);
|
|
353
354
|
}
|
|
354
355
|
async function getMeshComponentsViewerIds(
|
|
355
|
-
modelId:
|
|
356
|
+
modelId: ModelId,
|
|
356
357
|
meshComponentGeodeIds: readonly string[],
|
|
357
358
|
): Promise<number[]> {
|
|
358
359
|
const components = await model_components_db
|
|
359
|
-
.where("[
|
|
360
|
+
.where("[data_id+geode_id]")
|
|
360
361
|
.anyOf(meshComponentGeodeIds.map((geode_id) => [modelId, geode_id]))
|
|
361
362
|
.toArray();
|
|
362
363
|
return components.map((component: ModelComponentRecord) =>
|
|
@@ -388,12 +389,26 @@ export const useDataStore = defineStore("data", () => {
|
|
|
388
389
|
// Dexie's bulkPut expects mutable arrays, so this snapshot parameter can't deeply satisfy
|
|
389
390
|
// The prefer-readonly-parameter-types rule; same pattern as app/utils/import_workflow.ts.
|
|
390
391
|
async function importStores(snapshot: {
|
|
391
|
-
readonly modelComponents: readonly
|
|
392
|
-
|
|
392
|
+
readonly modelComponents: readonly (
|
|
393
|
+
| LegacyDataId<ModelComponentRecord>
|
|
394
|
+
| ModelComponentRecord
|
|
395
|
+
)[];
|
|
396
|
+
readonly modelComponentsRelations: readonly (
|
|
397
|
+
| LegacyDataId<ModelComponentRelationRecord>
|
|
398
|
+
| ModelComponentRelationRecord
|
|
399
|
+
)[];
|
|
393
400
|
}): Promise<void> {
|
|
394
401
|
await clear();
|
|
395
|
-
await model_components_db.bulkPut(
|
|
396
|
-
|
|
402
|
+
await model_components_db.bulkPut(
|
|
403
|
+
snapshot.modelComponents.map((component) =>
|
|
404
|
+
fromLegacyDataId<ModelComponentRecord>(component),
|
|
405
|
+
),
|
|
406
|
+
);
|
|
407
|
+
await model_components_relation_db.bulkPut(
|
|
408
|
+
snapshot.modelComponentsRelations.map((relation) =>
|
|
409
|
+
fromLegacyDataId<ModelComponentRelationRecord>(relation),
|
|
410
|
+
),
|
|
411
|
+
);
|
|
397
412
|
}
|
|
398
413
|
return {
|
|
399
414
|
refAllItems,
|
|
@@ -438,4 +453,4 @@ export const useDataStore = defineStore("data", () => {
|
|
|
438
453
|
};
|
|
439
454
|
});
|
|
440
455
|
|
|
441
|
-
export type { CrsItem, DataItem, NewDataItem, ModelComponentInput
|
|
456
|
+
export type { CrsItem, DataItem, NewDataItem, ModelComponentInput };
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import { type FormattedComponent, type ModelComponentRecord, useDataMesh } from "./mesh.js";
|
|
2
2
|
import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
|
|
3
|
+
import type { ModelComponentRelationRecord } from "./relations.js";
|
|
4
|
+
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
5
|
+
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
3
6
|
import type { Ref } from "vue";
|
|
4
7
|
import { getTable } from "@ogw_internal/database/database.js";
|
|
5
8
|
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
6
9
|
import { pluralize } from "@ogw_front/utils/string";
|
|
7
10
|
import { useObservable } from "@vueuse/rxjs";
|
|
8
11
|
|
|
9
|
-
interface ModelComponentRelationRecord {
|
|
10
|
-
id: string;
|
|
11
|
-
parent: string;
|
|
12
|
-
child: string;
|
|
13
|
-
type: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
12
|
interface CollectionComponent extends FormattedComponent {
|
|
17
13
|
readonly children: readonly FormattedComponent[];
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
id: string;
|
|
22
|
-
title: string;
|
|
23
|
-
readonly children: readonly CollectionComponent[];
|
|
24
|
-
}
|
|
16
|
+
type CollectionComponentGroup = ReadonlyTreeGroup<CollectionComponent>;
|
|
25
17
|
|
|
26
18
|
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
27
19
|
export function useDataCollections(): {
|
|
@@ -37,17 +29,17 @@ export function useDataCollections(): {
|
|
|
37
29
|
);
|
|
38
30
|
const { getAllMeshComponents } = useDataMesh();
|
|
39
31
|
|
|
40
|
-
async function hasCollectionComponents(modelId:
|
|
32
|
+
async function hasCollectionComponents(modelId: ModelId): Promise<boolean> {
|
|
41
33
|
const count = await model_components_db
|
|
42
|
-
.where("
|
|
34
|
+
.where("data_id")
|
|
43
35
|
.equals(modelId)
|
|
44
36
|
.and((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
45
37
|
.count();
|
|
46
38
|
return count > 0;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
async function getAllCollectionComponents(modelId:
|
|
50
|
-
const items = await model_components_db.where("
|
|
41
|
+
async function getAllCollectionComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
42
|
+
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
51
43
|
return items
|
|
52
44
|
.filter((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
53
45
|
.map((component: ModelComponentRecord) => ({
|
|
@@ -61,10 +53,10 @@ export function useDataCollections(): {
|
|
|
61
53
|
}
|
|
62
54
|
|
|
63
55
|
async function fetchAllCollectionComponents(
|
|
64
|
-
modelId:
|
|
56
|
+
modelId: ModelId,
|
|
65
57
|
): Promise<Record<string, CollectionComponent[]>> {
|
|
66
58
|
const components = await getAllCollectionComponents(modelId);
|
|
67
|
-
const relations = await model_components_relation_db.where("
|
|
59
|
+
const relations = await model_components_relation_db.where("data_id").equals(modelId).toArray();
|
|
68
60
|
const allMeshComponents = await getAllMeshComponents(modelId);
|
|
69
61
|
const meshComponentsById: Record<string, FormattedComponent> = {};
|
|
70
62
|
for (const meshComponent of allMeshComponents) {
|
|
@@ -90,7 +82,7 @@ export function useDataCollections(): {
|
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
async function formatedCollectionComponents(
|
|
93
|
-
modelId:
|
|
85
|
+
modelId: ModelId,
|
|
94
86
|
): Promise<CollectionComponentGroup[]> {
|
|
95
87
|
const byType = await fetchAllCollectionComponents(modelId);
|
|
96
88
|
const collectionTypes = Object.keys(byType);
|
|
@@ -105,7 +97,7 @@ export function useDataCollections(): {
|
|
|
105
97
|
}
|
|
106
98
|
|
|
107
99
|
function refFormatedCollectionComponents(
|
|
108
|
-
modelId:
|
|
100
|
+
modelId: ModelId,
|
|
109
101
|
): Ref<CollectionComponentGroup[] | undefined> {
|
|
110
102
|
return useObservable(
|
|
111
103
|
liveObservable(async () => {
|
|
@@ -127,4 +119,4 @@ export function useDataCollections(): {
|
|
|
127
119
|
};
|
|
128
120
|
}
|
|
129
121
|
|
|
130
|
-
export type { CollectionComponent, CollectionComponentGroup
|
|
122
|
+
export type { CollectionComponent, CollectionComponentGroup };
|
|
@@ -1,31 +1,26 @@
|
|
|
1
|
+
import type { DataIdentified, GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
|
+
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
1
3
|
import type { Table } from "dexie";
|
|
2
4
|
import { database } from "@ogw_internal/database/database.js";
|
|
3
5
|
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
4
6
|
import { useObservable } from "@vueuse/rxjs";
|
|
5
7
|
|
|
6
|
-
interface ModelComponentRecord {
|
|
7
|
-
id: string;
|
|
8
|
-
geode_id: string;
|
|
8
|
+
interface ModelComponentRecord extends DataIdentified, GeodeIdentified {
|
|
9
9
|
type: string;
|
|
10
10
|
viewer_id: string | number;
|
|
11
11
|
name: string;
|
|
12
12
|
is_active: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
interface FormattedComponent {
|
|
15
|
+
interface FormattedComponent extends Readonly<GeodeIdentified> {
|
|
16
16
|
readonly id: string;
|
|
17
|
-
readonly geode_id: string;
|
|
18
17
|
readonly title: string;
|
|
19
18
|
readonly category: string;
|
|
20
19
|
readonly viewer_id: number;
|
|
21
20
|
readonly is_active: boolean;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
id: string;
|
|
26
|
-
title: string;
|
|
27
|
-
readonly children: readonly FormattedComponent[];
|
|
28
|
-
}
|
|
23
|
+
type FormattedComponentGroup = ReadonlyTreeGroup<FormattedComponent>;
|
|
29
24
|
|
|
30
25
|
function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
|
|
31
26
|
return {
|
|
@@ -57,8 +52,8 @@ function useDataMesh(): {
|
|
|
57
52
|
string
|
|
58
53
|
>;
|
|
59
54
|
|
|
60
|
-
async function formatedMeshComponents(modelId:
|
|
61
|
-
const items = await model_components_db.where("
|
|
55
|
+
async function formatedMeshComponents(modelId: ModelId): Promise<FormattedComponentGroup[]> {
|
|
56
|
+
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
62
57
|
const componentTitles: Record<string, string> = {
|
|
63
58
|
Corner: "Corners",
|
|
64
59
|
Line: "Lines",
|
|
@@ -85,7 +80,7 @@ function useDataMesh(): {
|
|
|
85
80
|
}));
|
|
86
81
|
}
|
|
87
82
|
|
|
88
|
-
function refFormatedMeshComponents(modelId:
|
|
83
|
+
function refFormatedMeshComponents(modelId: ModelId): Ref<FormattedComponentGroup[] | undefined> {
|
|
89
84
|
return useObservable(
|
|
90
85
|
liveObservable(async () => {
|
|
91
86
|
const components = await formatedMeshComponents(modelId);
|
|
@@ -98,23 +93,23 @@ function useDataMesh(): {
|
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
async function getMeshComponentsByType(
|
|
101
|
-
modelId:
|
|
96
|
+
modelId: ModelId,
|
|
102
97
|
type: string,
|
|
103
98
|
): Promise<FormattedComponent[]> {
|
|
104
99
|
const components = await model_components_db
|
|
105
|
-
.where("[
|
|
100
|
+
.where("[data_id+type]")
|
|
106
101
|
.equals([modelId, type])
|
|
107
102
|
.toArray();
|
|
108
103
|
return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
109
104
|
}
|
|
110
105
|
|
|
111
|
-
async function getAllMeshComponents(modelId:
|
|
112
|
-
const items = await model_components_db.where("
|
|
106
|
+
async function getAllMeshComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
107
|
+
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
113
108
|
return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
114
109
|
}
|
|
115
110
|
|
|
116
111
|
async function fetchAllMeshComponents(
|
|
117
|
-
modelId:
|
|
112
|
+
modelId: ModelId,
|
|
118
113
|
): Promise<Record<string, FormattedComponent[]>> {
|
|
119
114
|
const components = await getAllMeshComponents(modelId);
|
|
120
115
|
const byType: Record<string, FormattedComponent[]> = {};
|
|
@@ -125,30 +120,30 @@ function useDataMesh(): {
|
|
|
125
120
|
return byType;
|
|
126
121
|
}
|
|
127
122
|
|
|
128
|
-
async function getMeshComponentGeodeIds(modelId:
|
|
123
|
+
async function getMeshComponentGeodeIds(modelId: ModelId, type: string): Promise<string[]> {
|
|
129
124
|
const components = await model_components_db
|
|
130
|
-
.where("[
|
|
125
|
+
.where("[data_id+type]")
|
|
131
126
|
.equals([modelId, type])
|
|
132
127
|
.toArray();
|
|
133
128
|
return components.map((component: ModelComponentRecord) => component.geode_id);
|
|
134
129
|
}
|
|
135
130
|
|
|
136
|
-
async function getCornersGeodeIds(modelId:
|
|
131
|
+
async function getCornersGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
137
132
|
const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
|
|
138
133
|
return geodeIds;
|
|
139
134
|
}
|
|
140
135
|
|
|
141
|
-
async function getLinesGeodeIds(modelId:
|
|
136
|
+
async function getLinesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
142
137
|
const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
|
|
143
138
|
return geodeIds;
|
|
144
139
|
}
|
|
145
140
|
|
|
146
|
-
async function getSurfacesGeodeIds(modelId:
|
|
141
|
+
async function getSurfacesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
147
142
|
const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
|
|
148
143
|
return geodeIds;
|
|
149
144
|
}
|
|
150
145
|
|
|
151
|
-
async function getBlocksGeodeIds(modelId:
|
|
146
|
+
async function getBlocksGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
152
147
|
const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
|
|
153
148
|
return geodeIds;
|
|
154
149
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DataIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
1
2
|
import {
|
|
2
3
|
type FormattedComponent,
|
|
3
4
|
type ModelComponentRecord,
|
|
@@ -6,18 +7,17 @@ import {
|
|
|
6
7
|
import { Dexie } from "dexie";
|
|
7
8
|
import { getTable } from "@ogw_internal/database/database.js";
|
|
8
9
|
|
|
9
|
-
interface ModelComponentRelationRecord {
|
|
10
|
-
id: string;
|
|
11
|
-
parent: string;
|
|
12
|
-
child: string;
|
|
13
|
-
type: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
interface ComponentRelations {
|
|
17
11
|
readonly boundaries: readonly FormattedComponent[];
|
|
18
12
|
readonly internals: readonly FormattedComponent[];
|
|
19
13
|
}
|
|
20
14
|
|
|
15
|
+
interface ModelComponentRelationRecord extends DataIdentified {
|
|
16
|
+
parent: string;
|
|
17
|
+
child: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
21
|
export function useDataRelations(): {
|
|
22
22
|
getComponentRelations: typeof getComponentRelations;
|
|
23
23
|
} {
|
|
@@ -27,23 +27,23 @@ export function useDataRelations(): {
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
async function getRelatedComponents(
|
|
30
|
-
modelId:
|
|
30
|
+
modelId: ModelId,
|
|
31
31
|
relations: readonly ModelComponentRelationRecord[],
|
|
32
32
|
type: string,
|
|
33
33
|
): Promise<FormattedComponent[]> {
|
|
34
34
|
const keys = relations
|
|
35
35
|
.filter((relation) => relation.type === type)
|
|
36
36
|
.map((relation) => [modelId, relation.child]);
|
|
37
|
-
const components = await model_components_db.where("[
|
|
37
|
+
const components = await model_components_db.where("[data_id+geode_id]").anyOf(keys).toArray();
|
|
38
38
|
return components.map((component) => toFormattedComponent(component));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async function getComponentRelations(
|
|
42
|
-
modelId:
|
|
42
|
+
modelId: ModelId,
|
|
43
43
|
componentId: string,
|
|
44
44
|
): Promise<ComponentRelations> {
|
|
45
45
|
const relations = await model_components_relation_db
|
|
46
|
-
.where("[
|
|
46
|
+
.where("[data_id+parent+child]")
|
|
47
47
|
.between([modelId, componentId, Dexie.minKey], [modelId, componentId, Dexie.maxKey])
|
|
48
48
|
.toArray();
|
|
49
49
|
const [boundaries, internals] = await Promise.all([
|
|
@@ -56,4 +56,4 @@ export function useDataRelations(): {
|
|
|
56
56
|
return { getComponentRelations };
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export type { ComponentRelations };
|
|
59
|
+
export type { ComponentRelations, ModelComponentRelationRecord };
|