From 0847eaf4cc4b050fc6f297940013a3e7e4c1cb81 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Thu, 25 Aug 2022 12:16:17 +0300 Subject: SILABMC-256: add limits for Voltage --- src/components/_sila/Global/Chart.vue | 117 ++---------- .../modules/HardwareStatus/PowerSupplyStore.js | 42 +++-- src/views/_sila/Power/Dynamic/VoltInput.vue | 124 ++++++++++--- src/views/_sila/Power/Dynamic/VoltOutput.vue | 202 +++++++++++++++++---- 4 files changed, 295 insertions(+), 190 deletions(-) diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue index 6a3775bb..5fd2dd31 100644 --- a/src/components/_sila/Global/Chart.vue +++ b/src/components/_sila/Global/Chart.vue @@ -31,10 +31,6 @@ export default { type: Number, default: null, }, - shutdown: { - type: Number, - default: null, - }, critical: { type: Number, default: null, @@ -196,70 +192,14 @@ export default { case 'processors': case 'power': case 'memory': - plotLines.push({ - color: '#E11717', - dashStyle: 'solid', - value: this.critical, - width: 2, - label: { - text: this.$t('chart.thresholdFailure'), - align: 'right', - style: { - fontFamily: 'Inter', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }); - break; case 'voltage-input': - plotLines.push({ - color: '#1A3E5B', - dashStyle: 'solid', - value: this.shutdown, - width: 2, - label: { - text: this.$t('chart.thresholdFailure'), - align: 'right', - style: { - fontFamily: 'Inter', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }); - break; case 'voltage-output': - plotLines.push({ - color: '#1A3E5B', - dashStyle: 'solid', - value: this.shutdown, - width: 2, - label: { - text: this.$t('chart.thresholdFailure'), - align: 'right', - style: { - fontFamily: 'Inter', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }); - break; case 'current': + case 'psu-power': plotLines.push({ - color: '#1A3E5B', + color: '#E11717', dashStyle: 'solid', - value: this.shutdown, + value: this.critical, width: 2, label: { text: this.$t('chart.thresholdFailure'), @@ -275,25 +215,6 @@ export default { }, }); break; - case 'psu-power': - plotLines.push({ - color: '#1A3E5B', - dashStyle: 'solid', - value: this.shutdown, - width: 2, - label: { - text: this.$t('chart.thresholdWarning'), - align: 'right', - style: { - fontFamily: 'Inter', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }); } return plotLines; }, @@ -316,6 +237,10 @@ export default { case 'processors': case 'power': case 'fans': + case 'voltage-input': + case 'voltage-output': + case 'current': + case 'psu-power': plotBands = [ { color: '#F0AC0C1A', @@ -343,22 +268,14 @@ export default { case 'memory': case 'processors': case 'fans': - yMax = this.max; - break; - case 'power': - yMax = 100; - break; case 'voltage-input': - yMax = 250; - break; case 'voltage-output': - yMax = 100; - break; case 'current': - yMax = 10; - break; case 'psu-power': - yMax = 125; + yMax = this.max; + break; + case 'power': + yMax = 100; break; } return yMax; @@ -369,25 +286,19 @@ export default { switch (this.type) { case 'motherboard': + case 'memory': + case 'processors': categories = this.setCategories(this.setMaxWithInterval(), 'С°'); break; case 'fans': categories = this.setSpeed(this.setMaxWithInterval()); break; - case 'memory': - categories = this.setCategories(this.setMaxWithInterval(), 'С°'); - break; - case 'processors': - categories = this.setCategories(this.setMaxWithInterval(), 'С°'); - break; case 'power': categories = this.setCategories(101, 'Вт'); break; case 'voltage-input': - categories = this.setCategories(251, 'В'); - break; case 'voltage-output': - categories = this.setCategories(101, 'В'); + categories = this.setCategories(this.setMaxWithInterval(), 'В'); break; case 'current': categories = this.setCategories(11, 'A'); diff --git a/src/store/modules/HardwareStatus/PowerSupplyStore.js b/src/store/modules/HardwareStatus/PowerSupplyStore.js index 567908f2..e70d8dd0 100644 --- a/src/store/modules/HardwareStatus/PowerSupplyStore.js +++ b/src/store/modules/HardwareStatus/PowerSupplyStore.js @@ -132,23 +132,25 @@ 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, - }, - ], - }) - ) - ) + return await api + .patch('/redfish/v1/Chassis/SILA_Baseboard/Power', { + Voltages: groups.map((group) => { + return { + MemberId: group, + UpperThresholdNonCritical: warning, + }; + }), + }) + .then(async () => { + return await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Power', { + Voltages: groups.map((group) => { + return { + MemberId: group, + UpperThresholdCritical: critical, + }; + }), + }); + }) .catch((error) => { console.log(error); throw new Error(i18n.t('pagePowerSup.toast.errorLimitUpdate')); @@ -157,9 +159,9 @@ const PowerSupplyStore = { }, async getLimitsVol({ commit }) { return await api - .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') - .then(({ data: { Temperatures = [] } }) => { - commit('setLimitsVol', Temperatures); + .get('/redfish/v1/Chassis/SILA_Baseboard/Power') + .then(({ data: { Voltages = [] } }) => { + commit('setLimitsVol', Voltages); }) .catch((error) => console.log(error)); }, diff --git a/src/views/_sila/Power/Dynamic/VoltInput.vue b/src/views/_sila/Power/Dynamic/VoltInput.vue index 38f7c077..b343ddbe 100644 --- a/src/views/_sila/Power/Dynamic/VoltInput.vue +++ b/src/views/_sila/Power/Dynamic/VoltInput.vue @@ -8,34 +8,61 @@ - + {{ $t('global.action.save') }} + + + + { + return limit?.MaxReadingRange && this.groups.includes(limit.MemberId); + })?.MaxReadingRange; + }, + filteredItems() { return psuFilter(this.allSensors, 'Input'); }, @@ -195,6 +258,9 @@ export default { }, methods: { saveLimit() { + this.$v.$touch(); + if (this.$v.$invalid) return; + this.startLoader(); this.$store .dispatch('powerSupply/patchLimitsVol', { diff --git a/src/views/_sila/Power/Dynamic/VoltOutput.vue b/src/views/_sila/Power/Dynamic/VoltOutput.vue index f657b064..e03c04b6 100644 --- a/src/views/_sila/Power/Dynamic/VoltOutput.vue +++ b/src/views/_sila/Power/Dynamic/VoltOutput.vue @@ -8,41 +8,69 @@ - + {{ $t('global.action.save') }} + + + + { + return ( + limit?.UpperThresholdNonCritical && + this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdNonCritical; + }, + + criticalLimit() { + return this.limits.find((limit) => { + return ( + limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId) + ); + })?.UpperThresholdCritical; + }, + + maxLimit() { + return this.limits.find((limit) => { + return limit?.MaxReadingRange && this.groups.includes(limit.MemberId); + })?.MaxReadingRange; + }, + filteredItems() { return psuFilter(this.allSensors, 'Output'); }, @@ -162,10 +250,44 @@ export default { }, watch: { items() { - this.items.length ? (this.isBusy = false) : (this.isBusy = true); + if (this.items && this.items.length > 0) { + this.isBusy = false; + this.endLoader(); + } + }, + + limits() { + if (this.limits && this.limits.length > 0) { + this.warning = this.warningLimit; + this.critical = this.criticalLimit; + } + }, + + timeScale() { + this.loadData(); }, }, + + /*created() { + this.loadData(); + },*/ + methods: { + saveLimit() { + this.$v.$touch(); + if (this.$v.$invalid) return; + + 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(); @@ -179,9 +301,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.isBusy = false; + this.endLoader(); + }); }); }, }, -- cgit v1.2.3