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/Fans/Dynamic/FanSpeedSystem.vue | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

(limited to 'src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue')

diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
index 2271ef5c..b86e1672 100644
--- a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
+++ b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
@@ -1,7 +1,9 @@
 <template>
   <collapse
     id="collapse_FansSystem"
+    :class="{ disabledDiv: loading && opened }"
     :title="$t('pageFans.speedSystem')"
+    :opened="true"
     @opened="onOpened"
   >
     <template #image>
@@ -153,6 +155,7 @@ export default {
       warning: null,
       critical: null,
       isBusy: true,
+      opened: false,
       fields: [
         {
           key: 'name',
@@ -258,8 +261,8 @@ export default {
 
     allSensors() {
       return this.timeScale === 'hour'
-        ? this.$store.getters['fan/fansLastHour']
-        : this.$store.getters['fan/fans'];
+        ? this.$store.getters['fan/fansSystemLastHour']
+        : this.$store.getters['fan/fansSystem'];
     },
 
     preFiltered() {
@@ -287,14 +290,14 @@ export default {
 
   watch: {
     timeScale() {
+      if (!this.opened) {
+        return;
+      }
+
       this.loadData();
     },
   },
 
-  created() {
-    this.loadData();
-  },
-
   methods: {
     saveLimit() {
       this.$v.$touch();
@@ -328,6 +331,7 @@ export default {
       if (state) {
         this.loadData();
       }
+      this.opened = state;
     },
 
     loadData() {
@@ -336,11 +340,13 @@ export default {
         payload = { lastHour: true };
       }
 
+      this.$root.$emit('fan-system', true);
       this.startLoader();
-      this.$store.dispatch('fan/getFansDynamic', payload).finally(() => {
+      this.$store.dispatch('fan/getFansSystem', payload).finally(() => {
         this.$store.dispatch('fan/getLimits').finally(() => {
           this.warning = this.warningLimit;
           this.critical = this.criticalLimit;
+          this.$root.$emit('fan-system', false);
           this.endLoader();
           this.isBusy = false;
         });
-- 
cgit v1.2.3

