</template>
<script setup lang="ts">
-import { getCurrentInstance } from 'vue'
import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ConnectorStatus, Status } from '@/types'
import ToggleButton from '@/components/buttons/ToggleButton.vue'
+import { useUIClient } from '@/composables'
const props = defineProps<{
hashId: string
const $emit = defineEmits(['need-refresh'])
-const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
+const uiClient = useUIClient()
const $toast = useToast()
</template>
<script setup lang="ts">
-import { getCurrentInstance } from 'vue'
import { useToast } from 'vue-toast-notification'
import CSConnector from '@/components/charging-stations/CSConnector.vue'
import Button from '@/components/buttons/Button.vue'
import type { ChargingStationData, ConnectorStatus, Status } from '@/types'
import ToggleButton from '@/components/buttons/ToggleButton.vue'
+import { useUIClient } from '@/composables'
const props = defineProps<{
chargingStation: ChargingStationData
}
}
-const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
+const uiClient = useUIClient()
const $toast = useToast()
this.responseHandlers = new Map<string, ResponseHandler>()
}
- public static getInstance(uiServerConfiguration: UIServerConfigurationSection): UIClient {
+ public static getInstance(uiServerConfiguration?: UIServerConfigurationSection): UIClient {
if (UIClient.instance === null) {
+ if (uiServerConfiguration == null) {
+ throw new Error('Cannot initialize UIClient if no configuration is provided')
+ }
UIClient.instance = new UIClient(uiServerConfiguration)
}
return UIClient.instance
+import { UIClient } from './UIClient'
+
export const convertToBoolean = (value: unknown): boolean => {
let result = false
if (value != null) {
export const randomUUID = (): `${string}-${string}-${string}-${string}-${string}` => {
return crypto.randomUUID()
}
+
+export const useUIClient = (): UIClient => {
+ return UIClient.getInstance()
+}
getFromLocalStorage,
getLocalStorage,
randomUUID,
- setToLocalStorage
+ setToLocalStorage,
+ useUIClient
} from './Utils'
getFromLocalStorage,
getLocalStorage,
randomUUID,
- setToLocalStorage
+ setToLocalStorage,
+ useUIClient
} from '@/composables'
import ToggleButton from '@/components/buttons/ToggleButton.vue'
state.value.renderChargingStations = randomUUID()
}
-const uiClient = app?.appContext.config.globalProperties.$uiClient
+const uiClient = useUIClient()
const $toast = useToast()