From 007058b316a7715e2ea09c29aa82ed915839407a Mon Sep 17 00:00:00 2001 From: djuarezgf Date: Fri, 18 Oct 2024 19:50:13 +0200 Subject: [PATCH] Test --- src/main.ts | 20 ++++++++------------ src/services/projetManagerBackendService.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index 76904a6..ff7a02e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,6 @@ import 'bootstrap-icons/font/bootstrap-icons.css'; import 'bootstrap'; import store from './services/store'; -import {getConfig} from "@/services/configLoader"; // Import the config loader const app = createApp(App); @@ -26,18 +25,15 @@ const vueLifecycles = singleSpaVue({ app.use(router); app.use(store); -export const bootstrap = () => { + +export const bootstrap = async () => { return new Promise((resolve) => { - // Load the configuration first - getConfig().then(() => { - const onAuthenticatedCallback = () => { - console.log('Authenticated!'); - resolve(vueLifecycles.bootstrap); - }; - - // Continue with Keycloak authentication after config is loaded - KeyCloakService.CallLogin(onAuthenticatedCallback); - }); + const onAuthenticatedCallback = () => { + console.log('Authenticated!'); + resolve(vueLifecycles.bootstrap); + }; + + KeyCloakService.CallLogin(onAuthenticatedCallback); }); }; diff --git a/src/services/projetManagerBackendService.ts b/src/services/projetManagerBackendService.ts index 2412efd..c4ac1a7 100644 --- a/src/services/projetManagerBackendService.ts +++ b/src/services/projetManagerBackendService.ts @@ -5,7 +5,6 @@ import KeyCloakService from "@/services/keycloak"; import {getConfig} from "@/services/configLoader"; -const baseURL = (await getConfig()).VUE_APP_PROJECT_MANAGER_BACKEND_URL; const bridgeheadParam = 'bridgehead' const projectCodeParam = 'project-code' @@ -243,8 +242,14 @@ export class ProjetManagerBackendService { private _isInitialized: Promise | undefined; constructor(context: ProjectManagerContext, site: Site) { - this.baseURL = baseURL - this.fetchActiveModuleActions(context, site) + // Do not assign baseURL directly in the constructor + this._isInitialized = this.initialize(context, site); + } + + private async initialize(context: ProjectManagerContext, site: Site): Promise { + const config = await getConfig(); + this.baseURL = config.VUE_APP_PROJECT_MANAGER_BACKEND_URL; + await this.fetchActiveModuleActions(context, site); } private fetchActiveModuleActions(context: ProjectManagerContext, site: Site) {