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