@geode/opengeodeweb-front 9.8.3 → 9.9.0-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.
@@ -27,7 +27,7 @@
27
27
  watch(
28
28
  () => infra_store.is_captcha_validated,
29
29
  (value, oldValue) => {
30
- if (value && !oldValue && process.client) {
30
+ if (value && !oldValue && import.meta.client) {
31
31
  infra_store.create_backend()
32
32
  }
33
33
  },
@@ -20,14 +20,15 @@
20
20
  })
21
21
 
22
22
  onMounted(() => {
23
- if (process.client) {
24
- const config = useRuntimeConfig()
25
- if (config.public.NODE_ENV !== "production" || !infra_store.is_cloud) {
23
+ if (import.meta.client) {
24
+ if (
25
+ process.env.NODE_ENV !== "production" ||
26
+ !infra_store.app_mode !== appMode.appMode.CLOUD
27
+ ) {
26
28
  infra_store.$patch({ is_captcha_validated: true })
27
29
  }
28
30
  }
29
31
  })
30
-
31
32
  async function submit_recaptcha(token) {
32
33
  try {
33
34
  const response = await $fetch.raw(
@@ -108,7 +108,7 @@
108
108
  }
109
109
 
110
110
  onMounted(async () => {
111
- if (process.client) {
111
+ if (import.meta.client) {
112
112
  window.addEventListener("resize", resize)
113
113
  await nextTick()
114
114
  view.setContainer(viewer.value.$el)
@@ -12,6 +12,11 @@ export function api_fetch(
12
12
  const { valid, error } = validate_schema(schema, body)
13
13
 
14
14
  if (!valid) {
15
+ if (process.env.NODE_ENV === "development") {
16
+ console.log("Bad request", error, schema, params)
17
+ console.log("schema", schema)
18
+ console.log("params", params)
19
+ }
15
20
  feedback_store.add_error(400, schema.$id, "Bad request", error)
16
21
  throw new Error(schema.$id.concat(": ", error))
17
22
  }
@@ -8,6 +8,11 @@ export function viewer_call(
8
8
  const { valid, error } = validate_schema(schema, params)
9
9
 
10
10
  if (!valid) {
11
+ if (process.env.NODE_ENV === "development") {
12
+ console.log("Bad request", error, schema, params)
13
+ console.log("schema", schema)
14
+ console.log("params", params)
15
+ }
11
16
  feedback_store.add_error(400, schema.route, "Bad request", error)
12
17
  throw new Error(schema.route.concat(": ", error))
13
18
  }
package/nuxt.config.js CHANGED
@@ -5,7 +5,9 @@ export default defineNuxtConfig({
5
5
  SITE_BRANCH:
6
6
  process.env.NODE_ENV === "production" ? process.env.SITE_BRANCH : "",
7
7
  PROJECT: process.env.NODE_ENV === "production" ? process.env.PROJECT : "",
8
- NODE_ENV: process.env.NODE_ENV,
8
+ BROWSER: process.env.BROWSER ?? false,
9
+ GEODE_PORT: process.env.GEODE_PORT ?? null,
10
+ VIEWER_PORT: process.env.VIEWER_PORT ?? null,
9
11
  },
10
12
  },
11
13
 
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "description": "OpenSource Vue/Vuetify framework for web applications",
36
36
  "type": "module",
37
- "version": "9.8.3",
37
+ "version": "9.9.0-rc.2",
38
38
  "main": "./nuxt.config.js",
39
39
  "dependencies": {
40
40
  "@geode/opengeodeweb-back": "5.8.7",
package/stores/geode.js CHANGED
@@ -9,21 +9,25 @@ export const use_geode_store = defineStore("geode", {
9
9
  }),
10
10
  getters: {
11
11
  protocol() {
12
- if (use_infra_store().is_cloud) {
12
+ if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
13
13
  return "https"
14
14
  }
15
15
  return "http"
16
16
  },
17
17
  port() {
18
- if (use_infra_store().is_cloud) {
18
+ if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
19
19
  return "443"
20
20
  }
21
+ const GEODE_PORT = useRuntimeConfig().public.GEODE_PORT
22
+ if (GEODE_PORT != null && GEODE_PORT !== "") {
23
+ return GEODE_PORT
24
+ }
21
25
  return this.default_local_port
22
26
  },
23
27
  base_url() {
24
28
  const infra_store = use_infra_store()
25
29
  let geode_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
26
- if (infra_store.is_cloud) {
30
+ if (infra_store.app_mode == appMode.appMode.CLOUD) {
27
31
  if (infra_store.ID == "") {
28
32
  throw new Error("ID must not be empty in cloud mode")
29
33
  }
package/stores/infra.js CHANGED
@@ -1,25 +1,19 @@
1
1
  import { useStorage } from "@vueuse/core"
2
- import isElectron from "is-electron"
3
2
  import Status from "@ogw_f/utils/status.js"
4
3
 
5
4
  export const use_infra_store = defineStore("infra", {
6
5
  state: () => ({
6
+ app_mode: getAppMode(),
7
7
  ID: useStorage("ID", ""),
8
8
  is_captcha_validated: false,
9
9
  status: Status.NOT_CREATED,
10
10
  }),
11
11
  getters: {
12
- is_cloud() {
13
- return (
14
- !isElectron() && useRuntimeConfig().public.NODE_ENV === "production"
15
- )
16
- },
17
12
  domain_name() {
18
- if (this.is_cloud) {
13
+ if (this.app_mode == appMode.appMode.CLOUD) {
19
14
  return useRuntimeConfig().public.API_URL
20
- } else {
21
- return "localhost"
22
15
  }
16
+ return "localhost"
23
17
  },
24
18
  lambda_url() {
25
19
  const geode_store = use_geode_store()
@@ -47,27 +41,30 @@ export const use_infra_store = defineStore("infra", {
47
41
  },
48
42
  actions: {
49
43
  async create_backend() {
44
+ console.log("create_backend this.app_mode", this.app_mode)
50
45
  if (this.status === Status.CREATED) return
51
46
  return navigator.locks.request("infra.create_backend", async (lock) => {
52
47
  this.status = Status.CREATING
53
48
  if (this.status === Status.CREATED) return
54
49
  console.log("LOCK GRANTED !", lock)
55
- const geode_store = use_geode_store()
56
- const viewer_store = use_viewer_store()
57
- const feedback_store = use_feedback_store()
58
- if (isElectron()) {
59
- const back_port = await window.electronAPI.run_back(geode_store.port)
50
+ if (this.app_mode == appMode.appMode.DESKTOP) {
51
+ const viewer_store = use_viewer_store()
52
+ const geode_store = use_geode_store()
53
+ const back_port = await window.electronAPI.run_back(
54
+ geode_store.default_local_port,
55
+ )
60
56
  geode_store.$patch({ default_local_port: back_port })
61
57
  const viewer_port = await window.electronAPI.run_viewer(
62
- viewer_store.port,
58
+ viewer_store.default_local_port,
63
59
  )
64
60
  viewer_store.$patch({ default_local_port: viewer_port })
65
- } else {
61
+ } else if (this.app_mode == appMode.appMode.CLOUD) {
66
62
  const { data, error } = await useFetch(this.lambda_url, {
67
63
  method: "POST",
68
64
  })
69
65
  if (error.value || !data.value) {
70
66
  this.status = Status.NOT_CREATED
67
+ const feedback_store = use_feedback_store()
71
68
  feedback_store.server_error = true
72
69
  return
73
70
  }
@@ -79,6 +76,7 @@ export const use_infra_store = defineStore("infra", {
79
76
  })
80
77
  },
81
78
  async create_connection() {
79
+ console.log("create_connection")
82
80
  await use_viewer_store().ws_connect()
83
81
  await use_geode_store().do_ping()
84
82
  return
package/stores/viewer.js CHANGED
@@ -16,23 +16,26 @@ export const use_viewer_store = defineStore("viewer", {
16
16
  }),
17
17
  getters: {
18
18
  protocol() {
19
- if (use_infra_store().is_cloud) {
19
+ if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
20
20
  return "wss"
21
21
  } else {
22
22
  return "ws"
23
23
  }
24
24
  },
25
25
  port() {
26
- if (use_infra_store().is_cloud) {
26
+ if (use_infra_store().app_mode == appMode.appMode.CLOUD) {
27
27
  return "443"
28
- } else {
29
- return this.default_local_port
30
28
  }
29
+ const VIEWER_PORT = useRuntimeConfig().public.VIEWER_PORT
30
+ if (VIEWER_PORT != null && VIEWER_PORT !== "") {
31
+ return VIEWER_PORT
32
+ }
33
+ return this.default_local_port
31
34
  },
32
35
  base_url() {
33
36
  const infra_store = use_infra_store()
34
37
  let viewer_url = `${this.protocol}://${infra_store.domain_name}:${this.port}`
35
- if (infra_store.is_cloud) {
38
+ if (infra_store.app_mode == appMode.appMode.CLOUD) {
36
39
  if (infra_store.ID == "") {
37
40
  throw new Error("ID must not be empty in cloud mode")
38
41
  }
@@ -31,7 +31,7 @@ global.ResizeObserver = require("resize-observer-polyfill")
31
31
 
32
32
  describe("Launcher.vue", async () => {
33
33
  test(`Mount`, async () => {
34
- const spy_infra_store = vi.spyOn(infra_store, "create_backend")
34
+ const spy_create_backend = vi.spyOn(infra_store, "create_backend")
35
35
  const wrapper = await mountSuspended(Launcher, {
36
36
  global: {
37
37
  plugins: [vuetify],
@@ -40,6 +40,6 @@ describe("Launcher.vue", async () => {
40
40
  expect(wrapper.exists()).toBe(true)
41
41
  await infra_store.$patch({ is_captcha_validated: true })
42
42
  flushPromises()
43
- expect(spy_infra_store).toHaveBeenCalled()
43
+ expect(spy_create_backend).toHaveBeenCalled()
44
44
  })
45
45
  })
@@ -30,50 +30,57 @@ describe("Geode Store", () => {
30
30
 
31
31
  describe("getters", () => {
32
32
  describe("protocol", () => {
33
- test("test is_cloud true", () => {
34
- infra_store.is_cloud = true
33
+ test("test app_mode CLOUD", () => {
34
+ infra_store.app_mode = appMode.appMode.CLOUD
35
35
  expect(geode_store.protocol).toBe("https")
36
36
  })
37
-
38
- test("test is_cloud false", () => {
39
- infra_store.is_cloud = false
37
+ test("test app_mode BROWSER", () => {
38
+ infra_store.app_mode = appMode.appMode.BROWSER
39
+ expect(geode_store.protocol).toBe("http")
40
+ })
41
+ test("test app_mode DESKTOP", () => {
42
+ infra_store.app_mode = appMode.appMode.DESKTOP
40
43
  expect(geode_store.protocol).toBe("http")
41
44
  })
42
45
  })
43
46
 
44
47
  describe("port", () => {
45
- test("test is_cloud true", () => {
46
- infra_store.is_cloud = true
48
+ test("test app_mode CLOUD", () => {
49
+ infra_store.app_mode = appMode.appMode.CLOUD
47
50
  expect(geode_store.port).toBe("443")
48
51
  })
49
- test("test is_cloud false", () => {
50
- infra_store.is_cloud = false
52
+ test("test app_mode BROWSER", () => {
53
+ infra_store.app_mode = appMode.appMode.BROWSER
54
+ expect(geode_store.port).toBe(geode_store.default_local_port)
55
+ })
56
+ test("test app_mode DESKTOP", () => {
57
+ infra_store.app_mode = appMode.appMode.DESKTOP
51
58
  expect(geode_store.port).toBe(geode_store.default_local_port)
52
59
  })
53
60
 
54
61
  test("test override default_local_port", () => {
55
- infra_store.is_cloud = false
62
+ infra_store.app_mode = appMode.appMode.DESKTOP
56
63
  geode_store.default_local_port = "12"
57
64
  expect(geode_store.port).toBe("12")
58
65
  })
59
66
  })
60
67
 
61
68
  describe("base_url", () => {
62
- test("test is_cloud false", () => {
63
- infra_store.is_cloud = false
69
+ test("test app_mode BROWSER", () => {
70
+ infra_store.app_mode = appMode.appMode.BROWSER
64
71
  infra_store.domain_name = "localhost"
65
72
  expect(geode_store.base_url).toBe("http://localhost:5000")
66
73
  })
67
- test("test is_cloud true", () => {
68
- infra_store.is_cloud = true
74
+ test("test app_mode CLOUD", () => {
75
+ infra_store.app_mode = appMode.appMode.CLOUD
69
76
  infra_store.ID = "123456"
70
77
  infra_store.domain_name = "example.com"
71
78
  expect(geode_store.base_url).toBe(
72
79
  "https://example.com:443/123456/geode",
73
80
  )
74
81
  })
75
- test("test is_cloud true, ID empty", () => {
76
- infra_store.is_cloud = true
82
+ test("test app_mode CLOUD, ID empty", () => {
83
+ infra_store.app_mode = appMode.appMode.CLOUD
77
84
  infra_store.ID = ""
78
85
  infra_store.domain_name = "example.com"
79
86
  expect(() => geode_store.base_url).toThrowError(
@@ -40,22 +40,23 @@ describe("Infra Store", () => {
40
40
  })
41
41
  })
42
42
  describe("getters", () => {
43
- describe("is_cloud", () => {
43
+ describe("app_mode", () => {
44
44
  test("test type", () => {
45
- expectTypeOf(infra_store.is_cloud).toBeBoolean()
45
+ expectTypeOf(infra_store.app_mode).toBeString()
46
46
  })
47
47
  })
48
48
 
49
49
  describe("domain_name", () => {
50
- test("test type", () => {
51
- expectTypeOf(infra_store.is_cloud).toBeString()
50
+ test("test app_mode BROWSER", () => {
51
+ infra_store.app_mode = appMode.appMode.BROWSER
52
+ expect(infra_store.domain_name).toBe("localhost")
52
53
  })
53
- test("test is_cloud false", () => {
54
- infra_store.is_cloud = false
54
+ test("test app_mode DESKTOP", () => {
55
+ infra_store.app_mode = appMode.appMode.DESKTOP
55
56
  expect(infra_store.domain_name).toBe("localhost")
56
57
  })
57
- test("test is_cloud false", () => {
58
- infra_store.is_cloud = true
58
+ test("test app_mode CLOUD", () => {
59
+ infra_store.app_mode = appMode.appMode.CLOUD
59
60
  expect(infra_store.domain_name).toBe("api.geode-solutions.com")
60
61
  })
61
62
  })
@@ -64,7 +65,7 @@ describe("Infra Store", () => {
64
65
  test("test is cloud true", () => {
65
66
  useRuntimeConfig().public.SITE_BRANCH = "/test"
66
67
  useRuntimeConfig().public.PROJECT = "/project"
67
- infra_store.is_cloud = true
68
+ infra_store.app_mode = appMode.appMode.CLOUD
68
69
  expect(infra_store.lambda_url).toBe(
69
70
  "https://api.geode-solutions.com:443/test/project/createbackend",
70
71
  )
@@ -30,42 +30,49 @@ describe("Viewer Store", () => {
30
30
 
31
31
  describe("getters", () => {
32
32
  describe("protocol", () => {
33
- test("test is_cloud true", () => {
34
- infra_store.is_cloud = true
33
+ test("test app_mode CLOUD", () => {
34
+ infra_store.app_mode = appMode.appMode.CLOUD
35
35
  expect(viewer_store.protocol).toBe("wss")
36
36
  })
37
-
38
- test("test is_cloud false", () => {
39
- infra_store.is_cloud = false
37
+ test("test app_mode BROWSER", () => {
38
+ infra_store.app_mode = appMode.appMode.BROWSER
39
+ expect(viewer_store.protocol).toBe("ws")
40
+ })
41
+ test("test app_mode DESKTOP", () => {
42
+ infra_store.app_mode = appMode.appMode.DESKTOP
40
43
  expect(viewer_store.protocol).toBe("ws")
41
44
  })
42
45
  })
43
46
 
44
47
  describe("port", () => {
45
- test("test is_cloud true", () => {
46
- infra_store.is_cloud = true
48
+ test("test app_mode CLOUD", () => {
49
+ infra_store.app_mode = appMode.appMode.CLOUD
47
50
  expect(viewer_store.port).toBe("443")
48
51
  })
49
- test("test is_cloud false", () => {
50
- infra_store.is_cloud = false
52
+ test("test app_mode BROWSER", () => {
53
+ infra_store.app_mode = appMode.appMode.BROWSER
54
+ expect(viewer_store.port).toBe(viewer_store.default_local_port)
55
+ })
56
+ test("test app_mode DESKTOP", () => {
57
+ infra_store.app_mode = appMode.appMode.DESKTOP
51
58
  expect(viewer_store.port).toBe(viewer_store.default_local_port)
52
59
  })
53
60
 
54
61
  test("test override default_local_port", () => {
55
- infra_store.is_cloud = false
62
+ infra_store.app_mode = appMode.appMode.DESKTOP
56
63
  viewer_store.default_local_port = "8080"
57
64
  expect(viewer_store.port).toBe("8080")
58
65
  })
59
66
  })
60
67
  describe("base_url", () => {
61
- test("test is_cloud false", () => {
62
- infra_store.is_cloud = false
68
+ test("test app_mode DESKTOP", () => {
69
+ infra_store.app_mode = appMode.appMode.DESKTOP
63
70
  infra_store.domain_name = "localhost"
64
71
  expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
65
72
  })
66
73
 
67
- test("test is_cloud true", () => {
68
- infra_store.is_cloud = true
74
+ test("test app_mode CLOUD", () => {
75
+ infra_store.app_mode = appMode.appMode.CLOUD
69
76
  infra_store.ID = "123456"
70
77
  infra_store.domain_name = "example.com"
71
78
  expect(viewer_store.base_url).toBe(
@@ -73,8 +80,8 @@ describe("Viewer Store", () => {
73
80
  )
74
81
  })
75
82
 
76
- test("test is_cloud true, ID empty", () => {
77
- infra_store.is_cloud = true
83
+ test("test app_mode CLOUD, ID empty", () => {
84
+ infra_store.app_mode = appMode.appMode.CLOUD
78
85
  infra_store.ID = ""
79
86
  infra_store.domain_name = "example.com"
80
87
  expect(() => viewer_store.base_url).toThrowError(
@@ -0,0 +1,18 @@
1
+ import isElectron from "is-electron"
2
+
3
+ export const appMode = {
4
+ DESKTOP: "DESKTOP",
5
+ BROWSER: "BROWSER",
6
+ CLOUD: "CLOUD",
7
+ }
8
+
9
+ export function getAppMode() {
10
+ if (isElectron()) {
11
+ return appMode.DESKTOP
12
+ }
13
+ if (useRuntimeConfig().public.BROWSER === "true") {
14
+ return appMode.BROWSER
15
+ }
16
+ return appMode.CLOUD
17
+ }
18
+ export default { appMode, getAppMode }