2 <Container id="charging-stations-container">
3 <Container id="buttons-container">
4 <Button @click="startSimulator()">Start Simulator</Button>
5 <Button @click="stopSimulator()">Stop Simulator</Button>
6 <Button @click="$router.push({ name: 'add-charging-stations' })">
11 :loading="state.isLoading"
12 @click="loadChargingStations(() => $router.go(0))"
17 Array.isArray(app?.appContext.config.globalProperties.$chargingStations) &&
18 app?.appContext.config.globalProperties.$chargingStations.length > 0
20 :charging-stations="app?.appContext.config.globalProperties.$chargingStations"
25 <script setup lang="ts">
26 import { getCurrentInstance, reactive } from 'vue'
27 import { useToast } from 'vue-toast-notification'
28 import CSTable from '@/components/charging-stations/CSTable.vue'
29 import type { ResponsePayload } from '@/types'
30 import Container from '@/components/Container.vue'
31 import ReloadButton from '@/components/buttons/ReloadButton.vue'
32 import Button from '@/components/buttons/Button.vue'
34 const state = reactive({
38 const app = getCurrentInstance()
39 const uiClient = app?.appContext.config.globalProperties.$uiClient
41 const $toast = useToast()
43 const loadChargingStations = (reloadCallback?: () => void): void => {
44 if (state.isLoading === false) {
45 state.isLoading = true
47 .listChargingStations()
48 .then((response: ResponsePayload) => {
50 app.appContext.config.globalProperties.$chargingStations = response.chargingStations
53 .catch((error: Error) => {
54 $toast.error('Error at fetching charging stations')
55 console.error('Error at fetching charging stations:', error)
58 if (reloadCallback != null) {
61 state.isLoading = false
66 const startSimulator = (): void => {
70 $toast.success('Simulator successfully started')
72 .catch((error: Error) => {
73 $toast.error('Error at starting simulator')
74 console.error('Error at starting simulator:', error)
77 const stopSimulator = (): void => {
82 app.appContext.config.globalProperties.$chargingStations = []
84 $toast.success('Simulator successfully stopped')
86 .catch((error: Error) => {
87 $toast.error('Error at stopping simulator')
88 console.error('Error at stopping simulator:', error)
94 #charging-stations-container {
99 flex-direction: column;
114 background-color: blue;
118 justify-content: center;
121 #reload-button:hover {
122 background-color: rgb(0, 0, 225);
125 #reload-button:active {
126 background-color: red;
131 background-color: black;