"finalhandler": "^1.2.0",
"serve-static": "^1.15.0",
"vue": "^3.4.19",
- "vue-router": "^4.2.5"
+ "vue-router": "^4.2.5",
+ "vue-toast-notification": "^3.1.2"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.7.2",
vue-router:
specifier: ^4.2.5
version: 4.2.5(vue@3.4.19)
+ vue-toast-notification:
+ specifier: ^3.1.2
+ version: 3.1.2(vue@3.4.19)
devDependencies:
'@rushstack/eslint-patch':
vue: 3.4.19(typescript@5.3.3)
dev: false
+ /vue-toast-notification@3.1.2(vue@3.4.19):
+ resolution: {integrity: sha512-oNRL/W9aaHoeScp+iTIW7k09vM16/+8aptp2maa+7qTB43JuxmAgKdXKFYtf+uvSNOYYq2BIWgLCeJ61pwom/A==}
+ engines: {node: '>=12.15.0'}
+ peerDependencies:
+ vue: ^3.0
+ dependencies:
+ vue: 3.4.19(typescript@5.3.3)
+ dev: false
+
/vue@3.4.19(typescript@5.3.3):
resolution: {integrity: sha512-W/7Fc9KUkajFU8dBeDluM4sRGc/aa4YJnOYck8dkjgZoXtVsn3OeTGni66FV1l3+nvPA7VBFYtPioaGKUmEADw==}
peerDependencies:
() => {
uiClient
.addChargingStations(state.template, state.numberOfStations)
+ .then(() => {
+ $toast.success('Charging stations successfully added')
+ })
.catch((error: Error) => {
- // TODO: add code for UI notifications or other error handling logic
+ $toast.error('Error at adding charging stations')
console.error('Error at adding charging stations:', error)
})
.finally(() => {
<script setup lang="ts">
import { getCurrentInstance, onMounted, reactive } from 'vue'
+import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ResponsePayload } from '@/types'
const app = getCurrentInstance()
const uiClient = app?.appContext.config.globalProperties.$uiClient
+const $toast = useToast()
+
onMounted(() => {
uiClient
.listTemplates()
}
})
.catch((error: Error) => {
- // TODO: add code for UI notifications or other error handling logic
+ $toast.error('Error at fetching charging station templates')
console.error('Error at fetching charging station templates:', error)
})
.finally(() => {
() => {
uiClient
.setSupervisionUrl(props.hashId, state.supervisionUrl)
+ .then(() => {
+ $toast.success('Supervision url successfully set')
+ })
.catch((error: Error) => {
- // TODO: add code for UI notifications or other error handling logic
+ $toast.error('Error at setting supervision url')
console.error('Error at setting supervision url:', error)
})
.finally(() => {
() => {
uiClient
.startTransaction(props.hashId, parseInt(props.connectorId), state.idTag)
+ .then(() => {
+ $toast.success('Transaction successfully started')
+ })
.catch((error: Error) => {
- // TODO: add code for UI notifications or other error handling logic
+ $toast.error('Error at starting transaction')
console.error('Error at starting transaction:', error)
})
.finally(() => {
<script setup lang="ts">
import { getCurrentInstance } from 'vue'
+import { useToast } from 'vue-toast-notification'
import Button from '@/components/buttons/Button.vue'
import type { ConnectorStatus, Status } from '@/types'
const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
+const $toast = useToast()
+
function stopTransaction(): void {
- uiClient.stopTransaction(props.hashId, props.connector.transactionId)
+ uiClient
+ .stopTransaction(props.hashId, props.connector.transactionId)
+ .then(() => {
+ $toast.success('Transaction successfully stopped')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at stopping transaction')
+ console.error('Error at stopping transaction:', error)
+ })
}
function startAutomaticTransactionGenerator(): void {
- uiClient.startAutomaticTransactionGenerator(props.hashId, props.connectorId)
+ uiClient
+ .startAutomaticTransactionGenerator(props.hashId, props.connectorId)
+ .then(() => {
+ $toast.success('Automatic transaction generator successfully started')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at starting automatic transaction generator')
+ console.error('Error at starting automatic transaction generator:', error)
+ })
}
function stopAutomaticTransactionGenerator(): void {
- uiClient.stopAutomaticTransactionGenerator(props.hashId, props.connectorId)
+ uiClient
+ .stopAutomaticTransactionGenerator(props.hashId, props.connectorId)
+ .then(() => {
+ $toast.success('Automatic transaction generator successfully stopped')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at stopping automatic transaction generator')
+ console.error('Error at stopping automatic transaction generator:', error)
+ })
}
</script>
<script setup lang="ts">
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'
const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
+const $toast = useToast()
+
function startChargingStation(): void {
- uiClient.startChargingStation(props.chargingStation.stationInfo.hashId)
+ 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)
+ 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)
+ 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)
+ 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)
+ 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)
+ })
}
</script>
import { createApp } from 'vue'
+import ToastPlugin from 'vue-toast-notification'
import type { ConfigurationData, ResponsePayload } from './types'
import { router } from '@/router'
import { UIClient } from '@/composables'
import App from '@/App.vue'
+import 'vue-toast-notification/dist/theme-default.css'
const initializeApp = (config: ConfigurationData) => {
const app = createApp(App)
throw error
})
.finally(() => {
- app.use(router).mount('#app')
+ app.use(router).use(ToastPlugin).mount('#app')
})
})
}
<script setup lang="ts">
import { getCurrentInstance, reactive } from 'vue'
+import { useToast } from 'vue-toast-notification'
import CSTable from '@/components/charging-stations/CSTable.vue'
import type { ResponsePayload } from '@/types'
import Container from '@/components/Container.vue'
const app = getCurrentInstance()
const uiClient = app?.appContext.config.globalProperties.$uiClient
+const $toast = useToast()
+
function loadChargingStations(reloadCallback?: () => void): void {
if (state.isLoading === false) {
state.isLoading = true
}
})
.catch((error: Error) => {
- // TODO: add code for UI notifications or other error handling logic
+ $toast.error('Error at fetching charging stations')
console.error('Error at fetching charging stations:', error)
})
.finally(() => {
}
function startSimulator(): void {
- uiClient.startSimulator()
+ uiClient
+ .startSimulator()
+ .then(() => {
+ $toast.success('Simulator successfully started')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at starting simulator')
+ console.error('Error at starting simulator:', error)
+ })
}
function stopSimulator(): void {
- uiClient.stopSimulator()
+ uiClient
+ .stopSimulator()
+ .then(() => {
+ $toast.success('Simulator successfully stopped')
+ })
+ .catch((error: Error) => {
+ $toast.error('Error at stopping simulator')
+ console.error('Error at stopping simulator:', error)
+ })
}
</script>