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/Processors/Dynamic/CpuTemp.vue | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'src/views/_sila/Processors/Dynamic/CpuTemp.vue')

diff --git a/src/views/_sila/Processors/Dynamic/CpuTemp.vue b/src/views/_sila/Processors/Dynamic/CpuTemp.vue
index f4e9a49f..f33b328a 100644
--- a/src/views/_sila/Processors/Dynamic/CpuTemp.vue
+++ b/src/views/_sila/Processors/Dynamic/CpuTemp.vue
@@ -1,7 +1,9 @@
 <template>
   <collapse
     id="collapse_temp"
+    :class="{ disabledDiv: loading && opened }"
     :title="$t('pageProcessors.temperature')"
+    :opened="true"
     @opened="onOpened"
   >
     <template #image>
@@ -147,6 +149,7 @@ export default {
       warning: null,
       critical: null,
       isBusy: true,
+      opened: false,
       fields: [
         {
           key: 'name',
@@ -251,12 +254,14 @@ export default {
 
   watch: {
     timeScale() {
+      if (!this.opened) {
+        return;
+      }
+
       this.loadData();
     },
   },
-  created() {
-    this.loadData();
-  },
+
   methods: {
     saveLimit() {
       this.$v.$touch();
@@ -276,6 +281,7 @@ export default {
       if (state) {
         this.loadData();
       }
+      this.opened = state;
     },
 
     loadData() {
@@ -284,6 +290,7 @@ export default {
         payload = { lastHour: true };
       }
 
+      this.$root.$emit('cpu-temp', true);
       this.startLoader();
       this.$store
         .dispatch('processors/getCpuTempDynamic', payload)
@@ -291,6 +298,7 @@ export default {
           this.$store.dispatch('processors/getLimitsTemp').finally(() => {
             this.warning = this.warningLimit;
             this.critical = this.criticalLimit;
+            this.$root.$emit('cpu-temp', false);
             this.endLoader();
             this.isBusy = false;
           });
-- 
cgit v1.2.3

