X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fsrc%2Fcomponents%2Fcharging-stations%2FCSData.vue;h=2462e6d6172daeba545bbec7f03add81eae16bf2;hb=7e2e8c9b820004dc6a84d6a5629575460daf8167;hp=107df4947b540c9ec8b2bdc43818f4484fedc118;hpb=c317ae3edbd335e6dc52616df7d702c0d8419fd4;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index 107df494..2462e6d6 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -7,7 +7,7 @@ {{ getSupervisionUrl() }} - {{ getWsState() }} + {{ getWSState() }} {{ props.chargingStation?.bootNotificationResponse?.status ?? 'Ø' }} @@ -22,12 +22,26 @@ + + @@ -40,7 +54,7 @@ import { getCurrentInstance } from 'vue' +import { useToast } from 'vue-toast-notification' import CSConnector from '@/components/charging-stations/CSConnector.vue' import Button from '@/components/buttons/Button.vue' import type { ChargingStationData, ConnectorStatus, Status } from '@/types' @@ -63,29 +78,29 @@ const props = defineProps<{ chargingStation: ChargingStationData }>() -function getConnectors(): ConnectorStatus[] { +const getConnectorStatuses = (): ConnectorStatus[] => { if (Array.isArray(props.chargingStation.evses) && props.chargingStation.evses.length > 0) { - const connectorsStatus: ConnectorStatus[] = [] + const connectorStatuses: ConnectorStatus[] = [] for (const [evseId, evseStatus] of props.chargingStation.evses.entries()) { if (evseId > 0 && Array.isArray(evseStatus.connectors) && evseStatus.connectors.length > 0) { for (const connectorStatus of evseStatus.connectors) { - connectorsStatus.push(connectorStatus) + connectorStatuses.push(connectorStatus) } } } - return connectorsStatus + return connectorStatuses } return props.chargingStation.connectors?.slice(1) } -function getATGStatus(connectorId: number): Status | undefined { +const getATGStatus = (connectorId: number): Status | undefined => { return props.chargingStation.automaticTransactionGenerator ?.automaticTransactionGeneratorStatuses?.[connectorId - 1] } -function getSupervisionUrl(): string { +const getSupervisionUrl = (): string => { const supervisionUrl = new URL(props.chargingStation.supervisionUrl) return `${supervisionUrl.protocol}//${supervisionUrl.host.split('.').join('.\u200b')}` } -function getWsState(): string { +const getWSState = (): string => { switch (props.chargingStation?.wsState) { case WebSocket.CONNECTING: return 'Connecting' @@ -102,20 +117,62 @@ function getWsState(): string { const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient -function startChargingStation(): void { - uiClient.startChargingStation(props.chargingStation.stationInfo.hashId) +const $toast = useToast() + +const startChargingStation = (): void => { + uiClient + .startChargingStation(props.chargingStation.stationInfo.hashId) + .then(() => { + $toast.success('Charging station successfully started') + }) + .catch((error: Error) => { + $toast.error('Error at starting charging station') + console.error('Error at starting charging station', error) + }) } -function stopChargingStation(): void { - uiClient.stopChargingStation(props.chargingStation.stationInfo.hashId) +const stopChargingStation = (): void => { + uiClient + .stopChargingStation(props.chargingStation.stationInfo.hashId) + .then(() => { + $toast.success('Charging station successfully stopped') + }) + .catch((error: Error) => { + $toast.error('Error at stopping charging station') + console.error('Error at stopping charging station', error) + }) } -function openConnection(): void { - uiClient.openConnection(props.chargingStation.stationInfo.hashId) +const openConnection = (): void => { + uiClient + .openConnection(props.chargingStation.stationInfo.hashId) + .then(() => { + $toast.success('Connection successfully opened') + }) + .catch((error: Error) => { + $toast.error('Error at opening connection') + console.error('Error at opening connection', error) + }) } -function closeConnection(): void { - uiClient.closeConnection(props.chargingStation.stationInfo.hashId) +const closeConnection = (): void => { + uiClient + .closeConnection(props.chargingStation.stationInfo.hashId) + .then(() => { + $toast.success('Connection successfully closed') + }) + .catch((error: Error) => { + $toast.error('Error at closing connection') + console.error('Error at closing connection', error) + }) } -function deleteChargingStation(): void { - uiClient.deleteChargingStation(props.chargingStation.stationInfo.hashId) +const deleteChargingStation = (): void => { + uiClient + .deleteChargingStation(props.chargingStation.stationInfo.hashId) + .then(() => { + $toast.success('Charging station successfully deleted') + }) + .catch((error: Error) => { + $toast.error('Error at deleting charging station') + console.error('Error at deleting charging station', error) + }) } @@ -139,6 +196,7 @@ function deleteChargingStation(): void { flex-direction: row; justify-content: center; align-items: center; + border: solid 0.25px black; } .connectors-table__row:nth-of-type(even) {
Identifier