Skip to content

Commit 395b70b

Browse files
Merge branch 'next' of https://github.com/Geode-solutions/OpenGeodeWeb-Front into feat/feedbacks_timeout
2 parents 8767e5a + 23df5fa commit 395b70b

21 files changed

+350
-273
lines changed

components/Launcher.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<v-container class="justify">
33
<v-row align-content="center" align="center">
44
<v-col
5-
v-if="!is_captcha_validated"
5+
v-if="!infra_store.is_captcha_validated"
66
class="align"
77
cols="12"
88
align-self="center"
@@ -11,25 +11,31 @@
1111
<h4 class="pb-3">Please complete the recaptcha to launch the app</h4>
1212
<Recaptcha :site_key="site_key" />
1313
</v-col>
14-
<v-col v-else-if="!is_running && is_connexion_launched">
14+
<v-col v-else-if="infra_store.status == Status.CREATING">
1515
<Loading />
1616
</v-col>
1717
</v-row>
1818
</v-container>
1919
</template>
2020

2121
<script setup>
22-
const viewer_store = use_viewer_store()
23-
const infra_store = use_infra_store()
24-
const { is_captcha_validated, is_connexion_launched, is_running } =
25-
storeToRefs(infra_store)
22+
import Status from "@/utils/status.js"
2623
24+
const infra_store = use_infra_store()
2725
const site_key = useRuntimeConfig().public.RECAPTCHA_SITE_KEY
2826
29-
watch(is_captcha_validated, async (value) => {
30-
if (value === true && process.client) {
31-
await infra_store.create_connexion()
32-
await viewer_store.ws_connect()
27+
watch(
28+
() => infra_store.is_captcha_validated,
29+
(value, oldValue) => {
30+
if (value && !oldValue && process.client) {
31+
infra_store.create_backend()
32+
}
33+
},
34+
)
35+
36+
onMounted(() => {
37+
if (infra_store.is_captcha_validated) {
38+
infra_store.create_backend()
3339
}
3440
})
3541
</script>

components/Loading.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<v-col cols="12" class="ma-3">
44
<v-card loading>
55
<v-card-title class="text-center">
6-
Cloud instance is starting...
6+
Microservices are starting...
77
</v-card-title>
88
<v-card-subtitle class="text-center">
99
Why do you have to wait?
1010
</v-card-subtitle>
1111
<v-card-text class="text-center">
12-
We start our server only on demand... and this takes a few minutes
13-
before you can use our free app.
12+
We start our microservices only on demand... and this takes a few
13+
minutes before you can use our free app.
1414
<br />
1515
This is aligned with our energy sobriety policy. So be patient
1616
<v-icon color="primary" size="20">

components/PackagesVersions.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@
1919
</template>
2020

2121
<script setup>
22-
const infra_store = use_infra_store()
23-
const { is_running } = storeToRefs(infra_store)
22+
import Status from "@/utils/status.js"
2423
2524
const props = defineProps({
2625
schema: { type: Object, required: true },
2726
})
28-
const { schema } = props
2927
28+
const geode_store = use_geode_store()
3029
const packages_versions = ref([])
3130
3231
async function get_packages_versions() {
3332
const array_promise = []
3433
3534
const promise = new Promise((resolve, reject) => {
3635
api_fetch(
37-
{ schema },
36+
{ schema: props.schema },
3837
{
3938
request_error_function: () => {
4039
reject()
@@ -53,9 +52,12 @@
5352
await Promise.all(array_promise)
5453
}
5554
56-
watch(is_running, () => {
57-
get_packages_versions()
58-
})
55+
watch(
56+
() => geode_store.status,
57+
(value) => {
58+
if (value == Status.CONNECTED) get_packages_versions()
59+
},
60+
)
5961
6062
await get_packages_versions()
6163
</script>

components/Recaptcha.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<ClientOnly>
33
<vue-recaptcha
44
ref="recaptcha"
5-
:sitekey="site_key"
5+
:sitekey="props.site_key"
66
:load-recaptcha-script="true"
77
align-self="center"
8-
@expired="is_captcha_validated = false"
8+
@expired="infra_store.is_captcha_validated = false"
99
@verify="submit_recaptcha"
1010
/>
1111
</ClientOnly>
@@ -14,12 +14,10 @@
1414
<script setup>
1515
import { VueRecaptcha } from "vue-recaptcha"
1616
const infra_store = use_infra_store()
17-
const { is_captcha_validated } = storeToRefs(infra_store)
1817
1918
const props = defineProps({
2019
site_key: { type: String, required: true },
2120
})
22-
const { site_key } = props
2321
2422
onMounted(() => {
2523
if (process.client) {

components/RemoteRenderingView.vue

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"
1515
class="pa-0"
1616
@click="get_x_y"
17-
@keydown.esc="app_store.toggle_picking_mode(false)"
17+
@keydown.esc="viewer_store.toggle_picking_mode(false)"
1818
/>
1919
</div>
2020
</ClientOnly>
@@ -24,17 +24,20 @@
2424
import vtkRemoteView from "@kitware/vtk.js/Rendering/Misc/RemoteView"
2525
import { useElementSize, useWindowSize } from "@vueuse/core"
2626
import viewer_schemas from "@geode/opengeodeweb-viewer/schemas.json"
27+
import Status from "@/utils/status.js"
2728
28-
const viewer_store = use_viewer_store()
29-
const { client, is_running, picking_mode } = storeToRefs(viewer_store)
29+
const props = defineProps({
30+
viewId: { type: String, default: "-1" },
31+
})
3032
31-
const viewer = ref(null)
33+
const viewer_store = use_viewer_store()
34+
const viewer = useTemplateRef("viewer")
3235
const { width, height } = useElementSize(viewer)
3336
3437
const { width: windowWidth, height: windowHeight } = useWindowSize()
3538
3639
function get_x_y(event) {
37-
if (picking_mode.value === true) {
40+
if (viewer_store.picking_mode.value === true) {
3841
const { offsetX, offsetY } = event
3942
viewer_store.set_picked_point(offsetX, offsetY)
4043
viewer_call({
@@ -44,13 +47,7 @@
4447
}
4548
}
4649
47-
const props = defineProps({
48-
viewId: { type: String, default: "-1" },
49-
})
50-
51-
const { viewId } = toRefs(props)
5250
const connected = ref(false)
53-
5451
const view = vtkRemoteView.newInstance({
5552
rpcWheelEvent: "viewport.mouse.zoom.wheel",
5653
})
@@ -70,33 +67,42 @@
7067
resize()
7168
})
7269
73-
watch(picking_mode, (value) => {
74-
const cursor = value ? "crosshair" : "pointer"
75-
view.getCanvasView().setCursor(cursor)
76-
})
70+
watch(
71+
() => viewer_store.picking_mode,
72+
(value) => {
73+
const cursor = value ? "crosshair" : "pointer"
74+
view.getCanvasView().setCursor(cursor)
75+
},
76+
)
7777
7878
watch([width, height], () => {
7979
resize()
8080
})
8181
82-
watch(client, () => {
83-
connect()
84-
})
85-
86-
watch(viewId, (id) => {
87-
if (connected.value) {
88-
view.setViewId(id)
89-
view.render()
90-
}
91-
})
82+
watch(
83+
() => viewer_store.client,
84+
() => {
85+
connect()
86+
},
87+
)
88+
89+
watch(
90+
() => props.viewId,
91+
(id) => {
92+
if (connected.value) {
93+
view.setViewId(id)
94+
view.render()
95+
}
96+
},
97+
)
9298
9399
function connect() {
94-
if (!is_running.value) {
100+
if (viewer_store.status !== Status.CONNECTED) {
95101
return
96102
}
97-
const session = client.value.getConnection().getSession()
103+
const session = viewer_store.client.value.getConnection().getSession()
98104
view.setSession(session)
99-
view.setViewId(viewId.value)
105+
view.setViewId(props.viewId)
100106
connected.value = true
101107
view.render()
102108
}

components/Wrapper.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<template>
22
<v-container>
33
<v-row class="flex-column">
4-
<v-col v-if="!is_running">
5-
<Launcher />
6-
</v-col>
7-
<v-col v-if="is_running">
8-
<Stepper />
9-
</v-col>
10-
<v-col v-if="is_running">
11-
<PackagesVersions :schema="versions_schema" />
12-
</v-col>
4+
<template v-if="!infra_store.microservices_connected">
5+
<v-col>
6+
<Launcher />
7+
</v-col>
8+
</template>
9+
<template v-else>
10+
<v-col>
11+
<Stepper />
12+
</v-col>
13+
<v-col> <PackagesVersions :schema="versions_schema" /> </v-col>
14+
</template>
1315
</v-row>
1416
</v-container>
1517
</template>
1618

1719
<script setup>
1820
const infra_store = use_infra_store()
19-
const { is_running } = storeToRefs(infra_store)
2021
2122
const props = defineProps({
2223
versions_schema: { type: Object, required: true },

composables/run_function_when_infra_running.js

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export function run_function_when_microservices_connected(function_to_run) {
2+
const infra_store = use_infra_store()
3+
const { microservices_connected } = storeToRefs(infra_store)
4+
if (microservices_connected.value) {
5+
function_to_run()
6+
} else {
7+
watch(microservices_connected, (value) => {
8+
if (value) {
9+
function_to_run()
10+
}
11+
})
12+
}
13+
}
14+
15+
export default run_function_when_microservices_connected

nuxt.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default defineNuxtConfig({
3939
"ajv",
4040
"fast-deep-equal",
4141
"globalthis",
42+
"h3",
4243
"is-electron",
4344
"js-file-download",
4445
"lodash",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@nuxt/test-utils": "^3.15.1",
1111
"@pinia/testing": "^0.1.7",
1212
"@vitejs/plugin-vue": "^5.2.1",
13+
"@vitest/coverage-v8": "^3.0.8",
1314
"@vue/test-utils": "^2.4.6",
1415
"eslint": "^8.57.0",
1516
"eslint-plugin-import": "^2.29.1",

0 commit comments

Comments
 (0)