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