fix(ui): fix missing button imports
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / charging-stations / CSData.vue
CommitLineData
32de5a57 1<template>
9dc8b66f 2 <tr class="cs-table__row">
f1df3177
JB
3 <td class="cs-table__column">
4 {{ props.chargingStation.stationInfo.chargingStationId ?? 'Ø' }}
5 </td>
6 <td class="cs-table__column">{{ props.chargingStation.started === true ? 'Yes' : 'No' }}</td>
9dc8b66f
JB
7 <td class="cs-table__column">
8 {{ getSupervisionUrl() }}
9 </td>
1d41bc6b 10 <td class="cs-table__column">{{ getWsState() }}</td>
9dc8b66f 11 <td class="cs-table__column">
f1df3177 12 {{ props.chargingStation?.bootNotificationResponse?.status ?? 'Ø' }}
9dc8b66f
JB
13 </td>
14 <td class="cs-table__column">
f1df3177 15 {{ props.chargingStation.stationInfo.templateName }}
9dc8b66f 16 </td>
f1df3177
JB
17 <td class="cs-table__column">{{ props.chargingStation.stationInfo.chargePointVendor }}</td>
18 <td class="cs-table__column">{{ props.chargingStation.stationInfo.chargePointModel }}</td>
9dc8b66f 19 <td class="cs-table__column">
f1df3177 20 {{ props.chargingStation.stationInfo.firmwareVersion ?? 'Ø' }}
9dc8b66f
JB
21 </td>
22 <td class="cs-table__column">
23 <Button @click="startChargingStation()">Start Charging Station</Button>
24 <Button @click="stopChargingStation()">Stop Charging Station</Button>
25 <Button @click="openConnection()">Open Connection</Button>
26 <Button @click="closeConnection()">Close Connection</Button>
a64b9a64 27 <Button @click="deleteChargingStation()">Delete Charging Station</Button>
9dc8b66f
JB
28 </td>
29 <td class="cs-table__connectors-column">
30 <table id="connectors-table">
31 <thead id="connectors-table__head">
32 <tr class="connectors-table__row">
33 <th scope="col" class="connectors-table__column">Identifier</th>
34 <th scope="col" class="connectors-table__column">Status</th>
35 <th scope="col" class="connectors-table__column">Transaction</th>
36 <th scope="col" class="connectors-table__column">ATG Started</th>
37 <th scope="col" class="connectors-table__column">Actions</th>
38 </tr>
39 </thead>
40 <tbody id="connectors-table__body">
41 <!-- eslint-disable-next-line vue/valid-v-for -->
42 <CSConnector
43 v-for="(connector, index) in getConnectors()"
f1df3177 44 :hash-id="props.chargingStation.stationInfo.hashId"
9dc8b66f
JB
45 :connector-id="index + 1"
46 :connector="connector"
47 :atg-status="getATGStatus(index + 1)"
48 :transaction-id="connector.transactionId"
49 :id-tag="props.idTag"
50 />
51 </tbody>
52 </table>
53 </td>
32de5a57
LM
54 </tr>
55</template>
56
57<script setup lang="ts">
9dc8b66f 58import { getCurrentInstance } from 'vue'
9d76f5ec 59import CSConnector from '@/components/charging-stations/CSConnector.vue'
13c19b7b 60import Button from '@/components/buttons/Button.vue'
f1df3177 61import type { ChargingStationData, ConnectorStatus, Status } from '@/types'
32de5a57
LM
62
63const props = defineProps<{
66a7748d
JB
64 chargingStation: ChargingStationData
65 idTag: string
66}>()
32de5a57 67
f1df3177
JB
68function getConnectors(): ConnectorStatus[] {
69 if (Array.isArray(props.chargingStation.evses) && props.chargingStation.evses.length > 0) {
70 const connectorsStatus: ConnectorStatus[] = []
71 for (const [evseId, evseStatus] of props.chargingStation.evses.entries()) {
72 if (evseId > 0 && Array.isArray(evseStatus.connectors) && evseStatus.connectors.length > 0) {
73 for (const connectorStatus of evseStatus.connectors) {
74 connectorsStatus.push(connectorStatus)
75 }
76 }
77 }
78 return connectorsStatus
79 }
80 return props.chargingStation.connectors?.slice(1)
9dc8b66f
JB
81}
82function getATGStatus(connectorId: number): Status | undefined {
83 return props.chargingStation.automaticTransactionGenerator
84 ?.automaticTransactionGeneratorStatuses?.[connectorId - 1]
32de5a57 85}
1d41bc6b
JB
86function getSupervisionUrl(): string {
87 const supervisionUrl = new URL(props.chargingStation.supervisionUrl)
88 return `${supervisionUrl.protocol}//${supervisionUrl.host.split('.').join('.\u200b')}`
89}
5e3cb728
JB
90function getWsState(): string {
91 switch (props.chargingStation?.wsState) {
92 case WebSocket.CONNECTING:
66a7748d 93 return 'Connecting'
5e3cb728 94 case WebSocket.OPEN:
66a7748d 95 return 'Open'
5e3cb728 96 case WebSocket.CLOSING:
66a7748d 97 return 'Closing'
5e3cb728 98 case WebSocket.CLOSED:
66a7748d 99 return 'Closed'
5e3cb728 100 default:
66a7748d 101 return 'Ø'
5e3cb728
JB
102 }
103}
9dc8b66f
JB
104
105const UIClient = getCurrentInstance()?.appContext.config.globalProperties.$UIClient
106
107function startChargingStation(): void {
f1df3177 108 UIClient.startChargingStation(props.chargingStation.stationInfo.hashId)
9dc8b66f
JB
109}
110function stopChargingStation(): void {
f1df3177 111 UIClient.stopChargingStation(props.chargingStation.stationInfo.hashId)
9dc8b66f
JB
112}
113function openConnection(): void {
f1df3177 114 UIClient.openConnection(props.chargingStation.stationInfo.hashId)
9dc8b66f
JB
115}
116function closeConnection(): void {
f1df3177 117 UIClient.closeConnection(props.chargingStation.stationInfo.hashId)
9dc8b66f 118}
a64b9a64 119function deleteChargingStation(): void {
f1df3177 120 UIClient.deleteChargingStation(props.chargingStation.stationInfo.hashId)
a64b9a64 121}
32de5a57 122</script>
9dc8b66f
JB
123
124<style>
125#connectors-table {
126 display: flex;
9dc8b66f 127 flex-direction: column;
b002bbab 128 background-color: white;
9dc8b66f
JB
129 overflow: auto hidden;
130 border-collapse: collapse;
131 empty-cells: show;
132}
133
9dc8b66f
JB
134#connectors-table__body {
135 display: flex;
136 flex-direction: column;
137}
138
139.connectors-table__row {
140 display: flex;
b002bbab 141 flex-direction: row;
9dc8b66f
JB
142 justify-content: center;
143 align-items: center;
144}
145
9dc8b66f
JB
146.connectors-table__row:nth-of-type(even) {
147 background-color: whitesmoke;
148}
149
b002bbab
JB
150#connectors-table__head .connectors-table__row {
151 background-color: lightgrey;
152}
153
9dc8b66f
JB
154.connectors-table__column {
155 width: calc(100% / 5);
156 text-align: center;
157}
158</style>