@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
|
@@ -2,13 +2,17 @@ import type {
|
|
|
2
2
|
ModelComponentStyle,
|
|
3
3
|
ModelComponentTypeStyle,
|
|
4
4
|
ObjectStyle,
|
|
5
|
-
SceneStyle,
|
|
6
5
|
StyleValues,
|
|
7
6
|
} from "./types";
|
|
8
7
|
import { type SharedState, getSharedState } from "./state_shared";
|
|
8
|
+
import {
|
|
9
|
+
componentDataStyleDb,
|
|
10
|
+
componentTypeDataStyleDb,
|
|
11
|
+
dataStyleDb,
|
|
12
|
+
sceneStyleDb,
|
|
13
|
+
} from "@ogw_internal/database/database";
|
|
9
14
|
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
10
15
|
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
11
|
-
import { getTable } from "@ogw_internal/database/database";
|
|
12
16
|
import merge from "lodash/merge";
|
|
13
17
|
|
|
14
18
|
interface DataStyleStateApi extends SharedState {
|
|
@@ -23,11 +27,9 @@ interface DataStyleStateApi extends SharedState {
|
|
|
23
27
|
|
|
24
28
|
// oxlint-disable-next-line max-lines-per-function
|
|
25
29
|
export function useDataStyleState(): DataStyleStateApi {
|
|
26
|
-
const dataStyleTable =
|
|
27
|
-
const modelComponentDataStyleTable =
|
|
28
|
-
const modelComponentTypeDataStyleTable =
|
|
29
|
-
"model_component_type_datastyle",
|
|
30
|
-
);
|
|
30
|
+
const dataStyleTable = dataStyleDb();
|
|
31
|
+
const modelComponentDataStyleTable = componentDataStyleDb();
|
|
32
|
+
const modelComponentTypeDataStyleTable = componentTypeDataStyleDb();
|
|
31
33
|
|
|
32
34
|
const state = getSharedState();
|
|
33
35
|
const { styles, modelComponentTypeStyles, componentStyles } = state;
|
|
@@ -86,7 +88,7 @@ export function useDataStyleState(): DataStyleStateApi {
|
|
|
86
88
|
dataStyleTable.clear(),
|
|
87
89
|
modelComponentDataStyleTable.clear(),
|
|
88
90
|
modelComponentTypeDataStyleTable.clear(),
|
|
89
|
-
|
|
91
|
+
sceneStyleDb().clear(),
|
|
90
92
|
]);
|
|
91
93
|
modelComponentTypeStyles.value = {};
|
|
92
94
|
componentStyles.value = {};
|
|
@@ -5,10 +5,15 @@ import type {
|
|
|
5
5
|
SceneStyle,
|
|
6
6
|
StyleValues,
|
|
7
7
|
} from "./types";
|
|
8
|
+
import {
|
|
9
|
+
componentDataStyleDb,
|
|
10
|
+
componentTypeDataStyleDb,
|
|
11
|
+
dataStyleDb,
|
|
12
|
+
sceneStyleDb,
|
|
13
|
+
} from "@ogw_internal/database/database";
|
|
8
14
|
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
9
15
|
import type { Observable as RxObservable } from "rxjs";
|
|
10
16
|
import { getDefaultSceneStyle } from "@ogw_front/utils/default_styles";
|
|
11
|
-
import { getTable } from "@ogw_internal/database/database";
|
|
12
17
|
import { liveQuery } from "dexie";
|
|
13
18
|
import merge from "lodash/merge";
|
|
14
19
|
import { useObservable } from "@vueuse/rxjs";
|
|
@@ -52,11 +57,9 @@ function getSharedState(): SharedState {
|
|
|
52
57
|
return sharedState;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
const dataStyleTable =
|
|
56
|
-
const modelComponentDataStyleTable =
|
|
57
|
-
const modelComponentTypeDataStyleTable =
|
|
58
|
-
"model_component_type_datastyle",
|
|
59
|
-
);
|
|
60
|
+
const dataStyleTable = dataStyleDb();
|
|
61
|
+
const modelComponentDataStyleTable = componentDataStyleDb();
|
|
62
|
+
const modelComponentTypeDataStyleTable = componentTypeDataStyleDb();
|
|
60
63
|
|
|
61
64
|
// Dexie's `liveQuery` returns Dexie's own `Observable` type, structurally distinct
|
|
62
65
|
// From rxjs's `Observable` that `useObservable` (from @vueuse/rxjs) expects, even
|
|
@@ -78,7 +81,7 @@ function getSharedState(): SharedState {
|
|
|
78
81
|
|
|
79
82
|
const modelComponentTypeStyles = ref<Record<string, ModelComponentTypeStyle>>({});
|
|
80
83
|
const componentStyles = ref<Record<string, ModelComponentStyle>>({});
|
|
81
|
-
const sceneStyleTable =
|
|
84
|
+
const sceneStyleTable = sceneStyleDb();
|
|
82
85
|
const sceneStyle = ref<SceneStyle>(getDefaultSceneStyle());
|
|
83
86
|
|
|
84
87
|
async function loadFromDatabase(): Promise<void> {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
1
|
import { HOVER_DEBOUNCE_MS, HOVER_TIMEOUT_MS } from "./constants";
|
|
3
2
|
import type { HoverComponentInfo, HoverData } from "./vtk_types";
|
|
4
3
|
import viewer_schemas, {
|
|
@@ -6,14 +5,15 @@ import viewer_schemas, {
|
|
|
6
5
|
type ViewerHighlightResponse,
|
|
7
6
|
} from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
8
7
|
import type { GeodeId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
9
|
-
import type {
|
|
10
|
-
import {
|
|
8
|
+
import type { ModelId } from "@ogw_front/types/identifiers";
|
|
9
|
+
import { dataDb } from "@ogw_internal/database/database.js";
|
|
10
|
+
import { modelComponent } from "@ogw_internal/database/queries.js";
|
|
11
11
|
import { useHybridViewerCore } from "./core";
|
|
12
12
|
import { useHybridViewerScene } from "./scene";
|
|
13
13
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
14
14
|
|
|
15
15
|
async function lookupModelName(modelId: ModelId): Promise<string | undefined> {
|
|
16
|
-
const modelRecord =
|
|
16
|
+
const modelRecord = await dataDb().get(modelId);
|
|
17
17
|
return modelRecord?.name;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,22 +21,17 @@ async function lookupComponentInfo(
|
|
|
21
21
|
modelId: ModelId,
|
|
22
22
|
geodeId: GeodeId | undefined,
|
|
23
23
|
): Promise<HoverComponentInfo | undefined> {
|
|
24
|
-
|
|
25
|
-
if (geodeId === undefined || !modelComponentsTable) {
|
|
24
|
+
if (geodeId === undefined) {
|
|
26
25
|
return undefined;
|
|
27
26
|
}
|
|
28
|
-
const
|
|
29
|
-
const query = components.equals([modelId, geodeId] as IndexableType);
|
|
30
|
-
const component = (await query.first()) as
|
|
31
|
-
| (Partial<GeodeIdentified> & { name?: string; type?: string })
|
|
32
|
-
| undefined;
|
|
27
|
+
const component = await modelComponent(modelId, geodeId).first();
|
|
33
28
|
if (!component) {
|
|
34
29
|
return undefined;
|
|
35
30
|
}
|
|
36
31
|
return {
|
|
37
|
-
name: component.name
|
|
38
|
-
id: component.geode_id
|
|
39
|
-
type: component.type
|
|
32
|
+
name: component.name,
|
|
33
|
+
id: component.geode_id,
|
|
34
|
+
type: component.type,
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
|
|
@@ -51,7 +51,7 @@ function followZScaling(camera: vtkCamera, ratio: number): void {
|
|
|
51
51
|
|
|
52
52
|
async function fetchBinaryLightViewable(dataId: DataId): Promise<string | undefined> {
|
|
53
53
|
const dataStore = useDataStore();
|
|
54
|
-
const isViewable = await dataStore.
|
|
54
|
+
const isViewable = await dataStore.fetchIsViewable(dataId);
|
|
55
55
|
if (!isViewable) {
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
import type {
|
|
3
|
+
JsonRpcSchema,
|
|
4
|
+
MicroserviceVersionSchema,
|
|
5
|
+
ParamsOf,
|
|
6
|
+
RequestHandlers,
|
|
7
|
+
ResponseOf,
|
|
8
|
+
} from "@ogw_shared/utils/types.js";
|
|
9
|
+
import { type Microservice, api_fetch } from "@ogw_internal/utils/api_fetch";
|
|
10
|
+
import { upload_file } from "@ogw_internal/utils/upload_file.js";
|
|
11
|
+
|
|
12
|
+
// The pieces every microservice store is made of: a busy counter, an HTTP transport,
|
|
13
|
+
// A ping loop and a version. Each store composes the ones it needs.
|
|
14
|
+
|
|
15
|
+
const MILLISECONDS_IN_SECOND = 1000;
|
|
16
|
+
const DEFAULT_PING_INTERVAL_SECONDS = 10;
|
|
17
|
+
const DEFAULT_VERSION = "0.0.0";
|
|
18
|
+
|
|
19
|
+
interface RequestCounter {
|
|
20
|
+
request_counter: Ref<number>;
|
|
21
|
+
is_busy: ComputedRef<boolean>;
|
|
22
|
+
start_request: () => void;
|
|
23
|
+
stop_request: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type HttpRequestCallbacks<Response> = RequestHandlers<Response> & {
|
|
27
|
+
readonly skip_feedback_error?: boolean;
|
|
28
|
+
readonly timeout?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface HttpRequestArgs<Schema extends JsonRpcSchema> {
|
|
32
|
+
schema: Schema;
|
|
33
|
+
params?: ParamsOf<Schema>;
|
|
34
|
+
headers?: Record<string, string>;
|
|
35
|
+
log_success?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type HttpRequest = <Schema extends JsonRpcSchema>(
|
|
39
|
+
args: HttpRequestArgs<Schema>,
|
|
40
|
+
callbacks?: HttpRequestCallbacks<ResponseOf<Schema>>,
|
|
41
|
+
) => Promise<ResponseOf<Schema>>;
|
|
42
|
+
|
|
43
|
+
interface HttpUploadArgs {
|
|
44
|
+
schema: JsonRpcSchema;
|
|
45
|
+
file: File;
|
|
46
|
+
params?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// What a transport needs of the counter: it only reports when a request starts and stops
|
|
50
|
+
type RequestTracker = Pick<RequestCounter, "start_request" | "stop_request">;
|
|
51
|
+
|
|
52
|
+
interface HttpTransport {
|
|
53
|
+
request: HttpRequest;
|
|
54
|
+
upload: (args: HttpUploadArgs, callbacks?: RequestHandlers) => Promise<unknown>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type VersionRequest = (
|
|
58
|
+
args: { schema: MicroserviceVersionSchema },
|
|
59
|
+
callbacks: RequestHandlers<{ microservice_version: string }>,
|
|
60
|
+
) => Promise<{ microservice_version: string }>;
|
|
61
|
+
|
|
62
|
+
// HTTP schemas ("front"/"back"/"cloud") always carry `methods`; the shared JsonRpcSchema
|
|
63
|
+
// Type keeps it optional because websocket ("viewer") schemas have `rpc` instead.
|
|
64
|
+
function asHttpSchema(schema: JsonRpcSchema): JsonRpcSchema & { methods: string[] } {
|
|
65
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- see comment above.
|
|
66
|
+
return schema as JsonRpcSchema & { methods: string[] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function useRequestCounter(): RequestCounter {
|
|
70
|
+
const request_counter = ref(0);
|
|
71
|
+
const is_busy = computed(() => request_counter.value > 0);
|
|
72
|
+
|
|
73
|
+
function start_request(): void {
|
|
74
|
+
request_counter.value += 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function stop_request(): void {
|
|
78
|
+
request_counter.value -= 1;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { request_counter, is_busy, start_request, stop_request };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// `base_url` is read on each request: pass the store's ref, not a copy of its value
|
|
85
|
+
function useHttpTransport(
|
|
86
|
+
id: string,
|
|
87
|
+
base_url: MaybeRefOrGetter<string>,
|
|
88
|
+
{ start_request, stop_request }: RequestTracker,
|
|
89
|
+
): HttpTransport {
|
|
90
|
+
function microservice(): Microservice {
|
|
91
|
+
return { $id: id, base_url: toValue(base_url), start_request, stop_request };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function request<Schema extends JsonRpcSchema>(
|
|
95
|
+
{ schema, params, headers = {}, log_success }: HttpRequestArgs<Schema>,
|
|
96
|
+
callbacks: HttpRequestCallbacks<ResponseOf<Schema>> = {},
|
|
97
|
+
): Promise<ResponseOf<Schema>> {
|
|
98
|
+
const { response_function } = callbacks;
|
|
99
|
+
const result = await api_fetch(
|
|
100
|
+
microservice(),
|
|
101
|
+
{
|
|
102
|
+
schema: asHttpSchema(schema),
|
|
103
|
+
params: params ?? {},
|
|
104
|
+
headers,
|
|
105
|
+
...(log_success !== undefined && { log_success }),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
...callbacks,
|
|
109
|
+
response_function: async (response: unknown) => {
|
|
110
|
+
if (response_function) {
|
|
111
|
+
// The microservices validate their responses against the schema `response` the
|
|
112
|
+
// Typed schemas are generated from: this is the trusted API boundary.
|
|
113
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
114
|
+
await response_function(response as ResponseOf<Schema>);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- same trusted boundary as above.
|
|
120
|
+
return result as ResponseOf<Schema>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function upload(
|
|
124
|
+
{ schema, file, params }: HttpUploadArgs,
|
|
125
|
+
callbacks: RequestHandlers = {},
|
|
126
|
+
): Promise<unknown> {
|
|
127
|
+
const result = await upload_file(
|
|
128
|
+
microservice(),
|
|
129
|
+
{ schema: asHttpSchema(schema), file, params },
|
|
130
|
+
callbacks,
|
|
131
|
+
);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return { request, upload };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Calling start again restarts the loop: there is never more than one timer
|
|
139
|
+
function usePing(
|
|
140
|
+
ping: () => Promise<unknown>,
|
|
141
|
+
interval_milliseconds = DEFAULT_PING_INTERVAL_SECONDS * MILLISECONDS_IN_SECOND,
|
|
142
|
+
): { start_ping: () => void; stop_ping: () => void } {
|
|
143
|
+
let timer: ReturnType<typeof setInterval> | undefined = undefined;
|
|
144
|
+
|
|
145
|
+
function stop_ping(): void {
|
|
146
|
+
if (timer !== undefined) {
|
|
147
|
+
clearInterval(timer);
|
|
148
|
+
timer = undefined;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function start_ping(): void {
|
|
153
|
+
stop_ping();
|
|
154
|
+
void ping();
|
|
155
|
+
timer = setInterval(() => {
|
|
156
|
+
void ping();
|
|
157
|
+
}, interval_milliseconds);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return { start_ping, stop_ping };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function useMicroserviceVersion(request: VersionRequest): {
|
|
164
|
+
version: Ref<string>;
|
|
165
|
+
get_version: (
|
|
166
|
+
schema: MicroserviceVersionSchema | undefined,
|
|
167
|
+
) => Promise<{ microservice_version: string } | undefined>;
|
|
168
|
+
} {
|
|
169
|
+
const version = ref(DEFAULT_VERSION);
|
|
170
|
+
|
|
171
|
+
async function get_version(
|
|
172
|
+
schema: MicroserviceVersionSchema | undefined,
|
|
173
|
+
): Promise<{ microservice_version: string } | undefined> {
|
|
174
|
+
if (!schema) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const result = await request(
|
|
178
|
+
{ schema },
|
|
179
|
+
{
|
|
180
|
+
response_function: ({ microservice_version }) => {
|
|
181
|
+
version.value = microservice_version;
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return { version, get_version };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { useHttpTransport, useMicroserviceVersion, usePing, useRequestCounter };
|
|
192
|
+
export type { HttpRequest, HttpRequestCallbacks, HttpTransport, RequestCounter, RequestTracker };
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
moveMouseOutOfTheWay,
|
|
6
6
|
} from "#browser_helpers/viewer_interaction";
|
|
7
7
|
import { getMenuContainer, resetMenuScroll } from "./attribute_menu";
|
|
8
|
+
import type { ViewerObjectType } from "@geode/opengeodeweb-microservice/data_types";
|
|
8
9
|
import { setFeatureColorMap } from "./attribute_colors";
|
|
9
10
|
import { waitForActionSettled } from "#browser_helpers/wait_for_action_settled";
|
|
10
11
|
|
|
@@ -109,7 +110,7 @@ interface FeatureAttributeOptions {
|
|
|
109
110
|
|
|
110
111
|
async function setFeatureAttribute(
|
|
111
112
|
window: Page,
|
|
112
|
-
viewerObjectType:
|
|
113
|
+
viewerObjectType: ViewerObjectType,
|
|
113
114
|
feature: string,
|
|
114
115
|
attributeType: string,
|
|
115
116
|
attributeName: string,
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { type FormattedComponent, type ModelComponentRecord, useDataMesh } from "./mesh.js";
|
|
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";
|
|
6
|
-
import type { Ref } from "vue";
|
|
7
|
-
import { getTable } from "@ogw_internal/database/database.js";
|
|
8
|
-
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
9
|
-
import { pluralize } from "@ogw_front/utils/string";
|
|
10
|
-
import { useObservable } from "@vueuse/rxjs";
|
|
11
|
-
|
|
12
|
-
interface CollectionComponent extends FormattedComponent {
|
|
13
|
-
readonly children: readonly FormattedComponent[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type CollectionComponentGroup = ReadonlyTreeGroup<CollectionComponent>;
|
|
17
|
-
|
|
18
|
-
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
19
|
-
export function useDataCollections(): {
|
|
20
|
-
hasCollectionComponents: typeof hasCollectionComponents;
|
|
21
|
-
getAllCollectionComponents: typeof getAllCollectionComponents;
|
|
22
|
-
fetchAllCollectionComponents: typeof fetchAllCollectionComponents;
|
|
23
|
-
formatedCollectionComponents: typeof formatedCollectionComponents;
|
|
24
|
-
refFormatedCollectionComponents: typeof refFormatedCollectionComponents;
|
|
25
|
-
} {
|
|
26
|
-
const model_components_db = getTable<ModelComponentRecord>("model_components");
|
|
27
|
-
const model_components_relation_db = getTable<ModelComponentRelationRecord>(
|
|
28
|
-
"model_components_relation",
|
|
29
|
-
);
|
|
30
|
-
const { getAllMeshComponents } = useDataMesh();
|
|
31
|
-
|
|
32
|
-
async function hasCollectionComponents(modelId: ModelId): Promise<boolean> {
|
|
33
|
-
const count = await model_components_db
|
|
34
|
-
.where("data_id")
|
|
35
|
-
.equals(modelId)
|
|
36
|
-
.and((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
37
|
-
.count();
|
|
38
|
-
return count > 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function getAllCollectionComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
42
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
43
|
-
return items
|
|
44
|
-
.filter((component: ModelComponentRecord) => !MESH_COMPONENT_TYPES.includes(component.type))
|
|
45
|
-
.map((component: ModelComponentRecord) => ({
|
|
46
|
-
id: component.geode_id,
|
|
47
|
-
geode_id: component.geode_id,
|
|
48
|
-
title: component.name,
|
|
49
|
-
category: component.type,
|
|
50
|
-
viewer_id: Number(component.viewer_id),
|
|
51
|
-
is_active: component.is_active,
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function fetchAllCollectionComponents(
|
|
56
|
-
modelId: ModelId,
|
|
57
|
-
): Promise<Record<string, CollectionComponent[]>> {
|
|
58
|
-
const components = await getAllCollectionComponents(modelId);
|
|
59
|
-
const relations = await model_components_relation_db.where("data_id").equals(modelId).toArray();
|
|
60
|
-
const allMeshComponents = await getAllMeshComponents(modelId);
|
|
61
|
-
const meshComponentsById: Record<string, FormattedComponent> = {};
|
|
62
|
-
for (const meshComponent of allMeshComponents) {
|
|
63
|
-
meshComponentsById[meshComponent.id] = meshComponent;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const byType: Record<string, CollectionComponent[]> = {};
|
|
67
|
-
for (const component of components) {
|
|
68
|
-
byType[component.category] ??= [];
|
|
69
|
-
const itemRelations = relations.filter(
|
|
70
|
-
(relation: ModelComponentRelationRecord) =>
|
|
71
|
-
relation.parent === component.id && relation.type === "collection",
|
|
72
|
-
);
|
|
73
|
-
const children = itemRelations
|
|
74
|
-
.map((relation: ModelComponentRelationRecord) => meshComponentsById[relation.child])
|
|
75
|
-
.filter((child): child is FormattedComponent => Boolean(child));
|
|
76
|
-
byType[component.category]?.push({
|
|
77
|
-
...component,
|
|
78
|
-
children,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return byType;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async function formatedCollectionComponents(
|
|
85
|
-
modelId: ModelId,
|
|
86
|
-
): Promise<CollectionComponentGroup[]> {
|
|
87
|
-
const byType = await fetchAllCollectionComponents(modelId);
|
|
88
|
-
const collectionTypes = Object.keys(byType);
|
|
89
|
-
|
|
90
|
-
return collectionTypes
|
|
91
|
-
.filter((type) => (byType[type]?.length ?? 0) > 0)
|
|
92
|
-
.map((type) => ({
|
|
93
|
-
id: type,
|
|
94
|
-
title: pluralize(type),
|
|
95
|
-
children: byType[type] ?? [],
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function refFormatedCollectionComponents(
|
|
100
|
-
modelId: ModelId,
|
|
101
|
-
): Ref<CollectionComponentGroup[] | undefined> {
|
|
102
|
-
return useObservable(
|
|
103
|
-
liveObservable(async () => {
|
|
104
|
-
const groups = await formatedCollectionComponents(modelId);
|
|
105
|
-
return groups;
|
|
106
|
-
}),
|
|
107
|
-
{
|
|
108
|
-
initialValue: undefined,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
hasCollectionComponents,
|
|
115
|
-
getAllCollectionComponents,
|
|
116
|
-
fetchAllCollectionComponents,
|
|
117
|
-
formatedCollectionComponents,
|
|
118
|
-
refFormatedCollectionComponents,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export type { CollectionComponent, CollectionComponentGroup };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type { DataIdentified, GeodeIdentified, ModelId } from "@ogw_front/types/identifiers";
|
|
2
|
-
import type { ReadonlyTreeGroup } from "@ogw_front/types/tree";
|
|
3
|
-
import type { Table } from "dexie";
|
|
4
|
-
import type { ViewerId } from "@geode/opengeodeweb-viewer/schema_types";
|
|
5
|
-
import { database } from "@ogw_internal/database/database.js";
|
|
6
|
-
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
7
|
-
import { useObservable } from "@vueuse/rxjs";
|
|
8
|
-
|
|
9
|
-
interface ModelComponentRecord extends DataIdentified, GeodeIdentified {
|
|
10
|
-
type: string;
|
|
11
|
-
viewer_id: string | number;
|
|
12
|
-
name: string;
|
|
13
|
-
is_active: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FormattedComponent extends Readonly<GeodeIdentified> {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly title: string;
|
|
19
|
-
readonly category: string;
|
|
20
|
-
readonly viewer_id: ViewerId;
|
|
21
|
-
readonly is_active: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type FormattedComponentGroup = ReadonlyTreeGroup<FormattedComponent>;
|
|
25
|
-
|
|
26
|
-
function toFormattedComponent(meshComponent: ModelComponentRecord): FormattedComponent {
|
|
27
|
-
return {
|
|
28
|
-
id: meshComponent.geode_id,
|
|
29
|
-
geode_id: meshComponent.geode_id,
|
|
30
|
-
title: meshComponent.name,
|
|
31
|
-
category: meshComponent.type,
|
|
32
|
-
viewer_id: Math.trunc(Number(meshComponent.viewer_id)),
|
|
33
|
-
is_active: meshComponent.is_active,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// oxlint-disable-next-line eslint/max-lines-per-function
|
|
38
|
-
function useDataMesh(): {
|
|
39
|
-
formatedMeshComponents: typeof formatedMeshComponents;
|
|
40
|
-
refFormatedMeshComponents: typeof refFormatedMeshComponents;
|
|
41
|
-
getMeshComponentsByType: typeof getMeshComponentsByType;
|
|
42
|
-
getAllMeshComponents: typeof getAllMeshComponents;
|
|
43
|
-
fetchAllMeshComponents: typeof fetchAllMeshComponents;
|
|
44
|
-
getMeshComponentGeodeIds: typeof getMeshComponentGeodeIds;
|
|
45
|
-
getCornersGeodeIds: typeof getCornersGeodeIds;
|
|
46
|
-
getLinesGeodeIds: typeof getLinesGeodeIds;
|
|
47
|
-
getSurfacesGeodeIds: typeof getSurfacesGeodeIds;
|
|
48
|
-
getBlocksGeodeIds: typeof getBlocksGeodeIds;
|
|
49
|
-
} {
|
|
50
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- database's table map is dynamically typed at runtime.
|
|
51
|
-
const model_components_db = database.model_components as unknown as Table<
|
|
52
|
-
ModelComponentRecord,
|
|
53
|
-
string
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
async function formatedMeshComponents(modelId: ModelId): Promise<FormattedComponentGroup[]> {
|
|
57
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
58
|
-
const componentTitles: Record<string, string> = {
|
|
59
|
-
Corner: "Corners",
|
|
60
|
-
Line: "Lines",
|
|
61
|
-
Surface: "Surfaces",
|
|
62
|
-
Block: "Blocks",
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const componentsByType: Record<string, ModelComponentRecord[]> = {};
|
|
66
|
-
for (const component_item of items) {
|
|
67
|
-
if (componentTitles[component_item.type] !== undefined) {
|
|
68
|
-
componentsByType[component_item.type] ??= [];
|
|
69
|
-
componentsByType[component_item.type]?.push(component_item);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return Object.keys(componentTitles)
|
|
74
|
-
.filter((type) => componentsByType[type])
|
|
75
|
-
.map((type) => ({
|
|
76
|
-
id: type,
|
|
77
|
-
title: componentTitles[type] ?? type,
|
|
78
|
-
children: (componentsByType[type] ?? []).map((item: ModelComponentRecord) =>
|
|
79
|
-
toFormattedComponent(item),
|
|
80
|
-
),
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function refFormatedMeshComponents(modelId: ModelId): Ref<FormattedComponentGroup[] | undefined> {
|
|
85
|
-
return useObservable(
|
|
86
|
-
liveObservable(async () => {
|
|
87
|
-
const components = await formatedMeshComponents(modelId);
|
|
88
|
-
return components;
|
|
89
|
-
}),
|
|
90
|
-
{
|
|
91
|
-
initialValue: undefined,
|
|
92
|
-
},
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function getMeshComponentsByType(
|
|
97
|
-
modelId: ModelId,
|
|
98
|
-
type: string,
|
|
99
|
-
): Promise<FormattedComponent[]> {
|
|
100
|
-
const components = await model_components_db
|
|
101
|
-
.where("[data_id+type]")
|
|
102
|
-
.equals([modelId, type])
|
|
103
|
-
.toArray();
|
|
104
|
-
return components.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function getAllMeshComponents(modelId: ModelId): Promise<FormattedComponent[]> {
|
|
108
|
-
const items = await model_components_db.where("data_id").equals(modelId).toArray();
|
|
109
|
-
return items.map((item: ModelComponentRecord) => toFormattedComponent(item));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function fetchAllMeshComponents(
|
|
113
|
-
modelId: ModelId,
|
|
114
|
-
): Promise<Record<string, FormattedComponent[]>> {
|
|
115
|
-
const components = await getAllMeshComponents(modelId);
|
|
116
|
-
const byType: Record<string, FormattedComponent[]> = {};
|
|
117
|
-
for (const component of components) {
|
|
118
|
-
byType[component.category] ??= [];
|
|
119
|
-
byType[component.category]?.push(component);
|
|
120
|
-
}
|
|
121
|
-
return byType;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async function getMeshComponentGeodeIds(modelId: ModelId, type: string): Promise<string[]> {
|
|
125
|
-
const components = await model_components_db
|
|
126
|
-
.where("[data_id+type]")
|
|
127
|
-
.equals([modelId, type])
|
|
128
|
-
.toArray();
|
|
129
|
-
return components.map((component: ModelComponentRecord) => component.geode_id);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
async function getCornersGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
133
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Corner");
|
|
134
|
-
return geodeIds;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async function getLinesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
138
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Line");
|
|
139
|
-
return geodeIds;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async function getSurfacesGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
143
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Surface");
|
|
144
|
-
return geodeIds;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function getBlocksGeodeIds(modelId: ModelId): Promise<string[]> {
|
|
148
|
-
const geodeIds = await getMeshComponentGeodeIds(modelId, "Block");
|
|
149
|
-
return geodeIds;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
formatedMeshComponents,
|
|
154
|
-
refFormatedMeshComponents,
|
|
155
|
-
getMeshComponentsByType,
|
|
156
|
-
getAllMeshComponents,
|
|
157
|
-
fetchAllMeshComponents,
|
|
158
|
-
getMeshComponentGeodeIds,
|
|
159
|
-
getCornersGeodeIds,
|
|
160
|
-
getLinesGeodeIds,
|
|
161
|
-
getSurfacesGeodeIds,
|
|
162
|
-
getBlocksGeodeIds,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export { toFormattedComponent, useDataMesh };
|
|
167
|
-
export type { ModelComponentRecord, FormattedComponent, FormattedComponentGroup };
|