@geode/opengeodeweb-front 12.2.0-rc.4 → 12.2.0-rc.6
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/CameraOrientation.vue +85 -68
- package/app/components/CameraOrientationDial.vue +195 -0
- package/app/components/ClippingPlanes.vue +1 -1
- package/app/components/FactorFilterPanel.vue +1 -1
- package/app/components/Launcher.vue +3 -2
- package/app/components/ThresholdFilter.vue +1 -2
- package/app/components/Viewer/Basemap/CropOptions.vue +7 -8
- package/app/components/Viewer/Basemap/OpacityOptions.vue +7 -8
- package/app/components/Viewer/ContextMenu/CircularItems.vue +6 -43
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +1 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +14 -16
- package/app/components/Viewer/EdgedCurve/PointsOptions.vue +5 -4
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +10 -13
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +8 -11
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +16 -13
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +28 -31
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +9 -11
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/EdgesOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +1 -1
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +5 -7
- package/app/components/Viewer/Generic/Model/ModelStyleOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/PointsOptions.vue +7 -8
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +1 -1
- package/app/components/Viewer/Grid/2D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/2D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Grid/3D/CellsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/FacetsOptions.vue +6 -4
- package/app/components/Viewer/Grid/3D/PointsOptions.vue +5 -4
- package/app/components/Viewer/Image/ImageOptions.vue +10 -13
- package/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +5 -0
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
- package/app/components/Viewer/ObjectTree/Base/StickyHeader.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/TreeRow.vue +6 -8
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
- package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
- package/app/components/Viewer/OrientationCompass.vue +11 -34
- package/app/components/Viewer/OrientationGlobe.vue +2 -2
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +28 -31
- package/app/components/Viewer/Scene/BackgroundOptions.vue +4 -7
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +4 -7
- package/app/components/Viewer/Scene/TextOptions.vue +4 -7
- package/app/components/Viewer/Solid/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Solid/PointsOptions.vue +5 -4
- package/app/components/Viewer/Solid/PolygonsOptions.vue +6 -4
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +8 -11
- package/app/components/Viewer/Surface/EdgesOptions.vue +6 -4
- package/app/components/Viewer/Surface/PointsOptions.vue +6 -4
- package/app/components/Viewer/Surface/PolygonsOptions.vue +8 -11
- package/app/components/Viewer/Surface/Triangulated/TrianglesOptions.vue +5 -4
- package/app/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue +6 -4
- package/app/components/Viewer/TetrahedralSolid/TrianglesOptions.vue +6 -4
- package/app/composables/circular_menu.ts +45 -0
- package/app/composables/compass_dial.ts +40 -0
- package/app/composables/hover_highlight.ts +1 -1
- package/app/composables/model_menu_context.ts +7 -11
- package/app/composables/model_tree.ts +3 -3
- package/app/composables/project_manager_helpers/types.ts +2 -3
- package/app/composables/use_overlapping_picker.ts +7 -19
- package/app/composables/viewer_context_menu.ts +2 -1
- package/app/stores/api.ts +6 -59
- package/app/stores/app.ts +21 -55
- package/app/stores/back.ts +86 -145
- package/app/stores/camera_manager.ts +12 -25
- package/app/stores/cloud.ts +21 -101
- package/app/stores/crs.ts +3 -2
- package/app/stores/data.ts +66 -409
- package/app/stores/data_style.ts +99 -93
- package/app/stores/feedback.ts +57 -53
- package/app/stores/infra.ts +61 -101
- package/app/stores/treeview.ts +12 -31
- package/app/stores/viewer.ts +9 -29
- package/app/stores/viewer_helpers/actions.ts +1 -23
- package/app/utils/backend_lifecycle.ts +155 -0
- package/app/utils/brand_colors.ts +9 -0
- package/app/utils/camera_orientations.ts +136 -0
- package/app/utils/import_item.ts +5 -4
- package/app/utils/orientation_compass.ts +15 -0
- package/app/utils/orientation_cube_style.ts +70 -0
- package/app/utils/threshold_sources.ts +3 -2
- package/app/utils/treeview.ts +25 -1
- package/app/utils/viewer_object_type.ts +21 -0
- package/internal/database/base_database.ts +2 -1
- package/internal/database/database.ts +90 -7
- package/internal/database/queries.ts +45 -0
- package/internal/database/tables/camera_positions.ts +11 -1
- package/internal/database/tables/data.ts +20 -1
- package/internal/database/tables/data_style.ts +3 -1
- package/internal/database/tables/model_component_datastyle.ts +3 -1
- package/internal/database/tables/model_component_type_datastyle.ts +3 -1
- package/internal/database/tables/model_components.ts +12 -1
- package/internal/database/tables/model_components_relation.ts +11 -1
- package/internal/database/tables/scene_style.ts +3 -1
- package/internal/database/tables/treeview_config.ts +31 -0
- package/internal/stores/data/items.ts +110 -0
- package/internal/stores/data/model/collections.ts +107 -0
- package/internal/stores/data/model/components.ts +129 -0
- package/internal/stores/data/model/mesh_components.ts +134 -0
- package/internal/stores/data/model/relations.ts +76 -0
- package/internal/stores/data/model/types.ts +14 -0
- package/internal/stores/data/registration.ts +54 -0
- package/internal/stores/data/snapshot.ts +83 -0
- package/internal/stores/data/types.ts +26 -0
- package/internal/stores/data_style/model/common_mutations.ts +47 -77
- package/internal/stores/data_style/model/selection.ts +3 -10
- package/internal/stores/data_style/scene.ts +2 -2
- package/internal/stores/data_style/state.ts +10 -8
- package/internal/stores/data_style/state_shared.ts +10 -7
- package/internal/stores/hybrid_viewer/highlight.ts +9 -14
- package/internal/stores/hybrid_viewer/scene.ts +1 -1
- package/internal/stores/microservice.ts +192 -0
- package/package.json +1 -1
- package/tests/browser/helpers/data/helpers/attribute.ts +2 -1
- package/app/stores/data_helpers/collections.ts +0 -122
- package/app/stores/data_helpers/mesh.ts +0 -167
- package/app/stores/data_helpers/relations.ts +0 -94
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
|
+
import { modelComponentsOf, modelComponentsOfType } from "@ogw_internal/database/queries.js";
|
|
3
|
+
import type { ModelComponentRecord } from "@ogw_internal/database/tables/model_components";
|
|
4
|
+
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
5
|
+
import type { ViewerId } from "@geode/opengeodeweb-viewer/schema_types";
|
|
6
|
+
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
7
|
+
import { useObservable } from "@vueuse/rxjs";
|
|
8
|
+
|
|
9
|
+
interface FormattedComponent extends Readonly<GeodeIdentified> {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly title: string;
|
|
12
|
+
readonly category: string;
|
|
13
|
+
readonly viewer_id: ViewerId;
|
|
14
|
+
readonly is_active: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type FormattedComponentGroup = ReadonlyTreeGroup<FormattedComponent>;
|
|
18
|
+
|
|
19
|
+
function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
|
|
20
|
+
return {
|
|
21
|
+
id: meshComponent.geode_id,
|
|
22
|
+
geode_id: meshComponent.geode_id,
|
|
23
|
+
title: meshComponent.name,
|
|
24
|
+
category: meshComponent.type,
|
|
25
|
+
viewer_id: Math.trunc(Number(meshComponent.viewer_id)),
|
|
26
|
+
is_active: meshComponent.is_active,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function getMeshComponentGeodeIds(modelId: ModelId, type: string): Promise<string[]> {
|
|
31
|
+
const components = await modelComponentsOfType(modelId, type).toArray();
|
|
32
|
+
return components.map((component: ModelComponentRecord) => component.geode_id);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function formatedMeshComponents(modelId: ModelId): Promise<FormattedComponentGroup[]> {
|
|
36
|
+
const items = await modelComponentsOf(modelId).toArray();
|
|
37
|
+
const componentTitles: Record<string, string> = {
|
|
38
|
+
Corner: "Corners",
|
|
39
|
+
Line: "Lines",
|
|
40
|
+
Surface: "Surfaces",
|
|
41
|
+
Block: "Blocks",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const componentsByType: Record<string, ModelComponentRecord[]> = {};
|
|
45
|
+
for (const component_item of items) {
|
|
46
|
+
if (componentTitles[component_item.type] !== undefined) {
|
|
47
|
+
componentsByType[component_item.type] ??= [];
|
|
48
|
+
componentsByType[component_item.type]?.push(component_item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return Object.keys(componentTitles)
|
|
53
|
+
.filter((type) => componentsByType[type])
|
|
54
|
+
.map((type) => ({
|
|
55
|
+
id: type,
|
|
56
|
+
title: componentTitles[type] ?? type,
|
|
57
|
+
children: (componentsByType[type] ?? []).map((item: ModelComponentRecord) =>
|
|
58
|
+
toFormattedComponent(item),
|
|
59
|
+
),
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function refFormatedMeshComponents(modelId: ModelId): Ref<FormattedComponentGroup[] | undefined> {
|
|
64
|
+
return useObservable(
|
|
65
|
+
liveObservable(async () => {
|
|
66
|
+
const components = await formatedMeshComponents(modelId);
|
|
67
|
+
return components;
|
|
68
|
+
}),
|
|
69
|
+
{
|
|
70
|
+
initialValue: undefined,
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function getMeshComponentsByType(
|
|
76
|
+
modelId: ModelId,
|
|
77
|
+
type: string,
|
|
78
|
+
): Promise<FormattedComponent[]> {
|
|
79
|
+
const components = await modelComponentsOfType(modelId, type).toArray();
|
|
80
|
+
return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function getAllMeshComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
84
|
+
const items = await modelComponentsOf(modelId).toArray();
|
|
85
|
+
return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function fetchAllMeshComponents(
|
|
89
|
+
modelId: ModelId,
|
|
90
|
+
): Promise<Record<string, FormattedComponent[]>> {
|
|
91
|
+
const components = await getAllMeshComponents(modelId);
|
|
92
|
+
const byType: Record<string, FormattedComponent[]> = {};
|
|
93
|
+
for (const component of components) {
|
|
94
|
+
byType[component.category] ??= [];
|
|
95
|
+
byType[component.category]?.push(component);
|
|
96
|
+
}
|
|
97
|
+
return byType;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function getCornersGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
101
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
|
|
102
|
+
return geodeIds;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function getLinesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
106
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
|
|
107
|
+
return geodeIds;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function getSurfacesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
111
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
|
|
112
|
+
return geodeIds;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function getBlocksGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
116
|
+
const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
|
|
117
|
+
return geodeIds;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
fetchAllMeshComponents,
|
|
122
|
+
formatedMeshComponents,
|
|
123
|
+
getAllMeshComponents,
|
|
124
|
+
getBlocksGeodeIds,
|
|
125
|
+
getCornersGeodeIds,
|
|
126
|
+
getLinesGeodeIds,
|
|
127
|
+
getMeshComponentGeodeIds,
|
|
128
|
+
getMeshComponentsByType,
|
|
129
|
+
getSurfacesGeodeIds,
|
|
130
|
+
refFormatedMeshComponents,
|
|
131
|
+
toFormattedComponent,
|
|
132
|
+
};
|
|
133
|
+
export type { FormattedComponent, FormattedComponentGroup };
|
|
134
|
+
export type { ModelComponentRecord } from "@ogw_internal/database/tables/model_components";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type FormattedComponent, toFormattedComponent } from "./mesh_components.js";
|
|
2
|
+
import {
|
|
3
|
+
componentRelationsOf,
|
|
4
|
+
modelComponentRelationsOf,
|
|
5
|
+
modelComponentsByGeodeIds,
|
|
6
|
+
} from "@ogw_internal/database/queries.js";
|
|
7
|
+
import type { ModelComponentRelationRecord } from "@ogw_internal/database/tables/model_components_relation";
|
|
8
|
+
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
9
|
+
|
|
10
|
+
interface ComponentRelations {
|
|
11
|
+
readonly boundaries: readonly FormattedComponent[];
|
|
12
|
+
readonly internals: readonly FormattedComponent[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const RELATION_KEYS: Readonly<Record<string, keyof ComponentRelations>> = {
|
|
16
|
+
boundary: "boundaries",
|
|
17
|
+
internal: "internals",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type MutableComponentRelations = { [Key in keyof ComponentRelations]: FormattedComponent[] };
|
|
21
|
+
|
|
22
|
+
function groupRelationsByParent(
|
|
23
|
+
relations: readonly ModelComponentRelationRecord[],
|
|
24
|
+
components: readonly FormattedComponent[],
|
|
25
|
+
): Record<string, ComponentRelations> {
|
|
26
|
+
const componentsById = new Map(components.map((component) => [component.id, component]));
|
|
27
|
+
const byParent: Record<string, MutableComponentRelations> = {};
|
|
28
|
+
for (const relation of relations) {
|
|
29
|
+
const key = RELATION_KEYS[relation.type];
|
|
30
|
+
const child = componentsById.get(relation.child);
|
|
31
|
+
if (key !== undefined && child !== undefined) {
|
|
32
|
+
byParent[relation.parent] ??= { boundaries: [], internals: [] };
|
|
33
|
+
byParent[relation.parent]?.[key].push(child);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return byParent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function getRelatedComponents(
|
|
40
|
+
modelId: ModelId,
|
|
41
|
+
relations: readonly ModelComponentRelationRecord[],
|
|
42
|
+
type: string,
|
|
43
|
+
): Promise<FormattedComponent[]> {
|
|
44
|
+
const childIds = relations
|
|
45
|
+
.filter((relation) => relation.type === type)
|
|
46
|
+
.map((relation) => relation.child);
|
|
47
|
+
const components = await modelComponentsByGeodeIds(modelId, childIds).toArray();
|
|
48
|
+
return components.map((component) => toFormattedComponent(component));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function getComponentRelations(
|
|
52
|
+
modelId: ModelId,
|
|
53
|
+
componentId: string,
|
|
54
|
+
): Promise<ComponentRelations> {
|
|
55
|
+
const relations = await componentRelationsOf(modelId, componentId).toArray();
|
|
56
|
+
const [boundaries, internals] = await Promise.all([
|
|
57
|
+
getRelatedComponents(modelId, relations, "boundary"),
|
|
58
|
+
getRelatedComponents(modelId, relations, "internal"),
|
|
59
|
+
]);
|
|
60
|
+
return { boundaries, internals };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The boundaries and internals of every component of the model, among the given components:
|
|
64
|
+
// The caller already holds them, so only the relations are read
|
|
65
|
+
async function fetchAllComponentRelations(
|
|
66
|
+
modelId: ModelId,
|
|
67
|
+
components: readonly FormattedComponent[],
|
|
68
|
+
): Promise<Record<string, ComponentRelations>> {
|
|
69
|
+
const relations = await modelComponentRelationsOf(modelId).toArray();
|
|
70
|
+
return groupRelationsByParent(relations, components);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type { ComponentRelations };
|
|
74
|
+
export type { ModelComponentRelationRecord } from "@ogw_internal/database/tables/model_components_relation";
|
|
75
|
+
|
|
76
|
+
export { fetchAllComponentRelations, getComponentRelations };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GeodeIdentified } from "@ogw_front/types/identifiers";
|
|
2
|
+
|
|
3
|
+
// A model component as the back sends it, with the ids of its related components
|
|
4
|
+
interface ModelComponentInput extends GeodeIdentified {
|
|
5
|
+
type: string;
|
|
6
|
+
viewer_id: string | number;
|
|
7
|
+
name: string;
|
|
8
|
+
is_active: boolean;
|
|
9
|
+
boundaries?: string[];
|
|
10
|
+
internals?: string[];
|
|
11
|
+
items?: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { ModelComponentInput };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from "vue";
|
|
2
|
+
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
3
|
+
import type { DataItem } from "@ogw_internal/database/tables/data";
|
|
4
|
+
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
5
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
6
|
+
|
|
7
|
+
const viewerGenericSchemas = viewer_schemas.opengeodeweb_viewer.generic;
|
|
8
|
+
|
|
9
|
+
// Ids the viewer holds a pipeline for: an item is stored before it is registered, and non viewable items never are
|
|
10
|
+
function useDataRegistration(items: Readonly<Ref<DataItem[]>>): {
|
|
11
|
+
registeredItems: ComputedRef<DataItem[]>;
|
|
12
|
+
isRegistered: typeof isRegistered;
|
|
13
|
+
registerObject: typeof registerObject;
|
|
14
|
+
deregisterObject: typeof deregisterObject;
|
|
15
|
+
clearRegistrations: typeof clearRegistrations;
|
|
16
|
+
} {
|
|
17
|
+
const viewerStore = useViewerStore();
|
|
18
|
+
const registeredIds = reactive(new Set<string>());
|
|
19
|
+
|
|
20
|
+
function isRegistered(dataId: DataId): boolean {
|
|
21
|
+
return registeredIds.has(dataId);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const registeredItems = computed(() =>
|
|
25
|
+
items.value.filter((dataItem) => isRegistered(dataItem.data_id)),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
async function registerObject(dataId: DataId, name: string): Promise<unknown> {
|
|
29
|
+
const result = await viewerStore.request({
|
|
30
|
+
schema: viewerGenericSchemas.register,
|
|
31
|
+
params: { id: dataId, name },
|
|
32
|
+
timeout: 0,
|
|
33
|
+
});
|
|
34
|
+
registeredIds.add(dataId);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function deregisterObject(dataId: DataId): Promise<unknown> {
|
|
39
|
+
registeredIds.delete(dataId);
|
|
40
|
+
const result = await viewerStore.request({
|
|
41
|
+
schema: viewerGenericSchemas.deregister,
|
|
42
|
+
params: { id: dataId },
|
|
43
|
+
});
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function clearRegistrations(): void {
|
|
48
|
+
registeredIds.clear();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return { registeredItems, isRegistered, registerObject, deregisterObject, clearRegistrations };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { useDataRegistration };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
2
|
+
import {
|
|
3
|
+
dataDb,
|
|
4
|
+
modelComponentsDb,
|
|
5
|
+
modelComponentsRelationDb,
|
|
6
|
+
writeTransaction,
|
|
7
|
+
} from "@ogw_internal/database/database.js";
|
|
8
|
+
import { modelComponentRelationsOf, modelComponentsOf } from "@ogw_internal/database/queries.js";
|
|
9
|
+
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
10
|
+
import type { DataItem } from "@ogw_internal/database/tables/data";
|
|
11
|
+
import type { ModelComponentRecord } from "@ogw_internal/database/tables/model_components";
|
|
12
|
+
import type { ModelComponentRelationRecord } from "@ogw_internal/database/tables/model_components_relation";
|
|
13
|
+
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
14
|
+
|
|
15
|
+
const dataTable = dataDb();
|
|
16
|
+
const modelComponentsTable = modelComponentsDb();
|
|
17
|
+
const modelComponentsRelationTable = modelComponentsRelationDb();
|
|
18
|
+
const dataTables = [dataTable, modelComponentsTable, modelComponentsRelationTable];
|
|
19
|
+
|
|
20
|
+
interface DataSnapshot {
|
|
21
|
+
readonly modelComponents: readonly (LegacyDataId<ModelComponentRecord> | ModelComponentRecord)[];
|
|
22
|
+
readonly modelComponentsRelations: readonly (
|
|
23
|
+
| LegacyDataId<ModelComponentRelationRecord>
|
|
24
|
+
| ModelComponentRelationRecord
|
|
25
|
+
)[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function deleteModelComponents(modelId: ModelId): Promise<void> {
|
|
29
|
+
await writeTransaction([modelComponentsTable, modelComponentsRelationTable], async () => {
|
|
30
|
+
await modelComponentsOf(modelId).delete();
|
|
31
|
+
await modelComponentRelationsOf(modelId).delete();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// A data is deleted with its components and their relations, or not at all
|
|
36
|
+
async function deleteItem(dataId: DataId): Promise<void> {
|
|
37
|
+
await writeTransaction(dataTables, async () => {
|
|
38
|
+
await dataTable.delete(dataId);
|
|
39
|
+
await deleteModelComponents(dataId);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function exportStores(): Promise<{
|
|
44
|
+
items: DataItem[];
|
|
45
|
+
modelComponents: ModelComponentRecord[];
|
|
46
|
+
modelComponentsRelations: ModelComponentRelationRecord[];
|
|
47
|
+
}> {
|
|
48
|
+
return {
|
|
49
|
+
items: await dataTable.toArray(),
|
|
50
|
+
modelComponents: await modelComponentsTable.toArray(),
|
|
51
|
+
modelComponentsRelations: await modelComponentsRelationTable.toArray(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function clearTables(): Promise<void> {
|
|
56
|
+
await writeTransaction(dataTables, async () => {
|
|
57
|
+
await dataTable.clear();
|
|
58
|
+
await modelComponentsTable.clear();
|
|
59
|
+
await modelComponentsRelationTable.clear();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The snapshot replaces the stored data as a whole: a failed import leaves the previous one.
|
|
64
|
+
// Dexie's bulkPut expects mutable arrays, so this snapshot parameter can't deeply satisfy
|
|
65
|
+
// The prefer-readonly-parameter-types rule; same pattern as app/utils/import_workflow.ts.
|
|
66
|
+
async function importTables(snapshot: DataSnapshot): Promise<void> {
|
|
67
|
+
await writeTransaction(dataTables, async () => {
|
|
68
|
+
await clearTables();
|
|
69
|
+
await modelComponentsTable.bulkPut(
|
|
70
|
+
snapshot.modelComponents.map((component) =>
|
|
71
|
+
fromLegacyDataId<ModelComponentRecord>(component),
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
await modelComponentsRelationTable.bulkPut(
|
|
75
|
+
snapshot.modelComponentsRelations.map((relation) =>
|
|
76
|
+
fromLegacyDataId<ModelComponentRelationRecord>(relation),
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { clearTables, deleteItem, exportStores, importTables };
|
|
83
|
+
export type { DataSnapshot };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DataIdentified,
|
|
3
|
+
GeodeIdentified,
|
|
4
|
+
GeodeObjectTyped,
|
|
5
|
+
ViewerObjectTyped,
|
|
6
|
+
} from "@ogw_front/types/identifiers";
|
|
7
|
+
import type { CRS } from "@geode/opengeodeweb-back/schema_types";
|
|
8
|
+
import type { DataItem } from "@ogw_internal/database/tables/data";
|
|
9
|
+
import type { ModelComponentInput } from "@ogw_internal/stores/data/model/types";
|
|
10
|
+
|
|
11
|
+
// What the CRS features read of a data: light to copy on each change
|
|
12
|
+
type CrsItem = Pick<DataItem, "data_id" | "name" | "crs" | "created_at">;
|
|
13
|
+
|
|
14
|
+
interface NewDataItem extends DataIdentified, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
|
|
15
|
+
name?: string;
|
|
16
|
+
is_viewable?: boolean;
|
|
17
|
+
binary_light_viewable?: string;
|
|
18
|
+
crs?: CRS;
|
|
19
|
+
// Set on saved data: kept by the project snapshot
|
|
20
|
+
created_at?: string;
|
|
21
|
+
mesh_components?: ModelComponentInput[];
|
|
22
|
+
collection_components?: ModelComponentInput[];
|
|
23
|
+
nb_vertices?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type { CrsItem, NewDataItem };
|
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import type { Dexie, Table } from "dexie";
|
|
2
1
|
import type {
|
|
3
2
|
ModelComponentStyle,
|
|
4
3
|
ModelComponentTypeStyle,
|
|
5
4
|
StyleValues,
|
|
6
5
|
} from "@ogw_internal/stores/data_style/types.js";
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
componentDataStyleDb,
|
|
8
|
+
componentTypeDataStyleDb,
|
|
9
|
+
writeTransaction,
|
|
10
|
+
} from "@ogw_internal/database/database";
|
|
8
11
|
import merge from "lodash/merge";
|
|
9
12
|
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
10
13
|
|
|
11
|
-
// The underlying dexie tables use compound array keys ([id_model, id_component] /
|
|
12
|
-
// [id_model, type]) but the shared `database` proxy types every table as
|
|
13
|
-
// Table<Record<string, unknown>, string>. Cast locally to the real key shape.
|
|
14
|
-
type ComponentTable = Table<ModelComponentStyle, [string, string]>;
|
|
15
|
-
type ComponentTypeTable = Table<ModelComponentTypeStyle, [string, string]>;
|
|
16
|
-
|
|
17
14
|
interface ComponentStyleUpdate {
|
|
18
15
|
id_component: string;
|
|
19
16
|
values: StyleValues;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
function componentDatastyleTable(): ComponentTable {
|
|
23
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
24
|
-
return database.model_component_datastyle as unknown as ComponentTable;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function componentTypeDatastyleTable(): ComponentTypeTable {
|
|
28
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
|
|
29
|
-
return database.model_component_type_datastyle as unknown as ComponentTypeTable;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
19
|
interface UseModelComponentStyleMutationsReturn {
|
|
33
20
|
mutateComponentStyle: (
|
|
34
21
|
id_model: string,
|
|
@@ -59,8 +46,8 @@ interface UseModelComponentsPerComponentStyleMutationReturn {
|
|
|
59
46
|
|
|
60
47
|
function useModelComponentStyleMutations(): UseModelComponentStyleMutationsReturn {
|
|
61
48
|
const dataStyleState = useDataStyleState();
|
|
62
|
-
const
|
|
63
|
-
const
|
|
49
|
+
const componentDataStyleTable = componentDataStyleDb();
|
|
50
|
+
const componentTypeDataStyleTable = componentTypeDataStyleDb();
|
|
64
51
|
|
|
65
52
|
async function mutateComponentStyle(
|
|
66
53
|
id_model: string,
|
|
@@ -69,12 +56,12 @@ function useModelComponentStyleMutations(): UseModelComponentStyleMutationsRetur
|
|
|
69
56
|
): Promise<unknown> {
|
|
70
57
|
dataStyleState.updateComponentStyleCache(id_model, id_component, values);
|
|
71
58
|
const key: [string, string] = [id_model, id_component];
|
|
72
|
-
const entry: ModelComponentStyle = (await
|
|
59
|
+
const entry: ModelComponentStyle = (await componentDataStyleTable.get(key)) ?? {
|
|
73
60
|
id_model,
|
|
74
61
|
id_component,
|
|
75
62
|
};
|
|
76
63
|
merge(entry, values);
|
|
77
|
-
return
|
|
64
|
+
return componentDataStyleTable.put(structuredClone(toRaw(entry)));
|
|
78
65
|
}
|
|
79
66
|
|
|
80
67
|
async function mutateModelComponentTypeStyle(
|
|
@@ -83,22 +70,15 @@ function useModelComponentStyleMutations(): UseModelComponentStyleMutationsRetur
|
|
|
83
70
|
values: StyleValues,
|
|
84
71
|
): Promise<void> {
|
|
85
72
|
dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
id_model,
|
|
96
|
-
type,
|
|
97
|
-
};
|
|
98
|
-
merge(entry, values);
|
|
99
|
-
return model_component_type_datastyle_db.put(structuredClone(toRaw(entry)));
|
|
100
|
-
},
|
|
101
|
-
);
|
|
73
|
+
await writeTransaction([componentTypeDataStyleTable], async () => {
|
|
74
|
+
const key: [string, string] = [id_model, type];
|
|
75
|
+
const entry: ModelComponentTypeStyle = (await componentTypeDataStyleTable.get(key)) ?? {
|
|
76
|
+
id_model,
|
|
77
|
+
type,
|
|
78
|
+
};
|
|
79
|
+
merge(entry, values);
|
|
80
|
+
return componentTypeDataStyleTable.put(structuredClone(toRaw(entry)));
|
|
81
|
+
});
|
|
102
82
|
}
|
|
103
83
|
|
|
104
84
|
return {
|
|
@@ -109,7 +89,7 @@ function useModelComponentStyleMutations(): UseModelComponentStyleMutationsRetur
|
|
|
109
89
|
|
|
110
90
|
function useModelComponentsStyleMutation(): UseModelComponentsStyleMutationReturn {
|
|
111
91
|
const dataStyleState = useDataStyleState();
|
|
112
|
-
const
|
|
92
|
+
const componentDataStyleTable = componentDataStyleDb();
|
|
113
93
|
|
|
114
94
|
async function mutateComponentStyles(
|
|
115
95
|
id_model: string,
|
|
@@ -117,25 +97,20 @@ function useModelComponentsStyleMutation(): UseModelComponentsStyleMutationRetur
|
|
|
117
97
|
values: StyleValues,
|
|
118
98
|
): Promise<void> {
|
|
119
99
|
dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
137
|
-
},
|
|
138
|
-
);
|
|
100
|
+
await writeTransaction([componentDataStyleTable], async () => {
|
|
101
|
+
const keys: [string, string][] = id_components.map((id_component) => [
|
|
102
|
+
id_model,
|
|
103
|
+
id_component,
|
|
104
|
+
]);
|
|
105
|
+
const existing = await componentDataStyleTable.bulkGet(keys);
|
|
106
|
+
const updates = id_components.map((id_component, index) => {
|
|
107
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
108
|
+
merge(style, values);
|
|
109
|
+
return toRaw(style);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return componentDataStyleTable.bulkPut(structuredClone(updates));
|
|
113
|
+
});
|
|
139
114
|
}
|
|
140
115
|
|
|
141
116
|
return {
|
|
@@ -145,31 +120,26 @@ function useModelComponentsStyleMutation(): UseModelComponentsStyleMutationRetur
|
|
|
145
120
|
|
|
146
121
|
function useModelComponentsPerComponentStyleMutation(): UseModelComponentsPerComponentStyleMutationReturn {
|
|
147
122
|
const dataStyleState = useDataStyleState();
|
|
148
|
-
const
|
|
123
|
+
const componentDataStyleTable = componentDataStyleDb();
|
|
149
124
|
|
|
150
125
|
async function bulkMutateComponentStylesPerComponent(
|
|
151
126
|
id_model: string,
|
|
152
127
|
component_updates: ComponentStyleUpdate[],
|
|
153
128
|
): Promise<void> {
|
|
154
129
|
dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return toRaw(style);
|
|
169
|
-
});
|
|
170
|
-
return model_component_datastyle_db.bulkPut(structuredClone(updates));
|
|
171
|
-
},
|
|
172
|
-
);
|
|
130
|
+
await writeTransaction([componentDataStyleTable], async () => {
|
|
131
|
+
const keys: [string, string][] = component_updates.map((update) => [
|
|
132
|
+
id_model,
|
|
133
|
+
update.id_component,
|
|
134
|
+
]);
|
|
135
|
+
const existing = await componentDataStyleTable.bulkGet(keys);
|
|
136
|
+
const updates = component_updates.map(({ id_component, values }, index) => {
|
|
137
|
+
const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
|
|
138
|
+
merge(style, values);
|
|
139
|
+
return toRaw(style);
|
|
140
|
+
});
|
|
141
|
+
return componentDataStyleTable.bulkPut(structuredClone(updates));
|
|
142
|
+
});
|
|
173
143
|
}
|
|
174
144
|
|
|
175
145
|
return {
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import type { ModelId, ModelIdentified } from "@ogw_front/types/identifiers";
|
|
2
2
|
import { MESH_COMPONENT_TYPES } from "@ogw_front/utils/default_styles";
|
|
3
|
-
import type { ModelComponentRecord } from "@
|
|
3
|
+
import type { ModelComponentRecord } from "@ogw_internal/stores/data/model/mesh_components";
|
|
4
4
|
import type { StyleValues } from "@ogw_internal/stores/data_style/types.js";
|
|
5
|
-
import
|
|
6
|
-
import { database } from "@ogw_internal/database/database";
|
|
5
|
+
import { modelComponentsOf } from "@ogw_internal/database/queries";
|
|
7
6
|
import type { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
8
7
|
|
|
9
8
|
type DataStyleState = ReturnType<typeof useDataStyleState>;
|
|
10
9
|
|
|
11
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted Dexie table boundary; see other database table casts in this codebase.
|
|
12
|
-
const model_components_db = database.model_components as unknown as Table<
|
|
13
|
-
ModelComponentRecord,
|
|
14
|
-
string
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
10
|
function groupComponentsByType(
|
|
18
11
|
components: readonly ModelComponentRecord[],
|
|
19
12
|
): Record<string, ModelComponentRecord[]> {
|
|
@@ -113,7 +106,7 @@ function useModelSelection(
|
|
|
113
106
|
|
|
114
107
|
void (async (): Promise<void> => {
|
|
115
108
|
try {
|
|
116
|
-
allComponents.value = await
|
|
109
|
+
allComponents.value = await modelComponentsOf(modelId).toArray();
|
|
117
110
|
} catch {
|
|
118
111
|
allComponents.value = [];
|
|
119
112
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "@ogw_front/composables/orientation_overlay";
|
|
11
11
|
import { consola } from "consola";
|
|
12
12
|
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
13
|
-
import {
|
|
13
|
+
import { sceneStyleDb } from "@ogw_internal/database/database";
|
|
14
14
|
import { toViewerColor } from "@ogw_front/composables/viewer_reset";
|
|
15
15
|
import { useDataStyleState } from "./state";
|
|
16
16
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
@@ -32,7 +32,7 @@ export function useSceneStyle(): {
|
|
|
32
32
|
const viewerStore = useViewerStore();
|
|
33
33
|
const hybridViewerStore = useHybridViewerStore();
|
|
34
34
|
const { sceneStyle } = useDataStyleState();
|
|
35
|
-
const sceneStyleTable =
|
|
35
|
+
const sceneStyleTable = sceneStyleDb();
|
|
36
36
|
|
|
37
37
|
async function saveSceneStyle(values: Partial<Omit<SceneStyle, "id">>): Promise<void> {
|
|
38
38
|
// Values may hold nested reactive proxies (e.g. an exported snapshot), which IndexedDB cannot clone
|