Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions app/components/Launcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@
import { useInfraStore } from "@ogw_front/stores/infra"

const infraStore = useInfraStore()

watch(
() => infraStore.is_captcha_validated,
(value, oldValue) => {
if (value && !oldValue && import.meta.client) {
infraStore.create_backend()
}
},
)
if (infraStore.app_mode !== appMode.CLOUD) {
infraStore.create_backend()
}
</script>

<template>
<v-container class="justify">
<v-row align-content="center" align="center">
<v-col
v-if="!infraStore.is_captcha_validated"
v-if="!infraStore.status == Status.NOT_CREATED"
class="align"
cols="12"
align-self="center"
Expand Down
32 changes: 5 additions & 27 deletions app/components/Recaptcha.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup>
import { appMode } from "@ogw_front/utils/app_mode"
import { useInfraStore } from "@ogw_front/stores/infra"

const RESPONSE_STATUS_OK = 200

const { button_label, button_color, color } = defineProps({
button_label: {
type: String,
Expand All @@ -20,7 +17,7 @@
required: false,
},
})
const infraStore = useInfraStore()

const name = ref("")
const email = ref("")
const launch = ref(false)
Expand All @@ -40,28 +37,9 @@
},
]

onMounted(() => {
if (import.meta.client) {
if (
process.env.NODE_ENV !== "production" ||
infraStore.app_mode !== appMode.CLOUD
) {
infraStore.$patch({ is_captcha_validated: true })
}
}
})
async function submit_recaptcha() {
const response = await $fetch.raw(`/.netlify/functions/recaptcha`, {
method: "POST",
body: {
name: name.value,
email: email.value,
launch: launch.value,
},
})
infraStore.$patch({
is_captcha_validated: response.status === RESPONSE_STATUS_OK,
})
function submit() {
const infraStore = useInfraStore()
return infraStore.create_backend(name.value, email.value, launch.value)
}
</script>

Expand Down Expand Up @@ -99,7 +77,7 @@
<VBtn
:text="button_label"
:color="color || button_color"
@click="submit_recaptcha"
@click="submit"
/>
</VCol>
</VRow>
Expand Down
63 changes: 63 additions & 0 deletions app/stores/cloud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Status } from "@ogw_front/utils/status"
import { useAppStore } from "./app"
import { useFeedbackStore } from "./feedback"
import { useInfraStore } from "./infra"

export const useCloudStore = defineStore("cloud", {
state: () => ({
status: Status.NOT_CONNECTED,
}),
actions: {
launch(name, email, launch) {
this.status = Status.CONNECTING
console.log("[CLOUD] Launching cloud backend...")
const schema = {
$id: "/api/app/run_cloud",
methods: ["POST"],
type: "object",
properties: {
name: { type: "string" },
email: { type: "string" },
launch: { type: "boolean" },
},
required: ["name", "email", "launch"],
additionalProperties: true,
}
const params = {
name,
email,
launch,
}
console.log("[CLOUD] params", params)
const appStore = useAppStore()
const feedbackStore = useFeedbackStore()
return appStore.request(schema, params, {
request_error_function: () => {
feedbackStore.$patch({ server_error: true })
this.status = Status.NOT_CONNECTED
},
response_function: (response) => {
feedbackStore.$patch({ server_error: false })
console.log(`[CLOUD] Cloud launched on ${response.url}`)
this.status = Status.CONNECTED
const infraStore = useInfraStore()
infraStore.$patch({
domain_name: response.url,
})
},
response_error_function: () => {
feedbackStore.$patch({ server_error: true })
this.status = Status.NOT_CONNECTED
},
})
},
async connect() {
console.log("[CLOUD] Cloud connected")
this.status = Status.CONNECTED
return Promise.resolve()
},
},
share: {
omit: ["status"],
},
})
5 changes: 1 addition & 4 deletions app/stores/geode.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export const useGeodeStore = defineStore("geode", {
const infraStore = useInfraStore()
let geode_url = `${this.protocol}://${infraStore.domain_name}:${this.port}`
if (infraStore.app_mode === appMode.CLOUD) {
if (infraStore.ID === "") {
throw new Error("ID must not be empty in cloud mode")
}
geode_url += `/${infraStore.ID}/geode`
geode_url += `/geode`
}
return geode_url
},
Expand Down
24 changes: 6 additions & 18 deletions app/stores/infra.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { appMode, getAppMode } from "@ogw_front/utils/app_mode"
import { Status } from "@ogw_front/utils/status"
import { useAppStore } from "@ogw_front/stores/app"
import { useLambdaStore } from "@ogw_front/stores/lambda"
import { useCloudStore } from "@ogw_front/stores/cloud"

import { registerRunningExtensions } from "@ogw_front/utils/extension"

export const useInfraStore = defineStore("infra", {
state: () => ({
app_mode: getAppMode(),
ID: "",
is_captcha_validated: false,
status: Status.NOT_CREATED,
microservices: [],
domain_name: "localhost",
}),
getters: {
domain_name() {
if (this.app_mode === appMode.CLOUD) {
return useRuntimeConfig().public.API_URL
}
return "localhost"
},
microservices_connected() {
console.log("microservices", this.microservices)
return this.microservices.every(
Expand All @@ -44,7 +37,7 @@ export const useInfraStore = defineStore("infra", {
console.log("[INFRA] Microservice registered:", store_name)
}
},
async create_backend() {
async create_backend(name, email, launch) {
console.log("[INFRA] Starting create_backend - Mode:", this.app_mode)
console.log(
"[INFRA] Registered microservices:",
Expand All @@ -54,20 +47,15 @@ export const useInfraStore = defineStore("infra", {
return
}
return navigator.locks.request("infra.create_backend", async () => {
this.status = Status.CREATING
if (this.status === Status.CREATED) {
return
}
this.status = Status.CREATING
console.log("[INFRA] Lock granted for create_backend")
if (this.app_mode === appMode.CLOUD) {
console.log("[INFRA] CLOUD mode - Launching lambda...")
const lambdaStore = useLambdaStore()
this.ID = await lambdaStore.launch()
console.log("[INFRA] Lambda launched successfully")
const cloudStore = useCloudStore()
await cloudStore.launch(name, email, launch)
} else {
console.log(
`[INFRA] ${this.app_mode} mode - Launching microservices...`,
)
const appStore = useAppStore()
await appStore.createProjectFolder()
if (this.app_mode === appMode.DESKTOP) {
Expand Down
57 changes: 0 additions & 57 deletions app/stores/lambda.js

This file was deleted.

5 changes: 1 addition & 4 deletions app/stores/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import { appMode } from "@ogw_front/utils/app_mode"
import { useAppStore } from "@ogw_front/stores/app"
import { useInfraStore } from "@ogw_front/stores/infra"
import { viewer_call } from "@ogw_internal/utils/viewer_call"

Check warning on line 18 in app/stores/viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint-plugin-import(max-dependencies)

File has too many dependencies (11). Maximum allowed is 10.

const MS_PER_SECOND = 1000
const SECONDS_PER_REQUEST = 10
Expand Down Expand Up @@ -52,10 +52,7 @@
const base_url = computed(() => {
let viewer_url = `${protocol.value}://${infraStore.domain_name}:${port.value}`
if (infraStore.app_mode === appMode.CLOUD) {
if (infraStore.ID === "") {
throw new Error("ID must not be empty in cloud mode")
}
viewer_url += `/${infraStore.ID}/viewer`
viewer_url += `/viewer`
}
viewer_url += "/ws"
return viewer_url
Expand Down Expand Up @@ -87,7 +84,7 @@
return
}
try {
console.log("VIEWER LOCK GRANTED !", lock)

Check warning on line 87 in app/stores/viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
status.value = Status.CONNECTING
vtkWSLinkClient.setSmartConnectClass(SmartConnect)

Expand All @@ -100,7 +97,7 @@
})
client.value.onConnectionError((httpReq) => {
const message = httpReq?.response?.error || `Connection error`
console.error(message)

Check warning on line 100 in app/stores/viewer.js

View workflow job for this annotation

GitHub Actions / test / oxlint

eslint(no-console)

Unexpected console statement.
})
client.value.onConnectionClose((httpReq) => {
const message = httpReq?.response?.error || `Connection close`
Expand Down
24 changes: 0 additions & 24 deletions app/utils/recaptcha.js

This file was deleted.

4 changes: 1 addition & 3 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
export default defineNuxtConfig({
runtimeConfig: {
public: {
API_URL: "api.geode-solutions.com",
BACK_COMMAND: "opengeodeweb-back",
BACK_PATH: path.join(
__dirname,
Expand All @@ -21,8 +20,6 @@ export default defineNuxtConfig({
),
BROWSER: process.env.BROWSER ?? false,
PROJECT: package_json.name,
SITE_BRANCH:
process.env.NODE_ENV === "production" ? process.env.SITE_BRANCH : "",
VIEWER_COMMAND: "opengeodeweb-viewer",
VIEWER_PATH: path.join(
__dirname,
Expand All @@ -45,6 +42,7 @@ export default defineNuxtConfig({
alias: {
"@ogw_front": path.resolve(__dirname, "app"),
"@ogw_internal": path.resolve(__dirname, "internal"),
"@ogw_server": path.resolve(__dirname, "server"),
"@ogw_tests": path.resolve(__dirname, "tests"),
},

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": {
"@geode/opengeodeweb-back": "0.0.0",
"@geode/opengeodeweb-viewer": "0.0.0",
"@google-cloud/run": "3.2.0",
"@kitware/vtk.js": "33.3.0",
"@mdi/font": "7.4.47",
"@pinia/nuxt": "0.11.3",
Expand All @@ -45,6 +46,8 @@
"conf": "15.1.0",
"dexie": "4.2.1",
"get-port-please": "3.2.0",
"google-auth-library": "10.6.1",
"googleapis": "171.4.0",
"is-electron": "2.2.2",
"js-file-download": "0.4.12",
"jszip": "3.10.1",
Expand Down
Loading
Loading