Commit | Line | Data |
---|---|---|
7086aac2 | 1 | <template> |
916f0920 | 2 | <h1 id="action">Add Charging Stations</h1> |
878855a2 | 3 | <p>Template:</p> |
2610da71 | 4 | <select v-model="state.template"> |
b221407f | 5 | <option disabled value="">Please select a template</option> |
2610da71 JB |
6 | <option |
7 | v-for="template in app?.appContext.config.globalProperties.$templates" | |
8 | v-show=" | |
9 | Array.isArray(app?.appContext.config.globalProperties.$templates) && | |
3eea3ebc | 10 | app.appContext.config.globalProperties.$templates.length > 0 |
2610da71 JB |
11 | " |
12 | > | |
878855a2 JB |
13 | {{ template }} |
14 | </option> | |
15 | </select> | |
16 | <p>Number of stations:</p> | |
17 | <input | |
18 | id="number-of-stations" | |
19 | v-model="state.numberOfStations" | |
d18fc1e3 JB |
20 | type="number" |
21 | min="1" | |
3a3ba0a2 | 22 | name="number-of-stations" |
878855a2 JB |
23 | placeholder="number of stations" |
24 | /> | |
2293fadc | 25 | <p>Template options overrides:</p> |
ef2b2d03 | 26 | <ul id="template-options"> |
2293fadc JB |
27 | <li> |
28 | Supervision url: | |
29 | <input | |
30 | id="supervision-url" | |
31 | v-model.trim="state.supervisionUrl" | |
32 | type="url" | |
33 | name="supervision-url" | |
34 | placeholder="wss://" | |
35 | /> | |
36 | </li> | |
093ca832 JB |
37 | <li> |
38 | Auto start: | |
39 | <input v-model="state.autoStart" type="checkbox" true-value="true" false-value="false" /> | |
40 | </li> | |
3d9f3741 JB |
41 | <li> |
42 | Persistent configuration: | |
43 | <input | |
44 | v-model="state.persistentConfiguration" | |
45 | type="checkbox" | |
46 | true-value="true" | |
47 | false-value="false" | |
48 | /> | |
49 | </li> | |
50 | <li> | |
51 | OCPP strict compliance: | |
52 | <input | |
53 | v-model="state.ocppStrictCompliance" | |
54 | type="checkbox" | |
55 | true-value="true" | |
56 | false-value="false" | |
57 | /> | |
58 | </li> | |
59 | <li> | |
60 | Performance statistics: | |
61 | <input | |
62 | v-model="state.enableStatistics" | |
63 | type="checkbox" | |
64 | true-value="true" | |
65 | false-value="false" | |
66 | /> | |
67 | </li> | |
093ca832 | 68 | </ul> |
878855a2 JB |
69 | <br /> |
70 | <Button | |
14ee627a | 71 | id="action-button" |
878855a2 JB |
72 | @click=" |
73 | () => { | |
74 | uiClient | |
093ca832 | 75 | .addChargingStations(state.template, state.numberOfStations, { |
2293fadc | 76 | supervisionUrls: state.supervisionUrl.length > 0 ? state.supervisionUrl : undefined, |
3d9f3741 JB |
77 | autoStart: convertToBoolean(state.autoStart), |
78 | persistentConfiguration: convertToBoolean(state.persistentConfiguration), | |
79 | ocppStrictCompliance: convertToBoolean(state.ocppStrictCompliance), | |
80 | enableStatistics: convertToBoolean(state.enableStatistics) | |
093ca832 | 81 | }) |
cea23fa0 JB |
82 | .then(() => { |
83 | $toast.success('Charging stations successfully added') | |
84 | }) | |
878855a2 | 85 | .catch((error: Error) => { |
cea23fa0 | 86 | $toast.error('Error at adding charging stations') |
878855a2 JB |
87 | console.error('Error at adding charging stations:', error) |
88 | }) | |
89 | .finally(() => { | |
90 | $router.push({ name: 'charging-stations' }) | |
91 | }) | |
92 | } | |
93 | " | |
878855a2 | 94 | > |
1eb5f592 JB |
95 | Add Charging Stations |
96 | </Button> | |
7086aac2 JB |
97 | </template> |
98 | ||
99 | <script setup lang="ts"> | |
3b0c6e17 | 100 | import { getCurrentInstance, ref } from 'vue' |
cea23fa0 | 101 | import { useToast } from 'vue-toast-notification' |
878855a2 | 102 | import Button from '@/components/buttons/Button.vue' |
093ca832 | 103 | import { convertToBoolean } from '@/composables' |
878855a2 | 104 | |
cf959670 JB |
105 | const state = ref<{ |
106 | template: string | |
107 | numberOfStations: number | |
108 | supervisionUrl: string | |
109 | autoStart: boolean | |
110 | persistentConfiguration: boolean | |
111 | ocppStrictCompliance: boolean | |
112 | enableStatistics: boolean | |
113 | }>({ | |
878855a2 | 114 | template: '', |
093ca832 | 115 | numberOfStations: 1, |
2293fadc | 116 | supervisionUrl: '', |
3d9f3741 JB |
117 | autoStart: false, |
118 | persistentConfiguration: true, | |
119 | ocppStrictCompliance: true, | |
120 | enableStatistics: false | |
878855a2 | 121 | }) |
7086aac2 JB |
122 | |
123 | const app = getCurrentInstance() | |
124 | const uiClient = app?.appContext.config.globalProperties.$uiClient | |
125 | ||
cea23fa0 | 126 | const $toast = useToast() |
7086aac2 JB |
127 | </script> |
128 | ||
878855a2 JB |
129 | <style> |
130 | #number-of-stations { | |
d18fc1e3 | 131 | width: 15%; |
878855a2 JB |
132 | text-align: center; |
133 | } | |
427a4970 JB |
134 | |
135 | #supervision-url { | |
136 | width: 90%; | |
137 | text-align: left; | |
138 | } | |
ef2b2d03 JB |
139 | |
140 | #template-options { | |
141 | list-style: circle inside; | |
142 | text-align: left; | |
143 | } | |
878855a2 | 144 | </style> |