feat(ui): introduce toggle button and use it for actions
[e-mobility-charging-stations-simulator.git] / ui / web / src / components / actions / SetSupervisionUrl.vue
CommitLineData
f8696170 1<template>
229d8c34
JB
2 <h1 id="action">Action</h1>
3 <h2>Set Supervision Url</h2>
f8696170
JB
4 <h3>Charging Station {{ chargingStationId }}</h3>
5 <p>Supervision Url:</p>
6 <input
7 id="supervision-url"
d18fc1e3 8 v-model.trim="state.supervisionUrl"
70627077 9 type="url"
f8696170 10 name="supervision-url"
0475290a 11 placeholder="wss://"
f8696170
JB
12 />
13 <br />
14 <Button
14ee627a 15 id="action-button"
f8696170
JB
16 @click="
17 () => {
18 uiClient
19 .setSupervisionUrl(props.hashId, state.supervisionUrl)
cea23fa0
JB
20 .then(() => {
21 $toast.success('Supervision url successfully set')
22 })
f8696170 23 .catch((error: Error) => {
cea23fa0 24 $toast.error('Error at setting supervision url')
f8696170
JB
25 console.error('Error at setting supervision url:', error)
26 })
27 .finally(() => {
28 $router.push({ name: 'charging-stations' })
29 })
30 }
31 "
f8696170 32 >
1eb5f592
JB
33 Set Supervision Url
34 </Button>
f8696170
JB
35</template>
36
37<script setup lang="ts">
3b0c6e17 38import { getCurrentInstance, ref } from 'vue'
f8696170
JB
39import Button from '@/components/buttons/Button.vue'
40
41const props = defineProps<{
42 hashId: string
43 chargingStationId: string
44}>()
45
3b0c6e17 46const state = ref({
0475290a 47 supervisionUrl: ''
f8696170
JB
48})
49
50const uiClient = getCurrentInstance()?.appContext.config.globalProperties.$uiClient
51</script>
52
53<style>
54#supervision-url {
b221407f
JB
55 width: 90%;
56 text-align: left;
f8696170
JB
57}
58</style>