Commit | Line | Data |
---|---|---|
32de5a57 | 1 | <template> |
5a010bf0 | 2 | <tr v-for="(connector, index) in getConnectors()" class="cs-table__row"> |
32de5a57 LM |
3 | <CSConnector |
4 | :hash-id="getHashId()" | |
5 | :connector="connector" | |
6 | :connector-id="index + 1" | |
5a010bf0 JB |
7 | :transaction-id="connector.transactionId" |
8 | :id-tag="props.idTag" | |
32de5a57 LM |
9 | /> |
10 | <td class="cs-table__name-col">{{ getId() }}</td> | |
452a82ca | 11 | <td class="cs-table__started-col">{{ getStarted() }}</td> |
5e3cb728 | 12 | <td class="cs-table__wsState-col">{{ getWsState() }}</td> |
333c3566 | 13 | <td class="cs-table__registration-status-col">{{ getRegistrationStatus() }}</td> |
32de5a57 | 14 | <td class="cs-table__vendor-col">{{ getVendor() }}</td> |
5a010bf0 | 15 | <td class="cs-table__model-col">{{ getModel() }}</td> |
32de5a57 LM |
16 | <td class="cs-table__firmware-col">{{ getFirmwareVersion() }}</td> |
17 | </tr> | |
18 | </template> | |
19 | ||
20 | <script setup lang="ts"> | |
66a7748d JB |
21 | // import { reactive } from 'vue' |
22 | import CSConnector from './CSConnector.vue' | |
23 | import type { ChargingStationData, ChargingStationInfo, ConnectorStatus } from '@/types' | |
24 | import { ifUndefined } from '@/composables/Utils' | |
32de5a57 LM |
25 | |
26 | const props = defineProps<{ | |
66a7748d JB |
27 | chargingStation: ChargingStationData |
28 | idTag: string | |
29 | }>() | |
32de5a57 | 30 | |
5a010bf0 | 31 | // type State = { |
66a7748d JB |
32 | // isTagModalVisible: boolean |
33 | // idTag: string | |
34 | // } | |
5a010bf0 JB |
35 | |
36 | // const state: State = reactive({ | |
37 | // isTagModalVisible: false, | |
66a7748d JB |
38 | // idTag: '' |
39 | // }) | |
32de5a57 | 40 | |
5a010bf0 | 41 | function getConnectors(): ConnectorStatus[] { |
12f26d4a | 42 | if (Array.isArray(props.chargingStation.evses) && props.chargingStation.evses.length > 0) { |
66a7748d | 43 | const connectorsStatus: ConnectorStatus[] = [] |
12f26d4a JB |
44 | for (const [evseId, evseStatus] of props.chargingStation.evses.entries()) { |
45 | if (evseId > 0 && Array.isArray(evseStatus.connectors) && evseStatus.connectors.length > 0) { | |
78eddc8c | 46 | for (const connectorStatus of evseStatus.connectors) { |
66a7748d | 47 | connectorsStatus.push(connectorStatus) |
12f26d4a JB |
48 | } |
49 | } | |
50 | } | |
66a7748d | 51 | return connectorsStatus |
12f26d4a | 52 | } |
66a7748d | 53 | return props.chargingStation.connectors?.slice(1) |
32de5a57 LM |
54 | } |
55 | function getInfo(): ChargingStationInfo { | |
66a7748d | 56 | return props.chargingStation.stationInfo |
32de5a57 | 57 | } |
51c83d6f | 58 | function getHashId(): string { |
66a7748d | 59 | return getInfo().hashId |
51c83d6f | 60 | } |
32de5a57 | 61 | function getId(): string { |
66a7748d | 62 | return ifUndefined<string>(getInfo().chargingStationId, 'Ø') |
32de5a57 LM |
63 | } |
64 | function getModel(): string { | |
66a7748d | 65 | return getInfo().chargePointModel |
32de5a57 LM |
66 | } |
67 | function getVendor(): string { | |
66a7748d | 68 | return getInfo().chargePointVendor |
32de5a57 LM |
69 | } |
70 | function getFirmwareVersion(): string { | |
66a7748d | 71 | return ifUndefined<string>(getInfo().firmwareVersion, 'Ø') |
32de5a57 | 72 | } |
452a82ca | 73 | function getStarted(): string { |
66a7748d | 74 | return props.chargingStation.started === true ? 'Yes' : 'No' |
333c3566 | 75 | } |
5e3cb728 JB |
76 | function getWsState(): string { |
77 | switch (props.chargingStation?.wsState) { | |
78 | case WebSocket.CONNECTING: | |
66a7748d | 79 | return 'Connecting' |
5e3cb728 | 80 | case WebSocket.OPEN: |
66a7748d | 81 | return 'Open' |
5e3cb728 | 82 | case WebSocket.CLOSING: |
66a7748d | 83 | return 'Closing' |
5e3cb728 | 84 | case WebSocket.CLOSED: |
66a7748d | 85 | return 'Closed' |
5e3cb728 | 86 | default: |
66a7748d | 87 | return 'Ø' |
5e3cb728 JB |
88 | } |
89 | } | |
333c3566 | 90 | function getRegistrationStatus(): string { |
66a7748d | 91 | return props.chargingStation?.bootNotificationResponse?.status ?? 'Ø' |
8fc2e5cc | 92 | } |
32de5a57 | 93 | // function showTagModal(): void { |
66a7748d | 94 | // state.isTagModalVisible = true |
32de5a57 LM |
95 | // } |
96 | // function hideTagModal(): void { | |
66a7748d | 97 | // state.isTagModalVisible = false |
32de5a57 LM |
98 | // } |
99 | </script> |