Skip to content

Commit 1e38e27

Browse files
authored
Merge pull request #239 from Geode-solutions/fix/database
Fix/database
2 parents 9e8276d + dbbc49f commit 1e38e27

File tree

8 files changed

+107
-35
lines changed

8 files changed

+107
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ venv
2727
.pytest_cache
2828
__snapshots__
2929
coverage
30+
*.db
3031
# package-lock.json

components/Viewer/Options/TextureItem.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
4343
const props = defineProps({
4444
id: { type: String, required: true },
45+
texture_id: { type: String, required: true },
4546
texture_name: { type: String, required: true },
46-
texture_file_name: { type: String, required: true },
4747
})
4848
4949
const texture_name = ref("")
5050
texture_name.value = props.texture_name
5151
52-
const texture_file_name = ref("")
53-
texture_file_name.value = props.texture_file_name
52+
const texture_id = ref("")
53+
texture_id.value = props.texture_id
5454
5555
const texture_coordinates = ref([])
5656
@@ -86,7 +86,7 @@
8686
},
8787
{
8888
response_function: async (response) => {
89-
texture_file_name.value = response._data.viewable_file_name
89+
texture_id.value = response._data.id
9090
},
9191
},
9292
)
@@ -97,8 +97,8 @@
9797
emit("update_value", { key: "texture_name", value })
9898
})
9999
100-
watch(texture_file_name, (value) => {
101-
emit("update_value", { key: "texture_file_name", value })
100+
watch(texture_id, (value) => {
101+
emit("update_value", { key: "id", value })
102102
})
103103
</script>
104104

components/Viewer/Options/TexturesSelector.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<ViewerOptionsTextureItem
1919
:id="id"
2020
:texture_name="internal_textures[index].texture_name"
21-
:texture_file_name="internal_textures[index].texture_file_name"
21+
:texture_id="internal_textures[index].id"
2222
@update_value="update_value_event($event, index)"
2323
/>
2424
</v-row>
@@ -30,9 +30,7 @@
3030
icon="mdi-plus"
3131
v-tooltip:bottom="'Add a texture'"
3232
size="20"
33-
@click="
34-
internal_textures.push({ texture_name: '', texture_file_name: '' })
35-
"
33+
@click="internal_textures.push({ texture_name: '', id: '' })"
3634
/>
3735
</v-col>
3836
</v-row>
@@ -51,16 +49,16 @@
5149
if (textures.value != null) {
5250
internal_textures.value = textures.value
5351
} else {
54-
internal_textures.value = [{ texture_name: "", texture_file_name: "" }]
52+
internal_textures.value = [{ id: "", texture_name: "" }]
5553
}
5654
})
5755
5856
function update_value_event($event, index) {
5957
internal_textures.value[index][$event.key] = $event.value
6058
const filtered = internal_textures.value.filter((texture) => {
61-
return texture.texture_name != "" && texture.texture_file_name != ""
59+
return texture.texture_name !== "" && texture.id !== ""
6260
})
63-
if (filtered.length != 0) {
61+
if (filtered.length !== 0) {
6462
textures.value = filtered
6563
}
6664
}

stores/data_base.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export const useDataBaseStore = defineStore("dataBase", () => {
4242
}
4343

4444
/** Actions **/
45-
async function registerObject(id, file_name, viewer_object) {
45+
async function registerObject(id, viewer_object) {
4646
return viewer_call({
4747
schema: viewer_schemas.opengeodeweb_viewer.generic.register,
48-
params: { id, file_name, viewer_object },
48+
params: { id, viewer_object },
4949
})
5050
}
5151
async function addItem(
@@ -76,14 +76,11 @@ export const useDataBaseStore = defineStore("dataBase", () => {
7676
}
7777

7878
async function fetchMeshComponents(id) {
79-
const { native_filename, geode_object } = itemMetaDatas(id)
8079
await api_fetch(
8180
{
8281
schema: back_schemas.opengeodeweb_back.models.mesh_components,
8382
params: {
8483
id,
85-
filename: native_filename,
86-
geode_object,
8784
},
8885
},
8986
{
573 Bytes
Binary file not shown.

tests/integration/microservices/back/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
# pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in
66
#
77

8-
opengeodeweb-back==5.*,>=5.10.3rc16

tests/integration/microservices/viewer/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
# pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
66
#
77

8-
opengeodeweb-viewer==1.*,>=1.11.3rc7

tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js

Lines changed: 93 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from "path"
2+
import fs from "fs"
23

34
import { setActivePinia } from "pinia"
45
import { createTestingPinia } from "@pinia/testing"
@@ -17,19 +18,25 @@ import {
1718
import {
1819
executable_name,
1920
executable_path,
20-
kill_viewer,
2121
run_viewer,
22+
run_back,
23+
kill_viewer,
24+
kill_back,
2225
} from "@ogw_f/utils/local"
2326

2427
import Status from "@ogw_f/utils/status"
2528

29+
import { api_fetch } from "@ogw_f/composables/api_fetch"
2630
import * as composables from "@ogw_f/composables/viewer_call"
2731
import { useDataStyleStore } from "@ogw_f/stores/data_style"
2832
import { useDataBaseStore } from "@ogw_f/stores/data_base"
2933
import { useViewerStore } from "@ogw_f/stores/viewer"
3034
import { useInfraStore } from "@ogw_f/stores/infra"
35+
import { useGeodeStore } from "@ogw_f/stores/geode"
3136

3237
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
38+
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json"
39+
import appMode from "@ogw_f/utils/app_mode"
3340
import { WebSocket } from "ws"
3441

3542
const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
@@ -45,18 +52,50 @@ vi.stubGlobal("navigator", {
4552
},
4653
})
4754

55+
let foldersBeforeTests = new Set()
56+
const data_folder_path = path.join(__dirname, "..", "..", "..", "data")
57+
58+
function getCurrentFolders(dataFolderPath) {
59+
if (!fs.existsSync(dataFolderPath)) {
60+
return new Set()
61+
}
62+
const entries = fs.readdirSync(dataFolderPath)
63+
const folders = new Set()
64+
for (const entry of entries) {
65+
const entryPath = path.join(dataFolderPath, entry)
66+
if (fs.statSync(entryPath).isDirectory()) {
67+
folders.add(entry)
68+
}
69+
}
70+
return folders
71+
}
72+
73+
function cleanupCreatedFolders(dataFolderPath, foldersBeforeTests) {
74+
if (!fs.existsSync(dataFolderPath)) {
75+
return
76+
}
77+
const currentFolders = getCurrentFolders(dataFolderPath)
78+
for (const folder of currentFolders) {
79+
if (!foldersBeforeTests.has(folder)) {
80+
const folderPath = path.join(dataFolderPath, folder)
81+
fs.rmSync(folderPath, { recursive: true, force: true })
82+
}
83+
}
84+
}
85+
4886
beforeAll(() => {
4987
global.WebSocket = WebSocket
88+
foldersBeforeTests = getCurrentFolders(data_folder_path)
5089
})
5190

5291
afterAll(() => {
5392
delete global.WebSocket
93+
cleanupCreatedFolders(data_folder_path, foldersBeforeTests)
5494
})
5595

56-
const id = "fake_id"
57-
const file_name = "edged_curve.vtp"
96+
let id = "fake_id"
97+
const file_name = "test.og_edc2d"
5898
const geode_object = "EdgedCurve2D"
59-
const object_type = "mesh"
6099

61100
beforeEach(async () => {
62101
const pinia = createTestingPinia({
@@ -66,32 +105,71 @@ beforeEach(async () => {
66105
setActivePinia(pinia)
67106
const dataStyleStore = useDataStyleStore()
68107
const dataBaseStore = useDataBaseStore()
108+
const geodeStore = useGeodeStore()
69109
const viewerStore = useViewerStore()
70110
const infraStore = useInfraStore()
71-
infraStore.app_mode = appMode.appMode.BROWSER
111+
infraStore.app_mode = appMode.BROWSER
112+
113+
if (!fs.existsSync(data_folder_path)) {
114+
fs.mkdirSync(data_folder_path, { recursive: true })
115+
}
116+
117+
const back_path = path.join(
118+
executable_path(path.join("tests", "integration", "microservices", "back")),
119+
executable_name("opengeodeweb-back"),
120+
)
72121
const viewer_path = path.join(
73122
executable_path(
74123
path.join("tests", "integration", "microservices", "viewer"),
75124
),
76-
executable_name("opengeodeweb_viewer"),
125+
executable_name("opengeodeweb-viewer"),
77126
)
78-
const viewer_port = await run_viewer(viewer_path, {
127+
128+
const back_promise = run_back(back_path, {
129+
port: 5000,
130+
data_folder_path,
131+
})
132+
133+
const viewer_promise = run_viewer(viewer_path, {
79134
port: 1234,
80-
data_folder_path: path.join(__dirname, "..", "..", "..", "data"),
135+
data_folder_path,
81136
})
137+
138+
const [back_port, viewer_port] = await Promise.all([
139+
back_promise,
140+
viewer_promise,
141+
])
142+
console.log("Viewer path:", viewer_path)
143+
geodeStore.default_local_port = back_port
82144
viewerStore.default_local_port = viewer_port
83145
await viewerStore.ws_connect()
84-
await dataBaseStore.registerObject(id, file_name, object_type)
85-
await dataStyleStore.addDataStyle(id, geode_object, object_type)
146+
console.log("schema", back_schemas.opengeodeweb_back.save_viewable_file)
147+
148+
const response = await api_fetch({
149+
schema: back_schemas.opengeodeweb_back.save_viewable_file,
150+
params: {
151+
input_geode_object: geode_object,
152+
filename: file_name,
153+
},
154+
})
155+
id = response.data.value.id
156+
157+
await dataBaseStore.registerObject(id, "mesh")
158+
await dataStyleStore.addDataStyle(id, geode_object, "mesh")
159+
86160
expect(viewerStore.status).toBe(Status.CONNECTED)
87161
}, 15000)
88162

89-
describe("Mesh edges", () => {
90-
afterEach(async () => {
91-
const viewerStore = useViewerStore()
92-
await kill_viewer(viewerStore.default_local_port)
93-
})
163+
afterEach(async () => {
164+
const viewerStore = useViewerStore()
165+
const geodeStore = useGeodeStore()
166+
await Promise.all([
167+
kill_viewer(viewerStore.default_local_port),
168+
kill_back(geodeStore.default_local_port),
169+
])
170+
})
94171

172+
describe("Mesh edges", () => {
95173
describe("Edges visibility", () => {
96174
test("test visibility true", async () => {
97175
const dataStyleStore = useDataStyleStore()

0 commit comments

Comments
 (0)