Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions app/components/Viewer/Tree/ObjectTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
</template>

<script setup>
import ViewerBreadCrumb from "@/components/Viewer/BreadCrumb"
import ViewerTreeObject from "@/components/Viewer/TreeObject"
import ViewerTreeComponent from "@/components/Viewer/TreeComponent"
import ViewerBreadCrumb from "@ogw_front/components/Viewer/BreadCrumb"
import ViewerTreeObject from "@ogw_front/components/Viewer/TreeObject"
import ViewerTreeComponent from "@ogw_front/components/Viewer/TreeComponent"
import { useTreeviewStore } from "@ogw_front/stores/treeview"
import { useMenuStore } from "@ogw_front/stores/menu"

Expand Down
15 changes: 6 additions & 9 deletions app/components/Viewer/TreeObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@

const emit = defineEmits(["show-menu"])

function isLeafNode(item) {
return !item.children || item.children.length === 0
}

Check failure on line 55 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(func-style)

Expected a function expression.

watch(
() => treeviewStore.selection,
(current, previous) => {
async (current, previous) => {
if (!previous) previous = []

Check failure on line 60 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(curly)

Expected { after 'if' condition.
if (current.value === previous) {
return
}
Expand All @@ -67,26 +67,23 @@
dataStyleStore.setVisibility(item.id, true)
})

removed.forEach((item) => {
dataStyleStore.setVisibility(item.id, false)
for (const item of removed) {
await dataStyleStore.setVisibility(item.id, false)

Check failure on line 71 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-await-in-loop)

Unexpected `await` inside a loop.

const objectMeta = dataBaseStore.itemMetaDatas(item.id)
if (objectMeta.viewer_type === "mesh") {
if (dataBaseStore.db[item.id]?.mesh_components_selection) {
dataBaseStore.db[item.id].mesh_components_selection = []
}
const objectMeta = await dataBaseStore.itemMetaDatas(item.id)
if (objectMeta?.viewer_type === "mesh") {
if (dataStyleStore.visibleMeshComponentIds?.[item.id]) {

Check warning on line 75 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint-plugin-unicorn(no-lonely-if)

Unexpected `if` as the only statement in a `if` block without `else`.
dataStyleStore.updateVisibleMeshComponents(item.id, [])
}
}
})
}
hybridViewerStore.remoteRender()
},

Check failure on line 81 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(max-statements)

function has too many statements (12). Maximum allowed is 10.
)

function isModel(item) {
return item.viewer_type === "model"
}

Check failure on line 86 in app/components/Viewer/TreeObject.vue

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(func-style)

Expected a function expression.

onMounted(() => {
const savedSelection = treeviewStore.selection
Expand Down
2 changes: 1 addition & 1 deletion app/plugins/auto_store_register.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useAppStore } from "../stores/app"
import { useAppStore } from "@ogw_front/stores/app"

const autoStoreRegister = ({ store }) => {
if (store.$id === "app") {
Expand Down
4 changes: 2 additions & 2 deletions app/stores/app.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
export const useAppStore = defineStore("app", () => {
const stores = []

function registerStore(store) {
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 exportStores() {
function exportStores(params = {}) {
const snapshot = {}
let exportCount = 0

for (const store of stores) {
if (!store.exportStores) continue
const storeId = store.$id
try {
snapshot[storeId] = store.exportStores()
snapshot[storeId] = store.exportStores(params)
exportCount++
} catch (error) {
console.error(`[AppStore] Error exporting store "${storeId}":`, error)
}
}
console.log(
`[AppStore] Exported ${exportCount} stores; snapshot keys:`,
Object.keys(snapshot),
)
return snapshot
}

async function importStores(snapshot) {
if (!snapshot) {
console.warn("[AppStore] import called with invalid snapshot")
return
}
console.log("[AppStore] Import snapshot keys:", Object.keys(snapshot || {}))

let importedCount = 0
const notFoundStores = []
for (const store of stores) {
if (!store.importStores) continue
const storeId = store.$id
if (!snapshot[storeId]) {
notFoundStores.push(storeId)
continue
}
try {
await store.importStores(snapshot[storeId])
importedCount++
} catch (error) {
console.error(`[AppStore] Error importing store "${storeId}":`, error)
}
}
if (notFoundStores.length > 0) {
console.warn(
`[AppStore] Stores not found in snapshot: ${notFoundStores.join(", ")}`,
)
}
console.log(`[AppStore] Imported ${importedCount} stores`)
}

return {
stores,
registerStore,
exportStores,
importStores,
}
})

Check warning on line 76 in app/stores/app.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(max-lines-per-function)

The function has too many lines (76). Maximum allowed is 50.
164 changes: 114 additions & 50 deletions app/stores/data_base.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
// Third party imports
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
import { useViewerStore } from "@ogw_front/stores/viewer"
import { useGeodeStore } from "@ogw_front/stores/geode"
import { db } from "../../internal/database/db.js"
import { liveQuery } from "dexie"

// Local constants
const back_model_schemas = back_schemas.opengeodeweb_back.models
const viewer_generic_schemas = viewer_schemas.opengeodeweb_viewer.generic

import { useViewerStore } from "@ogw_front/stores/viewer"
import { useGeodeStore } from "@ogw_front/stores/geode"

export const useDataBaseStore = defineStore("dataBase", () => {
const viewerStore = useViewerStore()

const db = reactive({})
const syncCache = reactive({})

liveQuery(() => db.data.toArray()).subscribe((items) => {

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-node (ubuntu-latest)

[unit] ../tests/unit/plugins/project_load.nuxt.test.js > Project import > app.importStores restores stores

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-node (ubuntu-latest)

[unit] ../tests/unit/plugins/project_load.nuxt.test.js > Project import > app.importStores restores stores

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-node (ubuntu-latest)

[unit] ../tests/unit/plugins/project_load.nuxt.test.js > Project import > app.importStores restores stores

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-node (ubuntu-latest)

[unit] ../tests/unit/plugins/project_load.nuxt.test.js > Project import > app.importStores restores stores

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-integration (ubuntu-latest)

[integration] ../tests/integration/stores/data_style/mesh/cells.nuxt.test.js > Mesh cells > Cells color > Color red

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-integration (ubuntu-latest)

[integration] ../tests/integration/stores/data_style/mesh/cells.nuxt.test.js > Mesh cells > Cells visibility > Visibility true

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-integration (ubuntu-latest)

[integration] ../tests/integration/stores/data_style/mesh/cells.nuxt.test.js > Mesh cells > Cells visibility > Visibility true

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-integration (ubuntu-latest)

[integration] ../tests/integration/stores/data_style/mesh/cells.nuxt.test.js > Mesh cells > Cells visibility > Visibility true

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }

Check failure on line 19 in app/stores/data_base.js

View workflow job for this annotation

GitHub Actions / test / test-repository / test-integration (ubuntu-latest)

[integration] ../tests/integration/stores/data_style/mesh/cells.nuxt.test.js > Mesh cells > Cells visibility > Visibility true

MissingAPIError: IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb ❯ new WhereClause ../node_modules/dexie/dist/modern/dexie.mjs:2563:19 ❯ Table.toCollection ../node_modules/dexie/dist/modern/dexie.mjs:1387:39 ❯ Table.toArray ../node_modules/dexie/dist/modern/dexie.mjs:1384:21 ❯ stores/data_base.js:19:27 ❯ usePSD ../node_modules/dexie/dist/modern/dexie.mjs:1143:16 ❯ newScope ../node_modules/dexie/dist/modern/dexie.mjs:1047:14 ❯ exec ../node_modules/dexie/dist/modern/dexie.mjs:4822:32 ❯ execute ../node_modules/dexie/dist/modern/dexie.mjs:4826:19 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { _e: { stack: 'Error: \n at getErrorWithStack (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:286:12)\n at new DexieError (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:385:19)\n at new WhereClause (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:2563:19)\n at Table.toCollection (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1387:39)\n at Table.toArray (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1384:21)\n at /home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/app/stores/data_base.js:19:27\n at usePSD (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1143:16)\n at newScope (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:1047:14)\n at exec (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4822:32)\n at execute (file:///home/runner/work/OpenGeodeWeb-Front/OpenGeodeWeb-Front/node_modules/dexie/dist/modern/dexie.mjs:4826:19)', constructor: 'Function<Error>', name: 'Error', message: '', toString: 'Function<toString>' }, inner: null }
Object.keys(syncCache).forEach((key) => delete syncCache[key])
items.forEach((item) => {
syncCache[item.id] = item
})
})

function getAllItemsLive() {
return liveQuery(() => db.data.toArray())
}

function getItemLive(id) {
return liveQuery(() => db.data.get(id))
}

async function itemMetaDatas(id) {
return await db.data.get(id)
}

function itemMetaDatas(id) {
return db[id]
function itemMetaDatasSync(id) {
return syncCache[id]
}

function formatedMeshComponents(id) {
const { mesh_components } = itemMetaDatas(id)
const formated_mesh_components = ref([])
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return []
const { mesh_components } = item
const formated_mesh_components = []

for (const [category, uuids] of Object.entries(mesh_components)) {
formated_mesh_components.value.push({
formated_mesh_components.push({
id: category,
title: category,
children: uuids.map((uuid) => ({
Expand All @@ -32,11 +56,13 @@
})),
})
}
return formated_mesh_components.value
return formated_mesh_components
}

function meshComponentType(id, uuid) {
const { mesh_components } = itemMetaDatas(id)
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return null
const { mesh_components } = item

if (mesh_components["Corner"]?.includes(uuid)) return "corner"
else if (mesh_components["Line"]?.includes(uuid)) return "line"
Expand All @@ -49,18 +75,39 @@
return viewerStore.request(viewer_generic_schemas.register, { id })
}

async function addItem(
id,
value = {
viewer_type,
geode_object_type,
native_file,
viewable_file,
name,
binary_light_viewable,
},
) {
db[id] = value
async function deregisterObject(id) {
return viewerStore.request(viewer_generic_schemas.deregister, { id })
}

async function addItem(id, value) {
const itemData = {
id,
name: value.name || id,
geode_object_type: value.geode_object_type,
visible: true,
created_at: new Date().toISOString(),
...value,
}

const serializedData = JSON.parse(JSON.stringify(itemData))
await db.data.put(serializedData)
syncCache[id] = serializedData
}

async function getAllItems() {
return await db.data.toArray()
}

async function deleteItem(id) {
await db.data.delete(id)
delete syncCache[id]
}

async function updateItem(id, changes) {
await db.data.update(id, changes)
if (syncCache[id]) {
Object.assign(syncCache[id], changes)
}
}

async function fetchMeshComponents(id) {
Expand All @@ -70,90 +117,107 @@
{ id },
{
response_function: async (response) => {
db[id].mesh_components = response._data.uuid_dict
const mesh_components = response._data.uuid_dict
await updateItem(id, { mesh_components })
},
},
)
}

async function fetchUuidToFlatIndexDict(id) {
console.log("fetchUuidToFlatIndexDict", id)
const geodeStore = useGeodeStore()
return geodeStore.request(
back_model_schemas.vtm_component_indices,
{ id },
{
response_function: async (response) => {
db[id]["uuid_to_flat_index"] = response._data.uuid_to_flat_index
const uuid_to_flat_index = response._data.uuid_to_flat_index
await updateItem(id, { uuid_to_flat_index })
},
},
)
}

function getCornersUuids(id) {
const { mesh_components } = itemMetaDatas(id)
return Object.values(mesh_components["Corner"])
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return []
const { mesh_components } = item
return Object.values(mesh_components["Corner"] || {})
}

function getLinesUuids(id) {
const { mesh_components } = itemMetaDatas(id)
return Object.values(mesh_components["Line"])
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return []
const { mesh_components } = item
return Object.values(mesh_components["Line"] || {})
}
function getSurfacesUuids(id) {
const { mesh_components } = itemMetaDatas(id)
return Object.values(mesh_components["Surface"])
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return []
const { mesh_components } = item
return Object.values(mesh_components["Surface"] || {})
}
function getBlocksUuids(id) {
const { mesh_components } = itemMetaDatas(id)
return Object.values(mesh_components["Block"])
const item = itemMetaDatasSync(id)
if (!item || !item.mesh_components) return []
const { mesh_components } = item
return Object.values(mesh_components["Block"] || {})
}

function getFlatIndexes(id, mesh_component_ids) {
const { uuid_to_flat_index } = itemMetaDatas(id)
const item = itemMetaDatasSync(id)
if (!item || !item.uuid_to_flat_index) return []
const { uuid_to_flat_index } = item
const flat_indexes = []
for (const mesh_component_id of mesh_component_ids) {
flat_indexes.push(uuid_to_flat_index[mesh_component_id])
if (uuid_to_flat_index[mesh_component_id] !== undefined) {
flat_indexes.push(uuid_to_flat_index[mesh_component_id])
}
}
return flat_indexes
}

function exportStores() {
async function exportStores() {
const items = await db.data.toArray()
const snapshotDb = {}
for (const [id, item] of Object.entries(db)) {
if (!item) continue
snapshotDb[id] = {
...item,
}

for (const item of items) {
snapshotDb[item.id] = { ...item }
}

return { db: snapshotDb }
}

async function importStores(snapshot) {
const hybridViewerStore = useHybridViewerStore()
await hybridViewerStore.initHybridViewer()
hybridViewerStore.clear()
console.log(
"[DataBase] importStores entries:",
Object.keys(snapshot?.db || {}),
)

await clear()

for (const [id, item] of Object.entries(snapshot?.db || {})) {
await registerObject(id)
await addItem(id, item)
}
}

function clear() {
for (const id of Object.keys(db)) {
delete db[id]
}
async function clear() {
await db.data.clear()
}

return {
db,
getAllItemsLive,
getItemLive,
itemMetaDatas,
itemMetaDatasSync,
meshComponentType,
formatedMeshComponents,
registerObject,
deregisterObject,
addItem,
getAllItems,
deleteItem,
updateItem,
fetchUuidToFlatIndexDict,
fetchMeshComponents,
getCornersUuids,
Expand Down
6 changes: 3 additions & 3 deletions app/stores/data_style.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@
import useMeshStyle from "../../internal/stores/mesh/index"
import useModelStyle from "../../internal/stores/model/index"

export const useDataStyleStore = defineStore("dataStyle", () => {
const dataStyleState = useDataStyleState()
const meshStyleStore = useMeshStyle()
const modelStyleStore = useModelStyle()
const dataBaseStore = useDataBaseStore()

function addDataStyle(id, geode_object) {
dataStyleState.styles[id] = getDefaultStyle(geode_object)
}

function setVisibility(id, visibility) {
console.log(
"dataBaseStore.itemMetaDatas(id)",
dataBaseStore.itemMetaDatas(id),
)
const { viewer_type } = dataBaseStore.itemMetaDatas(id)
const { viewer_type } = dataBaseStore.itemMetaDatasSync(id)
if (viewer_type === "mesh") {
return Promise.all([meshStyleStore.setMeshVisibility(id, visibility)])

Check warning on line 24 in app/stores/data_style.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint-plugin-unicorn(no-single-promise-in-promise-methods)

Wrapping single-element array with `Promise.all()` is unnecessary.
} else if (viewer_type === "model") {
return Promise.all([modelStyleStore.setModelVisibility(id, visibility)])

Check warning on line 26 in app/stores/data_style.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint-plugin-unicorn(no-single-promise-in-promise-methods)

Wrapping single-element array with `Promise.all()` is unnecessary.
}
throw new Error("Unknown viewer_type")
}

function applyDefaultStyle(id) {
const { viewer_type } = dataBaseStore.itemMetaDatas(id)
const { viewer_type } = dataBaseStore.itemMetaDatasSync(id)
if (viewer_type === "mesh") {
return meshStyleStore.applyMeshStyle(id)
} else if (viewer_type === "model") {
return modelStyleStore.applyModelStyle(id)

Check warning on line 36 in app/stores/data_style.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-else-return)

Unnecessary `else` after `return`.
} else {
throw new Error("Unknown viewer_type: " + viewer_type)
}
Expand All @@ -57,7 +57,7 @@
const ids = Object.keys(dataStyleState.styles || {})
const promises = []
for (const id of ids) {
const meta = dataBaseStore.itemMetaDatas(id)
const meta = dataBaseStore.itemMetaDatasSync(id)
const viewerType = meta?.viewer_type
const style = dataStyleState.styles[id]
if (style && viewerType === "mesh") {
Expand Down
11 changes: 10 additions & 1 deletion app/stores/hybrid_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
if (!genericRenderWindow.value) {
return
}
const value = dataBaseStore.db[id]
const value = await dataBaseStore.itemMetaDatas(id)
console.log("hybridViewerStore.addItem", { value })
const reader = vtkXMLPolyDataReader.newInstance()
const textEncoder = new TextEncoder()
Expand All @@ -74,6 +74,14 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
db[id] = { actor, polydata, mapper }
}

async function removeItem(id) {
if (!db[id]) return
const renderer = genericRenderWindow.value.getRenderer()
renderer.removeActor(db[id].actor)
genericRenderWindow.value.getRenderWindow().render()
delete db[id]
}

async function setVisibility(id, visibility) {
db[id].actor.setVisibility(visibility)
const renderWindow = genericRenderWindow.value.getRenderWindow()
Expand Down Expand Up @@ -281,6 +289,7 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
db,
genericRenderWindow,
addItem,
removeItem,
setVisibility,
setZScaling,
syncRemoteCamera,
Expand Down
Loading
Loading