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 | 9 | /> |
1d41bc6b JB |
10 | <td class="cs-table__column">{{ getId() }}</td> |
11 | <td class="cs-table__column">{{ getStarted() }}</td> | |
12 | <td class="cs-table__column">{{ getSupervisionUrl() }}</td> | |
13 | <td class="cs-table__column">{{ getWsState() }}</td> | |
14 | <td class="cs-table__column">{{ getRegistrationStatus() }}</td> | |
15 | <td class="cs-table__column">{{ getInfo().templateName }}</td> | |
16 | <td class="cs-table__column">{{ getVendor() }}</td> | |
17 | <td class="cs-table__column">{{ getModel() }}</td> | |
18 | <td class="cs-table__column">{{ getFirmwareVersion() }}</td> | |
32de5a57 LM |
19 | </tr> |
20 | </template> | |
21 | ||
22 | <script setup lang="ts"> | |
66a7748d | 23 | // import { reactive } from 'vue' |
9d76f5ec | 24 | import CSConnector from '@/components/charging-stations/CSConnector.vue' |
66a7748d | 25 | import type { ChargingStationData, ChargingStationInfo, ConnectorStatus } from '@/types' |
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 { |
1d41bc6b | 63 | return 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 { | |
1d41bc6b | 72 | return getInfo().firmwareVersion ?? 'Ø' |
32de5a57 | 73 | } |
452a82ca | 74 | function getStarted(): string { |
66a7748d | 75 | return props.chargingStation.started === true ? 'Yes' : 'No' |
333c3566 | 76 | } |
1d41bc6b JB |
77 | function getSupervisionUrl(): string { |
78 | const supervisionUrl = new URL(props.chargingStation.supervisionUrl) | |
79 | return `${supervisionUrl.protocol}//${supervisionUrl.host.split('.').join('.\u200b')}` | |
80 | } | |
5e3cb728 JB |
81 | function getWsState(): string { |
82 | switch (props.chargingStation?.wsState) { | |
83 | case WebSocket.CONNECTING: | |
66a7748d | 84 | return 'Connecting' |
5e3cb728 | 85 | case WebSocket.OPEN: |
66a7748d | 86 | return 'Open' |
5e3cb728 | 87 | case WebSocket.CLOSING: |
66a7748d | 88 | return 'Closing' |
5e3cb728 | 89 | case WebSocket.CLOSED: |
66a7748d | 90 | return 'Closed' |
5e3cb728 | 91 | default: |
66a7748d | 92 | return 'Ø' |
5e3cb728 JB |
93 | } |
94 | } | |
333c3566 | 95 | function getRegistrationStatus(): string { |
66a7748d | 96 | return props.chargingStation?.bootNotificationResponse?.status ?? 'Ø' |
8fc2e5cc | 97 | } |
32de5a57 | 98 | // function showTagModal(): void { |
66a7748d | 99 | // state.isTagModalVisible = true |
32de5a57 LM |
100 | // } |
101 | // function hideTagModal(): void { | |
66a7748d | 102 | // state.isTagModalVisible = false |
32de5a57 LM |
103 | // } |
104 | </script> |