@geode/opengeodeweb-front 10.44.1 → 11.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -256,6 +256,7 @@ onBeforeUnmount(cleanupLocalWidget);
256
256
  v-model="selectedDatasetIds"
257
257
  data-testid="selectedDatasetsSelect"
258
258
  :items="availableDatasets"
259
+ :item-props="() => ({ 'data-testid': 'selectedDatasetsOption' })"
259
260
  label="Select datasets"
260
261
  multiple
261
262
  chips
@@ -144,6 +144,7 @@ watch(
144
144
  v-model="selectedDatasetIds"
145
145
  :data-testid="`${testIdPrefix}SelectedDatasetsSelect`"
146
146
  :items="availableDatasets"
147
+ :item-props="() => ({ 'data-testid': `${testIdPrefix}SelectedDatasetsOption` })"
147
148
  label="Select datasets"
148
149
  multiple
149
150
  chips
@@ -64,7 +64,8 @@ watch(
64
64
  },
65
65
  );
66
66
 
67
- watch([width, height], () => {
67
+ watch([width, height], ([new_width, new_height]) => {
68
+ viewerStore.set_view_size(Math.round(new_width), Math.round(new_height));
68
69
  resize();
69
70
  });
70
71
 
@@ -1,4 +1,9 @@
1
1
  <script setup lang="ts">
2
+ import {
3
+ MAX_SCREENSHOT_SIZE,
4
+ MIN_SCREENSHOT_SIZE,
5
+ useScreenshotSize,
6
+ } from "@ogw_front/composables/screenshot_size";
2
7
  import viewer_schemas, {
3
8
  type ViewerTakeScreenshotParams,
4
9
  } from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
@@ -9,6 +14,7 @@ import { useFeedbackStore } from "@ogw_front/stores/feedback";
9
14
  import { useViewerStore } from "@ogw_front/stores/viewer";
10
15
 
11
16
  const DEFAULT_PANEL_WIDTH = 260;
17
+ const EXTENSION_SELECT_WIDTH = 80;
12
18
 
13
19
  const show = defineModel<boolean>({ default: false });
14
20
 
@@ -33,6 +39,8 @@ const output_extension = ref<ViewerTakeScreenshotParams["output_extension"]>("pn
33
39
  const include_background = ref<boolean>(true);
34
40
  const include_ui = ref<boolean>(false);
35
41
  const screenshot_type = ref<string>("file");
42
+ const { screenshot_size, displayed_size, resetSize, setWidth, setHeight } =
43
+ useScreenshotSize(include_ui);
36
44
 
37
45
  const { copy } = useClipboardItems();
38
46
 
@@ -65,6 +73,7 @@ async function takeSceneScreenshot(current_filename: string): Promise<void> {
65
73
  filename: current_filename,
66
74
  output_extension: output_extension.value,
67
75
  include_background: include_background.value,
76
+ ...screenshot_size.value,
68
77
  };
69
78
  await viewerStore.request(
70
79
  {
@@ -146,6 +155,16 @@ watch([output_extension, include_ui], ([extension, with_ui]) => {
146
155
  }
147
156
  });
148
157
 
158
+ watch(
159
+ show,
160
+ (opened) => {
161
+ if (opened) {
162
+ resetSize();
163
+ }
164
+ },
165
+ { immediate: true },
166
+ );
167
+
149
168
  watch(screenshot_type, (value) => {
150
169
  if (value === "clipboard") {
151
170
  output_extension.value = "png";
@@ -203,8 +222,8 @@ function handleClose(): void {
203
222
  </v-col>
204
223
  </v-row>
205
224
 
206
- <v-row dense v-if="screenshot_type === 'file'">
207
- <v-col cols="12" class="py-1">
225
+ <v-row dense v-if="screenshot_type === 'file'" class="flex-nowrap">
226
+ <v-col class="py-1">
208
227
  <v-text-field
209
228
  data-testid="screenshotFileNameInput"
210
229
  v-model="filename"
@@ -215,11 +234,11 @@ function handleClose(): void {
215
234
  class="text-caption"
216
235
  ></v-text-field>
217
236
  </v-col>
218
- <v-col cols="12" class="py-1">
237
+ <v-col class="py-1 flex-grow-0" :style="{ minWidth: `${EXTENSION_SELECT_WIDTH}px` }">
219
238
  <v-select
220
239
  v-model="output_extension"
221
240
  :items="output_extensions"
222
- label="Extension"
241
+ label="Ext."
223
242
  variant="outlined"
224
243
  density="compact"
225
244
  data-testid="screenshotExtensionSelect"
@@ -230,8 +249,48 @@ function handleClose(): void {
230
249
  </v-col>
231
250
  </v-row>
232
251
 
233
- <v-row dense>
234
- <v-col cols="12" class="py-1">
252
+ <v-row dense class="flex-nowrap align-center">
253
+ <v-col class="py-1">
254
+ <v-number-input
255
+ data-testid="screenshotWidthInput"
256
+ :model-value="displayed_size.width"
257
+ :min="MIN_SCREENSHOT_SIZE"
258
+ :max="MAX_SCREENSHOT_SIZE"
259
+ :readonly="include_ui"
260
+ :prefix="include_ui ? '≈' : undefined"
261
+ label="Width"
262
+ control-variant="hidden"
263
+ variant="outlined"
264
+ density="compact"
265
+ hide-details
266
+ class="text-caption"
267
+ @update:model-value="setWidth"
268
+ />
269
+ </v-col>
270
+ <span class="text-caption">×</span>
271
+ <v-col class="py-1">
272
+ <v-number-input
273
+ data-testid="screenshotHeightInput"
274
+ :model-value="displayed_size.height"
275
+ :min="MIN_SCREENSHOT_SIZE"
276
+ :max="MAX_SCREENSHOT_SIZE"
277
+ :readonly="include_ui"
278
+ :prefix="include_ui ? '≈' : undefined"
279
+ label="Height"
280
+ control-variant="hidden"
281
+ variant="outlined"
282
+ density="compact"
283
+ hide-details
284
+ class="text-caption"
285
+ @update:model-value="setHeight"
286
+ />
287
+ </v-col>
288
+ <span class="text-caption">px</span>
289
+ <v-icon icon="mdi-lock" size="small" class="ml-1" title="Aspect ratio locked to the view" />
290
+ </v-row>
291
+
292
+ <v-row dense class="flex-nowrap">
293
+ <v-col class="py-0">
235
294
  <v-switch
236
295
  data-testid="screenshotIncludeUiSwitch"
237
296
  v-model="include_ui"
@@ -242,12 +301,12 @@ function handleClose(): void {
242
301
  class="text-caption"
243
302
  ></v-switch>
244
303
  </v-col>
245
- <v-col cols="12" class="py-1">
304
+ <v-col class="py-0">
246
305
  <v-switch
247
306
  data-testid="screenshotIncludeBackgroundSwitch"
248
307
  v-model="include_background"
249
308
  :disabled="(screenshot_type === 'file' && output_extension !== 'png') || include_ui"
250
- label="Include background"
309
+ label="Background"
251
310
  density="compact"
252
311
  hide-details
253
312
  inset
@@ -73,7 +73,11 @@ async function files_uploaded_event(value: UploadFile[]): Promise<void> {
73
73
  { schema, params },
74
74
  {
75
75
  response_function: (response) => {
76
- textureId.value = response.id;
76
+ // A texture file holds a single image: the first imported object is the texture
77
+ const [texture] = response.data;
78
+ if (texture) {
79
+ textureId.value = texture.id;
80
+ }
77
81
  },
78
82
  },
79
83
  );
@@ -0,0 +1,92 @@
1
+ // Third party imports
2
+ import { type ComputedRef, type Ref, computed, ref } from "vue";
3
+ import { useDevicePixelRatio, useWindowSize } from "@vueuse/core";
4
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
5
+
6
+ // Local imports
7
+ import { useViewerStore } from "@ogw_front/stores/viewer";
8
+
9
+ interface PixelSize {
10
+ width: number;
11
+ height: number;
12
+ }
13
+
14
+ interface ScreenshotSizeState {
15
+ screenshot_size: Ref<PixelSize | undefined>;
16
+ displayed_size: ComputedRef<Partial<PixelSize>>;
17
+ resetSize: () => void;
18
+ setWidth: (value: number | null | undefined) => void;
19
+ setHeight: (value: number | null | undefined) => void;
20
+ }
21
+
22
+ // Pixel bounds accepted by the take_screenshot RPC
23
+ const size_schema = viewer_schemas.opengeodeweb_viewer.viewer.take_screenshot.properties.width;
24
+ const MIN_SCREENSHOT_SIZE = size_schema.minimum;
25
+ const MAX_SCREENSHOT_SIZE = size_schema.maximum;
26
+
27
+ function clampSize(value: number): number {
28
+ return Math.min(MAX_SCREENSHOT_SIZE, Math.max(MIN_SCREENSHOT_SIZE, Math.round(value)));
29
+ }
30
+
31
+ function isSized({ width, height }: Readonly<PixelSize>): boolean {
32
+ return width > 0 && height > 0;
33
+ }
34
+
35
+ // Width / height ratio of the view, 1 while the view is not sized yet (0×0)
36
+ function ratioOf(view_size: Readonly<PixelSize>): number {
37
+ return isSized(view_size) ? view_size.width / view_size.height : 1;
38
+ }
39
+
40
+ function useScreenshotSize(include_ui: Readonly<Ref<boolean>>): ScreenshotSizeState {
41
+ const viewerStore = useViewerStore();
42
+ const { width: window_width, height: window_height } = useWindowSize();
43
+ const { pixelRatio } = useDevicePixelRatio();
44
+
45
+ // Undefined (no size sent, the server keeps its window size) until the view size is known
46
+ const screenshot_size = ref<PixelSize>();
47
+
48
+ function resetSize(): void {
49
+ const { view_size } = viewerStore;
50
+ if (isSized(view_size)) {
51
+ screenshot_size.value = {
52
+ width: clampSize(view_size.width),
53
+ height: clampSize(view_size.height),
54
+ };
55
+ }
56
+ }
57
+
58
+ // `value` is null when the field is cleared (VNumberInput): keep the current size
59
+ function setWidth(value: number | null | undefined): void {
60
+ if (typeof value === "number") {
61
+ // Cap the edited side so the derived one stays within the bounds and keeps the ratio
62
+ const ratio = ratioOf(viewerStore.view_size);
63
+ const width = clampSize(Math.min(value, MAX_SCREENSHOT_SIZE * ratio));
64
+ const height = clampSize(width / ratio);
65
+ screenshot_size.value = { width, height };
66
+ }
67
+ }
68
+
69
+ function setHeight(value: number | null | undefined): void {
70
+ if (typeof value === "number") {
71
+ const ratio = ratioOf(viewerStore.view_size);
72
+ const height = clampSize(Math.min(value, MAX_SCREENSHOT_SIZE / ratio));
73
+ const width = clampSize(height * ratio);
74
+ screenshot_size.value = { width, height };
75
+ }
76
+ }
77
+
78
+ // With the UI included, the page is captured at the browser tab size (getDisplayMedia)
79
+ const displayed_size = computed<Partial<PixelSize>>(() => {
80
+ if (include_ui.value) {
81
+ return {
82
+ width: Math.round(window_width.value * pixelRatio.value),
83
+ height: Math.round(window_height.value * pixelRatio.value),
84
+ };
85
+ }
86
+ return { ...screenshot_size.value };
87
+ });
88
+
89
+ return { screenshot_size, displayed_size, resetSize, setWidth, setHeight };
90
+ }
91
+
92
+ export { MAX_SCREENSHOT_SIZE, MIN_SCREENSHOT_SIZE, useScreenshotSize };
@@ -29,6 +29,11 @@ import type {
29
29
  } from "@ogw_shared/utils/types.js";
30
30
  import type { RpcClient } from "@ogw_shared/utils/call_raw.js";
31
31
 
32
+ interface ViewSize {
33
+ width: number;
34
+ height: number;
35
+ }
36
+
32
37
  interface PickedPoint {
33
38
  x: number | undefined;
34
39
  y: number | undefined;
@@ -50,6 +55,8 @@ export const useViewerStore = defineStore(
50
55
  y: undefined,
51
56
  z: undefined,
52
57
  });
58
+ // Pixel size of the remote rendering view, as sent to the server by RemoteView.resize()
59
+ const view_size = ref<ViewSize>({ width: 0, height: 0 });
53
60
  const request_counter = ref(0);
54
61
  const status = ref(Status.NOT_CONNECTED);
55
62
  const version = ref("0.0.0");
@@ -73,6 +80,9 @@ export const useViewerStore = defineStore(
73
80
  function toggle_picking_mode(value: boolean): void {
74
81
  picking_mode.value = value;
75
82
  }
83
+ function set_view_size(width: number, height: number): void {
84
+ view_size.value = { width, height };
85
+ }
76
86
  // oxlint-disable-next-line unicorn/consistent-function-scoping
77
87
  async function request<Schema extends JsonRpcSchema>(
78
88
  args: ViewerRequestArgs<Schema>,
@@ -152,6 +162,8 @@ export const useViewerStore = defineStore(
152
162
  config,
153
163
  picking_mode,
154
164
  picked_point,
165
+ view_size,
166
+ set_view_size,
155
167
  request_counter,
156
168
  status,
157
169
  protocol,
@@ -173,7 +185,7 @@ export const useViewerStore = defineStore(
173
185
  },
174
186
  {
175
187
  share: {
176
- omit: ["status", "client"],
188
+ omit: ["status", "client", "view_size"],
177
189
  },
178
190
  },
179
191
  );
@@ -78,7 +78,8 @@ async function importItem(imported: LegacyDataId<NewDataItem> | NewDataItem): Pr
78
78
  const dataId = await importDataItem(fromLegacyDataId(imported));
79
79
  return dataId;
80
80
  }
81
- async function importFile(filename: string, geode_object_type: GeodeObjectType): Promise<string> {
81
+ // A single file can hold several objects: every one of them is imported, ids are returned in the response order
82
+ async function importFile(filename: string, geode_object_type: GeodeObjectType): Promise<string[]> {
82
83
  const backStore = useBackStore();
83
84
  const schema = back_schemas.opengeodeweb_back.save_viewable_file;
84
85
  const params = {
@@ -89,8 +90,15 @@ async function importFile(filename: string, geode_object_type: GeodeObjectType):
89
90
  schema,
90
91
  params,
91
92
  });
92
- // oxlint-disable-next-line no-unsafe-type-assertion -- this is the trusted API boundary; the back-end response shape matches NewDataItem, except for its legacy id.
93
- return importItem(response as LegacyDataId<NewDataItem>);
93
+ // oxlint-disable-next-line no-unsafe-type-assertion -- this is the trusted API boundary; each back-end response item matches NewDataItem, except for its legacy id.
94
+ const items = response.data as LegacyDataId<NewDataItem>[];
95
+ const dataIds = await Promise.all(
96
+ items.map(async (item) => {
97
+ const dataId = await importItem(item);
98
+ return dataId;
99
+ }),
100
+ );
101
+ return dataIds;
94
102
  }
95
103
 
96
104
  async function importWorkflow(files: readonly FileToImport[]): Promise<string[]> {
@@ -113,13 +121,13 @@ async function importWorkflow(files: readonly FileToImport[]): Promise<string[]>
113
121
  // A failing file does not prevent the other files from being imported
114
122
  const chunk_results = await Promise.allSettled(
115
123
  chunk.map(async ({ filename, geode_object_type }) => {
116
- const dataId = await importFile(filename, geode_object_type);
117
- return dataId;
124
+ const dataIds = await importFile(filename, geode_object_type);
125
+ return dataIds;
118
126
  }),
119
127
  );
120
128
  for (const result of chunk_results) {
121
129
  if (result.status === "fulfilled") {
122
- results.push(result.value);
130
+ results.push(...result.value);
123
131
  } else {
124
132
  errors.push(result.reason);
125
133
  }
@@ -39,6 +39,8 @@ async function resize(width: number, height: number): Promise<void> {
39
39
  if (viewStream.value) {
40
40
  viewStream.value.setSize(width, height);
41
41
  }
42
+ // Size of the server render window, used as the default screenshot size
43
+ viewerStore.set_view_size(Math.round(width), Math.round(height));
42
44
  renderWindow.getRenderWindow().render();
43
45
  await remoteRender();
44
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.44.1",
3
+ "version": "11.0.0-rc.1",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -64,9 +64,9 @@
64
64
  "prepublishOnly": "npm run build"
65
65
  },
66
66
  "dependencies": {
67
- "@geode/cloud-api": "latest",
68
- "@geode/opengeodeweb-back": "latest",
69
- "@geode/opengeodeweb-viewer": "latest",
67
+ "@geode/cloud-api": "next",
68
+ "@geode/opengeodeweb-back": "next",
69
+ "@geode/opengeodeweb-viewer": "next",
70
70
  "@kitware/vtk.js": "33.3.0",
71
71
  "@mdi/font": "7.4.47",
72
72
  "@msgpack/msgpack": "2.8.0",