@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
package/app/stores/data_style.ts
CHANGED
|
@@ -5,11 +5,17 @@ import type {
|
|
|
5
5
|
ObjectStyle,
|
|
6
6
|
SceneStyle,
|
|
7
7
|
} from "@ogw_internal/stores/data_style/types";
|
|
8
|
+
import {
|
|
9
|
+
componentDataStyleDb,
|
|
10
|
+
componentTypeDataStyleDb,
|
|
11
|
+
dataStyleDb,
|
|
12
|
+
sceneStyleDb,
|
|
13
|
+
writeTransaction,
|
|
14
|
+
} from "@ogw_internal/database/database.js";
|
|
15
|
+
import { isImage, isMesh, isModel } from "@ogw_front/utils/viewer_object_type";
|
|
8
16
|
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
9
17
|
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
|
|
10
|
-
import type { Table } from "dexie";
|
|
11
18
|
import type { Visibility } from "@geode/opengeodeweb-viewer/schema_types";
|
|
12
|
-
import { database } from "@ogw_internal/database/database.js";
|
|
13
19
|
import { getDefaultStyle } from "@ogw_front/utils/default_styles";
|
|
14
20
|
import { useAttributeTimeStepStyle } from "@ogw_internal/stores/data_style/time_step";
|
|
15
21
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -23,21 +29,11 @@ interface DataStyleSnapshot {
|
|
|
23
29
|
// Projects saved before data_id existed hold their styles with an `id`
|
|
24
30
|
readonly styles: Record<string, LegacyDataId<ObjectStyle> | ObjectStyle>;
|
|
25
31
|
readonly componentStyles: Record<string, ModelComponentStyle>;
|
|
26
|
-
|
|
32
|
+
// Projects saved before the styles by component type (2026-04) have none
|
|
33
|
+
readonly modelComponentTypeStyles?: Record<string, ModelComponentTypeStyle>;
|
|
27
34
|
readonly sceneStyle?: SceneStyle;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
// The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so its exported type is a loose `{}`; cast it to the shape it actually has at runtime rather than widening every call site.
|
|
31
|
-
type DatabaseTables = Record<string, Table<Record<string, unknown>, string> | undefined>;
|
|
32
|
-
|
|
33
|
-
// `noUncheckedIndexedAccess` sees these as possibly undefined even though they're always registered before this store is used; guard defensively rather than asserting.
|
|
34
|
-
function requireTable<TableValue>(table: TableValue | undefined, name: string): TableValue {
|
|
35
|
-
if (table === undefined) {
|
|
36
|
-
throw new Error(`Database table not initialized: ${name}`);
|
|
37
|
-
}
|
|
38
|
-
return table;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
42
38
|
return typeof value === "object" && value !== null;
|
|
43
39
|
}
|
|
@@ -51,63 +47,86 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
51
47
|
const sceneStyleStore = useSceneStyle();
|
|
52
48
|
const attributeTimeStepStyle = useAttributeTimeStepStyle();
|
|
53
49
|
const dataStore = useDataStore();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
typedDatabase.model_component_type_datastyle,
|
|
59
|
-
"model_component_type_datastyle",
|
|
60
|
-
);
|
|
61
|
-
const component_datastyle_db = requireTable(
|
|
62
|
-
typedDatabase.model_component_datastyle,
|
|
63
|
-
"model_component_datastyle",
|
|
64
|
-
);
|
|
50
|
+
const dataStyleTable = dataStyleDb();
|
|
51
|
+
// Keyed by [id_model, type] and [id_model, id_component]
|
|
52
|
+
const componentTypeDataStyleTable = componentTypeDataStyleDb();
|
|
53
|
+
const componentDataStyleTable = componentDataStyleDb();
|
|
65
54
|
|
|
66
55
|
async function addDataStyle(dataId: DataId, geodeObjectType: GeodeObjectType): Promise<void> {
|
|
67
56
|
const defaultStyle = getDefaultStyle(geodeObjectType);
|
|
68
|
-
await
|
|
57
|
+
await dataStyleTable.put(
|
|
69
58
|
structuredClone({ data_id: dataId, ...(isRecord(defaultStyle) ? defaultStyle : {}) }),
|
|
70
59
|
);
|
|
71
60
|
}
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
// Runs the image, the mesh or the model implementation for a data, or `notViewable` for a data the viewer
|
|
63
|
+
// Does not show. An unknown viewer_object_type throws, unless `unknownType` handles it
|
|
64
|
+
async function forViewerType<Result>(
|
|
65
|
+
dataId: DataId,
|
|
66
|
+
handlers: {
|
|
67
|
+
image: (id: DataId) => Promise<Result>;
|
|
68
|
+
mesh: (id: DataId) => Promise<Result>;
|
|
69
|
+
model: (id: DataId) => Promise<Result>;
|
|
70
|
+
notViewable: (id: DataId) => Promise<Result> | Result;
|
|
71
|
+
unknownType?: (id: DataId) => Result;
|
|
72
|
+
},
|
|
73
|
+
): Promise<Result> {
|
|
74
74
|
const item = await dataStore.item(dataId);
|
|
75
|
-
if (!(await dataStore.
|
|
76
|
-
|
|
75
|
+
if (!(await dataStore.fetchIsViewable(dataId))) {
|
|
76
|
+
const result = await handlers.notViewable(dataId);
|
|
77
|
+
return result;
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (viewer_object_type === "image") {
|
|
82
|
-
return imageStyleStore.setImageVisibility(dataId, visibility);
|
|
79
|
+
if (isImage(item)) {
|
|
80
|
+
const result = await handlers.image(dataId);
|
|
81
|
+
return result;
|
|
83
82
|
}
|
|
84
|
-
if (
|
|
85
|
-
|
|
83
|
+
if (isMesh(item)) {
|
|
84
|
+
const result = await handlers.mesh(dataId);
|
|
85
|
+
return result;
|
|
86
86
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (isModel(item)) {
|
|
88
|
+
const result = await handlers.model(dataId);
|
|
89
|
+
return result;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
async function applyDefaultStyle(dataId: DataId): Promise<unknown[]> {
|
|
94
|
-
const item = await dataStore.item(dataId);
|
|
95
|
-
if (!(await dataStore.isItemViewable(item))) {
|
|
96
|
-
throw new Error(`applyDefaultStyle called for non-viewable item: ${dataId}`);
|
|
91
|
+
if (handlers.unknownType) {
|
|
92
|
+
return handlers.unknownType(dataId);
|
|
97
93
|
}
|
|
94
|
+
throw new Error(`Unknown viewer_object_type: ${item.viewer_object_type}`);
|
|
95
|
+
}
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
// A data the viewer does not show only keeps its visibility in its style
|
|
98
|
+
async function setVisibility(dataId: DataId, visibility: Visibility): Promise<unknown> {
|
|
99
|
+
const result = await forViewerType<unknown>(dataId, {
|
|
100
|
+
image: async (id) => {
|
|
101
|
+
const image_result = await imageStyleStore.setImageVisibility(id, visibility);
|
|
102
|
+
return image_result;
|
|
103
|
+
},
|
|
104
|
+
mesh: async (id) => {
|
|
105
|
+
const mesh_result = await meshStyleStore.setMeshVisibility(id, visibility);
|
|
106
|
+
return mesh_result;
|
|
107
|
+
},
|
|
108
|
+
model: async (id) => {
|
|
109
|
+
const model_result = await modelStyleStore.setModelVisibility(id, visibility);
|
|
110
|
+
return model_result;
|
|
111
|
+
},
|
|
112
|
+
notViewable: async (id) => {
|
|
113
|
+
const style_result = await dataStyleState.mutateStyle(id, { visibility });
|
|
114
|
+
return style_result;
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
100
119
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
120
|
+
async function applyDefaultStyle(dataId: DataId): Promise<unknown[]> {
|
|
121
|
+
const result = await forViewerType(dataId, {
|
|
122
|
+
image: imageStyleStore.applyImageStyle,
|
|
123
|
+
mesh: meshStyleStore.applyMeshStyle,
|
|
124
|
+
model: modelStyleStore.applyModelStyle,
|
|
125
|
+
notViewable: () => {
|
|
126
|
+
throw new Error(`applyDefaultStyle called for non-viewable item: ${dataId}`);
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return result;
|
|
111
130
|
}
|
|
112
131
|
|
|
113
132
|
function exportStores(): DataStyleSnapshot {
|
|
@@ -123,56 +142,43 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
123
142
|
async function importStores(snapshot: DataStyleSnapshot): Promise<void> {
|
|
124
143
|
const stylesSnapshot = snapshot.styles;
|
|
125
144
|
const componentStylesSnapshot = snapshot.componentStyles;
|
|
126
|
-
const modelComponentTypeStylesSnapshot = snapshot.modelComponentTypeStyles;
|
|
145
|
+
const modelComponentTypeStylesSnapshot = snapshot.modelComponentTypeStyles ?? {};
|
|
127
146
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const style_promises = Object.entries(stylesSnapshot).map(
|
|
147
|
+
const styles = Object.entries(stylesSnapshot).map(
|
|
131
148
|
// oxlint-disable-next-line prefer-readonly-parameter-types -- same external ObjectStyle limitation as above.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
structuredClone({ ...fromLegacyDataId<ObjectStyle>(style), data_id: dataId }),
|
|
135
|
-
);
|
|
136
|
-
return key;
|
|
137
|
-
},
|
|
149
|
+
([dataId, style]: readonly [string, LegacyDataId<ObjectStyle> | ObjectStyle]) =>
|
|
150
|
+
structuredClone({ ...fromLegacyDataId<ObjectStyle>(style), data_id: dataId }),
|
|
138
151
|
);
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return key;
|
|
143
|
-
},
|
|
152
|
+
const componentStyles = structuredClone(Object.values(componentStylesSnapshot));
|
|
153
|
+
const modelComponentTypeStyles = structuredClone(
|
|
154
|
+
Object.values(modelComponentTypeStylesSnapshot),
|
|
144
155
|
);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
|
|
157
|
+
// The snapshot replaces the stored styles as a whole: a failed import leaves the previous ones
|
|
158
|
+
await writeTransaction(
|
|
159
|
+
[dataStyleTable, componentDataStyleTable, componentTypeDataStyleTable, sceneStyleDb()],
|
|
160
|
+
async () => {
|
|
161
|
+
await dataStyleState.clear();
|
|
162
|
+
await dataStyleTable.bulkPut(styles);
|
|
163
|
+
await componentDataStyleTable.bulkPut(componentStyles);
|
|
164
|
+
await componentTypeDataStyleTable.bulkPut(modelComponentTypeStyles);
|
|
149
165
|
},
|
|
150
166
|
);
|
|
151
|
-
|
|
152
|
-
await Promise.all([
|
|
153
|
-
...style_promises,
|
|
154
|
-
...component_style_promises,
|
|
155
|
-
...model_component_type_style_promises,
|
|
156
|
-
]);
|
|
157
167
|
await dataStyleState.loadFromDatabase();
|
|
158
168
|
await sceneStyleStore.importSceneStyle(snapshot.sceneStyle);
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
async function applyAllStylesFromState(): Promise<void> {
|
|
162
172
|
const ids = Object.keys(dataStyleState.styles.value);
|
|
173
|
+
// Restores what can be shown: a non viewable data or an unknown type is skipped
|
|
163
174
|
const promises = ids.map(async (dataId) => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
} else if (viewerObjectType === "mesh") {
|
|
172
|
-
await meshStyleStore.applyMeshStyle(dataId);
|
|
173
|
-
} else if (viewerObjectType === "model") {
|
|
174
|
-
await modelStyleStore.applyModelStyle(dataId);
|
|
175
|
-
}
|
|
175
|
+
await forViewerType<unknown>(dataId, {
|
|
176
|
+
image: imageStyleStore.applyImageStyle,
|
|
177
|
+
mesh: meshStyleStore.applyMeshStyle,
|
|
178
|
+
model: modelStyleStore.applyModelStyle,
|
|
179
|
+
notViewable: () => undefined,
|
|
180
|
+
unknownType: () => undefined,
|
|
181
|
+
});
|
|
176
182
|
});
|
|
177
183
|
await Promise.all(promises);
|
|
178
184
|
await sceneStyleStore.applySceneStyle();
|
package/app/stores/feedback.ts
CHANGED
|
@@ -22,59 +22,63 @@ interface Feedback {
|
|
|
22
22
|
action?: FeedbackAction;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const useFeedbackStore = defineStore("feedback", {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
25
|
+
export const useFeedbackStore = defineStore("feedback", () => {
|
|
26
|
+
const feedbacks = ref<Feedback[]>([]);
|
|
27
|
+
const server_error = ref(false);
|
|
28
|
+
const feedbacks_timeout_miliseconds = ref(
|
|
29
|
+
DEFAULT_FEEDBACKS_TIMEOUT_SECONDS * MILLISECONDS_IN_SECOND,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
function delete_feedback(feedbackId: string): void {
|
|
33
|
+
feedbacks.value = feedbacks.value.filter((feedback) => feedback.id !== feedbackId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function push_feedback(feedback: Omit<Feedback, "id">): void {
|
|
37
|
+
const feedbackId = uuidv4();
|
|
38
|
+
feedbacks.value.push({ id: feedbackId, ...feedback });
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
delete_feedback(feedbackId);
|
|
41
|
+
}, feedbacks_timeout_miliseconds.value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function add_error(code: number, route: string, name: string, description: string): void {
|
|
45
|
+
push_feedback({
|
|
46
|
+
type: "error",
|
|
47
|
+
code,
|
|
48
|
+
route,
|
|
49
|
+
name: name === "" ? DEFAULT_ERROR_NAME : name,
|
|
50
|
+
// The snackbar only shows the description: never leave it empty
|
|
51
|
+
description: [description, name].find((text) => text !== "") ?? DEFAULT_ERROR_DESCRIPTION,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function add_success(description: string, action?: FeedbackAction): void {
|
|
56
|
+
push_feedback({ type: "success", description, ...(action !== undefined && { action }) });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function add_warning(description: string, action?: FeedbackAction): void {
|
|
60
|
+
push_feedback({ type: "warning", description, ...(action !== undefined && { action }) });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function set_server_error(value: boolean): void {
|
|
64
|
+
server_error.value = value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function delete_server_error(): void {
|
|
68
|
+
set_server_error(false);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
feedbacks,
|
|
73
|
+
server_error,
|
|
74
|
+
feedbacks_timeout_miliseconds,
|
|
75
|
+
add_error,
|
|
76
|
+
add_success,
|
|
77
|
+
add_warning,
|
|
78
|
+
delete_feedback,
|
|
79
|
+
set_server_error,
|
|
80
|
+
delete_server_error,
|
|
81
|
+
};
|
|
78
82
|
});
|
|
79
83
|
|
|
80
84
|
export type { FeedbackAction };
|
package/app/stores/infra.ts
CHANGED
|
@@ -1,126 +1,86 @@
|
|
|
1
1
|
import { Status } from "@ogw_front/utils/status";
|
|
2
|
-
import { appMode } from "@ogw_shared/app_mode";
|
|
3
|
-
import { setAppBaseUrl } from "@ogw_shared/scripts";
|
|
4
|
-
import { useCloudStore } from "@ogw_front/stores/cloud";
|
|
5
2
|
|
|
6
3
|
const LOCALHOST = "localhost";
|
|
7
4
|
const IPV4_LOOPBACK = "127.0.0.1";
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
6
|
+
export const useInfraStore = defineStore(
|
|
7
|
+
"infra",
|
|
8
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
9
|
+
() => {
|
|
10
|
+
const app_mode = ref(useRuntimeConfig().public.MODE);
|
|
11
|
+
// Set by the backend lifecycle (utils/backend_lifecycle.ts), which creates the backend
|
|
12
|
+
const status = ref(Status.NOT_CREATED);
|
|
13
|
+
const microservices = ref<Microservice[]>([]);
|
|
14
|
+
const domain_name = ref(globalThis.location.hostname);
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await appStore.createProjectFolder();
|
|
27
|
-
if (currentMode === appMode.DESKTOP) {
|
|
28
|
-
globalThis.electronAPI.project_folder_path({
|
|
29
|
-
projectFolderPath: appStore.projectFolderPath,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
await setAppBaseUrl(appStore.base_url);
|
|
33
|
-
const microservices_with_launch = microservices.filter((store: Microservice) => store.launch);
|
|
34
|
-
const launch_promises = microservices_with_launch.map(async (store: Microservice) => {
|
|
35
|
-
const result = await store.launch?.({
|
|
36
|
-
projectFolderPath: appStore.projectFolderPath,
|
|
37
|
-
});
|
|
38
|
-
return result;
|
|
39
|
-
});
|
|
40
|
-
const { registerRunningExtensions } = await import("@ogw_front/utils/extension");
|
|
41
|
-
launch_promises.push(registerRunningExtensions());
|
|
42
|
-
await Promise.all(launch_promises);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const useInfraStore = defineStore("infra", {
|
|
46
|
-
state: () => ({
|
|
47
|
-
app_mode: useRuntimeConfig().public.MODE,
|
|
48
|
-
status: Status.NOT_CREATED,
|
|
49
|
-
microservices: [] as Microservice[],
|
|
50
|
-
domain_name: globalThis.location.hostname,
|
|
51
|
-
}),
|
|
52
|
-
getters: {
|
|
53
|
-
microservices_connected(): boolean {
|
|
54
|
-
return this.microservices.every((store: Microservice) => store.status === Status.CONNECTED);
|
|
55
|
-
},
|
|
56
|
-
microservices_busy(): boolean {
|
|
57
|
-
return this.microservices.some((store: Microservice) => store.is_busy === true);
|
|
58
|
-
},
|
|
16
|
+
const microservices_connected = computed(() =>
|
|
17
|
+
microservices.value.every((store: Microservice) => store.status === Status.CONNECTED),
|
|
18
|
+
);
|
|
19
|
+
const microservices_busy = computed(() =>
|
|
20
|
+
microservices.value.some((store: Microservice) => store.is_busy === true),
|
|
21
|
+
);
|
|
59
22
|
// The local Flask microservices (Werkzeug) only listen on IPv4. With "localhost", browsers try ::1 first.
|
|
60
23
|
// Windows is slow to refuse it: every request to them would pay that delay.
|
|
61
24
|
// The page host stays in domain_name: the app store must remain same-origin (its API has no CORS).
|
|
62
|
-
microservice_domain_name()
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
actions: {
|
|
67
|
-
register_microservice(store: Microservice) {
|
|
68
|
-
const store_name = store.$id;
|
|
25
|
+
const microservice_domain_name = computed(() =>
|
|
26
|
+
domain_name.value === LOCALHOST ? IPV4_LOOPBACK : domain_name.value,
|
|
27
|
+
);
|
|
69
28
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
) {
|
|
73
|
-
|
|
29
|
+
function register_microservice(store: Microservice): void {
|
|
30
|
+
const store_name = store.$id;
|
|
31
|
+
if (!microservices.value.some((microservice) => microservice.$id === store_name)) {
|
|
32
|
+
microservices.value.push(store);
|
|
74
33
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function unregister_microservice(microserviceId: string): void {
|
|
37
|
+
microservices.value = microservices.value.filter(
|
|
38
|
+
(microservice) => microservice.$id !== microserviceId,
|
|
79
39
|
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
await navigator.locks.request("infra.create_backend", async () => {
|
|
86
|
-
if (this.status === Status.CREATED) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
this.status = Status.CREATING;
|
|
90
|
-
if (this.app_mode === appMode.CLOUD) {
|
|
91
|
-
const cloudStore = useCloudStore();
|
|
92
|
-
try {
|
|
93
|
-
await cloudStore.start(authToken);
|
|
94
|
-
} catch (error) {
|
|
95
|
-
// Back to the "Load the app" button so the user is not stuck on the loading screen.
|
|
96
|
-
this.status = Status.NOT_CREATED;
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
await launchLocalServices(this.app_mode, this.microservices);
|
|
101
|
-
}
|
|
102
|
-
this.status = Status.CREATED;
|
|
103
|
-
return this.create_connection();
|
|
104
|
-
});
|
|
105
|
-
return undefined;
|
|
106
|
-
},
|
|
107
|
-
async create_connection() {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function create_connection(): Promise<void> {
|
|
108
43
|
await Promise.all(
|
|
109
|
-
|
|
44
|
+
microservices.value.map(async (store: Microservice) => {
|
|
110
45
|
await store.connect();
|
|
111
46
|
}),
|
|
112
47
|
);
|
|
113
|
-
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function set_status(value: string): void {
|
|
51
|
+
status.value = value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function set_domain_name(value: string): void {
|
|
55
|
+
domain_name.value = value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
app_mode,
|
|
60
|
+
status,
|
|
61
|
+
microservices,
|
|
62
|
+
domain_name,
|
|
63
|
+
microservices_connected,
|
|
64
|
+
microservices_busy,
|
|
65
|
+
microservice_domain_name,
|
|
66
|
+
register_microservice,
|
|
67
|
+
unregister_microservice,
|
|
68
|
+
set_status,
|
|
69
|
+
set_domain_name,
|
|
70
|
+
create_connection,
|
|
71
|
+
};
|
|
114
72
|
},
|
|
115
|
-
|
|
116
|
-
|
|
73
|
+
{
|
|
74
|
+
share: {
|
|
75
|
+
omit: ["microservices"],
|
|
76
|
+
},
|
|
117
77
|
},
|
|
118
|
-
|
|
78
|
+
);
|
|
119
79
|
|
|
120
80
|
export interface Microservice {
|
|
121
81
|
$id: string;
|
|
122
82
|
status?: string;
|
|
123
83
|
is_busy?: boolean;
|
|
124
84
|
launch?: (params: { projectFolderPath: string }) => Promise<unknown>;
|
|
125
|
-
connect: () => Promise<void>;
|
|
85
|
+
connect: () => void | Promise<void>;
|
|
126
86
|
}
|
package/app/stores/treeview.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { consola } from "consola";
|
|
2
|
-
|
|
3
|
-
// Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
|
|
4
|
-
// oxlint-disable eslint/sort-imports, eslint/max-lines
|
|
5
|
-
import { defineStore } from "pinia";
|
|
6
|
-
|
|
7
1
|
import type { DataId, GeodeId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
8
2
|
import type {
|
|
9
3
|
GeodeIdentified,
|
|
@@ -14,25 +8,21 @@ import type {
|
|
|
14
8
|
GeodeObjectType,
|
|
15
9
|
ViewerObjectType,
|
|
16
10
|
} from "@geode/opengeodeweb-microservice/data_types";
|
|
11
|
+
import type {
|
|
12
|
+
OpenedView,
|
|
13
|
+
TreeviewConfigRecord,
|
|
14
|
+
} from "@ogw_internal/database/tables/treeview_config";
|
|
17
15
|
import type { TreeGroup, TreeNode } from "@ogw_front/types/tree";
|
|
18
16
|
import { ref, watch } from "vue";
|
|
19
|
-
import {
|
|
17
|
+
import { consola } from "consola";
|
|
18
|
+
// Not auto-fixable (eslint's sort-imports core rule has no autofixer) and this file's import order doesn't match its syntax-kind-then-alphabetical requirement - left as-is rather than manually reordered across the codebase for a purely cosmetic rule.
|
|
19
|
+
// oxlint-disable eslint/sort-imports, eslint/max-lines
|
|
20
|
+
import { defineStore } from "pinia";
|
|
20
21
|
import { nextModelTreeColor } from "@ogw_front/utils/treeview";
|
|
22
|
+
import { treeviewConfigDb } from "@ogw_internal/database/database";
|
|
21
23
|
|
|
22
24
|
const PANEL_WIDTH = 300;
|
|
23
25
|
|
|
24
|
-
interface OpenedView extends Partial<GeodeObjectTyped> {
|
|
25
|
-
type: "object" | "component";
|
|
26
|
-
id: string;
|
|
27
|
-
title: string;
|
|
28
|
-
scrollTop: number;
|
|
29
|
-
opened: string[];
|
|
30
|
-
// Ties a model tree to its row in the objects tree
|
|
31
|
-
color?: string;
|
|
32
|
-
// A model tree reduced to its button in the activity bar: still open, with its state kept
|
|
33
|
-
collapsed?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
26
|
interface TreeviewChild extends TreeNode, GeodeIdentified, GeodeObjectTyped, ViewerObjectTyped {
|
|
37
27
|
// Still being loaded in the viewer: shown with a spinner and not interactive yet
|
|
38
28
|
loading?: boolean;
|
|
@@ -45,15 +35,6 @@ interface PendingImport extends TreeNode, GeodeObjectTyped {
|
|
|
45
35
|
|
|
46
36
|
type TreeviewGroup = TreeGroup<TreeviewChild>;
|
|
47
37
|
|
|
48
|
-
interface TreeviewConfigRecord {
|
|
49
|
-
id: string;
|
|
50
|
-
opened_views: OpenedView[];
|
|
51
|
-
panelWidth: number;
|
|
52
|
-
additionalPanelWidth: number;
|
|
53
|
-
selectionIds: string[];
|
|
54
|
-
rowHeights: number[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
38
|
interface TreeviewSnapshot {
|
|
58
39
|
opened_views?: OpenedView[];
|
|
59
40
|
panelWidth?: number;
|
|
@@ -119,11 +100,11 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
119
100
|
// Model hovered in the objects tree or on its model tree header: not saved
|
|
120
101
|
const hoveredModelId = ref<string | undefined>(undefined);
|
|
121
102
|
|
|
122
|
-
const
|
|
103
|
+
const treeviewConfigTable = treeviewConfigDb();
|
|
123
104
|
|
|
124
105
|
async function loadConfig(): Promise<void> {
|
|
125
106
|
try {
|
|
126
|
-
const config = await
|
|
107
|
+
const config = await treeviewConfigTable.get("main");
|
|
127
108
|
if (config?.opened_views) {
|
|
128
109
|
opened_views.value = withModelTreeColors(config.opened_views);
|
|
129
110
|
}
|
|
@@ -158,7 +139,7 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
158
139
|
|
|
159
140
|
// Best-effort persistence: a failure is logged, not thrown.
|
|
160
141
|
try {
|
|
161
|
-
await
|
|
142
|
+
await treeviewConfigTable.put({
|
|
162
143
|
id: "main",
|
|
163
144
|
opened_views: clean_opened_views,
|
|
164
145
|
panelWidth: panelWidth.value,
|