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