<select v-model="state.template">
<option disabled value="">Please select a template</option>
<option
- v-for="template in app?.appContext.config.globalProperties.$templates"
- v-show="
- Array.isArray(app?.appContext.config.globalProperties.$templates) &&
- app.appContext.config.globalProperties.$templates.length > 0
- "
+ v-for="template in $templates.value"
+ v-show="Array.isArray($templates.value) && $templates.value.length > 0"
>
{{ template }}
</option>
id="action-button"
@click="
() => {
- uiClient
+ $uiClient
.addChargingStations(state.template, state.numberOfStations, {
supervisionUrls: state.supervisionUrl.length > 0 ? state.supervisionUrl : undefined,
autoStart: convertToBoolean(state.autoStart),
</template>
<script setup lang="ts">
-import { getCurrentInstance, ref } from 'vue'
-import { useToast } from 'vue-toast-notification'
+import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
import { convertToBoolean } from '@/composables'
ocppStrictCompliance: true,
enableStatistics: false
})
-
-const app = getCurrentInstance()
-
-const uiClient = app?.appContext.config.globalProperties.$uiClient
-
-const $toast = useToast()
</script>
<style>
id="action-button"
@click="
() => {
- uiClient
+ $uiClient
.setSupervisionUrl(hashId, state.supervisionUrl)
.then(() => {
$toast.success('Supervision url successfully set')
</template>
<script setup lang="ts">
-import { getCurrentInstance, ref } from 'vue'
+import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
defineProps<{
const state = ref<{ supervisionUrl: string }>({
supervisionUrl: ''
})
-
-const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
</script>
<style>
id="action-button"
@click="
() => {
- uiClient
+ $uiClient
.startTransaction(hashId, convertToInt(connectorId), state.idTag)
.then(() => {
$toast.success('Transaction successfully started')
</template>
<script setup lang="ts">
-import { getCurrentInstance, ref } from 'vue'
+import { ref } from 'vue'
import Button from '@/components/buttons/Button.vue'
import { convertToInt } from '@/composables'
const state = ref<{ idTag: string }>({
idTag: ''
})
-
-const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
</script>
<style>
--- /dev/null
+export {}
+
+declare module 'vue' {
+ interface ComponentCustomProperties {
+ $configuration: Ref<ConfigurationData>
+ $templates: Ref<string[]>
+ $chargingStations: Ref<ChargingStationData[]>
+ $uiClient: UIClient
+ }
+}
-import { type App as AppType, createApp } from 'vue'
+import { type App as AppType, createApp, ref } from 'vue'
import ToastPlugin from 'vue-toast-notification'
-import type { ConfigurationData } from '@/types'
+import type { ChargingStationData, ConfigurationData } from '@/types'
import { router } from '@/router'
import { UIClient, getFromLocalStorage, setToLocalStorage } from '@/composables'
import App from '@/App.vue'
config.uiServer = [config.uiServer]
}
if (app.config.globalProperties.$configuration == null) {
- app.config.globalProperties.$configuration = config
+ app.config.globalProperties.$configuration = ref<ConfigurationData>(config)
}
- if (!Array.isArray(app.config.globalProperties.$templates)) {
- app.config.globalProperties.$templates = []
+ if (!Array.isArray(app.config.globalProperties.$templates.value)) {
+ app.config.globalProperties.$templates = ref<string[]>([])
}
- if (!Array.isArray(app.config.globalProperties.$chargingStations)) {
- app.config.globalProperties.$chargingStations = []
+ if (!Array.isArray(app.config.globalProperties.$chargingStations.value)) {
+ app.config.globalProperties.$chargingStations = ref<ChargingStationData[]>([])
}
if (
getFromLocalStorage<number | undefined>('uiServerConfigurationIndex', undefined) == null ||
getFromLocalStorage<number>('uiServerConfigurationIndex', 0) >
- app.config.globalProperties.$configuration.uiServer.length - 1
+ app.config.globalProperties.$configuration.value.uiServer.length - 1
) {
setToLocalStorage<number>('uiServerConfigurationIndex', 0)
}
if (app.config.globalProperties.$uiClient == null) {
app.config.globalProperties.$uiClient = UIClient.getInstance(
- app.config.globalProperties.$configuration.uiServer[
+ app.config.globalProperties.$configuration.value.uiServer[
getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
]
)
if (
getFromLocalStorage<number>('uiServerConfigurationIndex', 0) !== state.uiServerIndex
) {
- uiClient.setConfiguration(
- app?.appContext.config.globalProperties.$configuration.uiServer[
- state.uiServerIndex
- ]
- )
+ $uiClient.setConfiguration($configuration.value.uiServer[state.uiServerIndex])
registerWSEventListeners()
- uiClient.registerWSEventListener(
+ $uiClient.registerWSEventListener(
'open',
() => {
setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
},
{ once: true }
)
- uiClient.registerWSEventListener(
+ $uiClient.registerWSEventListener(
'error',
() => {
state.uiServerIndex = getFromLocalStorage<number>(
'uiServerConfigurationIndex',
0
)
- uiClient.setConfiguration(
- app?.appContext.config.globalProperties.$configuration.uiServer[
+ $uiClient.setConfiguration(
+ $configuration.value.uiServer[
getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
]
)
/>
</Container>
<CSTable
- v-show="
- Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
- app.appContext.config.globalProperties.$chargingStations.length > 0
- "
+ v-show="Array.isArray($chargingStations.value) && $chargingStations.value.length > 0"
:key="state.renderChargingStations"
- :charging-stations="app?.appContext.config.globalProperties.$chargingStations"
+ :charging-stations="$chargingStations.value"
@need-refresh="
() => {
state.renderAddChargingStations = randomUUID()
const clearChargingStations = (): void => {
if (app != null) {
- app.appContext.config.globalProperties.$chargingStations = []
+ app.appContext.config.globalProperties.$chargingStations.value = []
}
state.value.renderChargingStations = randomUUID()
}
.listTemplates()
.then((response: ResponsePayload) => {
if (app != null) {
- app.appContext.config.globalProperties.$templates = response.templates
+ app.appContext.config.globalProperties.$templates.value = response.templates
}
})
.catch((error: Error) => {
if (app != null) {
- app.appContext.config.globalProperties.$templates = []
+ app.appContext.config.globalProperties.$templates.value = []
}
$toast.error('Error at fetching charging station templates')
console.error('Error at fetching charging station templates:', error)
.listChargingStations()
.then((response: ResponsePayload) => {
if (app != null) {
- app.appContext.config.globalProperties.$chargingStations = response.chargingStations
+ app.appContext.config.globalProperties.$chargingStations.value = response.chargingStations
}
})
.catch((error: Error) => {
if (app != null) {
- app.appContext.config.globalProperties.$chargingStations = []
+ app.appContext.config.globalProperties.$chargingStations.value = []
}
$toast.error('Error at fetching charging stations')
console.error('Error at fetching charging stations:', error)
})
const uiServerConfigurations: { index: number; configuration: UIServerConfigurationSection }[] =
- app?.appContext.config.globalProperties.$configuration.uiServer.map(
+ app?.appContext.config.globalProperties.$configuration.value.uiServer.map(
(configuration: UIServerConfigurationSection, index: number) => ({
index,
configuration
.stopSimulator()
.then(() => {
if (app != null) {
- app.appContext.config.globalProperties.$chargingStations = []
+ app.appContext.config.globalProperties.$chargingStations.value = []
}
$toast.success('Simulator successfully stopped')
})