2 <Container id="charging-stations-container">
4 v-show="Array.isArray(uiServerConfigurations) && uiServerConfigurations.length > 1"
5 id="ui-server-container"
8 id="ui-server-selector"
9 v-model="state.uiServerIndex"
14 getFromLocalStorage<number>('uiServerConfigurationIndex', 0) !== state.uiServerIndex
16 setToLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
17 app!.appContext.config.globalProperties.$uiClient.setConfiguration(
18 app?.appContext.config.globalProperties.$configuration.uiServer[
19 getFromLocalStorage<number>('uiServerConfigurationIndex', state.uiServerIndex)
24 $toast.error('Error at changing UI server configuration')
25 console.error('Error at changing UI server configuration:', error)
31 v-for="uiServerConfiguration in uiServerConfigurations"
32 :value="uiServerConfiguration.index"
34 {{ uiServerConfiguration.configuration.host }}
38 <Container id="buttons-container">
39 <Button @click="startSimulator()">Start Simulator</Button>
40 <Button @click="stopSimulator()">Stop Simulator</Button>
41 <Button @click="$router.push({ name: 'add-charging-stations' })">
46 :loading="state.isLoading"
47 @click="loadChargingStations(() => $router.go(0))"
52 Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
53 app?.appContext.config.globalProperties.$chargingStations.length > 0
55 :charging-stations="app?.appContext.config.globalProperties.$chargingStations"
60 <script setup lang="ts">
61 import { getCurrentInstance, reactive } from 'vue'
62 import { useToast } from 'vue-toast-notification'
63 import CSTable from '@/components/charging-stations/CSTable.vue'
64 import type { ResponsePayload, UIServerConfigurationSection } from '@/types'
65 import Container from '@/components/Container.vue'
66 import ReloadButton from '@/components/buttons/ReloadButton.vue'
67 import Button from '@/components/buttons/Button.vue'
68 import { getFromLocalStorage, setToLocalStorage } from '@/composables'
70 const state = reactive({
72 uiServerIndex: getFromLocalStorage<number>('uiServerConfigurationIndex', 0)
75 const app = getCurrentInstance()
76 const uiClient = app?.appContext.config.globalProperties.$uiClient
77 const uiServerConfigurations: { configuration: UIServerConfigurationSection; index: number }[] =
78 app?.appContext.config.globalProperties.$configuration.uiServer.map(
79 (configuration: UIServerConfigurationSection, index: number) => ({
85 const $toast = useToast()
87 const loadChargingStations = (reloadCallback?: () => void): void => {
88 if (state.isLoading === false) {
89 state.isLoading = true
91 .listChargingStations()
92 .then((response: ResponsePayload) => {
94 app.appContext.config.globalProperties.$chargingStations = response.chargingStations
97 .catch((error: Error) => {
98 $toast.error('Error at fetching charging stations')
99 console.error('Error at fetching charging stations:', error)
102 if (reloadCallback != null) {
105 state.isLoading = false
110 const startSimulator = (): void => {
114 $toast.success('Simulator successfully started')
116 .catch((error: Error) => {
117 $toast.error('Error at starting simulator')
118 console.error('Error at starting simulator:', error)
121 const stopSimulator = (): void => {
126 app.appContext.config.globalProperties.$chargingStations = []
128 $toast.success('Simulator successfully stopped')
130 .catch((error: Error) => {
131 $toast.error('Error at stopping simulator')
132 console.error('Error at stopping simulator:', error)
138 #charging-stations-container {
142 flex-direction: column;
145 #ui-server-container {
150 #ui-server-selector {
167 background-color: blue;
171 justify-content: center;
174 #reload-button:hover {
175 background-color: rgb(0, 0, 225);
178 #reload-button:active {
179 background-color: red;
184 background-color: black;