webapp: select first inverter when loaded

This commit is contained in:
Thomas Basler 2022-06-18 05:20:01 +02:00
parent 670c2d6762
commit b4aad4b3c7

View File

@ -71,6 +71,7 @@
<script> <script>
import InverterChannelInfo from "@/components/partials/InverterChannelInfo"; import InverterChannelInfo from "@/components/partials/InverterChannelInfo";
import bootstrap from "bootstrap/dist/js/bootstrap.js";
export default { export default {
components: { components: {
@ -82,6 +83,7 @@ export default {
heartInterval: null, heartInterval: null,
waitForData: true, waitForData: true,
inverterData: [], inverterData: [],
isFirstFetchAfterConnect: true,
}; };
}, },
created() { created() {
@ -90,6 +92,20 @@ export default {
unmounted() { unmounted() {
this.closeSocket(); this.closeSocket();
}, },
updated() {
// Select first tab
if (this.isFirstFetchAfterConnect) {
this.isFirstFetchAfterConnect = false;
var firstTabEl = this.$el.querySelector(
"#v-pills-tab:first-child button"
);
if (firstTabEl != null) {
var firstTab = new bootstrap.Tab(firstTabEl);
firstTab.show();
}
}
},
methods: { methods: {
initSocket() { initSocket() {
console.log("Starting connection to WebSocket Server"); console.log("Starting connection to WebSocket Server");
@ -134,6 +150,7 @@ export default {
closeSocket() { closeSocket() {
this.socket.close(); this.socket.close();
this.heartInterval && clearTimeout(this.heartInterval); this.heartInterval && clearTimeout(this.heartInterval);
this.isFirstFetchAfterConnect = true;
}, },
}, },
}; };