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