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