| 1 | <template> |
| 2 | <tr class="connectors-table__row"> |
| 3 | <td class="connectors-table__column">{{ connectorId }}</td> |
| 4 | <td class="connectors-table__column">{{ connector.status ?? 'Ø' }}</td> |
| 5 | <td class="connectors-table__column"> |
| 6 | {{ connector.transactionStarted === true ? 'Yes' : 'No' }} |
| 7 | </td> |
| 8 | <td class="connectors-table__column"> |
| 9 | {{ atgStatus?.start === true ? 'Yes' : 'No' }} |
| 10 | </td> |
| 11 | <td class="connectors-table__column"> |
| 12 | <ToggleButton |
| 13 | :id="`${hashId}-${connectorId}-start-transaction`" |
| 14 | :shared="true" |
| 15 | :on=" |
| 16 | () => { |
| 17 | $router.push({ |
| 18 | name: 'start-transaction', |
| 19 | params: { hashId, chargingStationId, connectorId } |
| 20 | }) |
| 21 | } |
| 22 | " |
| 23 | :off=" |
| 24 | () => { |
| 25 | $router.push({ name: 'charging-stations' }) |
| 26 | } |
| 27 | " |
| 28 | @clicked=" |
| 29 | () => { |
| 30 | $emit('need-refresh') |
| 31 | } |
| 32 | " |
| 33 | > |
| 34 | Start Transaction |
| 35 | </ToggleButton> |
| 36 | <Button @click="stopTransaction()">Stop Transaction</Button> |
| 37 | <Button @click="startAutomaticTransactionGenerator()">Start ATG</Button> |
| 38 | <Button @click="stopAutomaticTransactionGenerator()">Stop ATG</Button> |
| 39 | </td> |
| 40 | </tr> |
| 41 | </template> |
| 42 | |
| 43 | <script setup lang="ts"> |
| 44 | import { useToast } from 'vue-toast-notification' |
| 45 | |
| 46 | import Button from '@/components/buttons/Button.vue' |
| 47 | import ToggleButton from '@/components/buttons/ToggleButton.vue' |
| 48 | import { useUIClient } from '@/composables' |
| 49 | import type { ConnectorStatus, Status } from '@/types' |
| 50 | |
| 51 | const props = defineProps<{ |
| 52 | hashId: string |
| 53 | chargingStationId: string |
| 54 | connectorId: number |
| 55 | connector: ConnectorStatus |
| 56 | atgStatus?: Status |
| 57 | }>() |
| 58 | |
| 59 | const $emit = defineEmits(['need-refresh']) |
| 60 | |
| 61 | const uiClient = useUIClient() |
| 62 | |
| 63 | const $toast = useToast() |
| 64 | |
| 65 | const stopTransaction = (): void => { |
| 66 | uiClient |
| 67 | .stopTransaction(props.hashId, props.connector.transactionId) |
| 68 | .then(() => { |
| 69 | $toast.success('Transaction successfully stopped') |
| 70 | }) |
| 71 | .catch((error: Error) => { |
| 72 | $toast.error('Error at stopping transaction') |
| 73 | console.error('Error at stopping transaction:', error) |
| 74 | }) |
| 75 | } |
| 76 | const startAutomaticTransactionGenerator = (): void => { |
| 77 | uiClient |
| 78 | .startAutomaticTransactionGenerator(props.hashId, props.connectorId) |
| 79 | .then(() => { |
| 80 | $toast.success('Automatic transaction generator successfully started') |
| 81 | }) |
| 82 | .catch((error: Error) => { |
| 83 | $toast.error('Error at starting automatic transaction generator') |
| 84 | console.error('Error at starting automatic transaction generator:', error) |
| 85 | }) |
| 86 | } |
| 87 | const stopAutomaticTransactionGenerator = (): void => { |
| 88 | uiClient |
| 89 | .stopAutomaticTransactionGenerator(props.hashId, props.connectorId) |
| 90 | .then(() => { |
| 91 | $toast.success('Automatic transaction generator successfully stopped') |
| 92 | }) |
| 93 | .catch((error: Error) => { |
| 94 | $toast.error('Error at stopping automatic transaction generator') |
| 95 | console.error('Error at stopping automatic transaction generator:', error) |
| 96 | }) |
| 97 | } |
| 98 | </script> |