From 5463c8aec08dfa07a01f95646e44a3b4bee070fe Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Fri, 26 Aug 2022 14:50:55 +0300
Subject: optimization for dynamic

---
 src/views/_sila/Power/Dynamic/PowerInput.vue | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'src/views/_sila/Power/Dynamic/PowerInput.vue')

diff --git a/src/views/_sila/Power/Dynamic/PowerInput.vue b/src/views/_sila/Power/Dynamic/PowerInput.vue
index 676f236c..bfbf9953 100644
--- a/src/views/_sila/Power/Dynamic/PowerInput.vue
+++ b/src/views/_sila/Power/Dynamic/PowerInput.vue
@@ -107,6 +107,7 @@ export default {
       warning: Infinity,
       shutdown: Infinity,
       isBusy: true,
+      opened: false,
       fields: [
         {
           key: 'name',
@@ -162,17 +163,19 @@ export default {
   },
   watch: {
     timeScale() {
+      if (!this.opened) {
+        return;
+      }
+
       this.loadData();
     },
   },
-  created() {
-    this.loadData();
-  },
   methods: {
     onOpened(state) {
       if (state) {
         this.loadData();
       }
+      this.opened = state;
     },
 
     loadData() {
@@ -180,9 +183,11 @@ export default {
       if (this.timeScale === 'hour') {
         payload.lastHour = true;
       }
+
+      this.$root.$emit('psu-power-input', true);
       this.startLoader();
       this.$store.dispatch('powerSupply/getPsu', payload).finally(() => {
-        this.$root.$emit('psu-power');
+        this.$root.$emit('psu-power-input', false);
         this.isBusy = false;
         this.endLoader();
       });
-- 
cgit v1.2.3

