fix(ui): fix missing button imports
[e-mobility-charging-stations-simulator.git] / ui / web / src / views / ChargingStationsView.vue
1 <template>
2 <Container id="charging-stations">
3 <Container id="buttons-container">
4 <Button id="simulator-button" @click="startSimulator()">Start Simulator</Button>
5 <Button id="simulator-button" @click="stopSimulator()">Stop Simulator</Button>
6 <ReloadButton id="reload-button" :loading="state.isLoading" @click="load()" />
7 </Container>
8 <Container id="inputs-container">
9 <input
10 id="idtag-field"
11 v-model="state.idTag"
12 type="text"
13 name="idtag-field"
14 placeholder="RFID tag"
15 />
16 </Container>
17 <CSTable :charging-stations="state.chargingStations" :id-tag="state.idTag" />
18 </Container>
19 </template>
20
21 <script setup lang="ts">
22 import { getCurrentInstance, onMounted, reactive } from 'vue'
23 import CSTable from '@/components/charging-stations/CSTable.vue'
24 import type { ChargingStationData } from '@/types'
25 import Container from '@/components/Container.vue'
26 import ReloadButton from '@/components/buttons/ReloadButton.vue'
27 import Button from '@/components/buttons/Button.vue'
28
29 const UIClient = getCurrentInstance()?.appContext.config.globalProperties.$UIClient
30
31 onMounted(() => {
32 UIClient.registerWSonOpenListener(load)
33 })
34
35 type State = {
36 isLoading: boolean
37 chargingStations: ChargingStationData[]
38 idTag: string
39 }
40
41 const state: State = reactive({
42 isLoading: false,
43 chargingStations: [],
44 idTag: ''
45 })
46
47 async function load(): Promise<void> {
48 if (state.isLoading === false) {
49 state.isLoading = true
50 state.chargingStations = (await UIClient.listChargingStations())
51 .chargingStations as ChargingStationData[]
52 state.isLoading = false
53 }
54 }
55
56 function startSimulator(): void {
57 UIClient.startSimulator()
58 }
59 function stopSimulator(): void {
60 UIClient.stopSimulator()
61 }
62 </script>
63
64 <style>
65 #charging-stations {
66 height: fit-content;
67 width: 100%;
68 display: flex;
69 flex-direction: column;
70 }
71
72 #buttons-container {
73 display: flex;
74 flex-direction: row;
75 }
76
77 #inputs-container {
78 display: flex;
79 flex-direction: row;
80 }
81
82 #reload-button {
83 flex: auto;
84 color: white;
85 background-color: blue;
86 font-size: 1.5rem;
87 font-weight: bold;
88 text-align: center;
89 }
90
91 #reload-button:hover {
92 background-color: rgb(0, 0, 225);
93 }
94
95 #reload-button:active {
96 background-color: red;
97 }
98
99 #simulator-button {
100 flex: auto;
101 }
102
103 #idtag-field {
104 flex: auto;
105 font-size: 1.5rem;
106 text-align: center;
107 }
108 </style>