1c213741953a0e4571411d72f29c7771b3c6b128
[e-mobility-charging-stations-simulator.git] / ui / web / src / main.ts
1 import { createApp } from 'vue'
2 import type { ConfigurationData } from './types'
3 import router from '@/router'
4 import { UIClient } from '@/composables'
5 import App from '@/App.vue'
6
7 const initializeApp = async (config: ConfigurationData) => {
8 const app = createApp(App)
9 app.config.errorHandler = (error, instance, info) => {
10 console.error('Error:', error)
11 console.info('Vue instance:', instance)
12 console.info('Error info:', info)
13 // TODO: Add code for UI notifications or other error handling logic
14 }
15 app.config.globalProperties.$UIClient = UIClient.getInstance(config)
16 app.config.globalProperties.$UIClient.openWS()
17 app.use(router).mount('#app')
18 }
19
20 fetch('/config.json')
21 .then(response => response.json())
22 .catch(error => {
23 console.error('Error at fetching app configuration:', error)
24 throw error
25 })
26 .then(config => {
27 initializeApp(config)
28 })
29 .catch(error => {
30 console.error('Error at initializing app:', error)
31 })