From 214d4d58742478b1e9ad3d0549568a92114179b8 Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Mon, 29 Aug 2022 17:45:10 +0300
Subject: one req for fans, dynamic

---
 src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 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 b86e1672..a499a08d 100644
--- a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
+++ b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
@@ -1,7 +1,7 @@
 <template>
   <collapse
     id="collapse_FansSystem"
-    :class="{ disabledDiv: loading && opened }"
+    :class="{ disabledDiv: (loading || isPageLoading) && opened }"
     :title="$t('pageFans.speedSystem')"
     :opened="true"
     @opened="onOpened"
@@ -56,7 +56,9 @@
               variant="primary"
               style="height: 35px"
               :disabled="
-                loading || $store.getters['authentication/role'] === 'ReadOnly'
+                loading ||
+                isPageLoading ||
+                $store.getters['authentication/role'] === 'ReadOnly'
               "
               @click="saveLimit"
             >
@@ -154,7 +156,7 @@ export default {
       loading,
       warning: null,
       critical: null,
-      isBusy: true,
+      isBusy: false,
       opened: false,
       fields: [
         {
@@ -236,6 +238,10 @@ export default {
       return this.$store.getters['fan/limits'];
     },
 
+    isPageLoading() {
+      return this.$store.getters['fan/isLoading'];
+    },
+
     warningLimit() {
       return this.limits.find((limit) => {
         return (
@@ -261,8 +267,8 @@ export default {
 
     allSensors() {
       return this.timeScale === 'hour'
-        ? this.$store.getters['fan/fansSystemLastHour']
-        : this.$store.getters['fan/fansSystem'];
+        ? this.$store.getters['fan/fansLastHour']
+        : this.$store.getters['fan/fans'];
     },
 
     preFiltered() {
@@ -335,6 +341,10 @@ export default {
     },
 
     loadData() {
+      if (this.isPageLoading) {
+        return;
+      }
+
       let payload = { lastHour: false };
       if (this.timeScale === 'hour') {
         payload = { lastHour: true };
@@ -342,13 +352,16 @@ export default {
 
       this.$root.$emit('fan-system', true);
       this.startLoader();
-      this.$store.dispatch('fan/getFansSystem', payload).finally(() => {
+      this.isBusy = true;
+      this.$store.commit('fan/setIsLoading', true);
+      this.$store.dispatch('fan/getFans', 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;
+          this.$store.commit('fan/setIsLoading', false);
         });
       });
     },
-- 
cgit v1.2.3

