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
2 changes: 1 addition & 1 deletion app/components/Launcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Loading from "@ogw_front/components/Loading";
import Recaptcha from "@ogw_front/components/Recaptcha";
import { Status } from "@ogw_front/utils/status";
import { appMode } from "@ogw_front/utils/local/app_mode";
import { appMode } from "@ogw_shared/app_mode";
import { useInfraStore } from "@ogw_front/stores/infra";

const { appName, email, isUserAuthenticated, logo } = defineProps({
Expand Down
36 changes: 30 additions & 6 deletions app/stores/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
// Local imports
import { getRestApiPort, getRestApiProtocol, isCloudMode } from "@ogw_front/utils/stores.js";
import { Status } from "@ogw_front/utils/status";
import { api_fetch } from "@ogw_internal/utils/api_fetch.js";
import { upload_file } from "@ogw_internal/utils/upload_file.js";

import { killExtension } from "@ogw_front/utils/extension.js";
import { upload_file } from "@ogw_internal/utils/upload_file.js";
import { useInfraStore } from "@ogw_front/stores/infra";

// oxlint-disable-next-line max-lines-per-function, max-statements
export const useAppStore = defineStore("app", () => {
const stores = [];
const default_local_port = ref("3000");
const status = ref(Status.NOT_CONNECTED);

const protocol = computed(() => getRestApiProtocol());

const port = computed(() => getRestApiPort(default_local_port.value));

const base_url = computed(() => {
const infraStore = useInfraStore();
let app_url = `${protocol.value}://${infraStore.domain_name}:${port.value}`;
if (isCloudMode()) {
app_url += `/server`;
}
return app_url;
});

function registerStore(store) {
const isAlreadyRegistered = stores.some((registeredStore) => registeredStore.$id === store.$id);
Expand Down Expand Up @@ -91,7 +107,7 @@ export const useAppStore = defineStore("app", () => {
return loadedExtensions.value.get(id);
}

async function loadExtension(path, port, backendPath = undefined) {
async function loadExtension(path, extensionPort, backendPath = undefined) {
try {
let finalURL = path;

Expand All @@ -108,7 +124,7 @@ export const useAppStore = defineStore("app", () => {
// oxlint-disable-next-line no-inline-comments
const extensionModule = await import(/* @vite-ignore */ finalURL);
const store = extensionModule.metadata.store();
store.$patch({ default_local_port: port });
store.$patch({ default_local_port: extensionPort });

if (finalURL !== path && finalURL.startsWith("blob:")) {
URL.revokeObjectURL(finalURL);
Expand Down Expand Up @@ -196,7 +212,7 @@ export const useAppStore = defineStore("app", () => {
}

function upload(file, callbacks = {}) {
const route = "/api/microservice/extensions/upload";
const route = "/api/local/extensions/upload";
const store = useAppStore();
return upload_file(
store,
Expand Down Expand Up @@ -239,12 +255,13 @@ export const useAppStore = defineStore("app", () => {
function stop_request() {
request_counter.value -= 1;
}
const is_busy = computed(() => request_counter.value > 0);

const projectFolderPath = ref("");
function createProjectFolder() {
const { PROJECT } = useRuntimeConfig().public;
const schema = {
$id: "/api/local/project_folder_path",
$id: "/api/local/app/project_folder_path",
methods: ["POST"],
type: "object",
properties: { PROJECT: { type: "string" } },
Expand All @@ -265,6 +282,13 @@ export const useAppStore = defineStore("app", () => {

return {
stores,
default_local_port,
request_counter,
status,
protocol,
port,
base_url,
is_busy,
registerStore,
exportStores,
importStores,
Expand Down
22 changes: 8 additions & 14 deletions app/stores/back.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRestApiPort, getRestApiProtocol, isCloudMode } from "@ogw_front/utils/stores";
import { Status } from "@ogw_front/utils/status";
import { api_fetch } from "@ogw_internal/utils/api_fetch";
import { appMode } from "@ogw_front/utils/local/app_mode";
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json";
import { upload_file } from "@ogw_internal/utils/upload_file.js";
import { useAppStore } from "@ogw_front/stores/app";
Expand All @@ -19,24 +19,18 @@ export const useBackStore = defineStore("back", {
}),
getters: {
protocol() {
if (useInfraStore().app_mode === appMode.CLOUD) {
return "https";
}
return "http";
return getRestApiProtocol();
},
port() {
if (useInfraStore().app_mode === appMode.CLOUD) {
return "443";
}
return this.default_local_port;
return getRestApiPort(this.default_local_port);
},
base_url() {
const infraStore = useInfraStore();
let geode_url = `${this.protocol}://${infraStore.domain_name}:${this.port}`;
if (infraStore.app_mode === appMode.CLOUD) {
geode_url += `/geode`;
let back_url = `${this.protocol}://${infraStore.domain_name}:${this.port}`;
if (isCloudMode()) {
back_url += `/geode`;
}
return geode_url;
return back_url;
},
is_busy() {
return this.request_counter > 0;
Expand Down Expand Up @@ -81,7 +75,7 @@ export const useBackStore = defineStore("back", {
const appStore = useAppStore();
const { COMMAND_BACK, NUXT_ROOT_PATH } = useRuntimeConfig().public;
const schema = {
$id: "/api/local/run_back",
$id: "/api/local/app/run_back",
methods: ["POST"],
type: "object",
properties: {
Expand Down
2 changes: 1 addition & 1 deletion app/stores/infra.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Status } from "@ogw_front/utils/status";
import { appMode } from "@ogw_front/utils/local/app_mode";
import { appMode } from "@ogw_shared/app_mode";
import { registerRunningExtensions } from "@ogw_front/utils/extension";
import { useAppStore } from "@ogw_front/stores/app";
import { useCloudStore } from "@ogw_front/stores/cloud";
Expand Down
24 changes: 9 additions & 15 deletions app/stores/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import { connectImageStream } from "@kitware/vtk.js/Rendering/Misc/RemoteView";
import schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";

// Local imports
import {
getWebsocketApiPort,
getWebsocketApiProtocol,
isCloudMode,
} from "@ogw_front/utils/stores.js";
import { Status } from "@ogw_front/utils/status";
import { appMode } from "@ogw_front/utils/local/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";
Expand All @@ -33,23 +37,13 @@ export const useViewerStore = defineStore(
const version = ref("0.0.0");
const busy = ref(0);

const protocol = computed(() => {
if (infraStore.app_mode === appMode.CLOUD) {
return "wss";
}
return "ws";
});
const protocol = computed(() => getWebsocketApiProtocol());

const port = computed(() => {
if (infraStore.app_mode === appMode.CLOUD) {
return "443";
}
return default_local_port.value;
});
const port = computed(() => getWebsocketApiPort(default_local_port.value));

const base_url = computed(() => {
let viewer_url = `${protocol.value}://${infraStore.domain_name}:${port.value}`;
if (infraStore.app_mode === appMode.CLOUD) {
if (isCloudMode()) {
viewer_url += `/viewer`;
}
viewer_url += "/ws";
Expand Down Expand Up @@ -133,7 +127,7 @@ export const useViewerStore = defineStore(

const { COMMAND_VIEWER, NUXT_ROOT_PATH } = useRuntimeConfig().public;
const schema = {
$id: "/api/local/run_viewer",
$id: "/api/local/app/run_viewer",
methods: ["POST"],
type: "object",
properties: { COMMAND_VIEWER: { type: "string" }, NUXT_ROOT_PATH: { type: "string" } },
Expand Down
33 changes: 30 additions & 3 deletions app/utils/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ async function importExtensionFile(file) {
return registerRunningExtensions();
}

async function importExtensionURL(url) {
await downloadExtension(url);
return registerRunningExtensions();
}

async function registerRunningExtensions() {
const appStore = useAppStore();
const infraStore = useInfraStore();
Expand Down Expand Up @@ -74,6 +79,27 @@ async function uploadExtension(file) {
await appStore.upload(file);
}

function downloadExtension({ url, extensionFileName }) {
const appStore = useAppStore();
const { PROJECT: projectName } = useRuntimeConfig().public;
const params = { projectName, url, extensionFileName };

const schema = {
$id: "/api/microservice/extensions/download",
methods: ["POST"],
type: "object",
properties: {
extensionFileName: { type: "string" },
projectName: { type: "string" },
url: { type: "string" },
},
required: ["extensionFileName", "projectName", "url"],
additionalProperties: false,
};

return appStore.request({ schema, params });
}

function runExtensions() {
const appStore = useAppStore();
const { projectFolderPath } = appStore;
Expand Down Expand Up @@ -121,9 +147,10 @@ function killExtension(extensionId) {

export {
importExtensionFile,
unloadExtension,
uploadExtension,
importExtensionURL,
killExtension,
registerRunningExtensions,
runExtensions,
killExtension,
unloadExtension,
uploadExtension,
};
32 changes: 32 additions & 0 deletions app/utils/stores.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { appMode } from "@ogw_shared/app_mode";
import { useInfraStore } from "@ogw_front/stores/infra";

function isCloudMode() {
const infraStore = useInfraStore();
return infraStore.app_mode === appMode.CLOUD;
}

function getRestApiProtocol() {
const protocol = isCloudMode() ? "https" : "http";
return protocol;
}
function getRestApiPort(defaultLocalPort) {
const port = isCloudMode() ? "443" : defaultLocalPort;
return port;
}
function getWebsocketApiProtocol() {
const protocol = isCloudMode() ? "wss" : "ws";
return protocol;
}
function getWebsocketApiPort(defaultLocalPort) {
const port = isCloudMode() ? "443" : defaultLocalPort;
return port;
}

export {
isCloudMode,
getRestApiPort,
getRestApiProtocol,
getWebsocketApiProtocol,
getWebsocketApiPort,
};
3 changes: 2 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ 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"),
"@ogw_shared": path.resolve(__dirname, "shared"),
"@ogw_server": path.resolve(__dirname, "server"),
},

// ** Global CSS
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createError, defineEventHandler, readBody } from "h3";
import {
createPath,
generateProjectFolderPath,
} from "@geode/opengeodeweb-front/app/utils/local/path.js";
} from "@geode/opengeodeweb-front/server/utils/path.js";

export default defineEventHandler(async (event) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createError, defineEventHandler, readBody } from "h3";
import {
addMicroserviceMetadatas,
runBack,
} from "@geode/opengeodeweb-front/app/utils/local/microservices.js";
} from "@geode/opengeodeweb-front/server/utils/microservices.js";

export default defineEventHandler(async (event) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createError, defineEventHandler, readBody } from "h3";
import {
addMicroserviceMetadatas,
runViewer,
} from "@geode/opengeodeweb-front/app/utils/local/microservices.js";
} from "@geode/opengeodeweb-front/server/utils/microservices.js";

export default defineEventHandler(async (event) => {
try {
Expand Down
Loading
Loading