Skip to content
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
aa86c91
feat(save_and_load): add save/load methods to all stores for project …
MaxNumerique Oct 27, 2025
5b2b4f3
Apply prepare changes
MaxNumerique Oct 28, 2025
f4ef491
cartStore becomes geodeStore
MaxNumerique Oct 28, 2025
5f3e0c6
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Oct 28, 2025
e6c54b5
Apply prepare changes
MaxNumerique Oct 28, 2025
01a9732
renames and move tests
MaxNumerique Oct 28, 2025
0b70454
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Oct 28, 2025
d577721
persist upload folder
MaxNumerique Oct 29, 2025
df419ec
renamed app_store store to app
MaxNumerique Oct 29, 2025
bb9d02d
rm unused var
MaxNumerique Oct 29, 2025
a93225c
importStore & exportStore refacto
MaxNumerique Oct 30, 2025
af41f9d
Apply prepare changes
MaxNumerique Oct 30, 2025
ea63e2b
testes with import/export
MaxNumerique Oct 30, 2025
97072b5
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Oct 30, 2025
63464b7
Apply prepare changes
MaxNumerique Oct 30, 2025
98991cf
test
MaxNumerique Oct 30, 2025
6321c8f
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Oct 30, 2025
35c75dd
Apply prepare changes
MaxNumerique Oct 30, 2025
22a67fe
test
MaxNumerique Oct 30, 2025
caf5a39
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Oct 30, 2025
18fc885
Apply prepare changes
MaxNumerique Oct 30, 2025
d4a1cd6
exportStores/importStores and createTestingPinia
MaxNumerique Oct 31, 2025
8aec8b8
Apply prepare changes
MaxNumerique Oct 31, 2025
6a282e4
export working
MaxNumerique Oct 31, 2025
196be52
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Oct 31, 2025
fdf547e
nothing appear in camera
MaxNumerique Nov 1, 2025
c208b30
Apply prepare changes
MaxNumerique Nov 1, 2025
3ef456f
test
MaxNumerique Nov 3, 2025
2ca553b
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 3, 2025
9fd6c0b
Apply prepare changes
MaxNumerique Nov 3, 2025
3806d54
feat(import_project): add 2 buttons : Export and import
MaxNumerique Nov 3, 2025
3d04f42
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 3, 2025
24eb5b6
test
MaxNumerique Nov 3, 2025
9866872
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 3, 2025
f01890f
Apply prepare changes
MaxNumerique Nov 3, 2025
344a873
test updated
MaxNumerique Nov 4, 2025
019fcd4
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 4, 2025
e512f73
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 4, 2025
f3140b6
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 4, 2025
e251104
Apply prepare changes
MaxNumerique Nov 4, 2025
dbf0a99
test
MaxNumerique Nov 4, 2025
a5b1ebf
test
MaxNumerique Nov 4, 2025
63f07e2
stable
MaxNumerique Nov 5, 2025
b1a9353
Apply prepare changes
MaxNumerique Nov 5, 2025
7b57603
logs everywhere
MaxNumerique Nov 5, 2025
9ae7357
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 5, 2025
1535343
Apply prepare changes
MaxNumerique Nov 5, 2025
bbfc846
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 6, 2025
f6c1304
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 6, 2025
16b61de
Apply prepare changes
MaxNumerique Nov 6, 2025
bb5a485
exports and imports OK
MaxNumerique Nov 6, 2025
779fbf9
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 6, 2025
2ad8f46
Apply prepare changes
MaxNumerique Nov 6, 2025
fdaca90
temporary fix for model's style
MaxNumerique Nov 6, 2025
0802579
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 6, 2025
769c481
Apply prepare changes
MaxNumerique Nov 6, 2025
597ca03
adding missing edge component_type
MaxNumerique Nov 6, 2025
5658e72
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 6, 2025
9eda52e
fix unused functions
MaxNumerique Nov 6, 2025
b686f44
multi import data work arround
MaxNumerique Nov 6, 2025
7812125
test delta
MaxNumerique Nov 6, 2025
e23b7e7
from next
MaxNumerique Nov 6, 2025
57e13f3
test camera_options
MaxNumerique Nov 6, 2025
2375805
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 6, 2025
6c3c9cf
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 6, 2025
6136cde
Apply prepare changes
MaxNumerique Nov 6, 2025
eecd8b7
restore
MaxNumerique Nov 6, 2025
328eb14
test
MaxNumerique Nov 7, 2025
0398bfe
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 7, 2025
7d392c0
Apply prepare changes
MaxNumerique Nov 7, 2025
5f65391
revert internal_stores
MaxNumerique Nov 7, 2025
a1725f8
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 7, 2025
f6e73f2
revert
MaxNumerique Nov 7, 2025
309b5f4
viewer_call
MaxNumerique Nov 7, 2025
cdbee18
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWe…
MaxNumerique Nov 7, 2025
7ab0049
Apply prepare changes
MaxNumerique Nov 7, 2025
7a0e43e
logs everywhere
MaxNumerique Nov 7, 2025
9954c87
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 7, 2025
933cb71
Apply prepare changes
MaxNumerique Nov 7, 2025
e0cf657
revert some
MaxNumerique Nov 7, 2025
2f464bb
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 7, 2025
44a70fe
Apply prepare changes
MaxNumerique Nov 7, 2025
499fc4b
please
MaxNumerique Nov 7, 2025
c0df47c
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 7, 2025
fca8a2a
OMGGGGG
MaxNumerique Nov 7, 2025
28abd57
Apply prepare changes
MaxNumerique Nov 7, 2025
c156eab
test
MaxNumerique Nov 7, 2025
e6d2c43
Merge branch 'feat/save_and_load' of https://github.com/Geode-solutio…
MaxNumerique Nov 7, 2025
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
93 changes: 93 additions & 0 deletions composables/project_manager.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JulienChampagnol que penses tu de cette proposition ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
import fileDownload from "js-file-download"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Imports should be sorted alphabetically.


export function useProjectManager() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected a function expression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Named exports are not allowed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
The function useProjectManager has too many lines (97). Maximum allowed is 50.

const geode = useGeodeStore()
const appStore = useAppStore()

async function exportProject() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected a function expression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
async is not allowed

geode.start_request()
try {
await useInfraStore().create_connection()
const snapshot = appStore.exportStores()
const schema = back_schemas.opengeodeweb_back.export_project
const defaultName = "project.zip"

await api_fetch(
{ schema, params: { snapshot, filename: defaultName } },
{
response_function: async (response) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Async function has no 'await' expression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
async is not allowed

const data = response._data
const downloadName =
response.headers?.get?.("new-file-name") || defaultName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.

fileDownload(data, downloadName)
},
},
)
} finally {
geode.stop_request()
}
}

async function importProjectFile(file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected a function expression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
async is not allowed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
The async function importProjectFile has too many lines (66). Maximum allowed is 50.

geode.start_request()
try {
await useInfraStore().create_connection()

const schemaImport = back_schemas.opengeodeweb_back.import_project
const form = new FormData()
form.append("file", file, file?.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.


const result = await $fetch(schemaImport.$id, {
baseURL: geode.base_url,
method: "POST",
body: form,
})
const snapshot = result?.snapshot ?? {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.


await viewer_call({
schema: viewer_schemas.opengeodeweb_viewer.import_project,
params: {},
})
await viewer_call({
schema: viewer_schemas.opengeodeweb_viewer.viewer.reset_visualization,
params: {},
})

const treeviewStore = useTreeviewStore()
treeviewStore.isImporting = true
await treeviewStore.importStores(snapshot?.treeview)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.


const hybridViewerStore = useHybridViewerStore()
await hybridViewerStore.initHybridViewer()
hybridViewerStore.clear()

const snapshotDataBase = snapshot?.dataBase?.db || {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.

const items = Object.entries(snapshotDataBase).map(([id, item]) => ({
id,
object_type: item.object_type,
geode_object: item.geode_object,
native_filename: item.native_filename,
viewable_filename: item.viewable_filename,
displayed_name: item.displayed_name,
vtk_js: { binary_light_viewable: item?.vtk_js?.binary_light_viewable },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.

}))

await importWorkflowFromSnapshot(items)

const dataStyleStore = useDataStyleStore()
await dataStyleStore.importStores(snapshot?.dataStyle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Optional chaining is not allowed.

await dataStyleStore.applyAllStylesFromState()

treeviewStore.finalizeImportSelection()
treeviewStore.isImporting = false
} finally {
geode.stop_request()
}
}

return { exportProject, importProjectFile }
}

export default useProjectManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Prefer named exports

6 changes: 6 additions & 0 deletions internal_stores/mesh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export default function useMeshStyle() {

function applyMeshStyle(id) {
const style = dataStyleStore.getStyle(id)
console.log(
"[MeshStyle] applyMeshDefaultStyle for id:",
id,
"style:",
style,
)
const promise_array = []
for (const [key, value] of Object.entries(style)) {
if (key === "visibility") {
Expand Down
21 changes: 15 additions & 6 deletions internal_stores/model/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,21 @@ export function useModelBlocksStyle() {
}

function applyModelBlocksStyle(id) {
const style = modelBlocksStyle(id)
const blocks_ids = dataBaseStore.getBlocksUuids(id)
return Promise.all([
setModelBlocksVisibility(id, blocks_ids, style.visibility),
setModelBlocksColor(id, blocks_ids, style.color),
])
const style = dataStyleStore.getStyle(id).blocks
const block_ids = dataBaseStore.getBlocksUuids(id)

if (!block_ids || block_ids.length === 0) {
return Promise.resolve()
}

const promises = []
if (typeof style?.visibility === "boolean") {
promises.push(setModelBlocksVisibility(id, block_ids, style.visibility))
}
if (style?.color) {
promises.push(setModelBlocksColor(id, block_ids, style.color))
}
return Promise.all(promises)
}

return {
Expand Down
17 changes: 13 additions & 4 deletions internal_stores/model/corners.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ export function useModelCornersStyle() {
function applyModelCornersStyle(id) {
const style = modelCornersStyle(id)
const corner_ids = dataBaseStore.getCornersUuids(id)
return Promise.all([
setModelCornersVisibility(id, corner_ids, style.visibility),
setModelCornersColor(id, corner_ids, style.color),
])

if (!corner_ids || corner_ids.length === 0) {
return Promise.resolve()
}

const promises = []
if (typeof style?.visibility === "boolean") {
promises.push(setModelCornersVisibility(id, corner_ids, style.visibility))
}
if (style?.color) {
promises.push(setModelCornersColor(id, corner_ids, style.color))
}
return Promise.all(promises)
}

return {
Expand Down
4 changes: 2 additions & 2 deletions internal_stores/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export default function useModelStyle() {
[component_id],
visibility,
)
} else if (component_type === "Edge") {
return modelEdgesStyleStore.setModelEdgesVisibility(id, visibility)
} else {
throw new Error("Unknown model component_type: " + component_type)
}
Expand Down Expand Up @@ -180,10 +182,8 @@ export default function useModelStyle() {
return {
modelVisibility,
visibleMeshComponents,
modelMeshComponentVisibility,
setModelVisibility,
setModelColor,
setModelMeshComponentVisibility,
applyModelStyle,
setModelMeshComponentsDefaultStyle,
...useModelBlocksStyle(),
Expand Down
19 changes: 15 additions & 4 deletions internal_stores/model/surfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,21 @@ export function useModelSurfacesStyle() {
function applyModelSurfacesStyle(id) {
const style = modelSurfacesStyle(id)
const surface_ids = dataBaseStore.getSurfacesUuids(id)
return Promise.all([
setModelSurfacesVisibility(id, surface_ids, style.visibility),
setModelSurfacesColor(id, surface_ids, style.color),
])

if (!surface_ids || surface_ids.length === 0) {
return Promise.resolve()
}

const promises = []
if (typeof style?.visibility === "boolean") {
promises.push(
setModelSurfacesVisibility(id, surface_ids, style.visibility),
)
}
if (style?.color) {
promises.push(setModelSurfacesColor(id, surface_ids, style.color))
}
return Promise.all(promises)
}

return {
Expand Down
File renamed without changes.
51 changes: 21 additions & 30 deletions stores/app_store.js → stores/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,72 @@ export const useAppStore = defineStore("app", () => {
const isAlreadyRegistered = stores.some(
(registeredStore) => registeredStore.$id === store.$id,
)

if (isAlreadyRegistered) {
console.log(
`[AppStore] Store "${store.$id}" already registered, skipping`,
)
return
}

console.log("[AppStore] Registering store", store.$id)
stores.push(store)
}

function save() {
function exportStores() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected a function expression.

const snapshot = {}
let savedCount = 0
let exportCount = 0

for (const store of stores) {
if (!store.save) {
continue
}
if (!store.exportStores) continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected { after 'if' condition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected use of continue statement.

const storeId = store.$id
try {
snapshot[storeId] = store.save()
savedCount++
snapshot[storeId] = store.exportStores()
exportCount++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unary operator '++' used.

} catch (error) {
console.error(`[AppStore] Error saving store "${storeId}":`, error)
console.error(`[AppStore] Error exporting store "${storeId}":`, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

}
}

console.log(`[AppStore] Saved ${savedCount} stores`)
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

`[AppStore] Exported ${exportCount} stores; snapshot keys:`,
Object.keys(snapshot),
)
return snapshot
}

function load(snapshot) {
async function importStores(snapshot) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected a function expression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
async is not allowed

if (!snapshot) {
console.warn("[AppStore] load called with invalid snapshot")
console.warn("[AppStore] import called with invalid snapshot")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

return
}
console.log("[AppStore] Import snapshot keys:", Object.keys(snapshot || {}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.


let loadedCount = 0
let importedCount = 0
const notFoundStores = []

for (const store of stores) {
if (!store.load) {
continue
}

if (!store.importStores) continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Expected { after 'if' condition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected use of continue statement.

const storeId = store.$id

if (!snapshot[storeId]) {
notFoundStores.push(storeId)
continue
}

try {
store.load(snapshot[storeId])
loadedCount++
await store.importStores(snapshot[storeId])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected await inside a loop.

importedCount++
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unary operator '++' used.

} catch (error) {
console.error(`[AppStore] Error loading store "${storeId}":`, error)
console.error(`[AppStore] Error importing store "${storeId}":`, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

}
}

if (notFoundStores.length > 0) {
console.warn(
`[AppStore] Stores not found in snapshot: ${notFoundStores.join(", ")}`,
)
}

console.log(`[AppStore] Loaded ${loadedCount} stores`)
console.log(`[AppStore] Imported ${importedCount} stores`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

}

return {
stores,
registerStore,
save,
load,
exportStores,
importStores,
}
})
46 changes: 46 additions & 0 deletions stores/data_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const useDataBaseStore = defineStore("dataBase", () => {
})
}

const treeviewStore = useTreeviewStore()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Variable 'treeviewStore' is declared but never used. Unused variables should start with a '_'.

const hybridViewerStore = useHybridViewerStore()

async function addItem(
id,
value = {
Expand All @@ -59,7 +62,17 @@ export const useDataBaseStore = defineStore("dataBase", () => {
vtk_js: { binary_light_viewable },
},
) {
console.log("[DataBase] addItem start", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
Unexpected console statement.

id,
object_type: value.object_type,
geode_object: value.geode_object,
})
db[id] = value

if (value.object_type === "model") {
await fetchMeshComponents(id)
await fetchUuidToFlatIndexDict(id)
}
}

async function fetchMeshComponents(id) {
Expand Down Expand Up @@ -93,6 +106,37 @@ export const useDataBaseStore = defineStore("dataBase", () => {
)
}

function exportStores() {
const snapshotDb = {}
for (const [id, item] of Object.entries(db)) {
if (!item) continue
snapshotDb[id] = {
object_type: item.object_type,
geode_object: item.geode_object,
native_filename: item.native_filename,
viewable_filename: item.viewable_filename,
displayed_name: item.displayed_name,
vtk_js: {
binary_light_viewable: item?.vtk_js?.binary_light_viewable,
},
}
}
return { db: snapshotDb }
}

async function importStores(snapshot) {
await hybridViewerStore.initHybridViewer()
hybridViewerStore.clear()
console.log(
"[DataBase] importStores entries:",
Object.keys(snapshot?.db || {}),
)
for (const [id, item] of Object.entries(snapshot?.db || {})) {
await registerObject(id)
await addItem(id, item)
}
}

function getCornersUuids(id) {
const { mesh_components } = itemMetaDatas(id)
return Object.values(mesh_components["Corner"])
Expand Down Expand Up @@ -134,5 +178,7 @@ export const useDataBaseStore = defineStore("dataBase", () => {
getSurfacesUuids,
getBlocksUuids,
getFlatIndexes,
exportStores,
importStores,
}
})
Loading
Loading