Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Oct 14, 2024
1 parent abe612f commit b35cee6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.github
.idea
.gitignore
dist
node_modules
57 changes: 35 additions & 22 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import 'bootstrap-icons/font/bootstrap-icons.css';
import 'bootstrap';
import store from './services/store';

let vueLifecycles: any;
let config: any;

// Fetch the config.json file before initializing the app
fetch('/config.json')
.then(response => response.json())
.then(config => {
export const bootstrap = async () => {
try {
const response = await fetch('/config.json');
config = await response.json();

// Create the app after the config is loaded
const app = createApp(App);

// Add the config to global properties so it can be accessed in components
app.config.globalProperties.$config = config;

const vueLifecycles = singleSpaVue({
vueLifecycles = singleSpaVue({
createApp: () => app,
appOptions: {
render() {
Expand All @@ -30,23 +35,31 @@ fetch('/config.json')
app.use(router);
app.use(store);

// Bootstrap function for single-spa lifecycle
export const bootstrap = async () => {
return new Promise((resolve) => {
const onAuthenticatedCallback = () => {
console.log('Authenticated!');
resolve(vueLifecycles.bootstrap);
};

KeyCloakService.CallLogin(onAuthenticatedCallback);
});
};
// Initialize Keycloak with loaded config if necessary
return new Promise((resolve) => {
const onAuthenticatedCallback = () => {
console.log('Authenticated!');
resolve(vueLifecycles.bootstrap);
};
KeyCloakService.CallLogin(onAuthenticatedCallback);
});
} catch (error) {
console.error('Failed to load config.json:', error);
throw new Error('Configuration loading failed');
}
};

// Export mount and unmount for single-spa
export const mount = vueLifecycles.mount;
export const unmount = vueLifecycles.unmount;
// Export mount and unmount for single-spa lifecycle
export const mount = async () => {
if (vueLifecycles) {
return vueLifecycles.mount();
}
console.error('Vue lifecycles not initialized');
};

})
.catch(error => {
console.error('Failed to load config.json:', error);
});
export const unmount = async () => {
if (vueLifecycles) {
return vueLifecycles.unmount();
}
console.error('Vue lifecycles not initialized');
};
2 changes: 1 addition & 1 deletion src/services/projetManagerBackendService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axiosRetry from "axios-retry";
import KeyCloakService from "@/services/keycloak";


const baseURL = this.$config.VUE_APP_PROJECT_MANAGER_BACKEND_URL
const baseURL = (this as any).$config.VUE_APP_PROJECT_MANAGER_BACKEND_URL

const bridgeheadParam = 'bridgehead'
const projectCodeParam = 'project-code'
Expand Down

0 comments on commit b35cee6

Please sign in to comment.