Skip to content

Commit 20bca49

Browse files
Merge pull request #141 from Geode-solutions/next
Next
2 parents b6054a7 + 2e2007c commit 20bca49

File tree

6 files changed

+33
-35
lines changed

6 files changed

+33
-35
lines changed

components/FeedBack/Snackers.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
transition="slide-x-reverse-transition"
1010
max-width="200px"
1111
height="20px"
12+
timeout="10000"
1213
>
1314
<v-row dense class="flex-nowrap">
1415
<v-col cols="auto">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"version": "0.0.0-semantically-released",
4141
"main": "./nuxt.config.js",
4242
"dependencies": {
43-
"@geode/opengeodeweb-back": "5.0.0",
43+
"@geode/opengeodeweb-back": "5.1.0",
4444
"@geode/opengeodeweb-viewer": "0.2.0",
4545
"@kitware/vtk.js": "30.3.1",
4646
"@mdi/font": "^7.4.47",

stores/geode.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,39 @@ export const use_geode_store = defineStore("geode", {
3232
}
3333
return geode_url
3434
},
35-
is_busy(state) {
36-
return state.request_counter > 0
35+
is_busy() {
36+
return this.request_counter > 0
3737
},
3838
},
3939
actions: {
4040
ping_task() {
41-
setInterval(() => this.do_ping(), 10 * 1000)
41+
setInterval(() => {
42+
if (this.is_running) {
43+
this.do_ping()
44+
}
45+
}, 10 * 1000)
4246
},
4347
async do_ping() {
4448
const feedback_store = use_feedback_store()
45-
await api_fetch(
46-
{ schema: back_schemas.opengeodeweb_back.ping, params: {} },
47-
{
48-
request_error_function: async () => {
49+
return new Promise((resolve, reject) => {
50+
useFetch(back_schemas.opengeodeweb_back.ping.$id, {
51+
baseURL: this.base_url,
52+
method: back_schemas.opengeodeweb_back.ping.methods[0],
53+
async onRequestError() {
4954
await feedback_store.$patch({ server_error: true })
5055
this.is_running = false
56+
reject()
5157
},
52-
response_function: async () => {
53-
this.is_running = true
58+
async onResponse() {
59+
resolve()
5460
},
55-
response_error_function: async () => {
61+
async onResponseError() {
5662
await feedback_store.$patch({ server_error: true })
5763
this.is_running = false
64+
reject()
5865
},
59-
},
60-
)
66+
})
67+
})
6168
},
6269
start_request() {
6370
this.request_counter++

stores/infra.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const use_infra_store = defineStore("infra", {
99
}),
1010
getters: {
1111
is_cloud() {
12-
return !isElectron() && !process.env.NODE_ENV === "development"
12+
return (
13+
!isElectron() && useRuntimeConfig().public.NODE_ENV === "production"
14+
)
1315
},
1416
domain_name() {
1517
if (this.is_cloud) {
@@ -41,21 +43,11 @@ export const use_infra_store = defineStore("infra", {
4143
},
4244
actions: {
4345
async create_connexion() {
44-
const geode_store = use_geode_store()
4546
if (this.is_connexion_launched) {
4647
return
4748
}
4849
this.is_connexion_launched = true
49-
if (["", null].includes(this.ID) || typeof this.ID === "undefined") {
50-
return this.create_backend()
51-
} else {
52-
try {
53-
await geode_store.do_ping()
54-
return geode_store.ping_task()
55-
} catch (e) {
56-
return this.create_backend()
57-
}
58-
}
50+
return this.create_backend()
5951
},
6052
async create_backend() {
6153
const geode_store = use_geode_store()

stores/viewer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ export const use_viewer_store = defineStore("viewer", {
2121
return "ws"
2222
}
2323
},
24-
port(state) {
24+
port() {
2525
if (use_infra_store().is_cloud) {
2626
return "443"
2727
} else {
28-
return state.default_local_port
28+
return this.default_local_port
2929
}
3030
},
31-
base_url(state) {
31+
base_url() {
3232
const infra_store = use_infra_store()
33-
let viewer_url = `${state.protocol}://${infra_store.domain_name}:${state.port}`
33+
let viewer_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
3434
if (infra_store.is_cloud) {
3535
if (infra_store.ID == "") {
3636
throw new Error("ID must not be empty in cloud mode")
@@ -40,8 +40,8 @@ export const use_viewer_store = defineStore("viewer", {
4040
viewer_url += "/ws"
4141
return viewer_url
4242
},
43-
is_busy(state) {
44-
return state.request_counter > 0
43+
is_busy() {
44+
return this.request_counter > 0
4545
},
4646
},
4747
actions: {

test/stores/Geode.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,18 @@ describe("Geode Store", () => {
9999
describe("do_ping", () => {
100100
test("request_error", async () => {
101101
geode_store.base_url = ""
102-
geode_store.is_running = true
103102
try {
104103
await geode_store.do_ping()
105104
} catch (e) {
106-
console.log(e)
105+
console.log("e", e)
107106
}
108-
109107
expect(geode_store.is_running).toBe(false)
110108
expect(feedback_store.server_error).toBe(true)
111-
expect(feedback_store.feedbacks.length).toBe(1)
112109
})
113110

114111
test("response", async () => {
115112
geode_store.base_url = ""
113+
geode_store.is_running = true
116114
registerEndpoint(back_schemas.opengeodeweb_back.ping.$id, {
117115
method: "POST",
118116
handler: () => ({}),

0 commit comments

Comments
 (0)