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