From 362937100773d9180a821e9ee4c1a872c406478a Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Wed, 17 Aug 2022 10:29:19 +0300 Subject: SILABMC-256: add fields for power, vol input --- .../modules/HardwareStatus/PowerSupplyStore.js | 37 +++++++++++ src/views/_sila/Power/Dynamic/VoltInput.vue | 73 +++++++++++++++++----- 2 files changed, 94 insertions(+), 16 deletions(-) diff --git a/src/store/modules/HardwareStatus/PowerSupplyStore.js b/src/store/modules/HardwareStatus/PowerSupplyStore.js index 01f70156..379bb3d1 100644 --- a/src/store/modules/HardwareStatus/PowerSupplyStore.js +++ b/src/store/modules/HardwareStatus/PowerSupplyStore.js @@ -14,6 +14,7 @@ const PowerSupplyStore = { psuCurrentLastHour: [], powerSupplies: [], limitsTemp: [], + limitsVol: [], }, getters: { powerSupplies: (state) => state.powerSupplies, @@ -26,6 +27,7 @@ const PowerSupplyStore = { psuCurrent: (state) => state.psuCurrent, psuCurrentLastHour: (state) => state.psuCurrentLastHour, limitsTemp: (state) => state.limitsTemp, + limitsVol: (state) => state.limitsTemp, }, mutations: { setPowerSupply: (state, data) => { @@ -90,6 +92,9 @@ const PowerSupplyStore = { setLimitsTemp: (state, data) => { state.limitsTemp = data; }, + setLimitsVol: (state, data) => { + state.limitsTemp = data; + }, }, actions: { async patchLimitsTemp({ dispatch }, { warning, groups }) { @@ -120,6 +125,38 @@ const PowerSupplyStore = { }) .catch((error) => console.log(error)); }, + async patchLimitsVol({ dispatch }, { warning, critical, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Power', { + Voltages: [ + { + MemberId: group, + UpperThresholdNonCritical: warning, + }, + { + MemberId: group, + UpperThresholdCritical: critical, + }, + ], + }) + ) + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pagePowerSup.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimitsVol')); + }, + async getLimitsVol({ commit }) { + return await api + .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') + .then(({ data: { Temperatures = [] } }) => { + commit('setLimitsVol', Temperatures); + }) + .catch((error) => console.log(error)); + }, async getPsu({ commit }, { lastHour, metricsName }) { let url = null; if (lastHour) { diff --git a/src/views/_sila/Power/Dynamic/VoltInput.vue b/src/views/_sila/Power/Dynamic/VoltInput.vue index 4d76b484..2843c27e 100644 --- a/src/views/_sila/Power/Dynamic/VoltInput.vue +++ b/src/views/_sila/Power/Dynamic/VoltInput.vue @@ -8,21 +8,21 @@ - + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + criticalLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + filteredItems() { return psuFilter(this.allSensors, 'Input'); }, @@ -168,6 +194,17 @@ export default { this.loadData(); }, methods: { + saveLimit() { + this.startLoader(); + this.$store + .dispatch('powerSupply/patchLimitsVol', { + warning: this.warning, + critical: this.critical, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, onOpened(state) { if (state) { this.loadData(); @@ -181,9 +218,13 @@ export default { this.startLoader(); this.$store.dispatch('powerSupply/getPsu', payload).finally(() => { - this.$root.$emit('psu-volt'); - this.isBusy = false; - this.endLoader(); + this.$store.dispatch('powerSupply/getLimitsVol').finally(() => { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + this.$root.$emit('psu-volt'); + this.endLoader(); + this.isBusy = false; + }); }); }, }, -- cgit v1.2.3