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