forked from openWB/openwb-ui-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.vue
80 lines (79 loc) · 2.42 KB
/
commands.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
<div class="charge-point-commands-openwbpro">
<openwb-base-button-input
title="Ladepunkt aktualisieren"
buttonText="Update anfordern"
subtype="success"
:disabled="configuration.ip_address == undefined"
@buttonClicked="triggerUpdate"
>
<template #help>
Mit diesem Befehl können Sie die Aktualisierung der openWB Pro
anstoßen. Bitte beachten Sie, dass kein Fahrzeug angesteckt ist.
</template>
</openwb-base-button-input>
</div>
</template>
<script>
export default {
name: "ChargePointCommandsOpenwbPro",
props: {
configuration: { type: Object, required: true },
chargePointId: { default: undefined },
},
methods: {
async triggerUpdate() {
let formData = new FormData();
formData.append("command", "update");
formData.append(
"data",
'{"ip_address":"' + this.configuration.ip_address + '"}',
);
const startedMessage =
"Die Aktualisierung der openWB Pro wird gestartet...";
this.$root.postClientMessage(startedMessage, "info");
console.debug(location);
this.axios
.post(
location.protocol +
"//" +
location.host +
"/openWB/web/settings/modules/charge_points/openwb_pro/commands.php",
formData,
{ timeout: 5000 },
)
.then(() => {
const successMessage =
"Die Aktualisierung der openWB Pro wurde erfolgreich gestartet.";
this.$root.postClientMessage(successMessage, "success");
})
.catch((error) => {
var alertMessage = "Aktualisierung fehlgeschlagen!<br />";
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error(
error.response.status,
error.response.data,
);
alertMessage +=
error.response.status + ": " + error.response.data;
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.error(error.request);
alertMessage +=
"Es wurde keine Antwort vom Server empfangen.";
} else {
// Something happened in setting up the request that triggered an Error
console.error("Error", error.message);
alertMessage +=
"Es ist ein unbekannter Fehler aufgetreten.";
}
this.$root.postClientMessage(alertMessage, "danger");
});
},
},
};
</script>