From ca981a5cf99f016be02dddc090c2927dd9997c42 Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Mon, 22 Aug 2022 17:31:25 +0300
Subject: SILABMC-271: add max reading as chart max

---
 src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue | 48 +++++++++++++++++++++----
 1 file changed, 42 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 06f4dd14..bcf0b375 100644
--- a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
+++ b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue
@@ -42,7 +42,8 @@
         :time-scale="timeScale"
         :data="filteredForChart"
         :warning="warning"
-        :shutdown="shutdown"
+        :critical="critical"
+        :max="maxLimit"
       ></chart>
 
       <b-table
@@ -96,7 +97,7 @@ import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin';
 import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin';
 import Collapse from '@/components/_sila/Global/Collapse';
 
-import { getItems } from '@/utilities/_sila/metricProperties';
+import { getGroups, getItems } from '@/utilities/_sila/metricProperties';
 import { fanFilter } from '@/utilities/_sila/psuFilter';
 
 export default {
@@ -110,8 +111,8 @@ export default {
   },
   data() {
     return {
-      warning: 8900,
-      shutdown: 9500,
+      warning: null,
+      critical: null,
       isBusy: true,
       fields: [
         {
@@ -151,6 +152,10 @@ export default {
   },
 
   computed: {
+    groups() {
+      return getGroups(this.filteredSensors);
+    },
+
     items() {
       const allArr = getItems(this.filteredSensors);
 
@@ -172,6 +177,33 @@ export default {
       });
     },
 
+    limits() {
+      return this.$store.getters['fan/limits'];
+    },
+
+    warningLimit() {
+      return this.limits.find((limit) => {
+        return (
+          limit?.UpperThresholdNonCritical &&
+          this.groups.includes(limit.MemberId)
+        );
+      })?.UpperThresholdNonCritical;
+    },
+
+    criticalLimit() {
+      return this.limits.find((limit) => {
+        return (
+          limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId)
+        );
+      })?.UpperThresholdCritical;
+    },
+
+    maxLimit() {
+      return this.limits.find((limit) => {
+        return limit?.MaxReadingRange;
+      })?.MaxReadingRange;
+    },
+
     allSensors() {
       return this.timeScale === 'hour'
         ? this.$store.getters['fan/fansLastHour']
@@ -239,8 +271,12 @@ export default {
 
       this.startLoader();
       this.$store.dispatch('fan/getFansDynamic', payload).finally(() => {
-        this.endLoader();
-        this.isBusy = false;
+        this.$store.dispatch('fan/getLimits').finally(() => {
+          this.warning = this.warningLimit;
+          this.critical = this.criticalLimit;
+          this.endLoader();
+          this.isBusy = false;
+        });
       });
     },
   },
-- 
cgit v1.2.3

