build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / ui / web / src / views / ChargingStationsView.vue
CommitLineData
32de5a57
LM
1<template>
2 <Container id="charging-stations">
5a010bf0
JB
3 <Button id="simulator-button" @click="startSimulator()">Start Simulator</Button>
4 <Button id="simulator-button" @click="stopSimulator()">Stop Simulator</Button>
5 <Container id="inputs-container">
32de5a57 6 <input
5a010bf0 7 id="idtag-field"
01ff4231 8 v-model="state.idTag"
32de5a57 9 type="text"
5a010bf0
JB
10 name="idtag-field"
11 placeholder="RFID tag"
32de5a57
LM
12 />
13 <ReloadButton id="reload-button" :loading="state.isLoading" @click="load()" />
14 </Container>
01ff4231 15 <CSTable :charging-stations="state.chargingStations" :id-tag="state.idTag" />
32de5a57
LM
16 </Container>
17</template>
18
19<script setup lang="ts">
66a7748d
JB
20import { onMounted, reactive } from 'vue'
21import CSTable from '@/components/charging-stations/CSTable.vue'
22import type { ChargingStationData } from '@/types'
23import Container from '@/components/Container.vue'
24import ReloadButton from '@/components/buttons/ReloadButton.vue'
25import { UIClient } from '@/composables/UIClient'
32de5a57 26
66a7748d 27const UIClientInstance = UIClient.getInstance()
32de5a57
LM
28
29onMounted(() => {
66a7748d
JB
30 UIClientInstance.registerWSonOpenListener(load)
31})
32de5a57
LM
32
33type State = {
66a7748d
JB
34 isLoading: boolean
35 chargingStations: ChargingStationData[]
36 idTag: string
37}
32de5a57
LM
38
39const state: State = reactive({
40 isLoading: false,
5e3cb728 41 chargingStations: [],
a974c8e4 42 idTag: ''
66a7748d 43})
32de5a57
LM
44
45async function load(): Promise<void> {
66a7748d
JB
46 if (state.isLoading === true) return
47 state.isLoading = true
48 const listChargingStationsPayload = await UIClientInstance.listChargingStations()
5e3cb728 49 state.chargingStations =
66a7748d
JB
50 listChargingStationsPayload.chargingStations as unknown as ChargingStationData[]
51 state.isLoading = false
32de5a57 52}
5a010bf0
JB
53
54function startSimulator(): void {
66a7748d 55 UIClientInstance.startSimulator()
5a010bf0
JB
56}
57function stopSimulator(): void {
66a7748d 58 UIClientInstance.stopSimulator()
5a010bf0 59}
32de5a57
LM
60</script>
61
62<style>
63#charging-stations {
1d41bc6b 64 height: fit-content;
32de5a57 65 width: 100%;
32de5a57 66 background-color: rgb(233, 227, 227);
5a010bf0 67 display: flex;
32de5a57 68 flex-direction: column;
5a010bf0
JB
69}
70
71#inputs-container {
72 display: flex;
73 justify-content: space-between;
32de5a57
LM
74}
75
76#reload-button {
5a010bf0 77 flex: auto;
32de5a57 78 background-color: rgb(25, 118, 210);
32de5a57
LM
79 color: white;
80 font-size: 35px;
81 font-weight: bold;
82}
83
84#reload-button:hover {
85 background-color: rgb(10, 113, 195);
86}
87
88#reload-button:active {
89 background-color: rgb(255, 113, 195);
90}
91
5a010bf0
JB
92#simulator-button {
93 flex: auto;
32de5a57
LM
94}
95
5a010bf0
JB
96#idtag-field {
97 flex: auto;
1d41bc6b 98 text-align: center;
32de5a57
LM
99}
100</style>