@geode/opengeodeweb-front 9.11.5 → 9.11.6-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Viewer/Options/TextureItem.vue +6 -6
- package/components/Viewer/Options/TexturesSelector.vue +5 -7
- package/composables/viewer_call.js +3 -3
- package/internal_stores/data_style_state.js +4 -1
- package/internal_stores/mesh/edges.js +30 -35
- package/internal_stores/mesh/index.js +23 -17
- package/package.json +4 -4
- package/stores/data_base.js +2 -5
- package/stores/data_style.js +3 -3
- package/tests/integration/data/uploads/test.og_edc2d +0 -0
- package/tests/integration/microservices/back/requirements-internal.in +1 -1
- package/tests/integration/microservices/back/requirements.txt +3 -101
- package/tests/integration/microservices/viewer/requirements-internal.in +1 -1
- package/tests/integration/microservices/viewer/requirements.txt +3 -156
- package/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js +91 -14
- package/utils/local.js +168 -53
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
|
|
43
43
|
const props = defineProps({
|
|
44
44
|
id: { type: String, required: true },
|
|
45
|
+
texture_id: { type: String, required: true },
|
|
45
46
|
texture_name: { type: String, required: true },
|
|
46
|
-
texture_file_name: { type: String, required: true },
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
const texture_name = ref("")
|
|
50
50
|
texture_name.value = props.texture_name
|
|
51
51
|
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const texture_id = ref("")
|
|
53
|
+
texture_id.value = props.texture_id
|
|
54
54
|
|
|
55
55
|
const texture_coordinates = ref([])
|
|
56
56
|
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
response_function: async (response) => {
|
|
89
|
-
|
|
89
|
+
texture_id.value = response._data.id
|
|
90
90
|
},
|
|
91
91
|
},
|
|
92
92
|
)
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
emit("update_value", { key: "texture_name", value })
|
|
98
98
|
})
|
|
99
99
|
|
|
100
|
-
watch(
|
|
101
|
-
emit("update_value", { key: "
|
|
100
|
+
watch(texture_id, (value) => {
|
|
101
|
+
emit("update_value", { key: "id", value })
|
|
102
102
|
})
|
|
103
103
|
</script>
|
|
104
104
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<ViewerOptionsTextureItem
|
|
19
19
|
:id="id"
|
|
20
20
|
:texture_name="internal_textures[index].texture_name"
|
|
21
|
-
:
|
|
21
|
+
:texture_id="internal_textures[index].id"
|
|
22
22
|
@update_value="update_value_event($event, index)"
|
|
23
23
|
/>
|
|
24
24
|
</v-row>
|
|
@@ -30,9 +30,7 @@
|
|
|
30
30
|
icon="mdi-plus"
|
|
31
31
|
v-tooltip:bottom="'Add a texture'"
|
|
32
32
|
size="20"
|
|
33
|
-
@click="
|
|
34
|
-
internal_textures.push({ texture_name: '', texture_file_name: '' })
|
|
35
|
-
"
|
|
33
|
+
@click="internal_textures.push({ texture_name: '', id: '' })"
|
|
36
34
|
/>
|
|
37
35
|
</v-col>
|
|
38
36
|
</v-row>
|
|
@@ -51,16 +49,16 @@
|
|
|
51
49
|
if (textures.value != null) {
|
|
52
50
|
internal_textures.value = textures.value
|
|
53
51
|
} else {
|
|
54
|
-
internal_textures.value = [{
|
|
52
|
+
internal_textures.value = [{ id: "", texture_name: "" }]
|
|
55
53
|
}
|
|
56
54
|
})
|
|
57
55
|
|
|
58
56
|
function update_value_event($event, index) {
|
|
59
57
|
internal_textures.value[index][$event.key] = $event.value
|
|
60
58
|
const filtered = internal_textures.value.filter((texture) => {
|
|
61
|
-
return texture.texture_name
|
|
59
|
+
return texture.texture_name !== "" && texture.id !== ""
|
|
62
60
|
})
|
|
63
|
-
if (filtered.length
|
|
61
|
+
if (filtered.length !== 0) {
|
|
64
62
|
textures.value = filtered
|
|
65
63
|
}
|
|
66
64
|
}
|
|
@@ -13,8 +13,8 @@ export function viewer_call(
|
|
|
13
13
|
console.log("schema", schema)
|
|
14
14
|
console.log("params", params)
|
|
15
15
|
}
|
|
16
|
-
feedback_store.add_error(400, schema
|
|
17
|
-
throw new Error(schema.
|
|
16
|
+
feedback_store.add_error(400, schema.$id, "Bad request", error)
|
|
17
|
+
throw new Error(schema.$id.concat(": "))
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const client = viewer_store.client
|
|
@@ -45,7 +45,7 @@ export function viewer_call(
|
|
|
45
45
|
.catch((error) => {
|
|
46
46
|
feedback_store.add_error(
|
|
47
47
|
error.code,
|
|
48
|
-
schema
|
|
48
|
+
schema.$id,
|
|
49
49
|
error.message,
|
|
50
50
|
error.message,
|
|
51
51
|
)
|
|
@@ -4,58 +4,56 @@ const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
|
|
|
4
4
|
export function useMeshEdgesStyle() {
|
|
5
5
|
const dataStyleStore = useDataStyleStore()
|
|
6
6
|
|
|
7
|
+
function edgesStyle(id) {
|
|
8
|
+
return dataStyleStore.getStyle(id).edges
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
function edgesVisibility(id) {
|
|
8
|
-
return
|
|
12
|
+
return edgesStyle(id).visibility
|
|
9
13
|
}
|
|
10
14
|
function setEdgesVisibility(id, visibility) {
|
|
11
|
-
const edges_style =
|
|
15
|
+
const edges_style = edgesStyle(id)
|
|
12
16
|
return viewer_call(
|
|
13
|
-
{
|
|
14
|
-
schema: mesh_edges_schemas.visibility,
|
|
15
|
-
params: { id, visibility },
|
|
16
|
-
},
|
|
17
|
+
{ schema: mesh_edges_schemas.visibility, params: { id, visibility } },
|
|
17
18
|
{
|
|
18
19
|
response_function: () => {
|
|
19
20
|
edges_style.visibility = visibility
|
|
20
|
-
console.log(`${setEdgesVisibility.name} ${
|
|
21
|
+
console.log(`${setEdgesVisibility.name} ${id} ${edgesVisibility(id)}`)
|
|
21
22
|
},
|
|
22
23
|
},
|
|
23
24
|
)
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
function edgesActiveColoring(id) {
|
|
27
|
-
return
|
|
28
|
+
return edgesStyle(id).coloring.active
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
const coloring =
|
|
31
|
-
if (type == "color") {
|
|
32
|
-
setEdgesColor(id, coloring.color)
|
|
33
|
-
// else if (type == "vertex") {
|
|
34
|
-
// const vertex = coloring.vertex
|
|
35
|
-
// if (vertex !== null) setEdgesVertexAttribute(id, vertex)
|
|
36
|
-
// } else if (type == "edges") {
|
|
37
|
-
// const edges = coloring.edges
|
|
38
|
-
// if (edges !== null) setEdgesEdgeAttribute(id, edges)
|
|
39
|
-
} else throw new Error("Unknown edges coloring type: " + type)
|
|
30
|
+
function setEdgesActiveColoring(id, type) {
|
|
31
|
+
const coloring = edgesStyle(id).coloring
|
|
40
32
|
coloring.active = type
|
|
41
|
-
console.log(
|
|
33
|
+
console.log(
|
|
34
|
+
`${setEdgesActiveColoring.name} ${id} ${edgesActiveColoring(id)}`,
|
|
35
|
+
)
|
|
36
|
+
if (type === "color") {
|
|
37
|
+
return setEdgesColor(id, coloring.color)
|
|
38
|
+
// } else if (type == "vertex" && coloring.vertex !== null) {
|
|
39
|
+
// return setEdgesVertexAttribute(id, coloring.vertex)
|
|
40
|
+
// } else if (type == "edges" && coloring.edges !== null) {
|
|
41
|
+
// return setEdgesEdgeAttribute(id, coloring.edges)
|
|
42
|
+
} else throw new Error("Unknown edges coloring type: " + type)
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function edgesColor(id) {
|
|
45
|
-
return
|
|
46
|
+
return edgesStyle(id).coloring.color
|
|
46
47
|
}
|
|
47
48
|
function setEdgesColor(id, color) {
|
|
48
|
-
const coloring_style =
|
|
49
|
+
const coloring_style = edgesStyle(id).coloring
|
|
49
50
|
return viewer_call(
|
|
50
|
-
{
|
|
51
|
-
schema: mesh_edges_schemas.color,
|
|
52
|
-
params: { id, color },
|
|
53
|
-
},
|
|
51
|
+
{ schema: mesh_edges_schemas.color, params: { id, color } },
|
|
54
52
|
{
|
|
55
53
|
response_function: () => {
|
|
56
54
|
coloring_style.color = color
|
|
57
55
|
console.log(
|
|
58
|
-
`${setEdgesColor.name} ${JSON.stringify(
|
|
56
|
+
`${setEdgesColor.name} ${id} ${JSON.stringify(edgesColor(id))}`,
|
|
59
57
|
)
|
|
60
58
|
},
|
|
61
59
|
},
|
|
@@ -63,25 +61,22 @@ export function useMeshEdgesStyle() {
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
function edgesWidth(id) {
|
|
66
|
-
return
|
|
64
|
+
return edgesStyle(id).size
|
|
67
65
|
}
|
|
68
66
|
function setEdgesWidth(id, width) {
|
|
69
|
-
const edges_style =
|
|
67
|
+
const edges_style = edgesStyle(id)
|
|
70
68
|
return viewer_call(
|
|
71
|
-
{
|
|
72
|
-
schema: mesh_edges_schemas.width,
|
|
73
|
-
params: { id, width },
|
|
74
|
-
},
|
|
69
|
+
{ schema: mesh_edges_schemas.width, params: { id, width } },
|
|
75
70
|
{
|
|
76
71
|
response_function: () => {
|
|
77
72
|
edges_style.width = width
|
|
78
|
-
console.log(`${setEdgesWidth.name} ${
|
|
73
|
+
console.log(`${setEdgesWidth.name} ${id} ${edgesWidth(id)}`)
|
|
79
74
|
},
|
|
80
75
|
},
|
|
81
76
|
)
|
|
82
77
|
}
|
|
83
78
|
|
|
84
|
-
|
|
79
|
+
function applyEdgesStyle(id, style) {
|
|
85
80
|
return Promise.all([
|
|
86
81
|
setEdgesVisibility(id, style.visibility),
|
|
87
82
|
setEdgesActiveColoring(id, style.coloring.active),
|
|
@@ -12,6 +12,9 @@ export default function useMeshStyle() {
|
|
|
12
12
|
const polyhedraStyleStore = useMeshPolyhedraStyle()
|
|
13
13
|
const hybridViewerStore = useHybridViewerStore()
|
|
14
14
|
|
|
15
|
+
function meshVisibility(id) {
|
|
16
|
+
return dataStyleStore.styles[id].visibility
|
|
17
|
+
}
|
|
15
18
|
function setMeshVisibility(id, visibility) {
|
|
16
19
|
return viewer_call(
|
|
17
20
|
{
|
|
@@ -22,32 +25,35 @@ export default function useMeshStyle() {
|
|
|
22
25
|
response_function: () => {
|
|
23
26
|
hybridViewerStore.setVisibility(id, visibility)
|
|
24
27
|
dataStyleStore.styles[id].visibility = visibility
|
|
28
|
+
console.log(`${setMeshVisibility.name} ${id} ${meshVisibility(id)}`)
|
|
25
29
|
},
|
|
26
30
|
},
|
|
27
31
|
)
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
function applyMeshDefaultStyle(id) {
|
|
35
|
+
const style = dataStyleStore.getStyle(id)
|
|
36
|
+
const promise_array = []
|
|
37
|
+
for (const [key, value] of Object.entries(style)) {
|
|
38
|
+
if (key == "visibility") {
|
|
39
|
+
promise_array.push(setMeshVisibility(id, value))
|
|
40
|
+
} else if (key == "points") {
|
|
41
|
+
promise_array.push(pointsStyleStore.applyPointsStyle(id, value))
|
|
42
|
+
} else if (key == "edges") {
|
|
43
|
+
promise_array.push(edgesStyleStore.applyEdgesStyle(id, value))
|
|
44
|
+
} else if (key == "polygons") {
|
|
45
|
+
promise_array.push(polygonsStyleStore.applyPolygonsStyle(id, value))
|
|
46
|
+
} else if (key == "polyhedra") {
|
|
47
|
+
promise_array.push(polyhedraStyleStore.applyPolyhedraStyle(id, value))
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error("Unknown key: " + key)
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
}
|
|
52
|
+
return promise_array
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
return {
|
|
56
|
+
meshVisibility,
|
|
51
57
|
setMeshVisibility,
|
|
52
58
|
applyMeshDefaultStyle,
|
|
53
59
|
...useMeshPointsStyle(),
|
package/package.json
CHANGED
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"description": "OpenSource Vue/Vuetify framework for web applications",
|
|
42
42
|
"type": "module",
|
|
43
|
-
"version": "9.11.
|
|
43
|
+
"version": "9.11.6-rc.2",
|
|
44
44
|
"main": "./nuxt.config.js",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@geode/opengeodeweb-back": "
|
|
47
|
-
"@geode/opengeodeweb-viewer": "
|
|
46
|
+
"@geode/opengeodeweb-back": "next",
|
|
47
|
+
"@geode/opengeodeweb-viewer": "next",
|
|
48
48
|
"@kitware/vtk.js": "33.3.0",
|
|
49
49
|
"@mdi/font": "7.4.47",
|
|
50
50
|
"@pinia/nuxt": "0.5.4",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"pinia": "3.0.3",
|
|
60
60
|
"sass": "1.87.0",
|
|
61
61
|
"semver": "7.7.1",
|
|
62
|
-
"tree-kill": "1.2.2",
|
|
63
62
|
"uuid": "11.1.0",
|
|
64
63
|
"vue-recaptcha": "2.0.3",
|
|
65
64
|
"vue3-carousel": "0.3.4",
|
|
66
65
|
"vuetify": "3.8.12",
|
|
66
|
+
"ws": "8.18.3",
|
|
67
67
|
"wslink": "1.12.4"
|
|
68
68
|
},
|
|
69
69
|
"repository": {
|
package/stores/data_base.js
CHANGED
|
@@ -42,10 +42,10 @@ export const useDataBaseStore = defineStore("dataBase", () => {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** Actions **/
|
|
45
|
-
async function registerObject(id,
|
|
45
|
+
async function registerObject(id, viewer_object) {
|
|
46
46
|
return viewer_call({
|
|
47
47
|
schema: viewer_schemas.opengeodeweb_viewer.generic.register,
|
|
48
|
-
params: { id,
|
|
48
|
+
params: { id, viewer_object },
|
|
49
49
|
})
|
|
50
50
|
}
|
|
51
51
|
async function addItem(
|
|
@@ -76,14 +76,11 @@ export const useDataBaseStore = defineStore("dataBase", () => {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
async function fetchMeshComponents(id) {
|
|
79
|
-
const { native_filename, geode_object } = itemMetaDatas(id)
|
|
80
79
|
await api_fetch(
|
|
81
80
|
{
|
|
82
81
|
schema: back_schemas.opengeodeweb_back.models.mesh_components,
|
|
83
82
|
params: {
|
|
84
83
|
id,
|
|
85
|
-
filename: native_filename,
|
|
86
|
-
geode_object,
|
|
87
84
|
},
|
|
88
85
|
},
|
|
89
86
|
{
|
package/stores/data_style.js
CHANGED
|
@@ -13,12 +13,12 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
|
|
|
13
13
|
function addDataStyle(id, geode_object, object_type) {
|
|
14
14
|
dataStyleState.styles[id] = getDefaultStyle(geode_object)
|
|
15
15
|
if (object_type === "mesh") {
|
|
16
|
-
return
|
|
16
|
+
return meshStyleStore.applyMeshDefaultStyle(id)
|
|
17
17
|
} else if (object_type === "model") {
|
|
18
|
-
return
|
|
18
|
+
return [
|
|
19
19
|
modelStyleStore.setMeshComponentsDefaultStyle(id),
|
|
20
20
|
modelStyleStore.applyModelDefaultStyle(id),
|
|
21
|
-
]
|
|
21
|
+
]
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
opengeodeweb-back
|
|
1
|
+
opengeodeweb-back
|
|
@@ -2,105 +2,7 @@
|
|
|
2
2
|
# This file is autogenerated by pip-compile with Python 3.12
|
|
3
3
|
# by the following command:
|
|
4
4
|
#
|
|
5
|
-
# pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements
|
|
5
|
+
# pip-compile --output-file=tests/integration/microservices/back/requirements.txt tests/integration/microservices/back/requirements.in
|
|
6
6
|
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# flask
|
|
10
|
-
# opengeodeweb-back
|
|
11
|
-
blinker~=1.9
|
|
12
|
-
# via
|
|
13
|
-
# flask
|
|
14
|
-
# opengeodeweb-back
|
|
15
|
-
# opengeodeweb-microservice
|
|
16
|
-
click~=8.3
|
|
17
|
-
# via
|
|
18
|
-
# flask
|
|
19
|
-
# opengeodeweb-back
|
|
20
|
-
# opengeodeweb-microservice
|
|
21
|
-
fastjsonschema~=2.21
|
|
22
|
-
# via
|
|
23
|
-
# opengeodeweb-back
|
|
24
|
-
# opengeodeweb-microservice
|
|
25
|
-
flask[async]~=3.0
|
|
26
|
-
# via
|
|
27
|
-
# flask-cors
|
|
28
|
-
# flask-sqlalchemy
|
|
29
|
-
# opengeodeweb-back
|
|
30
|
-
# opengeodeweb-microservice
|
|
31
|
-
flask-cors~=6.0
|
|
32
|
-
# via opengeodeweb-back
|
|
33
|
-
flask-sqlalchemy~=3.1
|
|
34
|
-
# via
|
|
35
|
-
# opengeodeweb-back
|
|
36
|
-
# opengeodeweb-microservice
|
|
37
|
-
geode-common~=33.11
|
|
38
|
-
# via
|
|
39
|
-
# geode-viewables
|
|
40
|
-
# opengeodeweb-back
|
|
41
|
-
geode-viewables~=3.3
|
|
42
|
-
# via opengeodeweb-back
|
|
43
|
-
greenlet~=3.2
|
|
44
|
-
# via
|
|
45
|
-
# opengeodeweb-back
|
|
46
|
-
# opengeodeweb-microservice
|
|
47
|
-
# sqlalchemy
|
|
48
|
-
itsdangerous~=2.2
|
|
49
|
-
# via
|
|
50
|
-
# flask
|
|
51
|
-
# opengeodeweb-back
|
|
52
|
-
# opengeodeweb-microservice
|
|
53
|
-
jinja2~=3.1
|
|
54
|
-
# via
|
|
55
|
-
# flask
|
|
56
|
-
# opengeodeweb-back
|
|
57
|
-
# opengeodeweb-microservice
|
|
58
|
-
markupsafe~=3.0
|
|
59
|
-
# via
|
|
60
|
-
# jinja2
|
|
61
|
-
# opengeodeweb-back
|
|
62
|
-
# opengeodeweb-microservice
|
|
63
|
-
# werkzeug
|
|
64
|
-
opengeode-core~=15.27
|
|
65
|
-
# via
|
|
66
|
-
# geode-common
|
|
67
|
-
# geode-viewables
|
|
68
|
-
# opengeode-geosciences
|
|
69
|
-
# opengeode-geosciencesio
|
|
70
|
-
# opengeode-inspector
|
|
71
|
-
# opengeode-io
|
|
72
|
-
# opengeodeweb-back
|
|
73
|
-
opengeode-geosciences~=9.4
|
|
74
|
-
# via
|
|
75
|
-
# geode-viewables
|
|
76
|
-
# opengeode-geosciencesio
|
|
77
|
-
# opengeodeweb-back
|
|
78
|
-
opengeode-geosciencesio~=5.8
|
|
79
|
-
# via opengeodeweb-back
|
|
80
|
-
opengeode-inspector~=6.8
|
|
81
|
-
# via opengeodeweb-back
|
|
82
|
-
opengeode-io~=7.4
|
|
83
|
-
# via
|
|
84
|
-
# geode-viewables
|
|
85
|
-
# opengeode-geosciencesio
|
|
86
|
-
# opengeodeweb-back
|
|
87
|
-
opengeodeweb-back~=5.10,>=5.10.1
|
|
88
|
-
# via -r tests/integration/microservices/back/requirements-internal.in
|
|
89
|
-
opengeodeweb-microservice~=1.0
|
|
90
|
-
# via opengeodeweb-back
|
|
91
|
-
sqlalchemy~=2.0
|
|
92
|
-
# via
|
|
93
|
-
# flask-sqlalchemy
|
|
94
|
-
# opengeodeweb-back
|
|
95
|
-
# opengeodeweb-microservice
|
|
96
|
-
typing-extensions~=4.15
|
|
97
|
-
# via
|
|
98
|
-
# opengeodeweb-back
|
|
99
|
-
# opengeodeweb-microservice
|
|
100
|
-
# sqlalchemy
|
|
101
|
-
werkzeug~=3.0
|
|
102
|
-
# via
|
|
103
|
-
# flask
|
|
104
|
-
# flask-cors
|
|
105
|
-
# opengeodeweb-back
|
|
106
|
-
# opengeodeweb-microservice
|
|
7
|
+
|
|
8
|
+
opengeodeweb-back==5.*,>=5.10.3rc18
|
|
@@ -1 +1 @@
|
|
|
1
|
-
opengeodeweb-viewer
|
|
1
|
+
opengeodeweb-viewer
|
|
@@ -2,160 +2,7 @@
|
|
|
2
2
|
# This file is autogenerated by pip-compile with Python 3.12
|
|
3
3
|
# by the following command:
|
|
4
4
|
#
|
|
5
|
-
# pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements
|
|
5
|
+
# pip-compile --output-file=tests/integration/microservices/viewer/requirements.txt tests/integration/microservices/viewer/requirements.in
|
|
6
6
|
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# aiohttp
|
|
10
|
-
# opengeodeweb-viewer
|
|
11
|
-
aiohttp~=3.12
|
|
12
|
-
# via
|
|
13
|
-
# opengeodeweb-viewer
|
|
14
|
-
# wslink
|
|
15
|
-
aiosignal~=1.4
|
|
16
|
-
# via
|
|
17
|
-
# aiohttp
|
|
18
|
-
# opengeodeweb-viewer
|
|
19
|
-
attrs~=25.3
|
|
20
|
-
# via
|
|
21
|
-
# aiohttp
|
|
22
|
-
# opengeodeweb-viewer
|
|
23
|
-
blinker~=1.9
|
|
24
|
-
# via
|
|
25
|
-
# flask
|
|
26
|
-
# opengeodeweb-microservice
|
|
27
|
-
# opengeodeweb-viewer
|
|
28
|
-
click~=8.3
|
|
29
|
-
# via
|
|
30
|
-
# flask
|
|
31
|
-
# opengeodeweb-microservice
|
|
32
|
-
# opengeodeweb-viewer
|
|
33
|
-
contourpy~=1.3
|
|
34
|
-
# via
|
|
35
|
-
# matplotlib
|
|
36
|
-
# opengeodeweb-viewer
|
|
37
|
-
cycler~=0.12
|
|
38
|
-
# via
|
|
39
|
-
# matplotlib
|
|
40
|
-
# opengeodeweb-viewer
|
|
41
|
-
fastjsonschema~=2.21
|
|
42
|
-
# via
|
|
43
|
-
# opengeodeweb-microservice
|
|
44
|
-
# opengeodeweb-viewer
|
|
45
|
-
flask~=3.1
|
|
46
|
-
# via
|
|
47
|
-
# flask-sqlalchemy
|
|
48
|
-
# opengeodeweb-microservice
|
|
49
|
-
# opengeodeweb-viewer
|
|
50
|
-
flask-sqlalchemy~=3.1
|
|
51
|
-
# via
|
|
52
|
-
# opengeodeweb-microservice
|
|
53
|
-
# opengeodeweb-viewer
|
|
54
|
-
fonttools~=4.60
|
|
55
|
-
# via
|
|
56
|
-
# matplotlib
|
|
57
|
-
# opengeodeweb-viewer
|
|
58
|
-
frozenlist~=1.7
|
|
59
|
-
# via
|
|
60
|
-
# aiohttp
|
|
61
|
-
# aiosignal
|
|
62
|
-
# opengeodeweb-viewer
|
|
63
|
-
greenlet~=3.2
|
|
64
|
-
# via
|
|
65
|
-
# opengeodeweb-microservice
|
|
66
|
-
# opengeodeweb-viewer
|
|
67
|
-
# sqlalchemy
|
|
68
|
-
idna==3.10
|
|
69
|
-
# via
|
|
70
|
-
# opengeodeweb-viewer
|
|
71
|
-
# yarl
|
|
72
|
-
itsdangerous~=2.2
|
|
73
|
-
# via
|
|
74
|
-
# flask
|
|
75
|
-
# opengeodeweb-microservice
|
|
76
|
-
# opengeodeweb-viewer
|
|
77
|
-
jinja2~=3.1
|
|
78
|
-
# via
|
|
79
|
-
# flask
|
|
80
|
-
# opengeodeweb-microservice
|
|
81
|
-
# opengeodeweb-viewer
|
|
82
|
-
kiwisolver~=1.4
|
|
83
|
-
# via
|
|
84
|
-
# matplotlib
|
|
85
|
-
# opengeodeweb-viewer
|
|
86
|
-
markupsafe~=3.0
|
|
87
|
-
# via
|
|
88
|
-
# flask
|
|
89
|
-
# jinja2
|
|
90
|
-
# opengeodeweb-microservice
|
|
91
|
-
# opengeodeweb-viewer
|
|
92
|
-
# werkzeug
|
|
93
|
-
matplotlib~=3.10
|
|
94
|
-
# via
|
|
95
|
-
# opengeodeweb-viewer
|
|
96
|
-
# vtk
|
|
97
|
-
multidict~=6.6
|
|
98
|
-
# via
|
|
99
|
-
# aiohttp
|
|
100
|
-
# opengeodeweb-viewer
|
|
101
|
-
# yarl
|
|
102
|
-
numpy~=2.3
|
|
103
|
-
# via
|
|
104
|
-
# contourpy
|
|
105
|
-
# matplotlib
|
|
106
|
-
# opengeodeweb-viewer
|
|
107
|
-
opengeodeweb-microservice~=1.0
|
|
108
|
-
# via opengeodeweb-viewer
|
|
109
|
-
opengeodeweb-viewer[cpu]~=1.11
|
|
110
|
-
# via -r tests/integration/microservices/viewer/requirements-internal.in
|
|
111
|
-
packaging==25.0
|
|
112
|
-
# via
|
|
113
|
-
# matplotlib
|
|
114
|
-
# opengeodeweb-viewer
|
|
115
|
-
pillow~=11.3
|
|
116
|
-
# via
|
|
117
|
-
# matplotlib
|
|
118
|
-
# opengeodeweb-viewer
|
|
119
|
-
propcache~=0.3
|
|
120
|
-
# via
|
|
121
|
-
# aiohttp
|
|
122
|
-
# opengeodeweb-viewer
|
|
123
|
-
# yarl
|
|
124
|
-
pyparsing~=3.2
|
|
125
|
-
# via
|
|
126
|
-
# matplotlib
|
|
127
|
-
# opengeodeweb-viewer
|
|
128
|
-
python-dateutil==2.9.0.post0
|
|
129
|
-
# via
|
|
130
|
-
# matplotlib
|
|
131
|
-
# opengeodeweb-viewer
|
|
132
|
-
six~=1.17
|
|
133
|
-
# via
|
|
134
|
-
# opengeodeweb-viewer
|
|
135
|
-
# python-dateutil
|
|
136
|
-
sqlalchemy~=2.0
|
|
137
|
-
# via
|
|
138
|
-
# flask-sqlalchemy
|
|
139
|
-
# opengeodeweb-microservice
|
|
140
|
-
# opengeodeweb-viewer
|
|
141
|
-
typing-extensions~=4.15
|
|
142
|
-
# via
|
|
143
|
-
# aiosignal
|
|
144
|
-
# opengeodeweb-microservice
|
|
145
|
-
# opengeodeweb-viewer
|
|
146
|
-
# sqlalchemy
|
|
147
|
-
vtk~=9.5
|
|
148
|
-
# via opengeodeweb-viewer
|
|
149
|
-
websocket-client~=1.8
|
|
150
|
-
# via opengeodeweb-viewer
|
|
151
|
-
werkzeug~=3.1
|
|
152
|
-
# via
|
|
153
|
-
# flask
|
|
154
|
-
# opengeodeweb-microservice
|
|
155
|
-
# opengeodeweb-viewer
|
|
156
|
-
wslink~=1.12
|
|
157
|
-
# via opengeodeweb-viewer
|
|
158
|
-
yarl~=1.20
|
|
159
|
-
# via
|
|
160
|
-
# aiohttp
|
|
161
|
-
# opengeodeweb-viewer
|
|
7
|
+
|
|
8
|
+
opengeodeweb-viewer==1.*,>=1.11.3rc9
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "path"
|
|
2
|
+
import fs from "fs"
|
|
2
3
|
|
|
3
4
|
import { setActivePinia } from "pinia"
|
|
4
5
|
import { createTestingPinia } from "@pinia/testing"
|
|
@@ -17,19 +18,25 @@ import {
|
|
|
17
18
|
import {
|
|
18
19
|
executable_name,
|
|
19
20
|
executable_path,
|
|
20
|
-
kill_processes,
|
|
21
21
|
run_viewer,
|
|
22
|
+
run_back,
|
|
23
|
+
kill_viewer,
|
|
24
|
+
kill_back,
|
|
22
25
|
} from "@ogw_f/utils/local"
|
|
23
26
|
|
|
24
27
|
import Status from "@ogw_f/utils/status"
|
|
25
28
|
|
|
29
|
+
import { api_fetch } from "@ogw_f/composables/api_fetch"
|
|
26
30
|
import * as composables from "@ogw_f/composables/viewer_call"
|
|
27
31
|
import { useDataStyleStore } from "@ogw_f/stores/data_style"
|
|
28
32
|
import { useDataBaseStore } from "@ogw_f/stores/data_base"
|
|
29
33
|
import { useViewerStore } from "@ogw_f/stores/viewer"
|
|
30
34
|
import { useInfraStore } from "@ogw_f/stores/infra"
|
|
35
|
+
import { useGeodeStore } from "@ogw_f/stores/geode"
|
|
31
36
|
|
|
32
37
|
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"
|
|
33
40
|
import { WebSocket } from "ws"
|
|
34
41
|
|
|
35
42
|
const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
|
|
@@ -45,18 +52,50 @@ vi.stubGlobal("navigator", {
|
|
|
45
52
|
},
|
|
46
53
|
})
|
|
47
54
|
|
|
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
|
+
|
|
48
86
|
beforeAll(() => {
|
|
49
87
|
global.WebSocket = WebSocket
|
|
88
|
+
foldersBeforeTests = getCurrentFolders(data_folder_path)
|
|
50
89
|
})
|
|
51
90
|
|
|
52
91
|
afterAll(() => {
|
|
53
92
|
delete global.WebSocket
|
|
93
|
+
cleanupCreatedFolders(data_folder_path, foldersBeforeTests)
|
|
54
94
|
})
|
|
55
95
|
|
|
56
|
-
|
|
57
|
-
const file_name = "
|
|
96
|
+
let id = "fake_id"
|
|
97
|
+
const file_name = "test.og_edc2d"
|
|
58
98
|
const geode_object = "EdgedCurve2D"
|
|
59
|
-
const object_type = "mesh"
|
|
60
99
|
|
|
61
100
|
beforeEach(async () => {
|
|
62
101
|
const pinia = createTestingPinia({
|
|
@@ -66,33 +105,71 @@ beforeEach(async () => {
|
|
|
66
105
|
setActivePinia(pinia)
|
|
67
106
|
const dataStyleStore = useDataStyleStore()
|
|
68
107
|
const dataBaseStore = useDataBaseStore()
|
|
108
|
+
const geodeStore = useGeodeStore()
|
|
69
109
|
const viewerStore = useViewerStore()
|
|
70
110
|
const infraStore = useInfraStore()
|
|
71
|
-
infraStore.app_mode = appMode.
|
|
111
|
+
infraStore.app_mode = appMode.BROWSER
|
|
112
|
+
|
|
113
|
+
if (!fs.existsSync(data_folder_path)) {
|
|
114
|
+
fs.mkdirSync(data_folder_path, { recursive: true })
|
|
115
|
+
}
|
|
72
116
|
|
|
117
|
+
const back_path = path.join(
|
|
118
|
+
executable_path(path.join("tests", "integration", "microservices", "back")),
|
|
119
|
+
executable_name("opengeodeweb-back"),
|
|
120
|
+
)
|
|
73
121
|
const viewer_path = path.join(
|
|
74
122
|
executable_path(
|
|
75
123
|
path.join("tests", "integration", "microservices", "viewer"),
|
|
76
124
|
),
|
|
77
|
-
executable_name("
|
|
125
|
+
executable_name("opengeodeweb-viewer"),
|
|
78
126
|
)
|
|
79
|
-
|
|
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, {
|
|
80
134
|
port: 1234,
|
|
81
|
-
data_folder_path
|
|
135
|
+
data_folder_path,
|
|
82
136
|
})
|
|
83
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
|
|
84
144
|
viewerStore.default_local_port = viewer_port
|
|
85
145
|
await viewerStore.ws_connect()
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
|
|
88
160
|
expect(viewerStore.status).toBe(Status.CONNECTED)
|
|
89
161
|
}, 15000)
|
|
90
162
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
})
|
|
95
171
|
|
|
172
|
+
describe("Mesh edges", () => {
|
|
96
173
|
describe("Edges visibility", () => {
|
|
97
174
|
test("test visibility true", async () => {
|
|
98
175
|
const dataStyleStore = useDataStyleStore()
|
package/utils/local.js
CHANGED
|
@@ -2,22 +2,15 @@
|
|
|
2
2
|
import fs from "fs"
|
|
3
3
|
import path from "path"
|
|
4
4
|
import child_process from "child_process"
|
|
5
|
+
import WebSocket from "ws"
|
|
5
6
|
|
|
6
7
|
// Third party imports
|
|
7
8
|
import pkg from "electron"
|
|
8
9
|
const { app, dialog } = pkg
|
|
9
10
|
import { getPort } from "get-port-please"
|
|
10
|
-
import kill from "tree-kill"
|
|
11
11
|
import isElectron from "is-electron"
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
|
|
16
|
-
const __dirname = path.dirname(__filename) // get the name of the directory
|
|
17
|
-
console.log("__dirname", __dirname)
|
|
18
|
-
|
|
19
|
-
// Global variables
|
|
20
|
-
var processes = []
|
|
12
|
+
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" }
|
|
13
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" with { type: "json" }
|
|
21
14
|
|
|
22
15
|
function venv_script_path(root_path, microservice_path) {
|
|
23
16
|
const venv_path = path.join(root_path, microservice_path, "venv")
|
|
@@ -30,15 +23,16 @@ function venv_script_path(root_path, microservice_path) {
|
|
|
30
23
|
return script_path
|
|
31
24
|
}
|
|
32
25
|
|
|
33
|
-
function executable_path(microservice_path
|
|
34
|
-
if (root_path != null) return venv_script_path(root_path, microservice_path)
|
|
26
|
+
function executable_path(microservice_path) {
|
|
35
27
|
if (isElectron()) {
|
|
36
28
|
if (app.isPackaged) {
|
|
37
29
|
return process.resourcesPath
|
|
30
|
+
} else {
|
|
31
|
+
return venv_script_path(app.getAppPath(), microservice_path)
|
|
38
32
|
}
|
|
39
|
-
|
|
33
|
+
} else {
|
|
34
|
+
return venv_script_path(process.cwd(), microservice_path)
|
|
40
35
|
}
|
|
41
|
-
return venv_script_path(process.cwd(), microservice_path)
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
function executable_name(name) {
|
|
@@ -50,40 +44,21 @@ function executable_name(name) {
|
|
|
50
44
|
|
|
51
45
|
function create_path(path) {
|
|
52
46
|
if (!fs.existsSync(path)) {
|
|
53
|
-
fs.
|
|
54
|
-
|
|
55
|
-
return console.error(err)
|
|
56
|
-
}
|
|
57
|
-
console.log(`${path} directory created successfully!`)
|
|
58
|
-
})
|
|
47
|
+
fs.mkdirSync(path, { recursive: true })
|
|
48
|
+
console.log(`${path} directory created successfully!`)
|
|
59
49
|
}
|
|
60
50
|
return path
|
|
61
51
|
}
|
|
62
52
|
|
|
63
53
|
async function get_available_port(port) {
|
|
64
|
-
const available_port = await getPort({
|
|
54
|
+
const available_port = await getPort({
|
|
55
|
+
port,
|
|
56
|
+
host: "localhost",
|
|
57
|
+
})
|
|
65
58
|
console.log("available_port", available_port)
|
|
66
59
|
return available_port
|
|
67
60
|
}
|
|
68
61
|
|
|
69
|
-
async function kill_processes() {
|
|
70
|
-
console.log("kill_processes", processes)
|
|
71
|
-
await processes.forEach(async function (proc) {
|
|
72
|
-
console.log(`Process ${proc} will be killed!`)
|
|
73
|
-
try {
|
|
74
|
-
kill(proc)
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.log(`${error} Process ${proc} could not be killed!`)
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function register_process(proc) {
|
|
82
|
-
if (!processes.includes(proc.pid)) {
|
|
83
|
-
processes.push(proc.pid)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
62
|
async function run_script(
|
|
88
63
|
command,
|
|
89
64
|
args,
|
|
@@ -98,7 +73,6 @@ async function run_script(
|
|
|
98
73
|
encoding: "utf8",
|
|
99
74
|
shell: true,
|
|
100
75
|
})
|
|
101
|
-
register_process(child)
|
|
102
76
|
|
|
103
77
|
// You can also use a variable to save the output for when the script closes later
|
|
104
78
|
child.stderr.setEncoding("utf8")
|
|
@@ -118,7 +92,7 @@ async function run_script(
|
|
|
118
92
|
}
|
|
119
93
|
console.log(data)
|
|
120
94
|
})
|
|
121
|
-
|
|
95
|
+
|
|
122
96
|
child.stderr.on("data", (data) => {
|
|
123
97
|
console.log(data)
|
|
124
98
|
})
|
|
@@ -131,28 +105,27 @@ async function run_script(
|
|
|
131
105
|
console.log("Child Process killed")
|
|
132
106
|
})
|
|
133
107
|
child.name = command.replace(/^.*[\\/]/, "")
|
|
108
|
+
return child
|
|
134
109
|
})
|
|
135
110
|
}
|
|
136
111
|
|
|
137
|
-
async function run_back(port, data_folder_path) {
|
|
112
|
+
async function run_back(command, args = { port, data_folder_path }) {
|
|
138
113
|
return new Promise(async (resolve, reject) => {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
executable_name("vease-back"),
|
|
142
|
-
)
|
|
143
|
-
const back_port = await get_available_port(port)
|
|
114
|
+
const back_port = await get_available_port(args.port)
|
|
115
|
+
const upload_folder_path = path.join(args.data_folder_path, "uploads")
|
|
144
116
|
const back_args = [
|
|
145
117
|
"--port " + back_port,
|
|
146
|
-
"--data_folder_path " + data_folder_path,
|
|
118
|
+
"--data_folder_path " + args.data_folder_path,
|
|
119
|
+
"--upload_folder_path " + upload_folder_path,
|
|
147
120
|
"--allowed_origin http://localhost:*",
|
|
148
121
|
"--timeout " + 0,
|
|
149
122
|
]
|
|
150
|
-
await run_script(
|
|
123
|
+
await run_script(command, back_args, "Serving Flask app")
|
|
151
124
|
resolve(back_port)
|
|
152
125
|
})
|
|
153
126
|
}
|
|
154
127
|
|
|
155
|
-
async function run_viewer(
|
|
128
|
+
async function run_viewer(command, args = { port, data_folder_path }) {
|
|
156
129
|
return new Promise(async (resolve, reject) => {
|
|
157
130
|
const viewer_port = await get_available_port(args.port)
|
|
158
131
|
const viewer_args = [
|
|
@@ -160,19 +133,161 @@ async function run_viewer(viewer_path, args = { port, data_folder_path }) {
|
|
|
160
133
|
"--data_folder_path " + args.data_folder_path,
|
|
161
134
|
"--timeout " + 0,
|
|
162
135
|
]
|
|
163
|
-
await run_script(
|
|
136
|
+
await run_script(command, viewer_args, "Starting factory")
|
|
164
137
|
resolve(viewer_port)
|
|
165
138
|
})
|
|
166
139
|
}
|
|
167
140
|
|
|
141
|
+
function delete_folder_recursive(data_folder_path) {
|
|
142
|
+
if (!fs.existsSync(data_folder_path)) {
|
|
143
|
+
console.log(`Folder ${data_folder_path} does not exist.`)
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
fs.rmSync(data_folder_path, { recursive: true, force: true })
|
|
148
|
+
console.log(`Deleted folder: ${data_folder_path}`)
|
|
149
|
+
} catch (err) {
|
|
150
|
+
console.error(`Error deleting folder ${data_folder_path}:`, err)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function kill_back(back_port) {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
console.log("back_schemas", back_schemas)
|
|
157
|
+
|
|
158
|
+
fetch(
|
|
159
|
+
"http://localhost:" +
|
|
160
|
+
back_port +
|
|
161
|
+
"/" +
|
|
162
|
+
back_schemas.opengeodeweb_back.kill.$id,
|
|
163
|
+
{
|
|
164
|
+
method: back_schemas.opengeodeweb_back.kill.methods[0],
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
.then(() => {
|
|
168
|
+
console.log("Back not killed")
|
|
169
|
+
reject()
|
|
170
|
+
})
|
|
171
|
+
.catch(() => {
|
|
172
|
+
console.log("Back closed")
|
|
173
|
+
resolve()
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function kill_viewer(viewer_port) {
|
|
179
|
+
return new Promise((resolve, reject) => {
|
|
180
|
+
const socket = new WebSocket("ws://localhost:" + viewer_port + "/ws")
|
|
181
|
+
socket.on("open", () => {
|
|
182
|
+
console.log("Connected to WebSocket server")
|
|
183
|
+
socket.send(
|
|
184
|
+
JSON.stringify({
|
|
185
|
+
id: "system:hello",
|
|
186
|
+
method: "wslink.hello",
|
|
187
|
+
args: [{ secret: "wslink-secret" }],
|
|
188
|
+
}),
|
|
189
|
+
)
|
|
190
|
+
})
|
|
191
|
+
socket.on("message", (data) => {
|
|
192
|
+
const message = data.toString()
|
|
193
|
+
console.log("Received from server:", message)
|
|
194
|
+
if (message.includes("hello")) {
|
|
195
|
+
try {
|
|
196
|
+
console.log("viewer_schemas", viewer_schemas)
|
|
197
|
+
socket.send(
|
|
198
|
+
JSON.stringify({
|
|
199
|
+
id: viewer_schemas.opengeodeweb_viewer.kill.$id,
|
|
200
|
+
method: viewer_schemas.opengeodeweb_viewer.kill.$id,
|
|
201
|
+
}),
|
|
202
|
+
)
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error("WebSocket error:", error)
|
|
205
|
+
resolve()
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
socket.on("close", () => {
|
|
210
|
+
console.log("Disconnected from WebSocket server")
|
|
211
|
+
resolve()
|
|
212
|
+
})
|
|
213
|
+
socket.on("error", (error) => {
|
|
214
|
+
console.error("WebSocket error:", error)
|
|
215
|
+
resolve()
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async function run_browser(
|
|
221
|
+
script_name,
|
|
222
|
+
microservices_options = {
|
|
223
|
+
back: { command, args: { port: 5000, data_folder_path } },
|
|
224
|
+
viewer: { command, args: { port: 1234, data_folder_path } },
|
|
225
|
+
},
|
|
226
|
+
) {
|
|
227
|
+
console.log("microservices_options", microservices_options)
|
|
228
|
+
const back_promise = run_back(microservices_options.back.command, {
|
|
229
|
+
...microservices_options.back.args,
|
|
230
|
+
})
|
|
231
|
+
console.log("back_promise", back_promise)
|
|
232
|
+
|
|
233
|
+
const viewer_promise = run_viewer(microservices_options.viewer.command, {
|
|
234
|
+
...microservices_options.viewer.args,
|
|
235
|
+
})
|
|
236
|
+
console.log("viewer_promise", viewer_promise)
|
|
237
|
+
|
|
238
|
+
const [back_port, viewer_port] = await Promise.all([
|
|
239
|
+
back_promise,
|
|
240
|
+
viewer_promise,
|
|
241
|
+
])
|
|
242
|
+
process.env.GEODE_PORT = back_port
|
|
243
|
+
process.env.VIEWER_PORT = viewer_port
|
|
244
|
+
console.log("back_port", back_port)
|
|
245
|
+
console.log("viewer_port", viewer_port)
|
|
246
|
+
|
|
247
|
+
process.env.BROWSER = true
|
|
248
|
+
process.on("SIGINT", async () => {
|
|
249
|
+
console.log("Shutting down microservices")
|
|
250
|
+
await Promise.all([
|
|
251
|
+
kill_back(process.env.GEODE_PORT),
|
|
252
|
+
kill_viewer(process.env.VIEWER_PORT),
|
|
253
|
+
])
|
|
254
|
+
console.log("Quitting App...")
|
|
255
|
+
process.exit(0)
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
const nuxt_port = await get_available_port()
|
|
259
|
+
console.log("nuxt_port", nuxt_port)
|
|
260
|
+
|
|
261
|
+
process.env.NUXT_PORT = nuxt_port
|
|
262
|
+
const nuxt_process = child_process.spawn("npm", ["run", script_name], {
|
|
263
|
+
shell: true,
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
return new Promise((resolve, reject) => {
|
|
267
|
+
nuxt_process.stdout.on("data", function (data) {
|
|
268
|
+
const output = data.toString()
|
|
269
|
+
const portMatch = output.match(
|
|
270
|
+
/Accepting\ connections\ at\ http:\/\/localhost:(\d+)/,
|
|
271
|
+
)
|
|
272
|
+
console.log("Nuxt: ", output)
|
|
273
|
+
if (portMatch) {
|
|
274
|
+
resolve(portMatch[1])
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
168
281
|
export {
|
|
169
282
|
create_path,
|
|
283
|
+
delete_folder_recursive,
|
|
170
284
|
executable_name,
|
|
171
285
|
executable_path,
|
|
172
286
|
get_available_port,
|
|
173
|
-
|
|
174
|
-
|
|
287
|
+
kill_back,
|
|
288
|
+
kill_viewer,
|
|
175
289
|
run_script,
|
|
176
290
|
run_back,
|
|
177
291
|
run_viewer,
|
|
292
|
+
run_browser,
|
|
178
293
|
}
|