@geode/opengeodeweb-front 12.2.0-rc.3 → 12.2.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build/tests/browser/helpers/object_trees/common.js +3 -1
- package/.build/tests/browser/helpers/object_trees/model_tree_bar.js +41 -0
- package/.build/tests/browser/helpers/wait_for_action_settled.js +2 -2
- package/.build/tests/browser/suites/index.js +2 -0
- package/.build/tests/browser/suites/model/collections.js +1 -1
- package/.build/tests/browser/suites/object_tree/controls.js +2 -1
- package/.build/tests/browser/suites/object_tree/model_tree_bar.js +81 -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 +17 -1
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +2 -2
- package/app/components/Viewer/ObjectTree/Base/Controls.vue +26 -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/Box.vue +30 -5
- package/app/components/Viewer/ObjectTree/Layout.vue +183 -54
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +10 -15
- package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +3 -0
- 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/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/model_tree_drag.ts +56 -0
- package/app/composables/project_manager_helpers/types.ts +2 -3
- package/app/composables/use_adaptive_styles.ts +15 -8
- package/app/composables/use_overlapping_picker.ts +7 -19
- package/app/composables/viewer_context_menu.ts +2 -1
- package/app/composables/virtual_tree.ts +7 -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 +39 -30
- 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/import_item.ts +5 -4
- 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/brightness.ts +36 -19
- 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/tests/browser/helpers/object_trees/common.ts +4 -0
- package/tests/browser/helpers/object_trees/model_tree_bar.ts +78 -0
- package/tests/browser/helpers/wait_for_action_settled.ts +2 -3
- package/tests/browser/suites/model/collections.ts +2 -1
- package/tests/browser/suites/object_tree/controls.ts +3 -0
- package/tests/browser/suites/object_tree/model_tree_bar.ts +125 -0
- 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
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ref } from "vue";
|
|
2
|
-
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
3
|
-
|
|
4
1
|
import { type DataItem, useDataStore } from "@ogw_front/stores/data";
|
|
5
2
|
import type {
|
|
6
3
|
GeodeObjectType,
|
|
@@ -10,8 +7,11 @@ import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
|
10
7
|
import type { DataIdentified } from "@ogw_front/types/identifiers";
|
|
11
8
|
import type { ViewerId } from "@geode/opengeodeweb-viewer/schema_types";
|
|
12
9
|
import { computeMenuPosition } from "@ogw_front/composables/overlapping_picker_menu";
|
|
10
|
+
import { isImage } from "@ogw_front/utils/viewer_object_type";
|
|
11
|
+
import { ref } from "vue";
|
|
13
12
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
14
13
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
14
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
15
15
|
|
|
16
16
|
interface PickedItem {
|
|
17
17
|
id: DataId;
|
|
@@ -55,7 +55,6 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
55
55
|
const dataStore = useDataStore();
|
|
56
56
|
const dataStyleStore = useDataStyleStore();
|
|
57
57
|
const viewerStore = useViewerStore();
|
|
58
|
-
const dataItems = dataStore.refAllItems();
|
|
59
58
|
|
|
60
59
|
const displayIntermediate = ref(false);
|
|
61
60
|
const intermediateItems = ref<ProposedItem[]>([]);
|
|
@@ -111,27 +110,16 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
|
|
113
|
+
function getViewableIds(): string[] {
|
|
115
114
|
// Images are not pickable
|
|
116
115
|
const activeIds = new Set(
|
|
117
|
-
|
|
118
|
-
.filter((i: DataItem) => i.viewer_object_type !== "image")
|
|
119
|
-
.map((i: DataItem) => i.data_id),
|
|
116
|
+
dataStore.items.filter((i: DataItem) => !isImage(i)).map((i: DataItem) => i.data_id),
|
|
120
117
|
);
|
|
121
118
|
const visibleStyleIds = Object.keys(dataStyleStore.styles).filter(
|
|
122
119
|
(styleId) => activeIds.has(styleId) && dataStyleStore.objectVisibility(styleId) === true,
|
|
123
120
|
);
|
|
124
121
|
|
|
125
|
-
|
|
126
|
-
visibleStyleIds.map(async (styleId) => {
|
|
127
|
-
try {
|
|
128
|
-
return (await dataStore.isItemViewable(styleId)) ? styleId : undefined;
|
|
129
|
-
} catch {
|
|
130
|
-
return undefined;
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
);
|
|
134
|
-
return viewableChecks.filter((id): id is string => Boolean(id));
|
|
122
|
+
return visibleStyleIds.filter((styleId) => dataStore.isViewable(styleId));
|
|
135
123
|
}
|
|
136
124
|
|
|
137
125
|
function showIntermediateMenu(
|
|
@@ -145,7 +133,7 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
|
|
|
145
133
|
}
|
|
146
134
|
|
|
147
135
|
async function get_viewer_id(params: GetViewerIdParams): Promise<ViewerIdResult> {
|
|
148
|
-
const ids =
|
|
136
|
+
const ids = getViewableIds();
|
|
149
137
|
|
|
150
138
|
const schema = viewer_schemas.opengeodeweb_viewer.viewer.picked_ids;
|
|
151
139
|
const { array_ids, viewer_id } = await viewerStore.request({
|
|
@@ -5,6 +5,7 @@ import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
|
5
5
|
import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
6
6
|
import type { ViewerId } from "@geode/opengeodeweb-viewer/schema_types";
|
|
7
7
|
import type { ViewerIdResult } from "@ogw_front/composables/use_overlapping_picker";
|
|
8
|
+
import { isModel } from "@ogw_front/utils/viewer_object_type";
|
|
8
9
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
10
|
import { useElementSize } from "@vueuse/core";
|
|
10
11
|
|
|
@@ -76,7 +77,7 @@ async function viewerMenuTarget(
|
|
|
76
77
|
): Promise<MenuTarget> {
|
|
77
78
|
const item = await dataStore.item(pickedId);
|
|
78
79
|
const meta_data: MenuMetaData = { ...item };
|
|
79
|
-
if (item
|
|
80
|
+
if (isModel(item) && viewer_id !== undefined) {
|
|
80
81
|
const component = await dataStore.getComponentByViewerId(pickedId, viewer_id);
|
|
81
82
|
if (component) {
|
|
82
83
|
meta_data.pickedComponentId = component.geode_id;
|
|
@@ -140,14 +140,20 @@ function useVirtualTree(
|
|
|
140
140
|
};
|
|
141
141
|
const displayItems = computed(() => flattenTree(flattenContext, props.value.items ?? []));
|
|
142
142
|
|
|
143
|
+
// A search opens every group to show its matches: clearing it reopens the groups opened before
|
|
144
|
+
let openedBeforeSearch: unknown[] | undefined = undefined;
|
|
143
145
|
watch(
|
|
144
146
|
() => props.value.search,
|
|
145
147
|
(newSearch, oldSearch) => {
|
|
146
148
|
const hasNewSearch = newSearch !== undefined && newSearch !== "";
|
|
147
149
|
const hadOldSearch = oldSearch !== undefined && oldSearch !== "";
|
|
148
150
|
if (hasNewSearch && !hadOldSearch) {
|
|
151
|
+
openedBeforeSearch = [...(props.value.opened ?? [])];
|
|
149
152
|
const allIds = collectNonLeafIds(props.value.items ?? []);
|
|
150
|
-
emit("update:opened", [...new Set([...
|
|
153
|
+
emit("update:opened", [...new Set([...openedBeforeSearch, ...allIds])]);
|
|
154
|
+
} else if (!hasNewSearch && hadOldSearch && openedBeforeSearch !== undefined) {
|
|
155
|
+
emit("update:opened", openedBeforeSearch);
|
|
156
|
+
openedBeforeSearch = undefined;
|
|
151
157
|
}
|
|
152
158
|
},
|
|
153
159
|
);
|
package/app/stores/api.ts
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { api_fetch } from "@ogw_internal/utils/api_fetch";
|
|
3
|
-
import { consola } from "consola";
|
|
4
|
-
|
|
5
|
-
interface ApiSchema {
|
|
6
|
-
$id: string;
|
|
7
|
-
methods: string[];
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type ApiCallbacks<Response = unknown> = RequestHandlers<Response> & {
|
|
12
|
-
skip_feedback_error?: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const MILLISECONDS_IN_SECOND = 1000;
|
|
1
|
+
import { useHttpTransport, useRequestCounter } from "@ogw_internal/stores/microservice";
|
|
16
2
|
|
|
17
3
|
export const useAPIStore = defineStore("api", () => {
|
|
18
|
-
const request_counter = ref(0);
|
|
19
4
|
const base_url = ref(useRuntimeConfig().public.CLOUD_API_URL);
|
|
5
|
+
const counter = useRequestCounter();
|
|
6
|
+
const { request_counter, is_busy, start_request, stop_request } = counter;
|
|
7
|
+
const { request } = useHttpTransport("api", base_url, counter);
|
|
20
8
|
|
|
21
|
-
function start_request(): void {
|
|
22
|
-
request_counter.value += 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function stop_request(): void {
|
|
26
|
-
request_counter.value -= 1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// The response type comes from the schema's generated `response` type (see the Cloud API typed schemas), asserted at the API boundary below, not verified
|
|
30
|
-
async function request<Schema extends ApiSchema>(
|
|
31
|
-
{
|
|
32
|
-
schema,
|
|
33
|
-
params,
|
|
34
|
-
headers = {},
|
|
35
|
-
}: { schema: Schema; params?: ParamsOf<Schema>; headers?: Record<string, string> },
|
|
36
|
-
callbacks: ApiCallbacks<ResponseOf<Schema>> = {},
|
|
37
|
-
): Promise<ResponseOf<Schema>> {
|
|
38
|
-
consola.info("[API] Request:", schema.$id);
|
|
39
|
-
const start = Date.now();
|
|
40
|
-
|
|
41
|
-
const result = await api_fetch(
|
|
42
|
-
{ $id: schema.$id, base_url: base_url.value, start_request, stop_request },
|
|
43
|
-
{ schema, params: params ?? {}, headers },
|
|
44
|
-
{
|
|
45
|
-
...callbacks,
|
|
46
|
-
response_function: async (response: unknown) => {
|
|
47
|
-
consola.info(
|
|
48
|
-
"[API] Request completed:",
|
|
49
|
-
schema.$id,
|
|
50
|
-
"in",
|
|
51
|
-
(Date.now() - start) / MILLISECONDS_IN_SECOND,
|
|
52
|
-
"s",
|
|
53
|
-
);
|
|
54
|
-
if (callbacks.response_function) {
|
|
55
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted API boundary; see comment above.
|
|
56
|
-
await callbacks.response_function(response as ResponseOf<Schema>);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
);
|
|
61
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted API boundary; see comment above.
|
|
62
|
-
return result as ResponseOf<Schema>;
|
|
63
|
-
}
|
|
64
9
|
return {
|
|
65
10
|
base_url,
|
|
11
|
+
request_counter,
|
|
12
|
+
is_busy,
|
|
66
13
|
request,
|
|
67
14
|
start_request,
|
|
68
15
|
stop_request,
|
package/app/stores/app.ts
CHANGED
|
@@ -5,18 +5,12 @@ import {
|
|
|
5
5
|
importRegisteredStores,
|
|
6
6
|
} from "./app_helpers/registry.js";
|
|
7
7
|
import { getRestApiPort, getRestApiProtocol, isCloudMode } from "@ogw_front/utils/stores.js";
|
|
8
|
+
import { useHttpTransport, useRequestCounter } from "@ogw_internal/stores/microservice";
|
|
8
9
|
import { Status } from "@ogw_front/utils/status";
|
|
9
|
-
import { api_fetch } from "@ogw_internal/utils/api_fetch.js";
|
|
10
|
-
import { upload_file } from "@ogw_internal/utils/upload_file.js";
|
|
11
10
|
import { useAppExtensions } from "./app_helpers/extension.js";
|
|
12
11
|
import { useInfraStore } from "@ogw_front/stores/infra";
|
|
13
12
|
|
|
14
|
-
import type {
|
|
15
|
-
JsonRpcSchema,
|
|
16
|
-
ParamsOf,
|
|
17
|
-
RequestHandlers,
|
|
18
|
-
ResponseOf,
|
|
19
|
-
} from "@ogw_shared/utils/types.js";
|
|
13
|
+
import type { RequestHandlers } from "@ogw_shared/utils/types.js";
|
|
20
14
|
import type { StateTree } from "pinia";
|
|
21
15
|
|
|
22
16
|
import opengeodeweb_front_schemas from "@geode/opengeodeweb-front/opengeodeweb_front_typed_schemas.js";
|
|
@@ -75,6 +69,14 @@ export const useAppStore = defineStore("app", () => {
|
|
|
75
69
|
stores.push(store);
|
|
76
70
|
}
|
|
77
71
|
|
|
72
|
+
// An uninstalled extension unregisters its stores: they are no longer saved in projects
|
|
73
|
+
function unregisterStore(storeId: string): void {
|
|
74
|
+
const index = stores.findIndex((registeredStore) => registeredStore.$id === storeId);
|
|
75
|
+
if (index !== -1) {
|
|
76
|
+
stores.splice(index, 1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
78
80
|
async function exportStores(
|
|
79
81
|
params: Record<string, unknown> = {},
|
|
80
82
|
): Promise<Record<string, unknown>> {
|
|
@@ -100,62 +102,24 @@ export const useAppStore = defineStore("app", () => {
|
|
|
100
102
|
getExtensionEnabled,
|
|
101
103
|
} = useAppExtensions();
|
|
102
104
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
function stop_request(): void {
|
|
108
|
-
request_counter.value -= 1;
|
|
109
|
-
}
|
|
110
|
-
const is_busy = computed(() => request_counter.value > 0);
|
|
105
|
+
const counter = useRequestCounter();
|
|
106
|
+
const { request_counter, is_busy, start_request, stop_request } = counter;
|
|
107
|
+
const transport = useHttpTransport("app", base_url, counter);
|
|
108
|
+
const { request } = transport;
|
|
111
109
|
|
|
112
110
|
async function upload(file: Readonly<File>, callbacks: RequestHandlers = {}): Promise<unknown> {
|
|
113
111
|
const schema = opengeodeweb_front_schemas.api.local.extensions.upload;
|
|
114
112
|
const { PROJECT: projectName } = useRuntimeConfig().public;
|
|
115
|
-
const
|
|
116
|
-
const result = await upload_file(
|
|
117
|
-
{ $id: "app", base_url: base_url.value, start_request, stop_request },
|
|
118
|
-
{ schema, file, params },
|
|
119
|
-
{
|
|
120
|
-
...callbacks,
|
|
121
|
-
response_function: async (response: unknown) => {
|
|
122
|
-
if (callbacks.response_function) {
|
|
123
|
-
await callbacks.response_function(response);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
);
|
|
113
|
+
const result = await transport.upload({ schema, file, params: { projectName } }, callbacks);
|
|
128
114
|
return result;
|
|
129
115
|
}
|
|
130
116
|
|
|
131
|
-
// The response type comes from the schema's generated `response` type, asserted at the single `as ResponseOf<Schema>` boundary below: the server checks its responses against that schema outside production.
|
|
132
|
-
// oxlint-disable-next-line unicorn/consistent-function-scoping
|
|
133
|
-
async function request<Schema extends JsonRpcSchema>(
|
|
134
|
-
{ schema, params }: { schema: Schema; params?: ParamsOf<Schema> },
|
|
135
|
-
callbacks: RequestHandlers<ResponseOf<Schema>> = {},
|
|
136
|
-
): Promise<ResponseOf<Schema>> {
|
|
137
|
-
const rpc_schema: JsonRpcSchema = schema;
|
|
138
|
-
const result = await api_fetch(
|
|
139
|
-
{ $id: "app", base_url: base_url.value, start_request, stop_request },
|
|
140
|
-
// The app store is only ever used with HTTP ("front") schemas, which always carry `methods`; the wider JsonRpcSchema param above is kept as-is to match this action's public signature (e.g. relayed from get_version-style callers that only know about the shared, looser schema shape).
|
|
141
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- narrowing optional `methods` to required is safe here; see comment above.
|
|
142
|
-
{ schema: rpc_schema as JsonRpcSchema & { methods: string[] }, params: params ?? {} },
|
|
143
|
-
{
|
|
144
|
-
...callbacks,
|
|
145
|
-
response_function: async (response: unknown) => {
|
|
146
|
-
if (callbacks.response_function) {
|
|
147
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- this is the trusted API boundary; see comment above.
|
|
148
|
-
await callbacks.response_function(response as ResponseOf<Schema>);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
);
|
|
153
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- this is the trusted API boundary; see comment above.
|
|
154
|
-
return result as ResponseOf<Schema>;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
117
|
const projectFolderPath = ref("");
|
|
158
118
|
|
|
119
|
+
function set_project_folder_path(path: string): void {
|
|
120
|
+
projectFolderPath.value = path;
|
|
121
|
+
}
|
|
122
|
+
|
|
159
123
|
async function createProjectFolder(): Promise<unknown> {
|
|
160
124
|
const { PROJECT } = useRuntimeConfig().public;
|
|
161
125
|
const schema = opengeodeweb_front_schemas.api.local.app.project_folder_path;
|
|
@@ -181,6 +145,7 @@ export const useAppStore = defineStore("app", () => {
|
|
|
181
145
|
base_url,
|
|
182
146
|
is_busy,
|
|
183
147
|
registerStore,
|
|
148
|
+
unregisterStore,
|
|
184
149
|
exportStores,
|
|
185
150
|
importStores,
|
|
186
151
|
loadedExtensions,
|
|
@@ -197,6 +162,7 @@ export const useAppStore = defineStore("app", () => {
|
|
|
197
162
|
request,
|
|
198
163
|
upload,
|
|
199
164
|
projectFolderPath,
|
|
165
|
+
set_project_folder_path,
|
|
200
166
|
createProjectFolder,
|
|
201
167
|
start_request,
|
|
202
168
|
stop_request,
|
package/app/stores/back.ts
CHANGED
|
@@ -1,93 +1,72 @@
|
|
|
1
1
|
import { getRestApiPort, getRestApiProtocol, isCloudMode } from "@ogw_front/utils/stores";
|
|
2
|
+
import {
|
|
3
|
+
useHttpTransport,
|
|
4
|
+
useMicroserviceVersion,
|
|
5
|
+
usePing,
|
|
6
|
+
useRequestCounter,
|
|
7
|
+
} from "@ogw_internal/stores/microservice";
|
|
8
|
+
import type { RequestHandlers } from "@ogw_shared/utils/types.js";
|
|
2
9
|
import { Status } from "@ogw_front/utils/status";
|
|
3
|
-
import { api_fetch } from "@ogw_internal/utils/api_fetch";
|
|
4
10
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
5
|
-
import
|
|
11
|
+
import opengeodeweb_front_schemas from "@geode/opengeodeweb-front/opengeodeweb_front_typed_schemas.js";
|
|
6
12
|
import { useAppStore } from "@ogw_front/stores/app";
|
|
7
13
|
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
8
14
|
import { useInfraStore } from "@ogw_front/stores/infra";
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from "@ogw_shared/utils/types.js";
|
|
16
|
+
export const useBackStore = defineStore(
|
|
17
|
+
"back",
|
|
18
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
19
|
+
() => {
|
|
20
|
+
const default_local_port = ref("5000");
|
|
21
|
+
const status = ref(Status.NOT_CONNECTED);
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
const protocol = computed(() => getRestApiProtocol());
|
|
24
|
+
const port = computed(() => getRestApiPort(default_local_port.value));
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
function base_url_for(domain_name: string): string {
|
|
27
|
+
let back_url = `${protocol.value}://${domain_name}:${port.value}`;
|
|
28
|
+
if (isCloudMode()) {
|
|
29
|
+
back_url += `/geode`;
|
|
30
|
+
}
|
|
31
|
+
return back_url;
|
|
32
|
+
}
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (domain_name: string) => {
|
|
42
|
-
let back_url = `${this.protocol}://${domain_name}:${this.port}`;
|
|
43
|
-
if (isCloudMode()) {
|
|
44
|
-
back_url += `/geode`;
|
|
45
|
-
}
|
|
46
|
-
return back_url;
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
is_busy(): boolean {
|
|
50
|
-
return this.request_counter > 0;
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
actions: {
|
|
54
|
-
set_ping() {
|
|
55
|
-
// oxlint-disable-next-line typescript/no-floating-promises
|
|
56
|
-
this.ping();
|
|
57
|
-
setInterval(() => {
|
|
58
|
-
// oxlint-disable-next-line typescript/no-floating-promises
|
|
59
|
-
this.ping();
|
|
60
|
-
}, DEFAULT_PING_INTERVAL_SECONDS * MILLISECONDS_IN_SECOND);
|
|
61
|
-
},
|
|
62
|
-
async ping() {
|
|
63
|
-
const feedbackStore = useFeedbackStore();
|
|
64
|
-
const schema = back_schemas.opengeodeweb_back.ping;
|
|
65
|
-
const result = await this.request(
|
|
66
|
-
{ schema, log_success: false },
|
|
34
|
+
// The infra store is read lazily: this store can be created before the Nuxt app context
|
|
35
|
+
const base_url = computed(() => base_url_for(useInfraStore().microservice_domain_name));
|
|
36
|
+
|
|
37
|
+
const counter = useRequestCounter();
|
|
38
|
+
const { request_counter, is_busy, start_request, stop_request } = counter;
|
|
39
|
+
const transport = useHttpTransport("back", base_url, counter);
|
|
40
|
+
const { request } = transport;
|
|
41
|
+
const { version, get_version } = useMicroserviceVersion(request);
|
|
42
|
+
|
|
43
|
+
// The status and the server error banner always change together
|
|
44
|
+
function set_connected(connected: boolean): void {
|
|
45
|
+
useFeedbackStore().set_server_error(!connected);
|
|
46
|
+
status.value = connected ? Status.CONNECTED : Status.NOT_CONNECTED;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function ping(): Promise<unknown> {
|
|
50
|
+
const result = await request(
|
|
51
|
+
{ schema: back_schemas.opengeodeweb_back.ping, log_success: false },
|
|
67
52
|
{
|
|
68
53
|
request_error_function: () => {
|
|
69
|
-
|
|
70
|
-
this.status = Status.NOT_CONNECTED;
|
|
54
|
+
set_connected(false);
|
|
71
55
|
},
|
|
72
56
|
response_function: () => {
|
|
73
|
-
|
|
74
|
-
this.status = Status.CONNECTED;
|
|
57
|
+
set_connected(true);
|
|
75
58
|
},
|
|
76
59
|
response_error_function: () => {
|
|
77
|
-
|
|
78
|
-
this.status = Status.NOT_CONNECTED;
|
|
60
|
+
set_connected(false);
|
|
79
61
|
},
|
|
80
62
|
},
|
|
81
63
|
);
|
|
82
64
|
return result;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.request_counter -= 1;
|
|
89
|
-
},
|
|
90
|
-
async launch(args: { projectFolderPath: string }) {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const { start_ping, stop_ping } = usePing(ping);
|
|
68
|
+
|
|
69
|
+
async function launch(args: { projectFolderPath: string }): Promise<unknown> {
|
|
91
70
|
const appStore = useAppStore();
|
|
92
71
|
const { COMMAND_BACK, NUXT_ROOT_PATH } = useRuntimeConfig().public;
|
|
93
72
|
const schema = opengeodeweb_front_schemas.api.local.app.run_back;
|
|
@@ -97,86 +76,48 @@ export const useBackStore = defineStore("back", {
|
|
|
97
76
|
{ schema, params },
|
|
98
77
|
{
|
|
99
78
|
response_function: (response) => {
|
|
100
|
-
|
|
79
|
+
default_local_port.value = String(response.port);
|
|
101
80
|
},
|
|
102
81
|
},
|
|
103
82
|
);
|
|
104
83
|
return result;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
schema,
|
|
113
|
-
params,
|
|
114
|
-
log_success,
|
|
115
|
-
}: { schema: Schema; params?: ParamsOf<Schema>; log_success?: boolean },
|
|
116
|
-
callbacks: RequestHandlers<ResponseOf<Schema>> = {},
|
|
117
|
-
): Promise<ResponseOf<Schema>> {
|
|
118
|
-
const rpc_schema: JsonRpcSchema = schema;
|
|
119
|
-
const result = await api_fetch(
|
|
120
|
-
this,
|
|
121
|
-
// The back store is only ever used with HTTP ("front"/"back") schemas,
|
|
122
|
-
// Which always carry `methods`; the wider JsonRpcSchema param above is
|
|
123
|
-
// Kept as-is to match this action's public signature.
|
|
124
|
-
{
|
|
125
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
126
|
-
schema: rpc_schema as JsonRpcSchema & { methods: string[] },
|
|
127
|
-
params: params ?? {},
|
|
128
|
-
headers: {},
|
|
129
|
-
...(log_success !== undefined && { log_success }),
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
...callbacks,
|
|
133
|
-
response_function: async (response: unknown) => {
|
|
134
|
-
if (callbacks.response_function) {
|
|
135
|
-
// The back validates its responses against the schema `response` it was generated from.
|
|
136
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
137
|
-
await callbacks.response_function(response as ResponseOf<Schema>);
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
143
|
-
return result as ResponseOf<Schema>;
|
|
144
|
-
},
|
|
145
|
-
async upload(file: File, callbacks: RequestHandlers = {}) {
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function connect(): void {
|
|
87
|
+
start_ping();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function upload(file: File, callbacks: RequestHandlers = {}): Promise<unknown> {
|
|
146
91
|
const schema = back_schemas.opengeodeweb_back.upload_file;
|
|
147
|
-
const result = await
|
|
148
|
-
this,
|
|
149
|
-
{
|
|
150
|
-
schema,
|
|
151
|
-
file,
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
...callbacks,
|
|
155
|
-
response_function: async (response: unknown) => {
|
|
156
|
-
if (callbacks.response_function) {
|
|
157
|
-
await callbacks.response_function(response);
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
);
|
|
92
|
+
const result = await transport.upload({ schema, file }, callbacks);
|
|
162
93
|
return result;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
default_local_port,
|
|
98
|
+
request_counter,
|
|
99
|
+
status,
|
|
100
|
+
version,
|
|
101
|
+
protocol,
|
|
102
|
+
port,
|
|
103
|
+
base_url,
|
|
104
|
+
base_url_for,
|
|
105
|
+
is_busy,
|
|
106
|
+
ping,
|
|
107
|
+
start_ping,
|
|
108
|
+
stop_ping,
|
|
109
|
+
start_request,
|
|
110
|
+
stop_request,
|
|
111
|
+
launch,
|
|
112
|
+
connect,
|
|
113
|
+
request,
|
|
114
|
+
upload,
|
|
115
|
+
get_version,
|
|
116
|
+
};
|
|
178
117
|
},
|
|
179
|
-
|
|
180
|
-
|
|
118
|
+
{
|
|
119
|
+
share: {
|
|
120
|
+
omit: ["status"],
|
|
121
|
+
},
|
|
181
122
|
},
|
|
182
|
-
|
|
123
|
+
);
|
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
import type { Table } from "dexie";
|
|
2
|
-
import { useObservable } from "@vueuse/rxjs";
|
|
3
|
-
|
|
4
1
|
// Local imports
|
|
5
2
|
import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types.js";
|
|
6
|
-
import {
|
|
3
|
+
import type { CameraPositionRecord } from "@ogw_internal/database/tables/camera_positions";
|
|
4
|
+
import { cameraPositionsDb } from "@ogw_internal/database/database.js";
|
|
7
5
|
import { liveObservable } from "@ogw_front/utils/live_observable";
|
|
6
|
+
import { useObservable } from "@vueuse/rxjs";
|
|
8
7
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
9
8
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
10
|
-
|
|
11
|
-
interface CameraPositionRecord {
|
|
12
|
-
id?: number;
|
|
13
|
-
name: string;
|
|
14
|
-
camera_options: CameraOptions;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
// oxlint-disable-next-line max-lines-per-function
|
|
18
|
-
export const useCameraManagerStore = defineStore("
|
|
10
|
+
export const useCameraManagerStore = defineStore("cameraManager", () => {
|
|
19
11
|
const viewerStore = useViewerStore();
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
// oxlint-disable-next-line no-unsafe-type-assertion -- trusted database table boundary.
|
|
23
|
-
const camera_positions_db = database.camera_positions as unknown as Table<
|
|
24
|
-
CameraPositionRecord,
|
|
25
|
-
number
|
|
26
|
-
>;
|
|
12
|
+
// Keyed by an auto-incremented number
|
|
13
|
+
const cameraPositionsTable = cameraPositionsDb();
|
|
27
14
|
|
|
28
15
|
function refAllCameraPositions(): Ref<CameraPositionRecord[]> {
|
|
29
16
|
return useObservable(
|
|
30
17
|
liveObservable(async () => {
|
|
31
|
-
const positions = await
|
|
18
|
+
const positions = await cameraPositionsTable.toArray();
|
|
32
19
|
return positions;
|
|
33
20
|
}),
|
|
34
21
|
{ initialValue: [] as CameraPositionRecord[] },
|
|
@@ -36,19 +23,19 @@ export const useCameraManagerStore = defineStore("camera_manager", () => {
|
|
|
36
23
|
}
|
|
37
24
|
|
|
38
25
|
async function getCameraPosition(id: number): Promise<CameraPositionRecord | undefined> {
|
|
39
|
-
const position = await
|
|
26
|
+
const position = await cameraPositionsTable.get(id);
|
|
40
27
|
return position;
|
|
41
28
|
}
|
|
42
29
|
|
|
43
30
|
async function saveCameraPosition(name: string, camera_options: CameraOptions): Promise<void> {
|
|
44
|
-
await
|
|
31
|
+
await cameraPositionsTable.put({
|
|
45
32
|
name,
|
|
46
33
|
camera_options,
|
|
47
34
|
});
|
|
48
35
|
}
|
|
49
36
|
|
|
50
37
|
async function restoreCameraPosition(id: number): Promise<void> {
|
|
51
|
-
const position = await
|
|
38
|
+
const position = await cameraPositionsTable.get(id);
|
|
52
39
|
if (position) {
|
|
53
40
|
const schema = viewer_schemas.opengeodeweb_viewer.viewer.update_camera;
|
|
54
41
|
const params = { camera_options: position.camera_options };
|
|
@@ -57,11 +44,11 @@ export const useCameraManagerStore = defineStore("camera_manager", () => {
|
|
|
57
44
|
}
|
|
58
45
|
|
|
59
46
|
async function deleteCameraPosition(id: number): Promise<void> {
|
|
60
|
-
await
|
|
47
|
+
await cameraPositionsTable.delete(id);
|
|
61
48
|
}
|
|
62
49
|
|
|
63
50
|
async function renameCameraPosition(id: number, newName: string): Promise<void> {
|
|
64
|
-
await
|
|
51
|
+
await cameraPositionsTable.update(id, { name: newName });
|
|
65
52
|
}
|
|
66
53
|
|
|
67
54
|
return {
|