Skip to content

Commit 4b74caf

Browse files
fix(watches): stores props
1 parent d7b6044 commit 4b74caf

File tree

5 files changed

+57
-47
lines changed

5 files changed

+57
-47
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+
async (value, oldValue) => {
30+
if (value && !oldValue && process.client) {
31+
await infra_store.create_backend()
32+
}
33+
},
34+
)
35+
36+
onMounted(async () => {
37+
if (infra_store.is_captcha_validated) {
38+
await infra_store.create_backend()
3339
}
3440
})
3541
</script>

components/PackagesVersions.vue

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

2121
<script setup>
22-
const infra_store = use_infra_store()
23-
const { is_running } = storeToRefs(infra_store)
24-
2522
const props = defineProps({
2623
schema: { type: Object, required: true },
2724
})
@@ -53,9 +50,12 @@
5350
await Promise.all(array_promise)
5451
}
5552
56-
watch(is_running, () => {
57-
get_packages_versions()
58-
})
53+
watch(
54+
() => geode_store.status,
55+
(value) => {
56+
if (value == Status.CONNECTED) get_packages_versions()
57+
},
58+
)
5959
6060
await get_packages_versions()
6161
</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: 30 additions & 25 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>
@@ -25,10 +25,12 @@
2525
import { useElementSize, useWindowSize } from "@vueuse/core"
2626
import viewer_schemas from "@geode/opengeodeweb-viewer/schemas.json"
2727
28-
const viewer_store = use_viewer_store()
29-
const { client, is_running, picking_mode } = storeToRefs(viewer_store)
28+
const props = defineProps({
29+
viewId: { type: String, default: "-1" },
30+
})
3031
31-
const viewer = ref(null)
32+
const viewer_store = use_viewer_store()
33+
const viewer = useTemplateRef("viewer")
3234
const { width, height } = useElementSize(viewer)
3335
3436
const { width: windowWidth, height: windowHeight } = useWindowSize()
@@ -44,13 +46,7 @@
4446
}
4547
}
4648
47-
const props = defineProps({
48-
viewId: { type: String, default: "-1" },
49-
})
50-
51-
const { viewId } = toRefs(props)
5249
const connected = ref(false)
53-
5450
const view = vtkRemoteView.newInstance({
5551
rpcWheelEvent: "viewport.mouse.zoom.wheel",
5652
})
@@ -70,33 +66,42 @@
7066
resize()
7167
})
7268
73-
watch(picking_mode, (value) => {
74-
const cursor = value ? "crosshair" : "pointer"
75-
view.getCanvasView().setCursor(cursor)
76-
})
69+
watch(
70+
() => viewer_store.picking_mode,
71+
(value) => {
72+
const cursor = value ? "crosshair" : "pointer"
73+
view.getCanvasView().setCursor(cursor)
74+
},
75+
)
7776
7877
watch([width, height], () => {
7978
resize()
8079
})
8180
82-
watch(client, () => {
83-
connect()
84-
})
85-
86-
watch(viewId, (id) => {
87-
if (connected.value) {
88-
view.setViewId(id)
89-
view.render()
90-
}
91-
})
81+
watch(
82+
() => viewer_store.client,
83+
() => {
84+
connect()
85+
},
86+
)
87+
88+
watch(
89+
() => props.viewId,
90+
(id) => {
91+
if (connected.value) {
92+
view.setViewId(id)
93+
view.render()
94+
}
95+
},
96+
)
9297
9398
function connect() {
9499
if (!is_running.value) {
95100
return
96101
}
97102
const session = client.value.getConnection().getSession()
98103
view.setSession(session)
99-
view.setViewId(viewId.value)
104+
view.setViewId(props.viewId)
100105
connected.value = true
101106
view.render()
102107
}

stores/infra.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import isElectron from "is-electron"
44
export const use_infra_store = defineStore("infra", {
55
state: () => ({
66
ID: useStorage("ID", ""),
7-
is_captcha_validated: false,
8-
is_connexion_launched: false,
7+
is_captcha_validated:
8+
is_cloud() || process.env.NODE_ENV === "development" ? true : false,
9+
status: Status.NOT_CREATED,
910
}),
1011
getters: {
1112
is_cloud() {

0 commit comments

Comments
 (0)