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>
import InverterChannelInfo from "@/components/partials/InverterChannelInfo";
import bootstrap from "bootstrap/dist/js/bootstrap.js";
export default {
components: {
@ -82,6 +83,7 @@ export default {
heartInterval: null,
waitForData: true,
inverterData: [],
isFirstFetchAfterConnect: true,
};
},
created() {
@ -90,6 +92,20 @@ export default {
unmounted() {
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: {
initSocket() {
console.log("Starting connection to WebSocket Server");
@ -134,6 +150,7 @@ export default {
closeSocket() {
this.socket.close();
this.heartInterval && clearTimeout(this.heartInterval);
this.isFirstFetchAfterConnect = true;
},
},
};