@geode/opengeodeweb-front 10.4.2-rc.1 → 10.5.0-rc.2

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.
@@ -101,20 +101,70 @@ export const useDataStore = defineStore("data", () => {
101
101
  await database.data.update(id, changes)
102
102
  }
103
103
 
104
- async function addModelComponents(values) {
104
+ async function addModelComponents(id, values) {
105
105
  if (!values || values.length === 0) {
106
- console.debug("[addModelComponents] No mesh components to add")
106
+ console.debug("[addModelComponents] No components to add")
107
107
  return
108
108
  }
109
- for (const value of values) {
110
- value.created_at = new Date().toISOString()
109
+
110
+ const { mesh_components, collection_components } = values
111
+ const allComponents = [
112
+ ...(mesh_components || []),
113
+ ...(collection_components || []),
114
+ ]
115
+
116
+ const relations = []
117
+ for (const component of allComponents) {
118
+ component.id = id
119
+ component.created_at = new Date().toISOString()
120
+
121
+ if (component.boundaries) {
122
+ for (const boundary_id of component.boundaries) {
123
+ relations.push({
124
+ id,
125
+ parent: component.geode_id,
126
+ child: boundary_id,
127
+ type: "boundary",
128
+ })
129
+ }
130
+ delete component.boundaries
131
+ }
132
+ if (component.internals) {
133
+ for (const internal_id of component.internals) {
134
+ relations.push({
135
+ id,
136
+ parent: component.geode_id,
137
+ child: internal_id,
138
+ type: "internal",
139
+ })
140
+ }
141
+ delete component.internals
142
+ }
143
+ if (component.items) {
144
+ for (const item_id of component.items) {
145
+ relations.push({
146
+ id,
147
+ parent: component.geode_id,
148
+ child: item_id,
149
+ type: "collection",
150
+ })
151
+ }
152
+ delete component.items
153
+ }
154
+ }
155
+
156
+ const serializedComponents = structuredClone(allComponents)
157
+ const serializedRelations = structuredClone(relations)
158
+
159
+ await database.model_components.bulkAdd(serializedComponents)
160
+ if (serializedRelations.length > 0) {
161
+ await database.model_components_relation.bulkAdd(serializedRelations)
111
162
  }
112
- const serializedData = structuredClone(values)
113
- await database.model_components.bulkAdd(serializedData)
114
163
  }
115
164
 
116
165
  async function deleteModelComponents(id) {
117
166
  await database.model_components.where({ id }).delete()
167
+ await database.model_components_relation.where({ id }).delete()
118
168
  }
119
169
 
120
170
  async function fetchModelComponents(id) {
@@ -124,19 +174,7 @@ export const useDataStore = defineStore("data", () => {
124
174
  { id },
125
175
  {
126
176
  response_function: async (response) => {
127
- const allComponents = [
128
- ...response.mesh_components.map(
129
- ({
130
- boundaries: _boundaries,
131
- internals: _internals,
132
- ...component
133
- }) => component,
134
- ),
135
- ...response.collection_components.map(
136
- ({ items: _items, ...component }) => component,
137
- ),
138
- ].map((component) => Object.assign(component, { id }))
139
- await addModelComponents(allComponents)
177
+ await addModelComponents(id, response)
140
178
  },
141
179
  },
142
180
  )
@@ -92,6 +92,7 @@ export const useGeodeStore = defineStore("geode", {
92
92
  },
93
93
  request(schema, params, callbacks = {}) {
94
94
  console.log("[GEODE] Request:", schema.$id)
95
+ const start = Date.now()
95
96
 
96
97
  return api_fetch(
97
98
  this,
@@ -99,7 +100,13 @@ export const useGeodeStore = defineStore("geode", {
99
100
  {
100
101
  ...callbacks,
101
102
  response_function: async (response) => {
102
- console.log("[GEODE] Request completed:", schema.$id)
103
+ console.log(
104
+ "[GEODE] Request completed:",
105
+ schema.$id,
106
+ "in",
107
+ (Date.now() - start) / 1_000,
108
+ "s",
109
+ )
103
110
  if (callbacks.response_function) {
104
111
  await callbacks.response_function(response)
105
112
  }
@@ -170,6 +170,7 @@ export const useViewerStore = defineStore(
170
170
  timeout = request_timeout,
171
171
  ) {
172
172
  console.log("[VIEWER] Request:", schema.$id)
173
+ const start = Date.now()
173
174
 
174
175
  // Get current store instance to pass to viewer_call
175
176
  const store = useViewerStore()
@@ -180,7 +181,13 @@ export const useViewerStore = defineStore(
180
181
  {
181
182
  ...callbacks,
182
183
  response_function: async (response) => {
183
- console.log("[VIEWER] Request completed:", schema.$id)
184
+ console.log(
185
+ "[VIEWER] Request completed:",
186
+ schema.$id,
187
+ "in",
188
+ (Date.now() - start) / 1_000,
189
+ "s",
190
+ )
184
191
  if (callbacks.response_function) {
185
192
  await callbacks.response_function(response)
186
193
  }
@@ -2,6 +2,7 @@ import { Dexie } from "dexie"
2
2
  import { ExtendedDatabase } from "./extended_database"
3
3
  import { dataTable } from "./tables/data_table"
4
4
  import { modelComponentsTable } from "./tables/model_components"
5
+ import { modelComponentsRelationTable } from "./tables/model_components_relation"
5
6
 
6
7
  class Database extends Dexie {
7
8
  constructor() {
@@ -10,6 +11,7 @@ class Database extends Dexie {
10
11
  this.version(1).stores({
11
12
  [dataTable.name]: dataTable.schema,
12
13
  [modelComponentsTable.name]: modelComponentsTable.schema,
14
+ [modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
13
15
  })
14
16
  }
15
17
 
@@ -26,6 +28,8 @@ class Database extends Dexie {
26
28
 
27
29
  currentStores[dataTable.name] = dataTable.schema
28
30
  currentStores[modelComponentsTable.name] = modelComponentsTable.schema
31
+ currentStores[modelComponentsRelationTable.name] =
32
+ modelComponentsRelationTable.schema
29
33
 
30
34
  for (const table of tempDb.tables) {
31
35
  const keyPath = table.schema.primKey.src
@@ -49,6 +53,8 @@ class Database extends Dexie {
49
53
  existingDb.version(1).stores({
50
54
  [dataTable.name]: dataTable.schema,
51
55
  [modelComponentsTable.name]: modelComponentsTable.schema,
56
+ [modelComponentsRelationTable.name]:
57
+ modelComponentsRelationTable.schema,
52
58
  })
53
59
  } else {
54
60
  existingDb.version(version).stores(currentStores)
@@ -1,6 +1,7 @@
1
1
  import { Dexie } from "dexie"
2
2
  import { dataTable } from "./tables/data_table"
3
3
  import { modelComponentsTable } from "./tables/model_components"
4
+ import { modelComponentsRelationTable } from "./tables/model_components_relation"
4
5
 
5
6
  export class ExtendedDatabase extends Dexie {
6
7
  constructor(currentVersion, currentStores, newTables) {
@@ -11,6 +12,8 @@ export class ExtendedDatabase extends Dexie {
11
12
  this.version(1).stores({
12
13
  [dataTable.name]: dataTable.schema,
13
14
  [modelComponentsTable.name]: modelComponentsTable.schema,
15
+ [modelComponentsRelationTable.name]:
16
+ modelComponentsRelationTable.schema,
14
17
  })
15
18
  } else {
16
19
  this.version(version).stores(currentStores)
@@ -0,0 +1,4 @@
1
+ export const modelComponentsRelationTable = {
2
+ name: "model_components_relation",
3
+ schema: "[id+parent+child+type], id, parent, child, type",
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.4.2-rc.1",
3
+ "version": "10.5.0-rc.2",
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": {