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(-) (limited to 'src') 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