Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions app/stores/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,32 @@ export const useDataStore = defineStore("data", () => {

async function formatedMeshComponents(id) {
const items = await database.model_components.where({ id }).toArray()
const distinctTypes = [...new Set(items.map((item) => item.type))]

const formated_mesh_components = await Promise.all(
distinctTypes.map(async (type) => {
const meshComponents = await database.model_components
.where({ id, type })
.toArray()

return {
id: type,
title: type,
children: meshComponents.map((meshComponent) => ({
id: meshComponent.geode_id,
title: meshComponent.name,
category: meshComponent.type,
})),
}
}),
)
const componentTitles = {
Corner: "Corners",
Line: "Lines",
Surface: "Surfaces",
Block: "Blocks",
}

return formated_mesh_components
const componentsByType = items.reduce((acc, item) => {
if (componentTitles[item.type]) {
if (!acc[item.type]) acc[item.type] = []
acc[item.type].push(item)
}
return acc
}, {})

return Object.keys(componentTitles)
.filter((type) => componentsByType[type])
.map((type) => ({
id: type,
title: componentTitles[type],
children: componentsByType[type].map((meshComponent) => ({
id: meshComponent.geode_id,
title: meshComponent.name,
category: meshComponent.type,
})),
}))
}

async function meshComponentType(id, geode_id) {
Expand Down Expand Up @@ -109,15 +114,19 @@ export const useDataStore = defineStore("data", () => {
await database.model_components.where({ id }).delete()
}

async function fetchMeshComponents(id) {
async function fetchModelComponents(id) {
const geodeStore = useGeodeStore()
return await geodeStore.request(
back_model_schemas.mesh_components,
back_model_schemas.model_components,
{ id },
{
response_function: async (response) => {
const { mesh_components } = response
await addModelComponents(mesh_components)
const { mesh_components, collection_components } = response
const allComponents = [
...mesh_components,
...collection_components,
].map((component) => ({ ...component, id }))
await addModelComponents(allComponents)
},
},
)
Expand Down Expand Up @@ -178,7 +187,7 @@ export const useDataStore = defineStore("data", () => {
addItem,
deleteItem,
updateItem,
fetchMeshComponents,
fetchModelComponents,
getCornersGeodeIds,
getLinesGeodeIds,
getSurfacesGeodeIds,
Expand Down
2 changes: 1 addition & 1 deletion app/utils/file_import_workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function importItem(item) {
await dataStyleStore.addDataStyle(item.id, item.geode_object_type)

if (item.viewer_type === "model") {
await dataStore.fetchMeshComponents(item.id)
await dataStore.fetchModelComponents(item.id)
}

await dataStyleStore.applyDefaultStyle(item.id)
Expand Down
2 changes: 1 addition & 1 deletion internal/database/tables/model_components.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const modelComponentsTable = {
name: "model_components",
schema: "[id+geode_id], [id+type], viewer_id, type, name, created_at",
schema: "[id+geode_id], [id+type], viewer_id, name",
}
1 change: 0 additions & 1 deletion tests/integration/microservices/back/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
# pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in
#

opengeodeweb-back==6.*,>=6.1.3
1 change: 0 additions & 1 deletion tests/integration/microservices/viewer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
# pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
#

opengeodeweb-viewer==1.*,>=1.15.3
Loading