]>
Commit | Line | Data |
---|---|---|
32de5a57 | 1 | <template> |
9dc8b66f | 2 | <tr class="cs-table__row"> |
f1df3177 | 3 | <td class="cs-table__column"> |
2610da71 | 4 | {{ chargingStation.stationInfo.chargingStationId }} |
f1df3177 | 5 | </td> |
64596c75 JB |
6 | <td class="cs-table__column"> |
7 | {{ chargingStation.started === true ? 'Yes' : 'No' }} | |
8 | </td> | |
9dc8b66f JB |
9 | <td class="cs-table__column"> |
10 | {{ getSupervisionUrl() }} | |
11 | </td> | |
64596c75 JB |
12 | <td class="cs-table__column"> |
13 | {{ getWSState() }} | |
14 | </td> | |
9dc8b66f | 15 | <td class="cs-table__column"> |
ec7366ed | 16 | {{ chargingStation.bootNotificationResponse?.status ?? 'Ø' }} |
9dc8b66f JB |
17 | </td> |
18 | <td class="cs-table__column"> | |
2610da71 | 19 | {{ chargingStation.stationInfo.templateName }} |
9dc8b66f | 20 | </td> |
64596c75 JB |
21 | <td class="cs-table__column"> |
22 | {{ chargingStation.stationInfo.chargePointVendor }} | |
23 | </td> | |
24 | <td class="cs-table__column"> | |
25 | {{ chargingStation.stationInfo.chargePointModel }} | |
26 | </td> | |
9dc8b66f | 27 | <td class="cs-table__column"> |
2610da71 | 28 | {{ chargingStation.stationInfo.firmwareVersion ?? 'Ø' }} |
9dc8b66f JB |
29 | </td> |
30 | <td class="cs-table__column"> | |
64596c75 JB |
31 | <Button @click="startChargingStation()"> |
32 | Start Charging Station | |
33 | </Button> | |
34 | <Button @click="stopChargingStation()"> | |
35 | Stop Charging Station | |
36 | </Button> | |
2610da71 JB |
37 | <ToggleButton |
38 | :id="`${chargingStation.stationInfo.hashId}-set-supervision-url`" | |
0749233f JB |
39 | :off=" |
40 | () => { | |
41 | $router.push({ name: 'charging-stations' }) | |
42 | } | |
43 | " | |
2610da71 JB |
44 | :on=" |
45 | () => { | |
46 | $router.push({ | |
47 | name: 'set-supervision-url', | |
48 | params: { | |
49 | hashId: chargingStation.stationInfo.hashId, | |
b015f776 JB |
50 | chargingStationId: chargingStation.stationInfo.chargingStationId, |
51 | }, | |
2610da71 JB |
52 | }) |
53 | } | |
54 | " | |
0749233f | 55 | :shared="true" |
eeb27da6 | 56 | @clicked="$emit('need-refresh')" |
f8696170 | 57 | > |
1eb5f592 | 58 | Set Supervision Url |
2610da71 | 59 | </ToggleButton> |
64596c75 JB |
60 | <Button @click="openConnection()"> |
61 | Open Connection | |
62 | </Button> | |
63 | <Button @click="closeConnection()"> | |
64 | Close Connection | |
65 | </Button> | |
66 | <Button @click="deleteChargingStation()"> | |
67 | Delete Charging Station | |
68 | </Button> | |
9dc8b66f JB |
69 | </td> |
70 | <td class="cs-table__connectors-column"> | |
71 | <table id="connectors-table"> | |
64596c75 | 72 | <caption /> |
9dc8b66f JB |
73 | <thead id="connectors-table__head"> |
74 | <tr class="connectors-table__row"> | |
64596c75 | 75 | <th |
64596c75 | 76 | class="connectors-table__column" |
0749233f | 77 | scope="col" |
64596c75 JB |
78 | > |
79 | Identifier | |
80 | </th> | |
81 | <th | |
64596c75 | 82 | class="connectors-table__column" |
0749233f | 83 | scope="col" |
64596c75 JB |
84 | > |
85 | Status | |
86 | </th> | |
87 | <th | |
64596c75 | 88 | class="connectors-table__column" |
0749233f | 89 | scope="col" |
64596c75 JB |
90 | > |
91 | Transaction | |
92 | </th> | |
93 | <th | |
64596c75 | 94 | class="connectors-table__column" |
0749233f | 95 | scope="col" |
64596c75 JB |
96 | > |
97 | ATG Started | |
98 | </th> | |
99 | <th | |
64596c75 | 100 | class="connectors-table__column" |
0749233f | 101 | scope="col" |
64596c75 JB |
102 | > |
103 | Actions | |
104 | </th> | |
9dc8b66f JB |
105 | </tr> |
106 | </thead> | |
107 | <tbody id="connectors-table__body"> | |
9dc8b66f | 108 | <CSConnector |
b221407f | 109 | v-for="(connector, index) in getConnectorStatuses()" |
84ec8d34 | 110 | :key="index + 1" |
0749233f | 111 | :atg-status="getATGStatus(index + 1)" |
2610da71 | 112 | :charging-station-id="chargingStation.stationInfo.chargingStationId" |
9dc8b66f | 113 | :connector="connector" |
0749233f JB |
114 | :connector-id="index + 1" |
115 | :hash-id="chargingStation.stationInfo.hashId" | |
83468764 | 116 | @need-refresh="$emit('need-refresh')" |
9dc8b66f JB |
117 | /> |
118 | </tbody> | |
119 | </table> | |
120 | </td> | |
32de5a57 LM |
121 | </tr> |
122 | </template> | |
123 | ||
124 | <script setup lang="ts"> | |
2c7bc466 JB |
125 | import { useToast } from 'vue-toast-notification' |
126 | ||
0749233f | 127 | import type { ChargingStationData, ConnectorStatus, Status } from '@/types' |
84ec8d34 | 128 | |
13c19b7b | 129 | import Button from '@/components/buttons/Button.vue' |
2610da71 | 130 | import ToggleButton from '@/components/buttons/ToggleButton.vue' |
84ec8d34 | 131 | import CSConnector from '@/components/charging-stations/CSConnector.vue' |
122e014f | 132 | import { deleteFromLocalStorage, getLocalStorage, useUIClient } from '@/composables' |
32de5a57 LM |
133 | |
134 | const props = defineProps<{ | |
66a7748d | 135 | chargingStation: ChargingStationData |
66a7748d | 136 | }>() |
32de5a57 | 137 | |
83468764 JB |
138 | const $emit = defineEmits(['need-refresh']) |
139 | ||
b221407f | 140 | const getConnectorStatuses = (): ConnectorStatus[] => { |
f1df3177 | 141 | if (Array.isArray(props.chargingStation.evses) && props.chargingStation.evses.length > 0) { |
a4baab63 | 142 | const connectorStatuses: ConnectorStatus[] = [] |
f1df3177 JB |
143 | for (const [evseId, evseStatus] of props.chargingStation.evses.entries()) { |
144 | if (evseId > 0 && Array.isArray(evseStatus.connectors) && evseStatus.connectors.length > 0) { | |
145 | for (const connectorStatus of evseStatus.connectors) { | |
a4baab63 | 146 | connectorStatuses.push(connectorStatus) |
f1df3177 JB |
147 | } |
148 | } | |
149 | } | |
a4baab63 | 150 | return connectorStatuses |
f1df3177 JB |
151 | } |
152 | return props.chargingStation.connectors?.slice(1) | |
9dc8b66f | 153 | } |
fa5d129a | 154 | const getATGStatus = (connectorId: number): Status | undefined => { |
9dc8b66f JB |
155 | return props.chargingStation.automaticTransactionGenerator |
156 | ?.automaticTransactionGeneratorStatuses?.[connectorId - 1] | |
32de5a57 | 157 | } |
fa5d129a | 158 | const getSupervisionUrl = (): string => { |
1d41bc6b JB |
159 | const supervisionUrl = new URL(props.chargingStation.supervisionUrl) |
160 | return `${supervisionUrl.protocol}//${supervisionUrl.host.split('.').join('.\u200b')}` | |
161 | } | |
f292861c | 162 | const getWSState = (): string => { |
5e3cb728 | 163 | switch (props.chargingStation?.wsState) { |
b3bd9446 JB |
164 | case WebSocket.CLOSED: |
165 | return 'Closed' | |
166 | case WebSocket.CLOSING: | |
167 | return 'Closing' | |
5e3cb728 | 168 | case WebSocket.CONNECTING: |
66a7748d | 169 | return 'Connecting' |
5e3cb728 | 170 | case WebSocket.OPEN: |
66a7748d | 171 | return 'Open' |
5e3cb728 | 172 | default: |
66a7748d | 173 | return 'Ø' |
5e3cb728 JB |
174 | } |
175 | } | |
9dc8b66f | 176 | |
39cd8fcb | 177 | const uiClient = useUIClient() |
9dc8b66f | 178 | |
cea23fa0 JB |
179 | const $toast = useToast() |
180 | ||
fa5d129a | 181 | const startChargingStation = (): void => { |
cea23fa0 JB |
182 | uiClient |
183 | .startChargingStation(props.chargingStation.stationInfo.hashId) | |
184 | .then(() => { | |
64596c75 | 185 | return $toast.success('Charging station successfully started') |
cea23fa0 JB |
186 | }) |
187 | .catch((error: Error) => { | |
188 | $toast.error('Error at starting charging station') | |
08b55289 | 189 | console.error('Error at starting charging station:', error) |
cea23fa0 | 190 | }) |
9dc8b66f | 191 | } |
fa5d129a | 192 | const stopChargingStation = (): void => { |
cea23fa0 JB |
193 | uiClient |
194 | .stopChargingStation(props.chargingStation.stationInfo.hashId) | |
195 | .then(() => { | |
64596c75 | 196 | return $toast.success('Charging station successfully stopped') |
cea23fa0 JB |
197 | }) |
198 | .catch((error: Error) => { | |
199 | $toast.error('Error at stopping charging station') | |
08b55289 | 200 | console.error('Error at stopping charging station:', error) |
cea23fa0 | 201 | }) |
9dc8b66f | 202 | } |
fa5d129a | 203 | const openConnection = (): void => { |
cea23fa0 JB |
204 | uiClient |
205 | .openConnection(props.chargingStation.stationInfo.hashId) | |
206 | .then(() => { | |
64596c75 | 207 | return $toast.success('Connection successfully opened') |
cea23fa0 JB |
208 | }) |
209 | .catch((error: Error) => { | |
210 | $toast.error('Error at opening connection') | |
08b55289 | 211 | console.error('Error at opening connection:', error) |
cea23fa0 | 212 | }) |
9dc8b66f | 213 | } |
fa5d129a | 214 | const closeConnection = (): void => { |
cea23fa0 JB |
215 | uiClient |
216 | .closeConnection(props.chargingStation.stationInfo.hashId) | |
217 | .then(() => { | |
64596c75 | 218 | return $toast.success('Connection successfully closed') |
cea23fa0 JB |
219 | }) |
220 | .catch((error: Error) => { | |
221 | $toast.error('Error at closing connection') | |
08b55289 | 222 | console.error('Error at closing connection:', error) |
cea23fa0 | 223 | }) |
9dc8b66f | 224 | } |
fa5d129a | 225 | const deleteChargingStation = (): void => { |
cea23fa0 JB |
226 | uiClient |
227 | .deleteChargingStation(props.chargingStation.stationInfo.hashId) | |
228 | .then(() => { | |
122e014f JB |
229 | for (const key in getLocalStorage()) { |
230 | if (key.includes(props.chargingStation.stationInfo.hashId)) { | |
231 | deleteFromLocalStorage(key) | |
232 | } | |
233 | } | |
64596c75 | 234 | return $toast.success('Charging station successfully deleted') |
cea23fa0 JB |
235 | }) |
236 | .catch((error: Error) => { | |
237 | $toast.error('Error at deleting charging station') | |
08b55289 | 238 | console.error('Error at deleting charging station:', error) |
cea23fa0 | 239 | }) |
a64b9a64 | 240 | } |
32de5a57 | 241 | </script> |
9dc8b66f JB |
242 | |
243 | <style> | |
244 | #connectors-table { | |
245 | display: flex; | |
9dc8b66f | 246 | flex-direction: column; |
b002bbab | 247 | background-color: white; |
9dc8b66f JB |
248 | overflow: auto hidden; |
249 | border-collapse: collapse; | |
250 | empty-cells: show; | |
251 | } | |
252 | ||
9dc8b66f JB |
253 | #connectors-table__body { |
254 | display: flex; | |
255 | flex-direction: column; | |
256 | } | |
257 | ||
258 | .connectors-table__row { | |
259 | display: flex; | |
b002bbab | 260 | flex-direction: row; |
9dc8b66f JB |
261 | justify-content: center; |
262 | align-items: center; | |
6dba76a5 | 263 | border: solid 0.25px black; |
9dc8b66f JB |
264 | } |
265 | ||
9dc8b66f JB |
266 | .connectors-table__row:nth-of-type(even) { |
267 | background-color: whitesmoke; | |
268 | } | |
269 | ||
b002bbab JB |
270 | #connectors-table__head .connectors-table__row { |
271 | background-color: lightgrey; | |
272 | } | |
273 | ||
9dc8b66f JB |
274 | .connectors-table__column { |
275 | width: calc(100% / 5); | |
3802683b JB |
276 | display: flex; |
277 | flex-direction: column; | |
9dc8b66f JB |
278 | text-align: center; |
279 | } | |
280 | </style> |