Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
91 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
17607da
fix : brep imports
MaxNumerique Nov 8, 2025
9853aab
renames
MaxNumerique Nov 8, 2025
5232228
brep fix
MaxNumerique Nov 8, 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
65 changes: 65 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,65 @@
import { useAppStore } from "@/stores/app.js"
import { useInfraStore } from "@ogw_f/stores/infra"
import { viewer_call } from "@/composables/viewer_call.js"
import { useGeodeStore } from "@/stores/geode.js"
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"

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 appStore = useAppStore()
const geode = useGeodeStore()

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.exportStore()

const schema = back_schemas.opengeodeweb_back.project.export_project
const url = `${geode.base_url}${schema.route}`
const method = schema.methods[0]

const response = await fetch(url, {
method,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ snapshot }),
})
if (!response.ok) {
throw new Error(`Export failed: ${response.statusText}`)
}
const blob = await response.blob()
const filename = response.headers.get("new-file-name")
const urlObject = URL.createObjectURL(blob)
const a = document.createElement("a")
a.href = urlObject
Copy link
Member

Choose a reason for hiding this comment

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

@JulienChampagnol tu n'avais pas utilisé un truc pour faire ça simplement ?

a.download = filename
a.click()
URL.revokeObjectURL(urlObject)
} 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 {
const snapshot = JSON.parse(await file.text())
await useInfraStore().create_connection()

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

await appStore.importStore(snapshot)
} finally {
geode.stop_request()
}
}

return { exportProject, importProjectFile }
}
172 changes: 38 additions & 134 deletions package-lock.json

Large diffs are not rendered by default.

File renamed without changes.
46 changes: 17 additions & 29 deletions stores/app_store.js → stores/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,69 @@ 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 exportStore() {
const snapshot = {}
let savedCount = 0
let exportCount = 0

for (const store of stores) {
if (!store.save) {
if (!store.exportStore) {
continue
}
const storeId = store.$id
try {
snapshot[storeId] = store.save()
savedCount++
snapshot[storeId] = store.exportStore()
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(`[AppStore] Exported ${exportCount} stores`)
return snapshot
}

function load(snapshot) {
async function importStore(snapshot) {
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
}

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

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

if (!store.importStore) continue
const storeId = store.$id

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

try {
store.load(snapshot[storeId])
loadedCount++
await store.importStore(snapshot[storeId])
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,
exportStore,
importStore,
}
})
18 changes: 18 additions & 0 deletions stores/data_base.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
import { viewer_call } from "@/composables/viewer_call.js"

export const useDataBaseStore = defineStore("dataBase", () => {
const treeview_store = useTreeviewStore()
Expand Down Expand Up @@ -134,6 +135,21 @@ export const useDataBaseStore = defineStore("dataBase", () => {
return flat_indexes.filter((index) => index !== null)
}

function exportStore() {
return { db: JSON.parse(JSON.stringify(db)) }
}

async function importStore(snapshot) {
const entries = snapshot?.db || {}
const hybrid_store = useHybridViewerStore()
await hybrid_store.initHybridViewer()
hybrid_store.clear()
for (const [id, item] of Object.entries(entries)) {
await registerObject(id)
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.

await addItem(id, item)
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.

}
}

return {
db,
itemMetaDatas,
Expand All @@ -148,5 +164,7 @@ export const useDataBaseStore = defineStore("dataBase", () => {
getSurfacesUuids,
getBlocksUuids,
getFlatIndexes,
exportStore,
importStore,
}
})
10 changes: 10 additions & 0 deletions stores/data_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,22 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
return modelStyleStore.modelMeshComponentVisibility(id, "Edge", null)
}

function exportStore() {
return { styles: dataStyleState.styles }
}

async function importStore(snapshot) {
dataStyleState.styles = snapshot?.styles || {}
}

return {
...dataStyleState,
addDataStyle,
setVisibility,
setModelEdgesVisibility,
modelEdgesVisibility,
exportStore,
importStore,
...meshStyleStore,
...modelStyleStore,
}
Expand Down
22 changes: 22 additions & 0 deletions stores/hybrid_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
remoteRender()
}

function clear() {
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 renderer = genericRenderWindow.value.getRenderer()
const actors = renderer.getActors()
actors.forEach((actor) => renderer.removeActor(actor))
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 🐶
Do not use Array#forEach

genericRenderWindow.value.getRenderWindow().render()
Object.keys(db).forEach((id) => delete db[id])
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 🐶
Do not use Array#forEach

}

function exportStore() {
return { zScale: zScale.value }
}

async function importStore(snapshot) {
const z_scale = snapshot?.zScale
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.

if (z_scale != null) {
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 !== and instead saw !=

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 🐶
Do not use null comparisons without type-checking operators.

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 🐶
Do not use null literals

await setZScaling(z_scale)
}
}

return {
db,
genericRenderWindow,
Expand All @@ -195,5 +214,8 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
resize,
setContainer,
zScale,
clear,
exportStore,
importStore,
}
})
35 changes: 32 additions & 3 deletions stores/treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ export const useTreeviewStore = defineStore("treeview", () => {
const selectedTree = ref(null)

/** Functions **/
function addItem(geodeObject, displayed_name, id, object_type) {
function addItem(
geodeObject,
displayed_name,
id,
object_type,
autoSelect = true,
) {
dataStyleStore.addDataStyle(id, geodeObject, object_type)
const child = { title: displayed_name, id, object_type }
for (let i = 0; i < items.value.length; i++) {
if (items.value[i].title === geodeObject) {
items.value[i].children.push(child)
selection.value.push(child)
if (autoSelect) selection.value.push(child)
return
}
}
items.value.push({ title: geodeObject, children: [child] })
selection.value.push(child)
if (autoSelect) selection.value.push(child)
}

function displayAdditionalTree(id) {
Expand All @@ -47,6 +53,27 @@ export const useTreeviewStore = defineStore("treeview", () => {
panelWidth.value = width
}

function exportStore() {
return {
isAdditionnalTreeDisplayed: isAdditionnalTreeDisplayed.value,
panelWidth: panelWidth.value,
model_id: model_id.value,
isTreeCollection: isTreeCollection.value,
selectedTree: selectedTree.value,
selection: selection.value,
}
}

async function importStore(snapshot) {
selection.value = snapshot?.selection || []
isAdditionnalTreeDisplayed.value =
snapshot?.isAdditionnalTreeDisplayed || false
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.

panelWidth.value = snapshot?.panelWidth || 300
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 🐶
300

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.

model_id.value = snapshot?.model_id || ""
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.

isTreeCollection.value = snapshot?.isTreeCollection || false
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.

selectedTree.value = snapshot?.selectedTree || null
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.

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 🐶
Do not use null literals

}

return {
items,
selection,
Expand All @@ -60,5 +87,7 @@ export const useTreeviewStore = defineStore("treeview", () => {
displayFileTree,
toggleTreeView,
setPanelWidth,
exportStore,
importStore,
}
})
Loading
Loading