From 7d5e7b6f494c16640790734c39ffb2f1ed511358 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Tue, 16 Aug 2022 13:16:28 +0300 Subject: SILABMC-256: patch/get for limits --- .../modules/HardwareStatus/MotherboardStore.js | 30 ++++++++++++++++++++ src/utilities/_sila/metricProperties.js | 9 ++++++ .../_sila/Motherboard/Dynamic/MotherboardTemp.vue | 32 ++++++++++++++++++++-- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/store/modules/HardwareStatus/MotherboardStore.js b/src/store/modules/HardwareStatus/MotherboardStore.js index 09f24498..eecd3bc7 100644 --- a/src/store/modules/HardwareStatus/MotherboardStore.js +++ b/src/store/modules/HardwareStatus/MotherboardStore.js @@ -5,10 +5,12 @@ const MotherboardStore = { state: { motherboard: [], motherboardLastHour: [], + limits: [], }, getters: { motherboard: (state) => state.motherboard, motherboardLastHour: (state) => state.motherboardLastHour, + limits: (state) => state.limits, }, mutations: { setMotherboardDynamic: (state, data) => { @@ -17,8 +19,36 @@ const MotherboardStore = { setMotherboardDynamicLastHour: (state, data) => { state.motherboardLastHour = data; }, + setLimits: (state, data) => { + state.limits = data; + }, }, actions: { + async patchLimits() { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => + Temperatures.map((temperature) => + api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Temperatures: [ + { + MemberId: temperature.MemberId, + UpperThresholdNonCritical: 7, + }, + ], + }) + ) + ) + .catch((error) => console.log(error)); + }, + async getLimits({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimits', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getMotherboardDynamic({ commit }, { lastHour }) { let url = null; if (lastHour) { diff --git a/src/utilities/_sila/metricProperties.js b/src/utilities/_sila/metricProperties.js index edc701d6..e435bab2 100644 --- a/src/utilities/_sila/metricProperties.js +++ b/src/utilities/_sila/metricProperties.js @@ -1,3 +1,12 @@ +export function getGroups(data) { + return Object.keys( + data.reduce(function (rv, x) { + (rv[x['Sensor']] = rv[x['Sensor']] || []).push(x); + return rv; + }, {}) + ); +} + export function getItems(data, float = false) { let filteredData = data.filter((metric) => { return metric.Value !== 'nan'; diff --git a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue index 9f8d41cb..fde051e1 100644 --- a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue +++ b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue @@ -72,7 +72,7 @@ import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin'; import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin'; import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin'; -import { getItems } from '@/utilities/_sila/metricProperties'; +import { getItems, getGroups } from '@/utilities/_sila/metricProperties'; export default { components: { Chart }, @@ -121,10 +121,27 @@ export default { }, computed: { + groups() { + return getGroups(this.filteredSensors); + }, + items() { return getItems(this.filteredSensors); }, + limits() { + return this.$store.getters['motherboard/limits']; + }, + + limit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + allSensors() { return this.timeScale === 'hour' ? this.$store.getters['motherboard/motherboardLastHour'] @@ -152,9 +169,16 @@ export default { created() { this.loadData(); + // this.saveLimits(); }, methods: { + saveLimits() { + this.startLoader(); + this.$store + .dispatch('motherboard/patchLimits') + .finally(() => this.endLoader()); + }, loadData() { let payload = { lastHour: false }; if (this.timeScale === 'hour') { @@ -165,8 +189,10 @@ export default { this.$store .dispatch('motherboard/getMotherboardDynamic', payload) .finally(() => { - this.endLoader(); - this.isBusy = false; + this.$store.dispatch('motherboard/getLimits').finally(() => { + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3 From fe9b637630e8a58a68721d8ade914eff81936a5f Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Tue, 16 Aug 2022 18:42:20 +0300 Subject: SILABMC-256: add fields for motherboard --- src/components/_sila/Global/Chart.vue | 206 +++++++++++---------- src/locales/en-US.json | 6 + src/locales/ru-RU.json | 6 + .../modules/HardwareStatus/MotherboardStore.js | 24 ++- .../_sila/Motherboard/Dynamic/MotherboardTemp.vue | 27 +-- 5 files changed, 154 insertions(+), 115 deletions(-) diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue index ac8fc325..01e54071 100644 --- a/src/components/_sila/Global/Chart.vue +++ b/src/components/_sila/Global/Chart.vue @@ -54,27 +54,6 @@ export default { yMax: null, minTickInterval: null, plotBands: null, - plotLines: [ - { - color: '#E11717', - dashStyle: 'solid', - value: this.warning, - zIndex: '1000', - width: 2, - label: { - text: this.$t('chart.thresholdWarning'), - align: 'right', - style: { - fontFamily: 'Inter, sans-serif', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }, - ], }; }, computed: { @@ -200,20 +179,33 @@ export default { }, }; }, - }, - async created() { - this.setOptions(); - }, + plotLines() { + let plotLines = [ + { + color: '#E11717', + dashStyle: 'solid', + value: this.warning, + zIndex: '1000', + width: 2, + label: { + text: this.$t('chart.thresholdWarning'), + align: 'right', + style: { + fontFamily: 'Inter, sans-serif', + fontSize: '12px', + fontStyle: 'normal', + fontWeight: '400', + lineHeight: '16px', + color: '#0C1C2999', + }, + }, + }, + ]; - methods: { - setOptions() { switch (this.type) { case 'fans': - this.categories = this.setSpeed(10000); - this.minRange = 10000; - this.minTickInterval = 1000; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -232,54 +224,8 @@ export default { }, }); break; - case 'memory': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotBands = [ - { - color: '#F0AC0C1A', - dashStyle: 'solid', - from: this.notNormal, - to: this.critical, - }, - { - color: '#FF41411A', - dashStyle: 'solid', - from: this.critical, - to: this.warning, - }, - ]; - break; - case 'processors': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotBands = [ - { - color: '#F0AC0C1A', - dashStyle: 'solid', - from: this.notNormal, - to: this.critical, - }, - { - color: '#FF41411A', - dashStyle: 'solid', - from: this.critical, - to: this.warning, - }, - ]; - break; - case 'motherboard': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - break; case 'power': - this.categories = this.setCategories(101, 'Вт'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -299,10 +245,7 @@ export default { }); break; case 'voltage-input': - this.categories = this.setCategories(251, 'В'); - this.yMax = 250; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -322,10 +265,7 @@ export default { }); break; case 'voltage-output': - this.categories = this.setCategories(101, 'В'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -345,10 +285,7 @@ export default { }); break; case 'current': - this.categories = this.setCategories(11, 'A'); - this.yMax = 10; - this.minTickInterval = 2; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -368,10 +305,7 @@ export default { }); break; case 'psu-power': - this.categories = this.setCategories(126, 'Вт'); - this.yMax = 125; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -390,6 +324,90 @@ export default { }, }); } + return plotLines; + }, + }, + + async created() { + this.setOptions(); + }, + + methods: { + setOptions() { + switch (this.type) { + case 'fans': + this.categories = this.setSpeed(10000); + this.minRange = 10000; + this.minTickInterval = 1000; + break; + case 'memory': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + this.plotBands = [ + { + color: '#F0AC0C1A', + dashStyle: 'solid', + from: this.notNormal, + to: this.critical, + }, + { + color: '#FF41411A', + dashStyle: 'solid', + from: this.critical, + to: this.warning, + }, + ]; + break; + case 'processors': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + this.plotBands = [ + { + color: '#F0AC0C1A', + dashStyle: 'solid', + from: this.notNormal, + to: this.critical, + }, + { + color: '#FF41411A', + dashStyle: 'solid', + from: this.critical, + to: this.warning, + }, + ]; + break; + case 'motherboard': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'power': + this.categories = this.setCategories(101, 'Вт'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'voltage-input': + this.categories = this.setCategories(251, 'В'); + this.yMax = 250; + this.minTickInterval = 25; + break; + case 'voltage-output': + this.categories = this.setCategories(101, 'В'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'current': + this.categories = this.setCategories(11, 'A'); + this.yMax = 10; + this.minTickInterval = 2; + break; + case 'psu-power': + this.categories = this.setCategories(126, 'Вт'); + this.yMax = 125; + this.minTickInterval = 25; + } }, setCategories(count, desc) { const arr = [...new Array(count)].map((i, k) => `${k} ${desc}`); diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 768b499c..2907982b 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -881,6 +881,9 @@ "temperature": "Temperature indicators", "labels": { "warning": "Meaning of the warning" + }, + "toast": { + "errorLimitUpdate": "Limit update error" } }, "pageProcessors": { @@ -923,6 +926,9 @@ "minDate": "Date of minimum", "maxTemperature": "Maximum, С°", "maxDate": "Date of maximum" + }, + "toast": { + "errorLimitUpdate": "Limit update error" } }, "pagePowerSup": { diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 13e6fcac..46d75e83 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -881,6 +881,9 @@ "temperature": "Показатели температуры", "labels": { "warning": "Значение предупреждения" + }, + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" } }, "pageProcessors": { @@ -923,6 +926,9 @@ "minDate": "Дата минимального", "maxTemperature": "Максимальное, С°", "maxDate": "Дата максимального" + }, + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" } }, "pagePowerSup": { diff --git a/src/store/modules/HardwareStatus/MotherboardStore.js b/src/store/modules/HardwareStatus/MotherboardStore.js index eecd3bc7..e565eaa0 100644 --- a/src/store/modules/HardwareStatus/MotherboardStore.js +++ b/src/store/modules/HardwareStatus/MotherboardStore.js @@ -1,4 +1,5 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const MotherboardStore = { namespaced: true, @@ -24,22 +25,25 @@ const MotherboardStore = { }, }, actions: { - async patchLimits() { - return await api - .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') - .then(({ data: { Temperatures = [] } }) => - Temperatures.map((temperature) => - api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + async patchLimits({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { Temperatures: [ { - MemberId: temperature.MemberId, - UpperThresholdNonCritical: 7, + MemberId: group, + UpperThresholdNonCritical: warning, }, ], }) - ) ) - .catch((error) => console.log(error)); + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageMotherboard.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimits')); }, async getLimits({ commit }) { return await api diff --git a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue index 0c482cad..5fac0a89 100644 --- a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue +++ b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue @@ -5,11 +5,11 @@ {{ $t('pageMotherboard.temperature') }} - + { return ( limit?.UpperThresholdNonCritical && @@ -169,14 +170,17 @@ export default { created() { this.loadData(); - // this.saveLimits(); }, methods: { - saveLimits() { + saveLimit() { this.startLoader(); this.$store - .dispatch('motherboard/patchLimits') + .dispatch('motherboard/patchLimits', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) .finally(() => this.endLoader()); }, loadData() { @@ -190,6 +194,7 @@ export default { .dispatch('motherboard/getMotherboardDynamic', payload) .finally(() => { this.$store.dispatch('motherboard/getLimits').finally(() => { + this.warning = this.warningLimit; this.endLoader(); this.isBusy = false; }); -- cgit v1.2.3 From 9145a3dfb6608188269a480f7c45a483166d332d Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Tue, 16 Aug 2022 18:43:29 +0300 Subject: SILABMC-256: add fields for fans --- src/store/modules/HardwareStatus/FanStore.js | 34 +++++++++++++++ src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue | 65 ++++++++++++++++++++++------ 2 files changed, 86 insertions(+), 13 deletions(-) diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 26c20254..792c5ad1 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -1,14 +1,17 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const FanStore = { namespaced: true, state: { fans: [], fansLastHour: [], + limits: [], }, getters: { fans: (state) => state.fans, fansLastHour: (state) => state.fansLastHour, + limits: (state) => state.limits, }, mutations: { setFanInfo: (state, data) => { @@ -46,8 +49,39 @@ const FanStore = { setFansDynamicLastHour: (state, data) => { state.fansLastHour = data; }, + setLimits: (state, data) => { + state.limits = data; + }, }, actions: { + async patchLimits({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Speed: [ + { + MemberId: group, + UpperThresholdNonCritical: warning, + }, + ], + }) + ) + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageMotherboard.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimits')); + }, + async getLimits({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimits', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getFansDynamic({ commit }, { lastHour }) { let url = null; if (lastHour) { diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue index 10f6c9c5..7a3a392d 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue @@ -8,11 +8,11 @@ - + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + shutdownLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + allSensors() { return this.timeScale === 'hour' ? this.$store.getters['fan/fansLastHour'] @@ -212,6 +237,16 @@ export default { }, methods: { + saveLimit() { + this.startLoader(); + this.$store + .dispatch('fan/patchLimits', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, getPwmByCpu(cpu) { switch (cpu) { case 'CPU1_Fan': @@ -237,8 +272,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.shutdown = this.shutdownLimit; + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3 From 143223d899c3c1373c76b851ad6933424277e9bb Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Tue, 16 Aug 2022 18:43:55 +0300 Subject: SILABMC-256: add fields for memory --- src/store/modules/HardwareStatus/MemoryStore.js | 34 ++++++++++ src/views/_sila/Memory/Dynamic/MemoryTemp.vue | 82 ++++++++++++++++--------- 2 files changed, 88 insertions(+), 28 deletions(-) diff --git a/src/store/modules/HardwareStatus/MemoryStore.js b/src/store/modules/HardwareStatus/MemoryStore.js index 924d52a1..dd6c9a51 100644 --- a/src/store/modules/HardwareStatus/MemoryStore.js +++ b/src/store/modules/HardwareStatus/MemoryStore.js @@ -6,10 +6,12 @@ const MemoryStore = { state: { dimms: [], dimmsLastHour: [], + limits: [], }, getters: { dimms: (state) => state.dimms, dimmsLastHour: (state) => state.dimmsLastHour, + limits: (state) => state.limits, }, mutations: { setMemoryInfo: (state, data) => { @@ -62,8 +64,40 @@ const MemoryStore = { setMemoryDynamicLastHour: (state, data) => { state.dimmsLastHour = data; }, + + setLimits: (state, data) => { + state.limits = data; + }, }, actions: { + async patchLimits({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Temperatures: [ + { + MemberId: group, + UpperThresholdNonCritical: warning, + }, + ], + }) + ) + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageMemory.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimits')); + }, + async getLimits({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimits', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getMemoryDynamic({ commit }, { lastHour }) { let url = null; if (lastHour) { diff --git a/src/views/_sila/Memory/Dynamic/MemoryTemp.vue b/src/views/_sila/Memory/Dynamic/MemoryTemp.vue index 3505f827..f69e797a 100644 --- a/src/views/_sila/Memory/Dynamic/MemoryTemp.vue +++ b/src/views/_sila/Memory/Dynamic/MemoryTemp.vue @@ -4,11 +4,11 @@ {{ $t('pageMemory.temperature') }} - + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + criticalLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + allSensors() { return this.timeScale === 'hour' ? this.$store.getters['memory/dimmsLastHour'] @@ -180,6 +192,16 @@ export default { }, methods: { + saveLimit() { + this.startLoader(); + this.$store + .dispatch('memory/patchLimits', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, loadData() { let payload = { lastHour: false }; if (this.timeScale === 'hour') { @@ -188,8 +210,12 @@ export default { this.startLoader(); this.$store.dispatch('memory/getMemoryDynamic', payload).finally(() => { - this.endLoader(); - this.isBusy = false; + this.$store.dispatch('memory/getLimits').finally(() => { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3 From abfcb75c06375d3159a718334bca563feafcc466 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Wed, 17 Aug 2022 09:37:28 +0300 Subject: SILABMC-256: add fields for processors --- src/locales/en-US.json | 3 + src/locales/ru-RU.json | 3 + src/store/modules/HardwareStatus/ProcessorStore.js | 34 +++++++++ src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue | 4 +- src/views/_sila/Processors/Dynamic/CpuTemp.vue | 84 ++++++++++++++++------ 5 files changed, 103 insertions(+), 25 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 2907982b..87892373 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -895,6 +895,9 @@ "warning": "Warning", "shutdown": "Shutdown" }, + "toast": { + "errorLimitUpdate": "Limit update error" + }, "table": { "temperature": { "name": "Name", diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 46d75e83..ce293d8f 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -895,6 +895,9 @@ "warning": "Значение предупреждения", "shutdown": "Значение отказа" }, + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" + }, "table": { "temperature": { "name": "Имя модуля", diff --git a/src/store/modules/HardwareStatus/ProcessorStore.js b/src/store/modules/HardwareStatus/ProcessorStore.js index 68b29ab6..9a09dff4 100644 --- a/src/store/modules/HardwareStatus/ProcessorStore.js +++ b/src/store/modules/HardwareStatus/ProcessorStore.js @@ -8,12 +8,14 @@ const ProcessorStore = { cpuPower: [], cpuTempLastHour: [], cpuPowerLastHour: [], + limitsTemp: [], }, getters: { cpuTemp: (state) => state.cpuTemp, cpuPower: (state) => state.cpuPower, cpuTempLastHour: (state) => state.cpuTempLastHour, cpuPowerLastHour: (state) => state.cpuPowerLastHour, + limitsTemp: (state) => state.limitsTemp, }, mutations: { setProcessorsInfo: (state, data) => { @@ -78,8 +80,40 @@ const ProcessorStore = { setCpuPowerDynamicLastHour: (state, data) => { state.cpuPowerLastHour = data; }, + + setLimitsTemp: (state, data) => { + state.limitsTemp = data; + }, }, actions: { + async patchLimitsTemp({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Temperatures: [ + { + MemberId: group, + UpperThresholdNonCritical: warning, + }, + ], + }) + ) + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageProcessor.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimitsTemp')); + }, + async getLimitsTemp({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimitsTemp', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getCpuPowerDynamic({ commit }, { lastHour }) { let url = null; if (lastHour) { diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue index 7a3a392d..018e19a1 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue @@ -8,7 +8,7 @@ - + - + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + criticalLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + allSensors() { return this.timeScale === 'hour' ? this.$store.getters['processors/cpuTempLastHour'] @@ -176,6 +200,16 @@ export default { this.loadData(); }, methods: { + saveLimit() { + this.startLoader(); + this.$store + .dispatch('processors/patchLimitsTemp', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, onOpened(state) { if (state) { this.loadData(); @@ -192,8 +226,12 @@ export default { this.$store .dispatch('processors/getCpuTempDynamic', payload) .finally(() => { - this.endLoader(); - this.isBusy = false; + this.$store.dispatch('processors/getLimitsTemp').finally(() => { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3 From 0237b9c60425bbcd2417bf31000cbd74d0112645 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Wed, 17 Aug 2022 10:01:26 +0300 Subject: SILABMC-256: add fields for power, temp --- src/locales/en-US.json | 3 + src/locales/ru-RU.json | 3 + .../modules/HardwareStatus/PowerSupplyStore.js | 34 +++++++++ src/views/_sila/Power/Dynamic/PowerTemp.vue | 85 ++++++++++++++++------ 4 files changed, 101 insertions(+), 24 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 87892373..7ccf4654 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -949,6 +949,9 @@ "warning": "Meaning of the warning", "shutdown": "Shutdown" }, + "toast": { + "errorLimitUpdate": "Limit update error" + }, "table": { "param": "Parameter", "value": "Значение", diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index ce293d8f..83cf8b2e 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -943,6 +943,9 @@ "OutputVolt": "Выходное напряжение", "InputCurrent": "Входная сила тока", "OutputCurrent": "Выходная сила тока", + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" + }, "labels": { "notNormal": "Не штатный режим", "critical": "Критический режим", diff --git a/src/store/modules/HardwareStatus/PowerSupplyStore.js b/src/store/modules/HardwareStatus/PowerSupplyStore.js index 775e86e8..01f70156 100644 --- a/src/store/modules/HardwareStatus/PowerSupplyStore.js +++ b/src/store/modules/HardwareStatus/PowerSupplyStore.js @@ -1,4 +1,5 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const PowerSupplyStore = { namespaced: true, @@ -12,6 +13,7 @@ const PowerSupplyStore = { psuCurrent: [], psuCurrentLastHour: [], powerSupplies: [], + limitsTemp: [], }, getters: { powerSupplies: (state) => state.powerSupplies, @@ -23,6 +25,7 @@ const PowerSupplyStore = { psuVoltageLastHour: (state) => state.psuVoltageLastHour, psuCurrent: (state) => state.psuCurrent, psuCurrentLastHour: (state) => state.psuCurrentLastHour, + limitsTemp: (state) => state.limitsTemp, }, mutations: { setPowerSupply: (state, data) => { @@ -84,8 +87,39 @@ const PowerSupplyStore = { setpsu_currentLastHour: (state, data) => { state.psuCurrentLastHour = data; }, + setLimitsTemp: (state, data) => { + state.limitsTemp = data; + }, }, actions: { + async patchLimitsTemp({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Temperatures: [ + { + MemberId: group, + UpperThresholdNonCritical: warning, + }, + ], + }) + ) + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pagePowerSup.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimitsTemp')); + }, + async getLimitsTemp({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimitsTemp', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getPsu({ commit }, { lastHour, metricsName }) { let url = null; if (lastHour) { diff --git a/src/views/_sila/Power/Dynamic/PowerTemp.vue b/src/views/_sila/Power/Dynamic/PowerTemp.vue index e0d4d154..1d18e8b1 100644 --- a/src/views/_sila/Power/Dynamic/PowerTemp.vue +++ b/src/views/_sila/Power/Dynamic/PowerTemp.vue @@ -8,43 +8,42 @@ - + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + criticalLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + allSensors() { return this.timeScale === 'hour' ? this.$store.getters['powerSupply/psuTempLastHour'] @@ -171,6 +195,16 @@ export default { this.loadData(); }, methods: { + saveLimit() { + this.startLoader(); + this.$store + .dispatch('powerSupply/patchLimitsTemp', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, onOpened(state) { if (state) { this.loadData(); @@ -183,9 +217,12 @@ export default { } this.startLoader(); this.$store.dispatch('powerSupply/getPsu', payload).finally(() => { - this.$root.$emit('psu-temp'); - this.isBusy = false; - this.endLoader(); + this.$store.dispatch('powerSupply/getLimitsTemp').finally(() => { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3