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