From 7cba13534cda94a1efdbad2ff8dbe68de1fbeaa3 Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Thu, 21 Jul 2022 20:56:53 +0300
Subject: add charts for fans and processors

---
 src/views/_sila/Fans/Dynamic/FansDynamicPage.vue | 44 ++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 src/views/_sila/Fans/Dynamic/FansDynamicPage.vue

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

diff --git a/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue
new file mode 100644
index 00000000..543eea33
--- /dev/null
+++ b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue
@@ -0,0 +1,44 @@
+<template>
+  <b-container fluid="xl">
+    <page-title :description="$t('appPageTitle.dynamicInformation')" />
+
+    <chart :data="filteredSensors"></chart>
+  </b-container>
+</template>
+
+<script>
+import PageTitle from '@/components/_sila/Global/PageTitle';
+import Chart from '@/components/_sila/Global/Chart';
+
+import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
+import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin';
+import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin';
+
+export default {
+  components: { PageTitle, Chart },
+  mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin],
+  data() {
+    return {
+      activeFilters: [],
+    };
+  },
+
+  computed: {
+    allSensors() {
+      let sensors = this.$store.getters['fan/fans'];
+      return sensors;
+    },
+
+    filteredSensors() {
+      return this.getFilteredTableData(this.allSensors, this.activeFilters);
+    },
+  },
+
+  created() {
+    this.startLoader();
+    this.$store.dispatch('fan/getFansDynamic').finally(() => {
+      this.endLoader();
+    });
+  },
+};
+</script>
-- 
cgit v1.2.3


From 381cc079a34a56d3b6f1bd78e52086d94814df80 Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Fri, 22 Jul 2022 12:16:07 +0300
Subject: add motherboard6 fix others

---
 src/components/_sila/Global/Chart.vue              | 109 +++++++++++++++++----
 src/components/_sila/Global/helpers.js             |  13 ---
 src/env/components/AppNavigation/sila.js           |  11 +++
 src/env/router/sila.js                             |   9 ++
 src/locales/en-US.json                             |   4 +-
 src/locales/ru-RU.json                             |   5 +-
 src/store/index.js                                 |   2 +
 .../_sila/HardwareStatus/MotherboardStore.js       |  28 ++++++
 src/views/_sila/Fans/Dynamic/FansDynamicPage.vue   |   9 +-
 .../_sila/Memory/Dynamic/MemoryDynamicPage.vue     |  11 ++-
 .../Motherboard/Dynamic/MotherboardDynamicPage.vue |  53 ++++++++++
 src/views/_sila/Motherboard/Dynamic/index.js       |   2 +
 .../Processors/Dynamic/ProcessorsDynamicPage.vue   |  11 ++-
 13 files changed, 230 insertions(+), 37 deletions(-)
 delete mode 100644 src/components/_sila/Global/helpers.js
 create mode 100644 src/store/modules/_sila/HardwareStatus/MotherboardStore.js
 create mode 100644 src/views/_sila/Motherboard/Dynamic/MotherboardDynamicPage.vue
 create mode 100644 src/views/_sila/Motherboard/Dynamic/index.js

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

diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue
index 8064a23f..c5214bd7 100644
--- a/src/components/_sila/Global/Chart.vue
+++ b/src/components/_sila/Global/Chart.vue
@@ -3,7 +3,6 @@
 </template>
 
 <script>
-import { setCategories } from './helpers';
 import { Chart } from 'highcharts-vue';
 
 export default {
@@ -15,6 +14,10 @@ export default {
       type: Array,
       default: () => [],
     },
+    type: {
+      type: String,
+      default: '',
+    },
     timeScale: {
       type: String,
       default: 'hour',
@@ -23,6 +26,10 @@ export default {
       type: Number,
       default: 70,
     },
+    shutdown: {
+      type: Number,
+      default: 3150,
+    },
     nonNormal: {
       type: Number,
       default: 70,
@@ -32,6 +39,15 @@ export default {
       default: 70,
     },
   },
+  data() {
+    return {
+      categories: null,
+      minRange: null,
+      yMax: null,
+      minTickInterval: null,
+      plotBands: null,
+    };
+  },
   computed: {
     metricData() {
       let filteredData = this.data.filter((metric) => {
@@ -122,11 +138,12 @@ export default {
           minorGridLineColor: '#1A3E5B1A',
         },
         yAxis: {
-          categories: setCategories(101, 'С°'),
+          categories: this.categories,
           min: 0,
-          max: 100,
+          max: this.yMax,
           title: null,
-          minTickInterval: 25,
+          minRange: this.minRange,
+          minTickInterval: this.minTickInterval,
           minorGridLineColor: '#1A3E5B1A',
           plotLines: [
             {
@@ -136,7 +153,7 @@ export default {
               zIndex: '1000',
               width: 2,
               label: {
-                text: 'Пороговое значение предупреждения, С°',
+                text: 'Пороговое значение предупреждения',
                 align: 'right',
                 style: {
                   fontFamily: 'Inter, sans-serif',
@@ -149,20 +166,7 @@ export default {
               },
             },
           ],
-          plotBands: [
-            {
-              color: '#F0AC0C1A',
-              dashStyle: 'solid',
-              from: this.nonNormal,
-              to: this.criticalStart,
-            },
-            {
-              color: '#FF41411A',
-              dashStyle: 'solid',
-              from: this.criticalStart,
-              to: this.warning,
-            },
-          ],
+          plotBands: this.plotBands,
         },
         series: this.metricData.map((item) => ({
           ...item,
@@ -185,6 +189,73 @@ export default {
       };
     },
   },
+
+  async created() {
+    this.setOptions();
+  },
+
+  methods: {
+    setOptions() {
+      switch (this.type) {
+        case 'fans':
+          this.categories = this.setSpeed(4000);
+          this.minRange = 4000;
+          this.minTickInterval = 1000;
+          this.plotBands = [
+            {
+              color: '#F0AC0C1A',
+              dashStyle: 'solid',
+              from: this.nonNormal,
+              to: this.criticalStart,
+            },
+            {
+              color: '#FF41411A',
+              dashStyle: 'solid',
+              from: this.criticalStart,
+              to: this.warning,
+            },
+          ];
+          break;
+        case 'memory':
+          this.categories = this.setCategories(101, 'С°');
+          this.yMax = 100;
+          this.minTickInterval = 25;
+          this.plotBands = [
+            {
+              color: '#F0AC0C1A',
+              dashStyle: 'solid',
+              from: this.nonNormal,
+              to: this.criticalStart,
+            },
+            {
+              color: '#FF41411A',
+              dashStyle: 'solid',
+              from: this.criticalStart,
+              to: this.warning,
+            },
+          ];
+          break;
+        case 'processors':
+          this.categories = this.setCategories(101, 'С°');
+          this.yMax = 100;
+          this.minTickInterval = 25;
+          break;
+        case 'motherboard':
+          this.categories = this.setCategories(101, 'С°');
+          this.yMax = 100;
+          this.minTickInterval = 25;
+          break;
+      }
+    },
+    setCategories(count, desc) {
+      const arr = [...new Array(count)].map((i, k) => `${k} ${desc}`);
+      return arr;
+    },
+    setSpeed(count) {
+      const arr = [...new Array(count)].map((i, k) => `${k}`);
+      return arr;
+    },
+  },
 };
 </script>
 <style lang="scss">
diff --git a/src/components/_sila/Global/helpers.js b/src/components/_sila/Global/helpers.js
deleted file mode 100644
index 687a9554..00000000
--- a/src/components/_sila/Global/helpers.js
+++ /dev/null
@@ -1,13 +0,0 @@
-export const colors = [
-  '#CB32F1',
-  '#F18638',
-  '#139BB9',
-  '#E1AB17',
-  '#175AE1',
-  '#13B937',
-];
-
-export const setCategories = (count, desc) => {
-  const arr = [...new Array(count)].map((i, k) => `${k} ${desc}`);
-  return arr;
-};
diff --git a/src/env/components/AppNavigation/sila.js b/src/env/components/AppNavigation/sila.js
index 4f47342e..3319368b 100644
--- a/src/env/components/AppNavigation/sila.js
+++ b/src/env/components/AppNavigation/sila.js
@@ -76,6 +76,17 @@ const AppNavigationMixin = {
             },
           ],
         },
+        {
+          id: 'motherboard',
+          label: this.$t('appNavigation.motherboard'),
+          children: [
+            {
+              id: 'motherboard/dynamic',
+              label: this.$t('appNavigation.dynamicInformation'),
+              route: '/motherboard/dynamic',
+            },
+          ],
+        },
         {
           id: 'operations',
           label: this.$t('appNavigation.operations'),
diff --git a/src/env/router/sila.js b/src/env/router/sila.js
index 4a5d5b71..dbf4369f 100644
--- a/src/env/router/sila.js
+++ b/src/env/router/sila.js
@@ -33,6 +33,7 @@ import FansStatic from '@/views/_sila/Fans/Static';
 import ProcessorsDynamic from '@/views/_sila/Processors/Dynamic';
 import MemoryDynamic from '@/views/_sila/Memory/Dynamic';
 import FansDynamic from '@/views/_sila/Fans/Dynamic';
+import MotherboardDynamic from '@/views/_sila/Motherboard/Dynamic';
 import i18n from '@/i18n';
 
 const routes = [
@@ -187,6 +188,14 @@ const routes = [
           title: i18n.t('appPageTitle.fans'),
         },
       },
+      {
+        path: 'motherboard/dynamic',
+        name: 'motherboard-dynamic',
+        component: MotherboardDynamic,
+        meta: {
+          title: i18n.t('appPageTitle.motherboard'),
+        },
+      },
       {
         path: '/security-and-access/sessions',
         name: 'sessions',
diff --git a/src/locales/en-US.json b/src/locales/en-US.json
index 1ec41e9e..6c303cd8 100644
--- a/src/locales/en-US.json
+++ b/src/locales/en-US.json
@@ -133,7 +133,8 @@
     "fans": "@:appPageTitle.fans",
     "processors": "@:appPageTitle.processors",
     "memory": "@:appPageTitle.memory",
-    "fans": "@:appPageTitle.fans"
+    "fans": "@:appPageTitle.fans",
+    "motherboard": "@:appPageTitle.motherboard"
   },
   "appPageTitle": {
     "changePassword": "Change password",
@@ -146,6 +147,7 @@
     "fans": "Fans",
     "processors": "Processors",
     "memory": "Memory modules",
+    "motherboard": "Motherboard",
     "firmware": "Firmware",
     "inventory": "Inventory and LEDs",
     "kvm": "KVM",
diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json
index 9bc62183..950a7ce3 100644
--- a/src/locales/ru-RU.json
+++ b/src/locales/ru-RU.json
@@ -110,6 +110,7 @@
     "processors": "Процессоры",
     "memory": "Модули памяти",
     "fans": "Ветиляторы",
+    "motherboard": "Материнская плата",
     "dateTime": "@:appPageTitle.dateTime",
     "dumps": "@:appPageTitle.dumps",
     "eventLogs": "@:appPageTitle.eventLogs",
@@ -139,7 +140,8 @@
     "staticInfo": "Статическая информация",
     "fans": "@:appPageTitle.fans",
     "processors": "@:appPageTitle.processors",
-    "memory": "@:appPageTitle.memory"
+    "memory": "@:appPageTitle.memory",
+    "motherboard": "@:appPageTitle.motherboard"
   },
   "appPageTitle": {
     "changePassword": "Изменить пароль",
@@ -152,6 +154,7 @@
     "fans": "Вентиляторы",
     "processors": "Процессоры",
     "memory": "Модули памяти",
+    "motherboard": "Материнская плата",
     "firmware": "Встроенное ПО",
     "inventory": "Перечень оборудования и LED",
     "kvm": "KVM",
diff --git a/src/store/index.js b/src/store/index.js
index 11183e00..fa857b3a 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -20,6 +20,7 @@ import SystemStore from './modules/HardwareStatus/SystemStore';
 import PowerSupplyStore from './modules/HardwareStatus/PowerSupplyStore';
 import MemoryStore from './modules/HardwareStatus/MemoryStore';
 import FanStore from './modules/_sila/HardwareStatus/FanStore';
+import MotherboardStore from './modules/_sila/HardwareStatus/MotherboardStore';
 import ChassisStore from './modules/HardwareStatus/ChassisStore';
 import BmcStore from './modules/HardwareStatus/BmcStore';
 import ProcessorStore from './modules/HardwareStatus/ProcessorStore';
@@ -60,6 +61,7 @@ export default new Vuex.Store({
     system: SystemStore,
     memory: MemoryStore,
     fan: FanStore,
+    motherboard: MotherboardStore,
     chassis: ChassisStore,
     bmc: BmcStore,
     processors: ProcessorStore,
diff --git a/src/store/modules/_sila/HardwareStatus/MotherboardStore.js b/src/store/modules/_sila/HardwareStatus/MotherboardStore.js
new file mode 100644
index 00000000..93d655f9
--- /dev/null
+++ b/src/store/modules/_sila/HardwareStatus/MotherboardStore.js
@@ -0,0 +1,28 @@
+import api from '@/store/api';
+
+const MotherboardStore = {
+  namespaced: true,
+  state: {
+    motherboard: [],
+  },
+  getters: {
+    motherboard: (state) => state.motherboard,
+  },
+  mutations: {
+    setMotherboardDynamic: (state, data) => {
+      state.motherboard = data;
+    },
+  },
+  actions: {
+    async getMotherboardDynamic({ commit }) {
+      return await api
+        .get('/redfish/v1/TelemetryService/MetricReports/hour_data&other_temp')
+        .then(({ data: { MetricValues = [] } }) =>
+          commit('setMotherboardDynamic', MetricValues)
+        )
+        .catch((error) => console.log(error));
+    },
+  },
+};
+
+export default MotherboardStore;
diff --git a/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue
index 543eea33..22374fa7 100644
--- a/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue
+++ b/src/views/_sila/Fans/Dynamic/FansDynamicPage.vue
@@ -2,7 +2,12 @@
   <b-container fluid="xl">
     <page-title :description="$t('appPageTitle.dynamicInformation')" />
 
-    <chart :data="filteredSensors"></chart>
+    <chart
+      type="fans"
+      :data="filteredSensors"
+      :warning="fanSpeedWarninig"
+      :shutdown="fanSpeedShutdown"
+    ></chart>
   </b-container>
 </template>
 
@@ -20,6 +25,8 @@ export default {
   data() {
     return {
       activeFilters: [],
+      fanSpeedWarninig: 2450,
+      fanSpeedShutdown: 3150,
     };
   },
 
diff --git a/src/views/_sila/Memory/Dynamic/MemoryDynamicPage.vue b/src/views/_sila/Memory/Dynamic/MemoryDynamicPage.vue
index 59f7cbc5..21e18fe1 100644
--- a/src/views/_sila/Memory/Dynamic/MemoryDynamicPage.vue
+++ b/src/views/_sila/Memory/Dynamic/MemoryDynamicPage.vue
@@ -2,7 +2,13 @@
   <b-container fluid="xl">
     <page-title :description="$t('appPageTitle.dynamicInformation')" />
 
-    <chart :data="filteredSensors"></chart>
+    <chart
+      type="memory"
+      :data="filteredSensors"
+      :warning="temperatureWarning"
+      :non-normal="temperatureNonNormal"
+      :critical-start="temperatureCriticalStart"
+    ></chart>
   </b-container>
 </template>
 
@@ -20,6 +26,9 @@ export default {
   data() {
     return {
       activeFilters: [],
+      temperatureWarning: 72,
+      temperatureNonNormal: 44,
+      temperatureCriticalStart: 55,
     };
   },
 
diff --git a/src/views/_sila/Motherboard/Dynamic/MotherboardDynamicPage.vue b/src/views/_sila/Motherboard/Dynamic/MotherboardDynamicPage.vue
new file mode 100644
index 00000000..b4d13f3f
--- /dev/null
+++ b/src/views/_sila/Motherboard/Dynamic/MotherboardDynamicPage.vue
@@ -0,0 +1,53 @@
+<template>
+  <b-container fluid="xl">
+    <page-title :description="$t('appPageTitle.dynamicInformation')" />
+
+    <chart
+      type="motherboard"
+      :data="filteredSensors"
+      :warning="temperatureWarning"
+      :non-normal="temperatureNonNormal"
+      :critical-start="temperatureCriticalStart"
+    ></chart>
+  </b-container>
+</template>
+
+<script>
+import PageTitle from '@/components/_sila/Global/PageTitle';
+import Chart from '@/components/_sila/Global/Chart';
+
+import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
+import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin';
+import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin';
+
+export default {
+  components: { PageTitle, Chart },
+  mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin],
+  data() {
+    return {
+      activeFilters: [],
+      temperatureWarning: 72,
+      temperatureNonNormal: 44,
+      temperatureCriticalStart: 55,
+    };
+  },
+
+  computed: {
+    allSensors() {
+      let sensors = this.$store.getters['motherboard/motherboard'];
+      return sensors;
+    },
+
+    filteredSensors() {
+      return this.getFilteredTableData(this.allSensors, this.activeFilters);
+    },
+  },
+
+  created() {
+    this.startLoader();
+    this.$store.dispatch('motherboard/getMotherboardDynamic').finally(() => {
+      this.endLoader();
+    });
+  },
+};
+</script>
diff --git a/src/views/_sila/Motherboard/Dynamic/index.js b/src/views/_sila/Motherboard/Dynamic/index.js
new file mode 100644
index 00000000..bd155997
--- /dev/null
+++ b/src/views/_sila/Motherboard/Dynamic/index.js
@@ -0,0 +1,2 @@
+import MotherboardDynamicPage from './MotherboardDynamicPage.vue';
+export default MotherboardDynamicPage;
diff --git a/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue b/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue
index 8525b174..656d16e9 100644
--- a/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue
+++ b/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue
@@ -30,7 +30,13 @@
   <b-container fluid="xl">
     <page-title :description="$t('appPageTitle.dynamicInformation')" />
 
-    <chart :data="filteredSensors"></chart>
+    <chart
+      type="processors"
+      :data="filteredSensors"
+      :warning="temperatureWarning"
+      :non-normal="temperatureNonNormal"
+      :critical-start="temperatureCriticalStart"
+    ></chart>
   </b-container>
 </template>
 
@@ -50,6 +56,9 @@ export default {
   data() {
     return {
       activeFilters: [],
+      temperatureWarning: 72,
+      temperatureNonNormal: 44,
+      temperatureCriticalStart: 55,
     };
   },
 
-- 
cgit v1.2.3

