Skip to content

Commit 15125bc

Browse files
remove logs
1 parent 72b328b commit 15125bc

File tree

4 files changed

+37
-53
lines changed

4 files changed

+37
-53
lines changed

composables/api_fetch.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ export function api_fetch(
2929
if (schema.max_retry) {
3030
request_options.max_retry = schema.max_retry
3131
}
32-
3332
return new Promise((resolve, reject) => {
34-
return useFetch(schema.$id, {
33+
useFetch(schema.$id, {
3534
baseURL: geode_store.base_url,
3635
...request_options,
3736
async onRequestError({ error }) {

stores/feedback.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ export const use_feedback_store = defineStore("feedback", {
2323
await this.feedbacks.splice(feedback_index, 1)
2424
},
2525
async delete_server_error() {
26-
console.group("delete_server_error")
27-
this.$patch({ server_error: false })
28-
// this.server_error = false
26+
this.server_error = false
2927
},
3028
},
3129
})

stores/geode.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,19 @@ export const use_geode_store = defineStore("geode", {
4545
await api_fetch(
4646
{ schema: back_schemas.opengeodeweb_back.ping, params: {} },
4747
{
48-
request_error_function: () => {
49-
feedback_store.$patch({ server_error: true })
48+
request_error_function: async () => {
49+
await feedback_store.$patch({ server_error: true })
50+
this.is_running = false
5051
},
51-
response_function: () => {
52+
response_function: async () => {
5253
this.is_running = true
5354
},
54-
response_error_function: () => {
55-
feedback_store.$patch({ server_error: true })
55+
response_error_function: async () => {
56+
await feedback_store.$patch({ server_error: true })
57+
this.is_running = false
5658
},
5759
},
5860
)
59-
// return new Promise((resolve, reject) => {
60-
// useFetch(schemas.opengeodeweb_back.ping, {
61-
// baseURL: this.base_url,
62-
// method: "POST",
63-
// onRequestError({ error }) {
64-
// feedback_store.$patch({ server_error: true })
65-
// reject(error)
66-
// },
67-
// onResponse({ response }) {
68-
// if (response.ok) {
69-
// this.is_running = true
70-
// resolve(response)
71-
// }
72-
// },
73-
// onResponseError({ response }) {
74-
// feedback_store.$patch({ server_error: true })
75-
// reject(response)
76-
// },
77-
// })
78-
// })
7961
},
8062
start_request() {
8163
this.request_counter++

stores/infra.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,27 @@ export const use_infra_store = defineStore("infra", {
1111
is_cloud() {
1212
return !isElectron() && !process.env.NODE_ENV === "development"
1313
},
14-
domain_name() {
15-
if (this.is_cloud) {
14+
domain_name(state) {
15+
if (state.is_cloud) {
1616
return useRuntimeConfig().public.API_URL
1717
} else {
1818
return "localhost"
1919
}
2020
},
21+
lambda_url(state) {
22+
const geode_store = use_geode_store()
23+
const public_runtime_config = useRuntimeConfig().public
24+
const url =
25+
geode_store.protocol +
26+
"://" +
27+
state.domain_name +
28+
":" +
29+
geode_store.port +
30+
public_runtime_config.SITE_BRANCH +
31+
public_runtime_config.PROJECT +
32+
"/createbackend"
33+
return url
34+
},
2135
is_running() {
2236
return use_geode_store().is_running && use_viewer_store().is_running
2337
},
@@ -32,21 +46,14 @@ export const use_infra_store = defineStore("infra", {
3246
return
3347
}
3448
this.is_connexion_launched = true
35-
if (
36-
this.ID === "" ||
37-
this.ID === null ||
38-
typeof this.ID === "undefined"
39-
) {
49+
if (["", null].includes(this.ID) || typeof this.ID === "undefined") {
4050
return this.create_backend()
4151
} else {
42-
const { data, error } = await useFetch(`${geode_store.base_url}/`, {
43-
method: "POST",
44-
})
45-
if (data.value !== null) {
46-
geode_store.is_running = true
52+
try {
53+
await geode_store.do_ping()
4754
return geode_store.ping_task()
48-
} else {
49-
await this.create_backend()
55+
} catch (e) {
56+
return this.create_backend()
5057
}
5158
}
5259
},
@@ -56,17 +63,15 @@ export const use_infra_store = defineStore("infra", {
5663
const feedback_store = use_feedback_store()
5764

5865
if (isElectron()) {
59-
await window.electronAPI.run_back(geode_store.PORT)
60-
await window.electronAPI.run_viewer(viewer_store.PORT)
66+
const back_port = await window.electronAPI.run_back(geode_store.port)
67+
geode_store.$patch({ default_local_port: back_port })
68+
const viewer_port = await window.electronAPI.run_viewer(
69+
viewer_store.port,
70+
)
71+
viewer_store.$patch({ default_local_port: viewer_port })
6172
return
6273
} else {
63-
const public_runtime_config = useRuntimeConfig().public
64-
const url = this.api_url.concat(
65-
public_runtime_config.SITE_BRANCH,
66-
public_runtime_config.PROJECT,
67-
"/createbackend",
68-
)
69-
const { data, error } = await useFetch(url, {
74+
const { data, error } = await useFetch(this.lambda_url, {
7075
method: "POST",
7176
})
7277
if (data.value !== null) {

0 commit comments

Comments
 (0)